Highs and Lows based on Stochastic Cycles

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

    Hello,
    I am busy with a indicator which marks the highs and lows of price based on the stochastic cycle, after the stochastic cycle has closed. A cyclehigh is where %D > 50 and a cyclelow is where %D < 50. I use EUR/USD.
    I would like to have a Textsignal at the candle with the highest high when the Stochastic D > 50 and at the candle with the lowest low when the stochastics D < 50. And preferable that is tells me also if this highest high is higher or lower then the previous highest high from the previous cycle.

    I manage to program to define the highest high and lowest low, and also the previous highest high and lowest low but I only manage to show them as lines. That makes to much noise in my charts so I am looking for a way where I can mark ONLY the candles with the highest high and the lowest low in the cycle and preferable that is tells me also if this highest high is higher or lower then the previous highest high from the previous cycle.

    So my challenge is in the part where I want to DrawText and define the candle where to do draw text. It needs to mark the highest high when the cycle high is over and not during the cycle high. And if the macd has made a lower high during that cycle high.

     

    // This indicator marks highs and lows based of price and macd based on the Stochastic cycle
    K = stochastic[5,3]
    D = average[3](K)
    sma20 = average[20]
    macdl = macdline[5,20,30]
    
     
    //start of cycle low looking for the lowest price and lowest MACD as long as Stochastic %D<50
    If D =< 50 and D[1] > 50 then
    incyclelow = 1
    lowestprice2 = lowestprice
    Lowestprice = low
    macdlowest2 = macdlowest
    macdlowest = macdl
    
    endif
     
    //End of cycle low
    If K => 50 and K[1] < 50 then
    incyclelow = 0
    endif
     
    //lowest macd and price in Stochastic cycle %D<50
    if incyclelow then
    lowestprice = min(lowestprice, low)
    macdlowest = min(macdlowest, macdl)
    endif
     
    
    //start of cycle high looking for the higestest price and higest MACD as long as Stochastic %D>50
    If D => 50 and D[1] < 50 then
    incyclehigh = 1
    highestprice2 = highestprice
    HighestPrice = high
    macdhighest2 = macdhighest
    macdhighest = macdl
    
    endif
     
    //End of cycle high
    If K < 50 and K[1] > 50 then
    incyclehigh = 0
    endif
     
    //highest stoch and price in cycle high
    if incyclehigh then
    highestPrice = max(highestPrice, high)
    macdhighest = max(macdhighest, macdl)
    endif
    
    //LONG
    if incyclelow = 0 and lowestprice > lowestprice2 then
    DRAWTEXT ("HLP", barindex, low-0.0008, Dialog, Bold, 10) COLOURED(0,0,0)
    endif
    if incyclelow = 0 and macdlowest > macdlowest2 then
    DRAWTEXT ("HLM", barindex, low-0.0010, Dialog, Bold, 10) COLOURED(0,0,0)
    endif
    
    //SHORT
    if incyclehigh=0 and  highestprice < highestprice2 then
    DRAWTEXT ("LHP", barindex, high+0.0008, Dialog, Bold, 10) COLOURED(0,0,0)
    endif
    if incyclehigh =0 and macdhighest < macdhighest2 then
    DRAWTEXT ("LHM", barindex, high+0.0010, Dialog, Bold, 10) COLOURED(0,0,0)
    endif
    
    return lowestprice as "lowest price in cycle low",macdlowest as "lowest macdline in cycle low",  lowestprice2 as "previous lowest price in cycle low", macdlowest2 as "previous lowest macdline in cycle low", highestprice as "highest price in cycle high",macdhighest as "highest macdline in cycle high", highestprice2 as "previous highest price in cycle high", macdhighest2 as "previous highest macdline in cycle high"

     

    In my indicator you see the highs and lows and the previous highs and lows.
    Red  = lowest price
    Purple = previous lowest price
    Green = highest price
    Light blue = previous highest price
    The signal from theHH HL LL and LH from the macd can also be done in a seperate indicator if it isn’t possible to combine them, The thing with the MACD of course is that the visibilaty of the signal depends on waht you trade.

    #146167 quote
    Malend
    Participant
    Average

    I would like to have it like this.

    #146182 quote
    Nicolas
    Keymaster
    Master

    I’m not sure of the complete picture of what you want to achieve, so I just modify the lowest (LONG) part of your code:

    // This indicator marks highs and lows based of price and macd based on the Stochastic cycle
    K = stochastic[5,3]
    D = average[3](K)
    //sma20 = average[20]
    macdl = macdline[5,20,30]
    
     
    //start of cycle low looking for the lowest price and lowest MACD as long as Stochastic %D<50
    If D =< 50 and D[1] > 50 then
    incyclelow = 1
    lowestprice2 = lowestprice
    Lowestprice = low
    macdlowest2 = macdlowest
    macdlowest = macdl
    endif
     
    //End of cycle low
    If K => 50 and K[1] < 50 then
    incyclelow = 0
    endif
     
    //lowest macd and price in Stochastic cycle %D<50
    if incyclelow then
    lowestprice = min(lowestprice, low)
    macdlowest = min(macdlowest, macdl)
    //what is the lowest price bar of this cycle?
    if lowestprice<>lowestprice[1] then 
    lowestpriceBar=barindex
    endif 
    if macdlowest<>macdlowest[1] then
    macdlowestBar=barindex
    macdlowestPrice=low-10*pointsize
    endif
    endif
     
    
    //LONG
    if incyclelow = 0 and lowestprice > lowestprice2 then
    DRAWTEXT ("HLP", lowestpriceBar, lowestprice, Dialog, Bold, 20) COLOURED(255,200,0)
    endif
    if incyclelow = 0 and macdlowest > macdlowest2 then
    DRAWTEXT ("HLM", macdlowestBar, macdlowestPrice, Dialog, Bold, 16) COLOURED(0,0,0)
    endif
    
    
    return //lowestprice as "lowest price in cycle low",macdlowest as "lowest macdline in cycle low",  lowestprice2 as "previous lowest price in cycle low", macdlowest2 as "previous lowest macdline in cycle low"
    Malend thanked this post
    #146188 quote
    Malend
    Participant
    Average

    Thanks a lot Nicolas,

    For sure this is great to continue to create what I had in mind. When I have finished it I will post the last version.

    Nicolas thanked this post
    #146200 quote
    Malend
    Participant
    Average

    Thanks again Nicolas for helping me out describing the candle with the higherst high within the Stochastic cycle.

    This indicator describes the Higher Lows and Lower Highs in Price and in Macd within the cycles of the Stochastics  (Stochastics %D is my oscillator, but you can use others as well. Just needs a bit editing). It also marks the Highs with a green line and Lows with a red line in every cycle high and low with a red line.
    HLP = Higher Low Price
    HLM = Higher Low Macdline
    LHP =  Lower High Price
    LHM =  Lower High Macdline
    -see  the image-

    // This indicator marks highs and lows based on the Stochastic cycle
    K = stochastic[5,3]
    D = average[3](K)
    sma20 = average[20]
    macdl = macdline[5,20,30]
    
     
    //start of cycle low looking for the lowest price and lowest MACD as long as Stochastic %D<50
    If D =< 50 and D[1] => 50 then
    incyclelow = 1
    lowestprice2 = lowestprice
    Lowestprice = low
    macdlowest2 = macdlowest
    macdlowest = macdl
    
    endif
     
    //End of cycle low
    If K => 50 and K[1] < 50 then
    incyclelow = 0
    endif
     
    //lowest macd and price in Stochastic cycle %D<50
    if incyclelow then
    lowestprice = min(lowestprice, low)
    macdlowest = min(macdlowest, macdl)
    
    endif
    
    //what is the lowest price bar of this cycle?
    if lowestprice<>lowestprice[1] then
    lowestpriceBar=barindex
    endif
    if macdlowest<>macdlowest[1] then
    macdlowestBar=barindex
    macdlowestPrice=low-10*pointsize
    endif
    
     
    
    //LONG
    if incyclelow = 0 and lowestprice > lowestprice2 then
    DRAWTEXT ("HLP", lowestpriceBar, lowestprice-0.0008, Dialog, standard, 10) COLOURED(200,200,200)
    endif
    if incyclelow = 0 then
    DRAWSEGMENT(lowestpriceBar,lowestprice,lowestpriceBar,lowestprice-50) COLOURED(100,0,0)
    
    endif
    if incyclelow = 0 and macdlowest > macdlowest2 then
    DRAWTEXT ("HLM", lowestpriceBar, lowestprice-0.0011, Dialog, standard, 10) COLOURED(200,200,200)
    endif
    
    //____________________________________________________________________________________________________________________
    
    //start of cycle high looking for the higestest price and higest MACD as long as Stochastic %D>50
    If D => 50 and D[1] =< 50 then
    incyclehigh = 1
    highestprice2 = highestprice
    HighestPrice = high
    macdhighest2 = macdhighest
    macdhighest = macdl
    
    //what is the lowest price bar of this cycle?
    if lowestprice<>lowestprice[1] then
    lowestpriceBar=barindex
    endif
    if macdlowest<>macdlowest[1] then
    macdlowestBar=barindex
    macdlowestPrice=low-10*pointsize
    endif
    
    endif
     
    //End of cycle high
    If K =< 50 and K[1] > 50 then
    incyclehigh = 0
    endif
     
    //highest stoch and price in cycle high
    if incyclehigh then
    highestPrice = max(highestPrice, high)
    macdhighest = max(macdhighest, macdl)
    endif
    
    //what is the lowest price bar of this cycle?
    if highestprice<>highestprice[1] then
    highestpriceBar=barindex
    endif
    if macdhighest<>macdhighest[1] then
    macdhighestBar=barindex
    macdhighestPrice=low-10*pointsize
    endif
    
    //SHORT
    if incyclehigh=0 and  highestprice < highestprice2 then
    DRAWTEXT ("LHP", highestpriceBar, highestprice+0.0008, Dialog, standard,10) COLOURED(1000,1000,1000)
    endif
    if incyclehigh = 0 then
    DRAWSEGMENT(highestpriceBar,highestprice,highestpriceBar,highestprice+50) COLOURED(0,100,0)
    endif
    if incyclehigh =0 and macdhighest < macdhighest2 then
    DRAWTEXT ("LHM", highestpriceBar, highestprice+0.0011, Dialog, standard, 10) COLOURED(1000,1000,1000)
    endif
    
    return 
    

     

    PLermite thanked this post
    #146202 quote
    Malend
    Participant
    Average

    This is for EUR/USD, so when you use other charts, check the distance between the chart and the text.

    #148373 quote
    gregoire
    Participant
    Senior

    Hello would it be possible to complete the code with these variables. thank you very much

    #148374 quote
    gregoire
    Participant
    Senior

    hello,

    there is an error line 96 in colored, it is necessarry to remove a 0 on each 1000 otherwise problem of RGB display, somebody modified the code and complete the variable.

    thank you.

    #148378 quote
    Madrosat
    Participant
    Master

    can we have this for 10 3  ??

    #148418 quote
    fifi743
    Participant
    Master

    Yes the color goes from 0 to 255 max

    #148465 quote
    Madrosat
    Participant
    Master

    Hello Fifi
    It is not a problem of color, the code as it is above does
    not work on 10 3.
    I am looking for the most reliable reversal signals
    I mainly test eur usd 1 hour, dear Fifi would you have an idea
    on what works best.
    This question I also ask Nicolas, Roberto, Paul, Nonetheles, Grahal and all of you ???

    #148896 quote
    gregoire
    Participant
    Senior

    hello is it possible to add a filter, buy on green candle and sell on red candle otherwise no signal. thank you

    #148921 quote
    fifi743
    Participant
    Master
    // This indicator marks highs and lows based on the Stochastic cycle
    K = stochastic[5,3]
    D = average[3](K)
    //sma20 = average[20]
    macdl = macdline[5,20,30]
    
     
    //start of cycle low looking for the lowest price and lowest MACD as long as Stochastic %D<50
    If D =< 50 and D[1] => 50 then
    incyclelow = 1
    lowestprice2 = lowestprice
    Lowestprice = low
    macdlowest2 = macdlowest
    macdlowest = macdl
    
    endif
     
    //End of cycle low
    If K => 50 and K[1] < 50 then
    incyclelow = 0
    endif
     
    //lowest macd and price in Stochastic cycle %D<50
    if incyclelow then
    lowestprice = min(lowestprice, low)
    macdlowest = min(macdlowest, macdl)
    
    endif
    
    //what is the lowest price bar of this cycle?
    if lowestprice<>lowestprice[1] then
    lowestpriceBar=barindex
    endif
    if macdlowest<>macdlowest[1] then
    //macdlowestBar=barindex
    //macdlowestPrice=low-10*pointsize
    endif
    
     
    
    //LONG
    if incyclelow = 0 and lowestprice > lowestprice2 then
    DRAWTEXT ("HLP", lowestpriceBar, lowestprice-0.0008, Dialog, standard, 10) COLOURED(200,200,200)
    endif
    if incyclelow = 0 then
    DRAWSEGMENT(lowestpriceBar,lowestprice,lowestpriceBar,lowestprice-50) COLOURED(100,0,0)
    
    endif
    if incyclelow = 0 and macdlowest > macdlowest2 then
    DRAWTEXT ("HLM", lowestpriceBar, lowestprice-0.0011, Dialog, standard, 10) COLOURED(200,200,200)
    endif
    
    //____________________________________________________________________________________________________________________
    
    //start of cycle high looking for the higestest price and higest MACD as long as Stochastic %D>50
    If D => 50 and D[1] =< 50 then
    incyclehigh = 1
    highestprice2 = highestprice
    HighestPrice = high
    macdhighest2 = macdhighest
    macdhighest = macdl
    
    //what is the lowest price bar of this cycle?
    if lowestprice<>lowestprice[1] then
    lowestpriceBar=barindex
    endif
    if macdlowest<>macdlowest[1] then
    //macdlowestBar=barindex
    //macdlowestPrice=low-10*pointsize
    endif
    
    endif
     
    //End of cycle high
    If K =< 50 and K[1] > 50 then
    incyclehigh = 0
    endif
     
    //highest stoch and price in cycle high
    if incyclehigh then
    highestPrice = max(highestPrice, high)
    macdhighest = max(macdhighest, macdl)
    endif
    
    //what is the lowest price bar of this cycle?
    if highestprice<>highestprice[1] then
    highestpriceBar=barindex
    endif
    if macdhighest<>macdhighest[1] then
    //macdhighestBar=barindex
    //macdhighestPrice=low-10*pointsize
    endif
    
    //SHORT
    if incyclehigh=0 and  highestprice < highestprice2 then
    DRAWTEXT ("LHP", highestpriceBar, highestprice+0.0008, Dialog, standard,10) COLOURED(0,0,0)
    endif
    if incyclehigh = 0 then
    DRAWSEGMENT(highestpriceBar,highestprice,highestpriceBar,highestprice+50) COLOURED(0,100,0)
    endif
    if incyclehigh =0 and macdhighest < macdhighest2 then
    DRAWTEXT ("LHM", highestpriceBar, highestprice+0.0011, Dialog, standard, 10) COLOURED(0,0,0)
    endif
    
    return  //lowestprice as "lowest price in cycle low",macdlowest as "lowest macdline in cycle low",  lowestprice2 as "previous lowest price in cycle low", macdlowest2 as "previous lowest macdline in cycle low"
    
    modify
    #148933 quote
    gregoire
    Participant
    Senior
    many thanks fifi 743 i tested it and i tell you
    #228676 quote
    Madrosat
    Participant
    Master
    Hello Fifi, Gregoire Can i use segments in a strategy?? I have try without success
Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.

Highs and Lows based on Stochastic Cycles


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Malend @malend Participant
Summary

This topic contains 16 replies,
has 6 voices, and was last updated by Madrosat
1 year, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/02/2020
Status: Active
Attachments: 4 files
Logo Logo
Loading...