I have made an indicator that consists among other things two lines that i want to draw arrows on when crossed.
The code for the specific area is at the bottom here:
hhatrx=highest[lookback](atrxlineh)
llatrx=lowest[lookback](atrxlinel)
mitten=(hhatrx+llatrx)/2
midatrx=mitten
midatrx2=average[SlowMid,1](mitten)
if midatrx crosses over midatrx2 then
drawarrowup(barindex[1],llatrx)
elsif midatrx crosses under midatrx2 then
drawarrowdown(barindex[1],hhatrx)
endif
but no arrows are drawn. Even if i try different colors, same result.
I have read several descriptions including the Pro Builder manual, but i cant get it to work.
Any takers?
Thanks!
What are atrxlineh and atrxlinel, please?
I see now that its DRAWONLASTBARONLY that seems to be the issue. Is it possible to have it drawn even though this setting is =true? Will the drawn arrows stay in the future?
This is the full code:
defparam DRAWONLASTBARONLY=true
//defparam CALCULATEONLASTBARS=200
if on=1then
x=ATRperiod
a=AverageTrueRange[x](close)[1]
//atrma=Average[10,1](a)
//xfactor=a/atrma
multiplier=a*atrx//*xfactor
alpha=255
//
//atrxlineh=(highest[lookback](high)+multiplier) // ÖVRE LINJE
atrxlineh=high+multiplier
//atrxlinel=(lowest[lookback](low)-multiplier) // UNDRE LINJE
atrxlinel=low-multiplier
if atrxlineh>atrxlineh[1] then
atrxlineh=atrxlineh[1]
endif
if close[1]>atrxlineh[1] then
atrxlineh=close[1]+a
atrxlinel=close[1]-multiplier
elsif high[1]>atrxlineh[1] then
atrxlineh=high[1]
endif
if atrxlinel<atrxlinel[1] then
atrxlinel=atrxlinel[1]
endif
if close[1]<atrxlinel[1] then
atrxlinel=close[1]-a
atrxlineh=close[1]+multiplier
elsif low[1]<atrxlinel[1] then
atrxlinel=low[1]
endif
//GAMLA GRUNDKODEN INNAN IHOPFLÄTAT
//if atrxlinel<atrxlinel[1] then
//atrxlinel=atrxlinel[1]
//endif
//if low[1]<atrxlinel[1] then
//atrxlinel=low[1]
//endif
//if close[1]<atrxlinel[1] then
//atrxlinel=close[1]-a
//endif
//OKLAR KOD SOM SKA DRA UPP STOPLOSSEN OM CLOSE BRYTS
//if close[1]>atrxlineh[1] then
//atrxlinel=open[1]-a
//endif
//if close[1]<atrxlinel[1] then
//atrxlineh=open[1]+a
//endif
//
//hhatrx=atrxlineh
//llatrx=atrxlinel
hhatrx=highest[lookback](atrxlineh)
llatrx=lowest[lookback](atrxlinel)
mitten=(hhatrx+llatrx)/2
midatrx=mitten
midatrx2=average[SlowMid,1](mitten)
if midatrx[1] crosses over midatrx2[1] then
drawarrowup(barindex[1],llatrx+a)
elsif midatrx[1] crosses under midatrx2[1] then
drawarrowdown(barindex[1],hhatrx-a)
endif
//
if Numbers=1 then
drawtext("ATR:#a#(X:#multiplier#)",barindex,hhatrx+a/2,sansserif,standard,12)
drawtext("ATR:#a#(X:#multiplier#)",barindex,llatrx-a/2,sansserif,standard,12)
endif
if Lines=1 then
drawsegment(barindex-20,hhatrx,barindex,hhatrx)coloured(30,144,255,alpha)
drawsegment(barindex-20,llatrx,barindex,llatrx)coloured(30,144,255,alpha)
endif
endif
return hhatrx as "ATRx High", llatrx as "ATRx Low", midatrx as "ATRx Mid", midatrx2 as "ATRx Mid Slow"
Dont know if it helps.. Some of it is in Swedish 🙂
Did set line 1 to false solve the problem?
If i do that all other drawings get all over the chart, so i need to have that setting to false.
Please share with us the settings of the indicator in order to help.
Its solved – it was “Drawonlastbaronly” that was the issue, and after recoding some other drawlines/segments it works to have it set to =false without having the whole chart cluttered. 🙂
ps. I would appreciate some help in the “How do i stop repeat signlas”-thread.
Thanks