Ascending and Descending sequence

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #230722 quote
    ZAZI
    Participant
    New

    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.

    #230730 quote
    JS
    Participant
    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
    
    ZAZI thanked this post
    #230767 quote
    ZAZI
    Participant
    New

    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

    JS thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Ascending and Descending sequence


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
ZAZI @zazi Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by ZAZI
1 year, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/29/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...