Help with Higher Lows Price sync with Higher Low MACD when candle crosses MA

Viewing 15 posts - 1 through 15 (of 73 total)
  • Author
    Posts
  • #106711 quote
    Malend
    Participant
    Average

    Hello all,
    What I want to see is this:

    A Cycle Low is the period when the MACD < Signal line. It starts when the MACD crosses under the Signal  line and ends when the MACD crosses over the Signal line. The MACD Cycle Lowest is the Lowest MACD during that Cycle Low, measured after the Cycle has finished,
    I want a Signal when:
    – a bullish candle crosses over the bullish SMA50at the close of the candle and
    – the MACD at that > previous MACD Cycle Lowest and
    – the MACD at that moment =< Signal line and
    – the price low at that moment > price low at the previous MACD Cycle Lowest.

    Where I fail is how to describe the period of the cycle low from the MACD, the start and the end and how to define the lowest MACD and the the lowes price in that MACD-period.
    I only have the long version here to keep it readable. When it works I will complete it with the short version included.

    Thanks a lot,
    Marc

     

    // Higher Lows Price in sync with Higher Low MACD
    
    //indicators SMA50 and MACD
    MA = Average[50]
    LM = MACDline[12,26,9]
    
     
    //CCL = CONDITIONS CANDLES IN RELATION TO AVERAGE FOR LONG POSITION
    //bullish candle crosses over bullish Average.
    C1 = ma[1] =< ma and open < m50 and close > m50
    // The body of the previous candle needs to be below the Average
    C2 = open[1] < m50 and close[1] < m50
    
    CCL = c1 and c2
    
    
    //  CYCLE LOW MACD (MCL), the lowest MACD in the period when MACD < Signalline
    // Comparing MACD in a next running CYCLE LOW at a close of a bar with the previous CYCLE LOW.
    // START MCL
    MD1 = LM(close) =< Signalline and LM[1] > LM(close)
    If MD1 then MCL = 1
    //END OF CYCLE LOW MACD
    MD2 = LM(close)  => Signalline and LM[1] < LM(close)
    If MD2 then MCL = 0
    //DEFINING MACD CYLCE LOWEST, MDLST
    MCLST = MCL [lowest]
    //MACD higher low
    MHL = [MCLST][1] < MCL
    //PRICE, PHL is PRICE LOW > PRICE LOW AT THE PREVIOUS,
    PHL = low > low [MCLST]
    
    // SIGNAL LONG
    If CCA and MHL and PHL then
    
    DRAWSEGMENT (barindex, close+1.7, barindex, close+2.2)COLOURED(0,250,0)
    DRAWSEGMENT (barindex, close+1.7, barindex+1, close+1.7)COLOURED(0,250,0)
    DRAWTEXT("1.7", barindex-1, close+1.7, Dialog, Standard, 10) COLOURED(0,0,0)
    DRAWSEGMENT (barindex, close+2.2, barindex+1, close+2.2)COLOURED(0,250,0)
    DRAWTEXT("2.2", barindex-1, close+2.2, Dialog, Standard, 10) COLOURED(0,0,0)
    DRAWSEGMENT (barindex, close+1, barindex+1, close+1)COLOURED(100,100,100)
    DRAWSEGMENT (barindex, close+1.7, barindex, close+1)COLOURED(100,100,100)
    DRAWTEXT("1.0", barindex-1, close+1, Dialog, Standard, 10) COLOURED(100,100,100)
    DRAWTEXT("F1", barindex, close+2.8, Dialog, Standard, 14) COLOURED(0,250,0)
    DRAWSEGMENT (barindex, close-sl, barindex+1, close-sl)COLOURED(250,0,100)
    DRAWSEGMENT (barindex, close-(sl-0.25), barindex, close-sl)COLOURED(250,0,100)
    
    
    
    endif
    endif
    endif 
    return
    
    #106712 quote
    Malend
    Participant
    Average

    I see that after
    // Signal Long
    I wrote CCA, which needs to be CCL, but that isn’t the help I am looking for. 🙂

    #106779 quote
    Malend
    Participant
    Average

    Here a Printscreen of what I am looking for.

    HL-MACD.jpg HL-MACD.jpg
    #106786 quote
    Vonasi
    Moderator
    Master

    I find your use of variable names very challenging! Not sure I am 100% on top of your code but perhaps you mean something like this?

    //start of cycle
    MD1 = LM(close) <= Signalline and LM[1] > LM(close)
    
    If MD1 then 
    MCL = 1
    mclst = LM
    endif
    
    //END OF CYCLE LOW MACD 
    MD2 = LM(close) => Signalline and LM[1] < LM(close) 
    
    If MD2 then 
    MCL = 0
    endif
    
    //lowest LM in cycle
    if mcl then
    mclst = min(mclst, LM)
    endif
    
    <br>

    Not tested.

    #106832 quote
    Malend
    Participant
    Average

    Hi Vonasi,
    Thanks a lot for your response. I am still looking for a better  and clearer way of naming the parameters. I can imagine it is challenging, sorry for that.
    I have added your lines ( see attachment), but I get a syntax error in your line 9 ( I know I coded that one :-). So something isn’t right in that line.

    How can I copy and paste the coding including the line numbers on the left?  When I copy and paste it doesn’t iclude the lines.

    // Higher Lows Price in sync with Higher Low MACD
     
    //indicators SMA50 and MACD
    MA = Average[50]
    LM = MACDline[12,26,9]
     
     
    //CCL = CONDITIONS CANDLES IN RELATION TO AVERAGE FOR LONG POSITION
    //bullish candle crosses over bullish Average.
    C1 = ma[1] =< ma and open < m50 and close > m50
    // The body of the previous candle needs to be below the Average
    C2 = open[1] < m50 and close[1] < m50
     
    CCL = c1 and c2
     
     
    //  CYCLE LOW MACD (MCL), the lowest MACD in the period when MACD < Signalline
    // Comparing MACD in a next running CYCLE LOW at a close of a bar with the previous CYCLE LOW.
    // START MCL
    
    MD1 = LM(close) <= Signalline and LM[1] > LM(close)
     
    If MD1 then
    MCL = 1
    mclst = LM
    endif
     
    //END OF CYCLE LOW MACD
    MD2 = LM(close) => Signalline and LM[1] < LM(close)
     
    If MD2 then
    MCL = 0
    endif
     
    //lowest LM in cycle
    if mcl then
    mclst = min(mclst, LM)
    endif
     
    // SIGNAL LONG
    If CCA and MHL and PHL then
    #106833 quote
    Vonasi
    Moderator
    Master

    ‘Signalline’ is not defined in your code.

    There are two MACD instructions in PRT.

    MACD is the histogram value.

    MACDLINE is the line value.

    To get a signal line value take an exponential average of the MACDLINE.

    #106834 quote
    Vonasi
    Moderator
    Master

    How can I copy and paste the coding including the line numbers on the left?  When I copy and paste it doesn’t iclude the lines.

    You can’t.

    #106837 quote
    Malend
    Participant
    Average

    I simplified the whole thing. I hope these variables are  better readable. I stille get a syntax error at line 19.
    And… I see the line numbers in the left show up after I submitted.

    //--- Higher Lows Price in sync with Higher Low MACD
    
    //---settings
    MA = Average[ma]
    Mline = MACDline[12,26,9]
    SLine = ExponentialAverage[9]
    
     
    once lastpoint = 0
    
    //MACDline Cycle Low 
    if (MLine crosses under Sline and Mline =< Sline) then //MACDline Cycle Low
    MCL = 1
    PriceLow = lowest[mcl](low)
    Macdlow = lowest [mcl](Sline)
    
    endif
    
    Pricelow[1] =< Pricelow and MACDlow[1] =< MACDlow then
    
    
    DRAWTEXT("■",TOPx,TOPy,Dialog,Bold,20) coloured(0,200,0,255)
    
    lastpoint = -1
    lastX = BOTx
    lastY = BOTy
    
    endif
    return
    #106838 quote
    Malend
    Participant
    Average

    This is just defining the MACD period with the Higher Lows.
    I need to add the crossing with the SMA.
    I will add that in a minute.
    Thanks a lot Vonasi for helping me out and challenging me to reconsider my way of programming

    #106842 quote
    GraHal
    Participant
    Master

    I stille get a syntax error at line 19.

    Haven’t you missed an If at the beginning of Line 19 or is it a copy and paste error?

    #106848 quote
    Malend
    Participant
    Average

    Thanks GraHal,
    Too many hours behand the screen :-).
    I will come back on the Backtest as we spoke about in the other Forum after I have doen this, so I can combine both.
    Cheers, Marc

    #106853 quote
    Vonasi
    Moderator
    Master

    Change line 6 to:

    SLine = ExponentialAverage[9](MLine)
    #106855 quote
    Vonasi
    Moderator
    Master
    PriceLow = lowest[mcl](low)
    Macdlow = lowest [mcl](Sline)

    This does not do what you are trying to do. With mcl = 1 it just tells you what the lowest low of the current bar is – which is always going to be the low! Same for the signal line. If the next low is higher then it will just change to that value.

    You need to go back to how I showed you and use the MIN instruction to store the lowest value while a flag to say you are in your low cycle is set.

    #106864 quote
    Malend
    Participant
    Average

    I have now the MACD Cycle Low and MACD Cycle High and the crossings from the close over and under the SMA. I don’t get a Syntax Error anymore, but I also don’t get any Signal in my chart.
    AND…. I really appreciate all your help as I started from scratch with coding a few weeks ago.

    //--- Higher Lows Price in sync with Higher Low MACD
    
    once lastpoint = 0
    
    //---settings
    MA = Average[ave]
    Mline = MACDline[12,26,9]
    SLine = ExponentialAverage[9]
    
    
    //---candle crosses Moving Average
    XH = close crosses over ma 
    XL = close crosses under MA
    
    //MACDline Cycle Low 
    if (MLine crosses under Sline and Mline =< Sline) then //---MACDline Cycle Low
    MCL = -1
    else
    MCL = 0
    endif
    
    if (MLine crosses over Sline and Mline => Sline) then //---MACDline Cycle High
    MCH = 1
    else
    MCh = 0
    endif
    
    if MCL = -1 then
    BOTy = lowest[mcl](low)
    BOTx = barindex[mcl]
    endif
    
    if MCL = 1 then
    TOPy = highest [mcl](high)
    TOPx = barindex[mcl]
    endif
    
    if XH and MCL>0 and (lastpoint=1 or lastpoint=0) then
    DRAWSEGMENT(lastX,lastY,TOPx,TOPy) COLOURED(0,0,0)
    DRAWTEXT("■",TOPx,TOPy,Dialog,Bold,20) coloured(0,0,0)
    lastpoint = 1
    lastX = TOPx
    lastY = TOPy
    endif
    if XL and MCH<0 and (lastpoint=-1 or lastpoint=0) then
    DRAWSEGMENT(lastX,lastY,BOTx,BOTy) COLOURED(0,0,0)
    DRAWTEXT("■",BOTx,BOTy,Dialog,Bold,20) coloured(0,0,0)
    lastpoint = -1
    lastX = BOTx
    
    
    endif
    return
    
    
    #106871 quote
    Vonasi
    Moderator
    Master
Viewing 15 posts - 1 through 15 (of 73 total)
  • You must be logged in to reply to this topic.

Help with Higher Lows Price sync with Higher Low MACD when candle crosses MA


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Malend @malend Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/06/2019
Status: Active
Attachments: 12 files
Logo Logo
Loading...