Converting Five Bar Trend indicator to Pro Order

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #105482 quote
    soulintact
    Participant
    Senior

    Good morning!

    I tried to rewrite the latest great indicator of Vonasi, Five Bar Trend Dashboard, to pro order, but failed. Any one care to elaborate what I am doing wrong, thanks!

    //-------------------------------------------------------------------------
    defparam cumulateorders=false
    Defparam preloadbars=10000
    
    //-------------------------------------------------------------------------
    
    // --- settings of ORDERS
    amount = 100 //quantity of shares/contracts to open for each new order
    
    //-------------------------------------------------------------------------
    //Indicators
    //Indicator type: Candle trend in 5 different time frames
    //Edited code originates from: Five Bar Trend
    //Author: Vonasi
    //Date: 20190822
    //Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard/
    
    
    m5 = customclose
    
    //m5=typicalprice
    //m5=medianprice
    //m5=totalprice
    //m5=weightedclose
    //m5=(close or customclose = open or customclose = high or customclose = low)
    
    m10h = highest[2](high)
    m10l = lowest[2](low)
    m10o = open[1]
     
    m15h = highest[3](high)
    m15l = lowest[3](low)
    m15o = open[2]
     
    m20h = highest[4](high)
    m20l = lowest[4](low)
    m20o = open[3]
     
    m25h = highest[5](high)
    m25l = lowest[5](low)
    m25o = open[4]
     
    if customclose = typicalprice then
    m10 = (m10h + m10l + close)/3
    m15 = (m15h + m15l + close)/3
    m20 = (m20h + m20l + close)/3
    m25 = (m25h + m25l + close)/3
    endif
     
    if customclose = medianprice then
    m10 = (m10h + m10l)/2
    m15 = (m15h + m15l)/2
    m20 = (m20h + m20l)/2
    m25 = (m25h + m25l)/2
    endif
     
    if customclose = totalprice then
    m10 = (m10h + m10l + m10o + close)/4
    m15 = (m15h + m15l + m15o + close)/4
    m20 = (m20h + m20l + m20o + close)/4
    m25 = (m25h + m25l + m25o + close)/4
    endif
     
    if customclose = weightedclose then
    m10 = (m10h + m10l + (2 * close))/4
    m15 = (m15h + m15l + (2 * close))/4
    m20 = (m20h + m20l + (2 * close))/4
    m25 = (m25h + m25l + (2 * close))/4
    endif
     
    if customclose = close or customclose = open or customclose = high or customclose = low then
    m5 = open
    m10 = m10o
    m15 = m15o
    m20 = m20o
    m25 = m25o
    endif
      
    //Line 1, First time frame
    //Red dot
    if close < m5 then
    L1=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m5 then
    L1=1
    up = up + 1
    endif
     
    //Line 2, Second time frame
    //Red dot
    if close < m10 then
    L2=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m10 then
    L2=1
    up = up + 1
    endif
     
    //Line 3, Third time frame
    //Red dot
    if close < m15 then
    L3=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m15 then
    L3=1
    up = up + 1
    endif
     
    //Line 4, Fourth time frame
    //Red dot
    if close < m20 then
    L4=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m20 then
    L4=1
    up = up + 1
    endif
    
    //Line 5, Fifth time frame
    //Red dot
    if close < m25 then
    L5=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m25 then
    L5=1
    up = up + 1
    endif
    
    //Market reversal
    //Down
    if up[1] = 5 and down <> 5 and up <> 5 then
    reda = ucount[1]
    ucount = 0
    Arrow=-1
    endif
    
    //Up
    if down[1] = 5 and down <> 5 and up <> 5 then
    greena = dcount[1]
    dcount = 0
    Arrow=1
    endif
     
    BullCandle5=((L1=1)and(L2=1)and(L3=1)and(L4=1)and(L5=1)) or ((Arrow=1) and (greena>=3))
    BearCandle5=((L1=-1)and(L2=-1)and(L3=-1)and(L4=-1)and(L5=-1)) or ((Arrow=-1) and (reda>=3))
    
    //Conditions when to act
    if (not longonmarket and BullCandle5) then
    buy amount shares at market
    endif
     
    if (longonmarket and BearCandle5 and positionperf>0) then
    sell at market
    endif
    
    #105487 quote
    GraHal
    Participant
    Master

    What is yours not doing? Maybe you are blowing your Account with Lot = 100?? 🙂

    Attached with Lot = 1

    soulintact thanked this post
    Soul.jpg Soul.jpg Soul-2.jpg Soul-2.jpg
    #105491 quote
    Vonasi
    Moderator
    Master

    Just like GraHal it works for me. I have removed all references to customclose and referenced m5 instead so that it will work with the various custom prices by // out the prices you don’t need.

    //-------------------------------------------------------------------------
    defparam cumulateorders=false
    Defparam preloadbars=10000
    
    //-------------------------------------------------------------------------
    
    // --- settings of ORDERS
    amount = 100 //quantity of shares/contracts to open for each new order
    
    //-------------------------------------------------------------------------
    //Indicators
    //Indicator type: Candle trend in 5 different time frames
    //Edited code originates from: Five Bar Trend
    //Author: Vonasi
    //Date: 20190822
    //Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard/
    
    //m5=typicalprice
    m5=medianprice
    //m5=totalprice
    //m5=weightedclose
    //m5=open
    
    m10h = highest[2](high)
    m10l = lowest[2](low)
    m10o = open[1]
     
    m15h = highest[3](high)
    m15l = lowest[3](low)
    m15o = open[2]
     
    m20h = highest[4](high)
    m20l = lowest[4](low)
    m20o = open[3]
     
    m25h = highest[5](high)
    m25l = lowest[5](low)
    m25o = open[4]
     
    if m5 = typicalprice then
    m10 = (m10h + m10l + close)/3
    m15 = (m15h + m15l + close)/3
    m20 = (m20h + m20l + close)/3
    m25 = (m25h + m25l + close)/3
    endif
     
    if m5 = medianprice then
    m10 = (m10h + m10l)/2
    m15 = (m15h + m15l)/2
    m20 = (m20h + m20l)/2
    m25 = (m25h + m25l)/2
    endif
     
    if m5 = totalprice then
    m10 = (m10h + m10l + m10o + close)/4
    m15 = (m15h + m15l + m15o + close)/4
    m20 = (m20h + m20l + m20o + close)/4
    m25 = (m25h + m25l + m25o + close)/4
    endif
     
    if m5 = weightedclose then
    m10 = (m10h + m10l + (2 * close))/4
    m15 = (m15h + m15l + (2 * close))/4
    m20 = (m20h + m20l + (2 * close))/4
    m25 = (m25h + m25l + (2 * close))/4
    endif
     
    if m5 = open then
    m5 = open
    m10 = m10o
    m15 = m15o
    m20 = m20o
    m25 = m25o
    endif
      
    //Line 1, First time frame
    //Red dot
    if close < m5 then
    L1=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m5 then
    L1=1
    up = up + 1
    endif
     
    //Line 2, Second time frame
    //Red dot
    if close < m10 then
    L2=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m10 then
    L2=1
    up = up + 1
    endif
     
    //Line 3, Third time frame
    //Red dot
    if close < m15 then
    L3=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m15 then
    L3=1
    up = up + 1
    endif
     
    //Line 4, Fourth time frame
    //Red dot
    if close < m20 then
    L4=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m20 then
    L4=1
    up = up + 1
    endif
    
    //Line 5, Fifth time frame
    //Red dot
    if close < m25 then
    L5=-1
    down = down + 1
    endif
    
    //Green dot
    if close > m25 then
    L5=1
    up = up + 1
    endif
    
    //Market reversal
    //Down
    if up[1] = 5 and down <> 5 and up <> 5 then
    reda = ucount[1]
    ucount = 0
    Arrow=-1
    endif
    
    //Up
    if down[1] = 5 and down <> 5 and up <> 5 then
    greena = dcount[1]
    dcount = 0
    Arrow=1
    endif
     
    BullCandle5=((L1=1)and(L2=1)and(L3=1)and(L4=1)and(L5=1)) or ((Arrow=1) and (greena>=3))
    BearCandle5=((L1=-1)and(L2=-1)and(L3=-1)and(L4=-1)and(L5=-1)) or ((Arrow=-1) and (reda>=3))
    
    //Conditions when to act
    if (not longonmarket and BullCandle5) then
    buy amount shares at market
    endif
     
    if (longonmarket and BearCandle5 and positionperf>0) then
    sell at market
    endif
    
    soulintact and Paul thanked this post
    #105497 quote
    soulintact
    Participant
    Senior

    Thank you Vonasi you solved it. I missed out to remove all references to customclose and to refere m5 instead, thanks!!

    #107886 quote
    soulintact
    Participant
    Senior

    Dear Vonasi,

    Now I am trying to figure out how to calculate the upper line, which I thought was dcount (down, green) or ucount (up, red). I made a simple exit condition, BearCount that you will find in the end of the code. What am I doing wrong?

    //Indicator type: Candle trend in 5 different time frames
    //Edited code originates from: Five Bar Trend
    //Author: Vonasi
    //Date: 20190822
    //Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard/
     
    //m5=typicalprice
    m5=medianprice
    //m5=totalprice
    //m5=weightedclose
    //m5=open
     
    m10h = highest[2](high)
    m10l = lowest[2](low)
    m10o = open[1]
     
    m15h = highest[3](high)
    m15l = lowest[3](low)
    m15o = open[2]
     
    m20h = highest[4](high)
    m20l = lowest[4](low)
    m20o = open[3]
     
    m25h = highest[5](high)
    m25l = lowest[5](low)
    m25o = open[4]
     
    if m5 = typicalprice then
    m10 = (m10h + m10l + close)/3
    m15 = (m15h + m15l + close)/3
    m20 = (m20h + m20l + close)/3
    m25 = (m25h + m25l + close)/3
    endif
     
    if m5 = medianprice then
    m10 = (m10h + m10l)/2
    m15 = (m15h + m15l)/2
    m20 = (m20h + m20l)/2
    m25 = (m25h + m25l)/2
    endif
     
    if m5 = totalprice then
    m10 = (m10h + m10l + m10o + close)/4
    m15 = (m15h + m15l + m15o + close)/4
    m20 = (m20h + m20l + m20o + close)/4
    m25 = (m25h + m25l + m25o + close)/4
    endif
     
    if m5 = weightedclose then
    m10 = (m10h + m10l + (2 * close))/4
    m15 = (m15h + m15l + (2 * close))/4
    m20 = (m20h + m20l + (2 * close))/4
    m25 = (m25h + m25l + (2 * close))/4
    endif
     
    if m5 = open then
    m5 = open
    m10 = m10o
    m15 = m15o
    m20 = m20o
    m25 = m25o
    endif
      
    //Line 1, First time frame
    //Red dot
    if close < m5 then
    L1=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m5 then
    L1=1
    up = up + 1
    endif
     
    //Line 2, Second time frame
    //Red dot
    if close < m10 then
    L2=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m10 then
    L2=1
    up = up + 1
    endif
     
    //Line 3, Third time frame
    //Red dot
    if close < m15 then
    L3=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m15 then
    L3=1
    up = up + 1
    endif
     
    //Line 4, Fourth time frame
    //Red dot
    if close < m20 then
    L4=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m20 then
    L4=1
    up = up + 1
    endif
     
    //Line 5, Fifth time frame
    //Red dot
    if close < m25 then
    L5=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m25 then
    L5=1
    up = up + 1
    endif
    
    //Calculating amount of ups eller downs reflected in first row
    up = 0
    down = 0
    
    if close < m5 then
    down = down + 1
    endif
    
    if close > m5 then
    up = up + 1
    endif
    
    if close < m10 then
    down = down + 1
    endif
    
    if close > m10 then
    up = up + 1
    endif
    
    if close < m15 then
    down = down + 1
    endif
    
    if close > m15 then
    up = up + 1
    endif
    
    if close < m20 then
    down = down + 1
    endif
    
    if close > m20 then
    up = up + 1
    endif
    
    if close < m25 then
    down = down + 1
    endif
    
    if close > m25 then
    up = up + 1
    endif
    
    if down = 5 then
    dcount = dcount + 1
    ucount = 0
    endif
    
    if up = 5 then
    dcount = 0
    ucount = ucount + 1
    endif
    
    BearCount=dcount > 7
    fivebar.png fivebar.png
    #107902 quote
    Vonasi
    Moderator
    Master

    Sorry soulintact but I don’t fully understand what you are trying to do. The top line is just the count of bars in a row where all tests have been either all up or all tests have been down.

    The only thing I can say is that if a test results in not all tests being up or not all tests being down then the following code does not reset dcount or ucount to zero.

    if down = 5 then
    dcount = dcount + 1
    ucount = 0
    endif
     
    if up = 5 then
    dcount = 0
    ucount = ucount + 1
    endif
     
    BearCount=dcount > 7
    soulintact thanked this post
    #107911 quote
    soulintact
    Participant
    Senior

    Thank you Vonasi for your prompt reply. Sorry for not being clear enough.

    As of the included file, I want to be able to calculate the numbers 3(green) 1 (green) 1 (red) 8 (red) 1 (red) 1 (green) 4 (green) 1 (green).

    By the code I wanted to exit the position when the number of red/down was greater than 7. I enclose the code again with your suggested modification.

     

    //Indicator type: Candle trend in 5 different time frames
    //Edited code originates from: Five Bar Trend
    //Author: Vonasi
    //Date: 20190822
    //Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard/
     
    //m5=typicalprice
    m5=medianprice
    //m5=totalprice
    //m5=weightedclose
    //m5=open
     
    m10h = highest[2](high)
    m10l = lowest[2](low)
    m10o = open[1]
     
    m15h = highest[3](high)
    m15l = lowest[3](low)
    m15o = open[2]
     
    m20h = highest[4](high)
    m20l = lowest[4](low)
    m20o = open[3]
     
    m25h = highest[5](high)
    m25l = lowest[5](low)
    m25o = open[4]
     
    if m5 = typicalprice then
    m10 = (m10h + m10l + close)/3
    m15 = (m15h + m15l + close)/3
    m20 = (m20h + m20l + close)/3
    m25 = (m25h + m25l + close)/3
    endif
     
    if m5 = medianprice then
    m10 = (m10h + m10l)/2
    m15 = (m15h + m15l)/2
    m20 = (m20h + m20l)/2
    m25 = (m25h + m25l)/2
    endif
     
    if m5 = totalprice then
    m10 = (m10h + m10l + m10o + close)/4
    m15 = (m15h + m15l + m15o + close)/4
    m20 = (m20h + m20l + m20o + close)/4
    m25 = (m25h + m25l + m25o + close)/4
    endif
     
    if m5 = weightedclose then
    m10 = (m10h + m10l + (2 * close))/4
    m15 = (m15h + m15l + (2 * close))/4
    m20 = (m20h + m20l + (2 * close))/4
    m25 = (m25h + m25l + (2 * close))/4
    endif
     
    if m5 = open then
    m5 = open
    m10 = m10o
    m15 = m15o
    m20 = m20o
    m25 = m25o
    endif
      
    //Line 1, First time frame
    //Red dot
    if close < m5 then
    L1=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m5 then
    L1=1
    up = up + 1
    endif
     
    //Line 2, Second time frame
    //Red dot
    if close < m10 then
    L2=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m10 then
    L2=1
    up = up + 1
    endif
     
    //Line 3, Third time frame
    //Red dot
    if close < m15 then
    L3=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m15 then
    L3=1
    up = up + 1
    endif
     
    //Line 4, Fourth time frame
    //Red dot
    if close < m20 then
    L4=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m20 then
    L4=1
    up = up + 1
    endif
     
    //Line 5, Fifth time frame
    //Red dot
    if close < m25 then
    L5=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m25 then
    L5=1
    up = up + 1
    endif
    
    up = 0
    down = 0
    
    if close < m5 then
    down = down + 1
    endif
    
    if close > m5 then
    up = up + 1
    endif
    
    if close < m10 then
    down = down + 1
    endif
    
    if close > m10 then
    up = up + 1
    endif
    
    if close < m15 then
    down = down + 1
    endif
    
    if close > m15 then
    up = up + 1
    endif
    
    if close < m20 then
    down = down + 1
    endif
    
    if close > m20 then
    up = up + 1
    endif
    
    if close < m25 then
    down = down + 1
    endif
    
    if close > m25 then
    up = up + 1
    endif
    
    if down = 5 then
    dcount = dcount + 1
    ucount = 0
    endif
    
    if up = 5 then
    dcount = 0
    ucount = ucount + 1
    endif
    
    BearCount=dcount > 7
    fivebar-1.png fivebar-1.png
    #107922 quote
    Vonasi
    Moderator
    Master

    That wasn’t a suggested modification – that was the bit of your original code that I cut and pasted in where values are not set to zero at any time!

    In the original code it was like this:

    flag = 0
    if down[1] = 5 and down <> 5 and up <> 5 then
     drawtext("▲",barindex,2,SansSerif,Bold,16)coloured(0,128,0)
     a = dcount[1]
     drawtext("#a#",barindex,3,SansSerif,Bold,16)coloured(0,128,0)
     dcount = 0
     flag = 1
    endif
     
    if up[1] = 5 and down <> 5 and up <> 5 then
     drawtext("▼",barindex,2,SansSerif,Bold,16)coloured(128,0,0)
     a = ucount[1]
     drawtext("#a#",barindex,3,SansSerif,Bold,16)coloured(128,0,0)
     ucount = 0
     flag = 1
    endif
     
    if flag = 0 and up <> 5 and down <> 5 then
     drawtext("○",barindex,2,SansSerif,Bold,16)coloured(0,0,255)
    endif

    If we remove the graphics and replace them with variables then we can get something like:

    flag = 0
    if down[1] = 5 and down <> 5 and up <> 5 then
     direction = 1
     a = dcount[1]
     dcount = 0
     flag = 1
    endif
     
    if up[1] = 5 and down <> 5 and up <> 5 then
     direction = -1
     a = ucount[1]
     ucount = 0
     flag = 1
    endif
     
    if flag = 0 and up <> 5 and down <> 5 then
    direction = 0
    a = 0
    endif

    So now we have a variable ‘direction’ that can be either -1, zero or 1 and the variable ‘a’ which is the quantity of the same direction in a row or zero if all directions are not the same.

    soulintact thanked this post
    #107952 quote
    soulintact
    Participant
    Senior

    Thank you Vonasi for your patience!

    What expression would I use to be able to “catch” the red 8, or rather 8 lines of green dots and one red dot of the following line?

    I tried a few, and the following is not correct, but with the best performance: BearCount=(direction=1) and (a < 1)

    What am I missing? Thanks!

    //Indicator type: Candle trend in 5 different time frames
    //Edited code originates from: Five Bar Trend
    //Author: Vonasi
    //Date: 20190822
    //Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard/
     
    //m5=typicalprice
    m5=medianprice
    //m5=totalprice
    //m5=weightedclose
    //m5=open
     
    m10h = highest[2](high)
    m10l = lowest[2](low)
    m10o = open[1]
     
    m15h = highest[3](high)
    m15l = lowest[3](low)
    m15o = open[2]
     
    m20h = highest[4](high)
    m20l = lowest[4](low)
    m20o = open[3]
     
    m25h = highest[5](high)
    m25l = lowest[5](low)
    m25o = open[4]
     
    if m5 = typicalprice then
    m10 = (m10h + m10l + close)/3
    m15 = (m15h + m15l + close)/3
    m20 = (m20h + m20l + close)/3
    m25 = (m25h + m25l + close)/3
    endif
     
    if m5 = medianprice then
    m10 = (m10h + m10l)/2
    m15 = (m15h + m15l)/2
    m20 = (m20h + m20l)/2
    m25 = (m25h + m25l)/2
    endif
     
    if m5 = totalprice then
    m10 = (m10h + m10l + m10o + close)/4
    m15 = (m15h + m15l + m15o + close)/4
    m20 = (m20h + m20l + m20o + close)/4
    m25 = (m25h + m25l + m25o + close)/4
    endif
     
    if m5 = weightedclose then
    m10 = (m10h + m10l + (2 * close))/4
    m15 = (m15h + m15l + (2 * close))/4
    m20 = (m20h + m20l + (2 * close))/4
    m25 = (m25h + m25l + (2 * close))/4
    endif
     
    if m5 = open then
    m5 = open
    m10 = m10o
    m15 = m15o
    m20 = m20o
    m25 = m25o
    endif
      
    //Line 1, First time frame
    //Red dot
    if close < m5 then
    L1=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m5 then
    L1=1
    up = up + 1
    endif
     
    //Line 2, Second time frame
    //Red dot
    if close < m10 then
    L2=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m10 then
    L2=1
    up = up + 1
    endif
     
    //Line 3, Third time frame
    //Red dot
    if close < m15 then
    L3=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m15 then
    L3=1
    up = up + 1
    endif
     
    //Line 4, Fourth time frame
    //Red dot
    if close < m20 then
    L4=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m20 then
    L4=1
    up = up + 1
    endif
     
    //Line 5, Fifth time frame
    //Red dot
    if close < m25 then
    L5=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m25 then
    L5=1
    up = up + 1
    endif
    
    up = 0
    down = 0
    
    if close < m5 then
    down = down + 1
    endif
    
    if close > m5 then
    up = up + 1
    endif
    
    if close < m10 then
    down = down + 1
    endif
    
    if close > m10 then
    up = up + 1
    endif
    
    if close < m15 then
    down = down + 1
    endif
    
    if close > m15 then
    up = up + 1
    endif
    
    if close < m20 then
    down = down + 1
    endif
    
    if close > m20 then
    up = up + 1
    endif
    
    if close < m25 then
    down = down + 1
    endif
    
    if close > m25 then
    up = up + 1
    endif
    
    flag = 0
    
    if down[1] = 5 and down <> 5 and up <> 5 then
    direction = 1
    a = dcount[1]
    dcount = 0
    flag = 1
    endif
    
    if up[1] = 5 and down <> 5 and up <> 5 then
    direction = -1
    a = ucount[1]
    ucount = 0
    flag = 1
    endif
    
    if flag = 0 and up <> 5 and down <> 5 then
    direction = 0
    a = 0
    endif
    
    BearCount=(direction=1) and (a < 1)
    fivebar-2.png fivebar-2.png
    #107957 quote
    Vonasi
    Moderator
    Master

    There is a critical bit of my original indicator code that does not seem to have found its way into your code. The calculation of dcount and ucount!

     
    if down = 5 then
     dcount = dcount + 1
     ucount = 0
    endif
     
    if up = 5 then
     dcount = 0
     ucount = ucount + 1
    endif
    
    flag = 0
     
    if down[1] = 5 and down <> 5 and up <> 5 then
    direction = 1
    a = dcount[1]
    dcount = 0
    flag = 1
    endif
     
    if up[1] = 5 and down <> 5 and up <> 5 then
    direction = -1
    a = ucount[1]
    ucount = 0
    flag = 1
    endif
     
    if flag = 0 and up <> 5 and down <> 5 then
    direction = 0
    a = 0
    endif
     
    BearCount=(direction=1) and (a > 7)
    soulintact thanked this post
    #107978 quote
    soulintact
    Participant
    Senior

    Sorry about that! Although it does not work with the edited code as enclosed. Strange! Any more ideas? Thanks!

     

    //Indicator type: Candle trend in 5 different time frames
    //Edited code originates from: Five Bar Trend
    //Author: Vonasi
    //Date: 20190822
    //Source: https://www.prorealcode.com/prorealtime-indicators/five-bar-trend-dashboard/
     
    //m5=typicalprice
    m5=medianprice
    //m5=totalprice
    //m5=weightedclose
    //m5=open
     
    m10h = highest[2](high)
    m10l = lowest[2](low)
    m10o = open[1]
     
    m15h = highest[3](high)
    m15l = lowest[3](low)
    m15o = open[2]
     
    m20h = highest[4](high)
    m20l = lowest[4](low)
    m20o = open[3]
     
    m25h = highest[5](high)
    m25l = lowest[5](low)
    m25o = open[4]
     
    if m5 = typicalprice then
    m10 = (m10h + m10l + close)/3
    m15 = (m15h + m15l + close)/3
    m20 = (m20h + m20l + close)/3
    m25 = (m25h + m25l + close)/3
    endif
     
    if m5 = medianprice then
    m10 = (m10h + m10l)/2
    m15 = (m15h + m15l)/2
    m20 = (m20h + m20l)/2
    m25 = (m25h + m25l)/2
    endif
     
    if m5 = totalprice then
    m10 = (m10h + m10l + m10o + close)/4
    m15 = (m15h + m15l + m15o + close)/4
    m20 = (m20h + m20l + m20o + close)/4
    m25 = (m25h + m25l + m25o + close)/4
    endif
     
    if m5 = weightedclose then
    m10 = (m10h + m10l + (2 * close))/4
    m15 = (m15h + m15l + (2 * close))/4
    m20 = (m20h + m20l + (2 * close))/4
    m25 = (m25h + m25l + (2 * close))/4
    endif
     
    if m5 = open then
    m5 = open
    m10 = m10o
    m15 = m15o
    m20 = m20o
    m25 = m25o
    endif
      
    //Line 1, First time frame
    //Red dot
    if close < m5 then
    L1=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m5 then
    L1=1
    up = up + 1
    endif
     
    //Line 2, Second time frame
    //Red dot
    if close < m10 then
    L2=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m10 then
    L2=1
    up = up + 1
    endif
     
    //Line 3, Third time frame
    //Red dot
    if close < m15 then
    L3=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m15 then
    L3=1
    up = up + 1
    endif
     
    //Line 4, Fourth time frame
    //Red dot
    if close < m20 then
    L4=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m20 then
    L4=1
    up = up + 1
    endif
     
    //Line 5, Fifth time frame
    //Red dot
    if close < m25 then
    L5=-1
    down = down + 1
    endif
     
    //Green dot
    if close > m25 then
    L5=1
    up = up + 1
    endif
    
    up = 0
    down = 0
    
    if close < m5 then
    down = down + 1
    endif
    
    if close > m5 then
    up = up + 1
    endif
    
    if close < m10 then
    down = down + 1
    endif
    
    if close > m10 then
    up = up + 1
    endif
    
    if close < m15 then
    down = down + 1
    endif
    
    if close > m15 then
    up = up + 1
    endif
    
    if close < m20 then
    down = down + 1
    endif
    
    if close > m20 then
    up = up + 1
    endif
    
    if close < m25 then
    down = down + 1
    endif
    
    if close > m25 then
    up = up + 1
    endif
    
    if down = 5 then
    dcount = dcount + 1
    ucount = 0
    endif
    
    if up = 5 then
    dcount = 0
    ucount = ucount + 1
    endif
    
    flag = 0
    
    if down[1] = 5 and down <> 5 and up <> 5 then
    direction = 1
    a = dcount[1]
    dcount = 0
    flag = 1
    endif
    
    if up[1] = 5 and down <> 5 and up <> 5 then
    direction = -1
    a = ucount[1]
    ucount = 0
    flag = 1
    endif
    
    if flag = 0 and up <> 5 and down <> 5 then
    direction = 0
    a = 0
    endif
    
    BearCount=(direction=1) and (a > 7)
    fivebar-3.png fivebar-3.png
    #107996 quote
    Vonasi
    Moderator
    Master

    It works fine for me.

    I took your code and just added ‘buy at -close limit’ to turn it into a dummy strategy. I rem’d out all references to L1, L2 etc to make it work and then graphed BEARCOUNT  – having changed it to ‘BearCount=(direction=1) and (a > 3)’ and every time there is a run of more than 3 red candles it returns a positive value for BEARCOUNT.

    soulintact thanked this post
    #107998 quote
    soulintact
    Participant
    Senior

    Dear Vonasi,

    Sorry for being so slow in mind and persistent, but I still do not follow fully. Do the statement below really correspond to the definition in words?

    BearCount=(direction=1) and (a > 7) := (direction is now negative with a least one red dot) and (previously more than 7 of the same direction in a row of green dots)

     

    Cheers!

    fivebar-4.png fivebar-4.png
    #108000 quote
    Vonasi
    Moderator
    Master

    No

    BearCount=(direction=1) and (a > 7) would be that we have just had a run of 8 (sets of 5) red dots and this set is not a set of 5 red dots nor a set of five green dots.

    soulintact thanked this post
    #108001 quote
    soulintact
    Participant
    Senior

    Aha, thanks!

    And how would we formulate the expression to “catch” the red 8 as enclosed.

    fivebar-5.png fivebar-5.png
Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.

Converting Five Bar Trend indicator to Pro Order


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
soulintact @soulintact Participant
Summary

This topic contains 16 replies,
has 3 voices, and was last updated by soulintact
6 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/25/2019
Status: Active
Attachments: 8 files
Logo Logo
Loading...