Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Price indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
ansinzhou
Posted : Tuesday, August 4, 2015 9:44:14 AM
Registered User
Joined: 10/6/2014
Posts: 34

Hi,

I created an indicator with realcode like this

plot = (price.Close - price.Open )/(price.High -price.Open )

 

However it wouldn't plot, what may be the issue?

 

Thank you

StockGuy
Posted : Tuesday, August 4, 2015 10:21:02 AM

Administration

Joined: 9/30/2004
Posts: 9,187

It's plotting fine for me in StockFinder 5.  I'm not sure what the problem might be.

Is it not plotting on any stock or one in particular?

ansinzhou
Posted : Tuesday, August 4, 2015 2:24:45 PM
Registered User
Joined: 10/6/2014
Posts: 34

It is not plotting on any stock

StockGuy
Posted : Tuesday, August 4, 2015 2:30:55 PM

Administration

Joined: 9/30/2004
Posts: 9,187

Does the RealCode editor show any errors?

ansinzhou
Posted : Tuesday, August 4, 2015 2:52:51 PM
Registered User
Joined: 10/6/2014
Posts: 34

No, it doesn't, it just draws blank. However a number does show on the right like a scale I guess, but no lines are drawn

StockGuy
Posted : Tuesday, August 4, 2015 3:08:18 PM

Administration

Joined: 9/30/2004
Posts: 9,187

Cick Share > Email Layout and send your layout to support@worden.com and we'll take a look.

ansinzhou
Posted : Tuesday, August 4, 2015 4:54:21 PM
Registered User
Joined: 10/6/2014
Posts: 34

I sent it

 

Thank You

StockGuy
Posted : Tuesday, August 4, 2015 5:02:49 PM

Administration

Joined: 9/30/2004
Posts: 9,187

We haven't gotten it yet. Try sending a test email from the same email account to support@worden.com

ansinzhou
Posted : Tuesday, August 4, 2015 5:12:50 PM
Registered User
Joined: 10/6/2014
Posts: 34

I sent the test and email

and I sent the layout once again.

 

Thank You

StockGuy
Posted : Tuesday, August 4, 2015 5:14:34 PM

Administration

Joined: 9/30/2004
Posts: 9,187

OK, we got it that time. Thanks.

StockGuy
Posted : Tuesday, August 4, 2015 5:25:36 PM

Administration

Joined: 9/30/2004
Posts: 9,187

The problem is a division by zero error when two values are equal.  Try this:

 

plot = ((price.Close - price.Open) + .00001) / ((price.High - price.Open) + .00001)

ansinzhou
Posted : Tuesday, August 4, 2015 5:35:58 PM
Registered User
Joined: 10/6/2014
Posts: 34

It does not plot properly. It plots a straight line on a certain value like 0.18, but then has drops that drops into the -250k, -500k. 

StockGuy
Posted : Tuesday, August 4, 2015 7:49:32 PM

Administration

Joined: 9/30/2004
Posts: 9,187

It's plotting correctly. Keep in mind when the High and the Close are equal, your divisor is going to be .00001 which is going to result in large values.  Before we added the +.00001, it was trying to divide by 0 which isn't possible. Edit the scaling on the plot and set manual max and min values for the scale. Set the max to 1 and the min value to -10 and see how that looks.

Maybe if you tell us what you're goal is we can approach it in a different way.

StockGuy
Posted : Tuesday, August 4, 2015 8:25:09 PM

Administration

Joined: 9/30/2004
Posts: 9,187

You can also try this code which makes the divisor 1 if the High and Open are equal.  If they are equal then the value of the indicator will be (Close - Open) + .0001.

 

Dim Divideby As Single
 
If price.high = price.Open Then 
Divideby = 1
ElseIf price.High > price.open Then 
Divideby = (price.high - price.close) + .0001
End If
 
plot = (price.Close - price.Open) + .0001 / Divideby
 
You'll probably need to play around with the Min and Max scales values using this method as well.
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.