Wedges based in Cycle Highs and Lows

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #147294 quote
    Malend
    Participant
    Average

    I have programmed an indicator to define the Highs and Lows based on Cycles, made by the Stochastics. Of course you can use other oscilators as well. Just edit it in the programming.
    The highs and lows will be confirmed after the cycle has closed. Now I would like to add an extended line connecting the last 2 highs and an extended line to connect the last 2 lows. It is a way to see when wedges start to show up. See the image.

    Another thing is that sometimes it doesn’t show me the high/low after the cycle has closed. When I edit the settings in the menu, which are only about the transparency of the vertical lines, it shows up, or after I have validated the indicator again. I don’t know why that happens.

    // This indicator marks highs and lows based on the Stochastic cycle
    K = stochastic[5,2]
    D = average[3](K)
    sma50 = average[50]
    macdl = macdline[5,20,30]
    M = momentum[42]
    
     
    //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
    Dlowest2 = Dlowest
    Dlowest = D
    Mlowest2 = Mlowest
    Mlowest = M
    endif
     
    //End of cycle low
    If D => 50 and D[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)
    Dlowest = min(Dlowest, D)
    Mlowest =  min(Mlowest, M)
    
    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
    if Dlowest<>Dlowest[1] then
    DlowestBar = barindex
    endif
    if Mlowest<>Mlowest[1] then
    MlowestBar = barindex
    endif
     
    
    //LONG
    if incyclelow = 0 then
    DRAWSEGMENT(lowestpriceBar,lowestprice,lowestpriceBar,lowestprice-50) COLOURED(0,groen,0) STYLE(dottedline, 1)
    DRAWSEGMENT(lowestpriceBar,lowestprice,lowestpriceBar-4,lowestprice) COLOURED(300,0,0) STYLE(line, 3)
    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
    Dhighest2 = Dhighest
    Dhighest = D
    Mhighest2 = Mhighest
    Mhighest = M
    endif
    //End of cycle high
    If D =< 50 and D[1] > 50 then
    incyclehigh = 0
    endif
     
    //highest stoch and price in cycle high
    if incyclehigh then
    highestPrice = max(highestPrice, high)
    macdhighest = max(macdhighest, macdl)
    Mhighest = max(Mhighest, M)
    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
    if Dhighest<>Dhighest[1] then
    DhighestBar=barindex
    endif
    if Mhighest<>Mhighest[1] then
    MhighestBar = barindex
    endif
    
    //SHORT
    if incyclehigh = 0 then
    DRAWSEGMENT(highestpriceBar,highestprice,highestpriceBar,highestprice+50) COLOURED(rood,0,0) STYLE(dottedline, 1)
    DRAWSEGMENT(highestpriceBar,highestprice,highestpriceBar-4,highestprice) COLOURED(0,300,0) STYLE(line, 3)
    endif
    
    return
    
    #147295 quote
    Malend
    Participant
    Average

    Sorry, for some reason I can’t add the image, JPEG 163k size. I also tried a PNG…..doesn’t work either.

    #147298 quote
    robertogozzi
    Moderator
    Master

    There are many variables missing or not defined.

    Can you please post a full working code?

    Eben better it would be attaching the ITF file.

    Thank you 🙂

    #147301 quote
    Malend
    Participant
    Average

    Ciao Roberto,
    Here is the ITF file

    robertogozzi thanked this post
    Highs-n-Lows-Price-Stoch-Cycle.itf
    #147303 quote
    Malend
    Participant
    Average

    I took away the setting in the menu where you could adjust the transparency of the vertical lines. The vertical line mark the candle with the high/low. The horizontal segment moves marks the price of the high/low.

    #147304 quote
    Malend
    Participant
    Average

    Another try with the image.

    Wedge.jpg Wedge.jpg
    #147315 quote
    robertogozzi
    Moderator
    Master

    The code is still not working, many variables are not used.

    When posting code, please make sure it’s fully functional! People may want to help you, but only if you help them not waste their time uselessly!

    #147316 quote
    Malend
    Participant
    Average

    It is fully functional. I even checked it with Nicolas. And it works for me.
    I know the MACD and the Momentum aren’t used, although they are described, but they are also not in the programming. The signals you get in the chart are Lows and Highs based on the Stochastic [5,2,3]. They show up in my chart. See the image I included.
    Please let me know what doesn’t work for you.
    I took out the unused parameters, so here again.

    Highs-n-Lows-Price-Stoch-Cycle-NEW.itf
    #147320 quote
    Malend
    Participant
    Average

    In the image here you see what shows up in the chart right now. But I would like to have the extended lines from the last two Highs connected and the last tw low connected as in the image above I posted 3:13 PM.

    HnL.jpg HnL.jpg
    #147333 quote
    robertogozzi
    Moderator
    Master

    I see it’s for v11.

    What TF and instrument is the one in your pics?

    What time is the unmarked low?

    #147335 quote
    Malend
    Participant
    Average

    I use it on different time frames. This one is on EURUSD 200 ticks.
    The unmarked low doesn’t stay unmarked, as I said, when I refresh the indicator by only open the indicator editor it marks it, or by making the whole indicator invisble first and then visible again. I don’t know why. So the dropp out  in the image is allready working, but then a new one, mainly the last ones, sometimes don’t show up.

    #147338 quote
    robertogozzi
    Moderator
    Master

    I cannot see the missing LOW you are referring, what time was it?

    Moreover, the candlesticks I see are pretty much different from yours, is that Spot EurUsd?

    If I can’t replicate exactly your trades, I can’t help you.

    #147341 quote
    Malend
    Participant
    Average

    Yes, it is Spot Eur Usd, 200 ticks.
    Aren’t you able to see the horizontal green and red lines? These are the Highs (green) and the Lows (red) based on the stochastic cycles. Now I want 2 extended lines. The first one connects the last 2 Highs and the other one connects the last 2 Lows.
    I have added a new dropp out this evening. You see the time bar 19:25:07

    dropp-out.jpg dropp-out.jpg
    #147484 quote
    robertogozzi
    Moderator
    Master

    To draw those lines (supported by v11 only), you need to use two slightly different copies, with different names, of the same indicator.

    This is the same indicator as yours (ITF file attached, as well as a screenshot), but I commented out drawing red and green segments, then I added instructions to keep track of the last two green and red segment to draw those elongated lines at the end:

    DEFPARAM DrawOnLastBarOnly = true
    
    ONCE MyHigh1  = 0
    ONCE MyHigh2  = 0
    ONCE MyLow1   = 0
    ONCE MyLow2   = 0
    ONCE BarHigh1 = 0
    ONCE BarHigh2 = 0
    ONCE BarLow1  = 0
    ONCE BarLow2  = 0
    
    // This indicator marks highs and lows based on the Stochastic cycle
    K = stochastic[5,2]
    D = average[3](K)
    
    //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
    Dlowest2 = Dlowest
    Dlowest = D
    endif
     
    //End of cycle low
    If D > 50 and D[1] < 50 then
    incyclelow = 0
    endif
     
    //lowest macd and price in Stochastic cycle %D<50
    if incyclelow then
    lowestprice = min(lowestprice, low)
    Dlowest = min(Dlowest, D)
    endif
    
    //what is the lowest price bar of this cycle?
    if lowestprice<>lowestprice[1] then
    lowestpriceBar=barindex
    endif
    
    //LONG
    if incyclelow = 0 then
    if lowestpricebar <> BarLow1 then
    MyLow2  = MyLow1
    BarLow2 = BarLow1
    MyLow1  = lowestPrice
    BarLow1 = lowestpriceBar
    ENDIF
    //DRAWSEGMENT(lowestpriceBar,lowestprice,lowestpriceBar,lowestprice-50) COLOURED(0,50,0)  STYLE(dottedline, 1)
    //DRAWSEGMENT(lowestpriceBar,lowestprice,lowestpriceBar-4,lowestprice)  COLOURED(300,0,0) STYLE(line, 3)
    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
    
    endif
    //End of cycle high
    If D < 50 and D[1] > 50 then
    incyclehigh = 0
    endif
     
    //highest stoch and price in cycle high
    if incyclehigh then
    highestPrice = max(highestPrice, high)
    
    endif
    
    //what is the lowest price bar of this cycle?
    if highestprice<>highestprice[1] then
    highestpriceBar=barindex
    endif
    
    //SHORT
    if incyclehigh = 0 then
    if highestpricebar <> BarHigh1 then
    MyHigh2  = MyHigh1
    BarHigh2 = BarHigh1
    MyHigh1  = highestPrice
    BarHigh1 = highestpriceBar
    ENDIF
    //DRAWSEGMENT(highestpriceBar,highestprice,highestpriceBar,highestprice+50) COLOURED(50,0,0)  STYLE(dottedline, 1)
    //DRAWSEGMENT(highestpriceBar,highestprice,highestpriceBar-4,highestprice)  COLOURED(0,300,0) STYLE(line, 3)
    endif
    
    DrawRay(BarHigh2,MyHigh2,BarHigh1,MyHigh1) coloured(0,0,255,255)
    DrawRay(BarLow2 ,MyLow2, BarLow1, MyLow1)  coloured(0,0,255,255)
    
    return

    as to missing Red/Green segments, please let me know instrument, TF, date and time there should have been one.

    Highs-n-Lows-Price-Stoch-lines.itf x-5.jpg x-5.jpg
Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.

Wedges based in Cycle Highs and Lows


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Malend @malend Participant
Summary

This topic contains 13 replies,
has 2 voices, and was last updated by robertogozzi
5 years, 4 months ago.

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