Hello, I need help with writing code for Ascending and Descending sequence .
Ascending sequence start when close cross up yesterday’s high, with a green arrow and with the word “buy”. The dashed line will be drawn below the candle’s low as long as the close does not cross below yesterday’s low.
Descending sequence start when close cross below yesterday’s low with a red arrow and with the word “sell”. The dashed line will be drawn above the candle’s high as long as the close does not cross up yesterday’s high.
I would appreciate your help,
Thanks in advance.
JSParticipant
Senior
Hi,
Try this one…
Dist=Average[5](Range)/10
If xBuy=0 and xBuy[1]=0 and Close Crosses Over High[1] then
DrawArrowUp(BarIndex,High+Dist)Coloured("Lime")
DrawText("Buy",BarIndex,High+2*Dist,SansSerif,Bold,16)Coloured("Lime")
xBuy=1
xSell=0
EndIf
If xSell=0 and Close Crosses Under Low[1] then
DrawArrowDown(BarIndex,Low-Dist)Coloured("Red")
DrawText("Sell",BarIndex,Low-2*Dist,SansSerif,Bold,16)Coloured("Red")
xBuy=0
xSell=1
EndIf
If xBuy=1 and xSell[1]=1 then
xBuy=1
ElsIf xBuy=1 and xBuy[1]=1 then
DrawSegment(BarIndex,Low,BarIndex-1,Low[1])Style(DottedLine,5)Coloured("Lime")
EndIf
If xSell=1 and xBuy[1]=1 then
xSell=1
ElsIf xSell=1 and xSell[1]=1 then
DrawSegment(BarIndex,High,BarIndex-1,High[1])Style(DottedLine,5)Coloured("Red")
EndIf
Return
Hi, thank you very much, i have made some changes, here is the code with changes.
Dist=Average[5](Range)/10
If xBuy=0 and xBuy[1]=0 and Close Crosses Over High[1] then
DrawArrowUp(BarIndex,Low-3*Dist)Coloured(“Lime”)
DrawText(“Buy”,BarIndex,Low-9*Dist,SansSerif,Bold,16)Coloured(“Lime”)
xBuy=1
xSell=0
EndIf
If xSell=0 and Close Crosses Under Low[1] then
DrawArrowDown(BarIndex,High+3*Dist)Coloured(“Red”)
DrawText(“Sell”,BarIndex,High+9*Dist,SansSerif,Bold,16)Coloured(“Red”)
xBuy=0
xSell=1
EndIf
If xBuy=1 and xSell[1]=1 then
xBuy=1
ElsIf xBuy=1 and xBuy[1]=1 then
DrawSegment(BarIndex,Low,BarIndex-1,Low[1])Style(DottedLine,2)COLOURED(“Blue”)
EndIf
If xSell=1 and xBuy[1]=1 then
xSell=1
ElsIf xSell=1 and xSell[1]=1 then
DrawSegment(BarIndex,High,BarIndex-1,High[1])Style(DottedLine,2)Coloured(“Red”)
EndIf
RETURN