Hi,
New to real time pro and coding indicators.
Im coding a true low indicator (example code below) but I find the indicator returns the wrong candle as being the true low. It shows the candle after the real true low candle.
Can anyone review my code please and advise if it’s inaccurate? Thanks
H0=High[0]
C1=Close[1]
Truelow0 = Min (H0,C1)
H1=High[1]
C2=Close[2]
Truelow1 = Min(H1,C2)
H2=High[2]
C3=Close[3]
Truelow2 = Min(H2,C3)
Result1 = Min(Truelow0, Truelow1)
Result2 = Truelow2 < Result1
Return Result2
What do you mean by “true low” please? Do you want to get the lowest low of the last 3 candlesticks?
Hi,
True low of a candle refers to the minimum between the current candle’s low and previous candle’s close.
Above I have gone back 3 candles. I want to return the 3rd previous candle if the true low of this is less than minimum between the true low of the following two candles.
What the code is returning me is the current candle rather than the 3rd previous candle.
Hope that makes sense.
The code is returning a boolean value (=1) when all your conditions are met and on the current candle because the code is read at each new period, it is the normal behavior to me. Sorry if I don’t understand clearly.. but you want the histogram to be plotted 3 bars ago when your indicator has found a positive result?
The code is returning a boolean value (=1) when all your conditions are met and on the current candle because the code is read at each new period, it is the normal behavior to me. Sorry if I don’t understand clearly.. but you want the histogram to be plotted 3 bars ago when your indicator has found a positive result?
Hi Nicolas, yes that is correct, I want the histogram to return the value of 1 on the period/candle which meets the conditions, not the current period/candle. This could be 3 days ago as per my example above or 10 days ago, the time period would be a variable. Can you help with the code for this? Thank you.
It’s not possible to return a value in the past, but we can plot graphical objects (such as arrows, text, rectangle, circle, etc.), would that be good enough?
Hi Nicolas,
Sorry for the delay in replying; been tied up with something else.
Yes, should be useful also, as I suppose that could be my indicator (e. g. an arrow on the candle where the condition is met, rather than the value of 1; is that what you mean?). Would be great if you could help with this. Thanks
Not tested, but should be ok: (draw a black up arrow below the 3rd previous low when “result2” is true, with count starting on the current candle).
H0=High[0]
C1=Close[1]
Truelow0 = Min (H0,C1)
H1=High[1]
C2=Close[2]
Truelow1 = Min(H1,C2)
H2=High[2]
C3=Close[3]
Truelow2 = Min(H2,C3)
Result1 = Min(Truelow0, Truelow1)
Result2 = Truelow2 < Result1
if Result2 then
drawarrowup(barindex[2],low[2])
endif
Return
Thanks for this. I have tried it but it doesn’t seem to be working; it is not drawing any arrows even though I can see where the condition is fulfilled but there are no arrows returned by the code.
Also, my explanation of what is a true low was right but the code I wrote was wrong; should have been the one below.
L0=Low[0]
C1=Close[1]
Truelow0 = Min (L0,C1)
L1=Low[1]
C2=Close[2]
Truelow1 = Min(L1,C2)
L2=Low[2]
C3=Close[3]
Truelow2 = Min(L2,C3)
Result1 = Min(Truelow0, Truelow1)
Result2 = Truelow2 < Result1
if Result2 then
drawarrowup(barindex[2],low[2])
endif
Return
Thanks
> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
I got many arrows on my chart. Please add the indicator on your price with the wrench at the left upper side of your price chart.
That seem to have worked; I normally click on “Add indicator to chart” from the window where I write the indicator but this time it didn’t work. Thank you for your help with this Nicolas
Hi,
I am trying to add this indicator to a trading system but not sure how do I call the arrows which are my signals to buy or sell. Thanks
Since your indicator’s code is not returning any value but only a graphical component, you have to copy/paste the code into your strategy and use ‘result2’ variable as a trigger for your order:
L0=Low[0]
C1=Close[1]
Truelow0 = Min (L0,C1)
L1=Low[1]
C2=Close[2]
Truelow1 = Min(L1,C2)
L2=Low[2]
C3=Close[3]
Truelow2 = Min(L2,C3)
Result1 = Min(Truelow0, Truelow1)
Result2 = Truelow2 < Result1
if Result2 then
// BUY OR SELLSHORT CODE GOES HERE
endif