Use Lower/Higher Low/ High as Trend signal
Forums › ProRealTime English forum › ProBuilder support › Use Lower/Higher Low/ High as Trend signal
- This topic has 17 replies, 4 voices, and was last updated 3 years ago by murre87.
Tagged: fractals
-
-
10/16/2020 at 4:21 PM #147578
Hello,
I wish to have a Trend indicator based on “higher high (HH) / higher low (HL) and lower low (LL) / lower high (LH)” system.
The rules would be the following :
- Trend UP (+1) : HH and HL alternating
- Trend Down (-1) : LH and LL alternating
- Neutral State (0) : when both are mixing up.
I guess that “Fractal ZigZag” would be a great help as I’m also considering to implement this in a ProBuilder strat besides my manual trading.
As per Nicolas comment this zigzag suits well for automatic purposes .
https://www.prorealcode.com/prorealtime-indicators/fractals-zigzag/
Yet I can’t figure out how to make that rule check
I would greatly appreciate your help on this matter as it overpasses my PRT knowledges . Thanks for any hint ot help on this.
Illustration picture attached. The goal is only to have a barchart indicator (1/0/-1), boxes are just a visual help not mandatory.
10/21/2020 at 3:01 PM #148000Hello,
- Sorry for not posting any code snipet but at this point I’m really struggling and all are failing to achieve what I want…
- Please find the below picture on Dax Cash Daily View so it can be easier to understand.
Don’t pay attention to color trendlines at the very top.
You can notice the code drawing HHHL / LHLL behind
(Wich isnt suited for ProOrder as per my understanding but it helps to make things clearer on chart)
Kind regards
10/21/2020 at 3:10 PM #14800210/22/2020 at 9:33 AM #148063The code for this latter indicator is zigzag based and therefore not available to execute an automatic trading strategy under ProOrder. What you are looking for is neither more nor less than a fractal breakout (high / low points), with the condition of bullish or bearish waves, as you describe in your first post.
10/25/2020 at 10:50 AM #148386- No worries, as said the zigzag code was here only for visual purpose. My attempts are based on Fractal “zigzag
My snippet for TrendUp at line 44. Doesnt seem to be close form what I want from the screenshot above.
Would you mind hinting more on this ?
Snippet for trend up try12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152defparam calculateonlastbars=10000//cp = 3once lastpoint = 0if high[cp] >= highest[2*cp+1](high) thenPEAK = 1elsePEAK = 0endifif low[cp] <= lowest[2*cp+1](low) thenTROUGH = -1elseTROUGH = 0endifif PEAK = 1 thenTOPy = high[cp]TOPx = barindex[cp]endifif TROUGH = -1 thenBOTy = low[cp]BOTx = barindex[cp]endifif PEAK>0 and (lastpoint=-1 or lastpoint=0) thenDRAWSEGMENT(lastX,lastY,TOPx,TOPy) COLOURED(200,0,0,255)DRAWTEXT("■",TOPx,TOPy,Dialog,Bold,20) coloured(200,0,0,255)lastpoint = 1lastX = TOPxlastY = TOPyendifif TROUGH<0 and (lastpoint=1 or lastpoint=0) thenDRAWSEGMENT(lastX,lastY,BOTx,BOTy) COLOURED(0,200,0,255)DRAWTEXT("■",BOTx,BOTy,Dialog,Bold,20) coloured(0,200,0,255)lastpoint = -1lastX = BOTxlastY = BOTyendif//TREND ATTEMPTif TOPy > TOPy[1] or Close > TOPy[1] thentrendup = 1elsetrendup = 0endifRETURN TOPy as "TOPy", BOTY as "BOTy", trendup as "trendup"10/26/2020 at 9:43 AM #148483In the below version of the code, I add an arrow when a new trend is detected (the new fractal top is higher than the last one). It only marks with an arrow the start of the new trend.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455defparam calculateonlastbars=10000cp = 3once lastpoint = 0if high[cp] >= highest[2*cp+1](high) thenPEAK = 1elsePEAK = 0endifif low[cp] <= lowest[2*cp+1](low) thenTROUGH = -1elseTROUGH = 0endifif PEAK = 1 thenTOPy = high[cp]TOPx = barindex[cp]endifif TROUGH = -1 thenBOTy = low[cp]BOTx = barindex[cp]endifif PEAK>0 and (lastpoint=-1 or lastpoint=0) thenDRAWSEGMENT(lastX,lastY,TOPx,TOPy) COLOURED(200,0,0,255)DRAWTEXT("■",TOPx,TOPy,Dialog,Bold,20) coloured(200,0,0,255)lastpoint = 1lastX = TOPxlastY = TOPyendifif TROUGH<0 and (lastpoint=1 or lastpoint=0) thenDRAWSEGMENT(lastX,lastY,BOTx,BOTy) COLOURED(0,200,0,255)DRAWTEXT("■",BOTx,BOTy,Dialog,Bold,20) coloured(0,200,0,255)lastpoint = -1lastX = BOTxlastY = BOTyendif//TREND ATTEMPTatr=AverageTrueRange[14](close)if TOPy > TOPy[1] and topy<>lasttop thendrawarrowup(barindex,low-atr/2) coloured(0,200,0)lasttop=topytrendup = 1elsetrendup = 0endifRETURN TOPy as "TOPy", BOTY as "BOTy", trendup as "trendup"10/26/2020 at 11:47 AM #148498Thanks Nicolas
see attached “late_signal” compared to my “lightening pattern”.
I tried to include the condition when Daily candle close higher than previous TOPy (wich make the Close the new potential higher high) :
With Close condition1234567891011cp = 10//TREND UP ATTEMPTatr=AverageTrueRange[14](close)if (TOPy > TOPy[1] and topy<>lasttop) OR (Close > TOPy[1] )thendrawarrowup(barindex,low-atr/2) coloured(0,200,0)lasttop=topytrendup = 1elsetrendup = 0endifResults on the second screenshot. Which looks closer to my expectation. Yet there is some unknown “glory holes” cutting the trend besides the fact that there is HH and HL from the Fractal PoV.
thanks
10/26/2020 at 1:21 PM #14850410/26/2020 at 3:54 PM #148526Sorry but I’m seriously confused in these fractals code to achieve what seems to be simple…
My TrendUP conditions should be the following :
- (Close > Latest Peak) AND ( Latest Trough > Previous Trough)
- OR
- (Close > Latest Trough) AND ( Latest Trough > Previous Trough)
Can you correct me if I’m wrong in the translation into code :
- (Close > TOPy ) AND ( BOTx > BOTx[1])
- OR
- (Close > BOTx ) AND (BOTx > BOTx[1])
Thanks
10/27/2020 at 10:04 AM #148636x = barindex and y = price , so ( Latest Trough > Previous Trough) , should be coded like this:
( BOTy > BOTy[1])
But, keep in mind that this condition will only work once, on the first bar when the new fractal low will be detected and not afterward..
10/27/2020 at 2:58 PM #148661What seems to be a “neither more nor less than a fractal breakout” is still far away from running properly 🙂
12345678910111213//TREND UP ATTEMPTatr=AverageTrueRange[14](close)//if ( TOPy > TOPy[1] and topy<>lasttop) OR (Close > TOPy[1]) OR (Close > lastY)thenif (Close > TOPx AND BOTy > BOTy[1])drawarrowup(barindex,low-atr*2) coloured(0,200,0)//lasttop=topytrendup = 1elsetrendup = 0endifTest of first condition alone : if (Close > TOPy AND BOTy > BOTy[1])
Screenshot attached.
-> The arrow ( under Close of May 27) is 2 candles late.
25 of May 2020 ‘s CLose was 11387 wich is higher than 11342 So the arrow should had start at this date.
And the result is exactly the same for the second condition (arrown drawn starting of 27 May 2020)
Second conditions (alone)1234567891011//TREND UP ATTEMPTatr=AverageTrueRange[14](close)//if ( TOPy > TOPy[1] and topy<>lasttop) OR (Close > TOPy[1]) OR (Close > lastY)thenif(Close > BOTx AND BOTy > BOTy[1]) thendrawarrowup(barindex,low-atr*2) coloured(0,200,0)//lasttop=topytrendup = 1elsetrendup = 0endif“But, keep in mind that this condition will only work once, on the first bar when the new fractal low will be detected and not afterward..”
As stated in the first message, this is supposed to be a Trend 1/0/-1 indicator so the signal must be alive as long at the conditions are valids. Are we okay to deal like this as per the code above ? Otherwise it’s an issue.
Thanks for your help, wish we can sort this out so it can assist my manual trading and work on the automatic later. I will share my tought on that.
10/28/2020 at 9:29 AM #14875610/28/2020 at 9:46 AM #148758So here is new attempt. I mark the bullish trend (trendup variable) with a dark green background on the price chart. I don’t know how the trend is ending, so I reset it on the first trough lower than the previous one.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960defparam calculateonlastbars=3000cp = 3once lastpoint = 0if high[cp] >= highest[2*cp+1](high) thenPEAK = 1elsePEAK = 0endifif low[cp] <= lowest[2*cp+1](low) thenTROUGH = 1elseTROUGH = 0endifif PEAK then//prevtop = topyTOPy = high[cp]TOPx = barindex[cp]endifif TROUGH thenprevbot = botyBOTy = low[cp]BOTx = barindex[cp]endifif PEAK and (lastpoint=-1 or lastpoint=0) thenDRAWSEGMENT(lastX,lastY,TOPx,TOPy) COLOURED(200,0,0,255)DRAWTEXT("■",TOPx,TOPy,Dialog,Bold,20) coloured(200,0,0,255)lastpoint = 1lastX = TOPxlastY = TOPyendifif TROUGH and (lastpoint=1 or lastpoint=0) thenDRAWSEGMENT(lastX,lastY,BOTx,BOTy) COLOURED(0,200,0,255)DRAWTEXT("■",BOTx,BOTy,Dialog,Bold,20) coloured(0,200,0,255)lastpoint = -1lastX = BOTxlastY = BOTyendif//TREND ATTEMPT//bullish trend is startingif boty>prevbot and close>topy and lasty<>lasty[1] and not trendup thentrendup = 1endif//bullish trend is endingif trough and boty<prevbot and lasty<>lasty[1] and trendup thentrendup=0endif//trend is up, coloring the background!if trendup thenbackgroundcolor(0,200,0,50)endifRETURN //TOPy as "TOPy", BOTY as "BOTy", trendup as "trendup"1 user thanked author for this post.
10/28/2020 at 2:39 PM #148788Seems perfect Nicolas 🙂
Thanks a lot
Below, fixed snipet for my personnal ending trend condition.
+ bearish trend
For trading purpose : In case of a trend up for example, please note that if the trend break on the indicator BUT the price come back 2/3 days after above the break line (wich is the previous higher low), it can be considered as a continuation in the trend up. This is pure discretionary, depending on the asset traded.
1234567891011121314151617// 1 bullish trend is startingif boty>prevbot and close>topy and lasty<>lasty[1] and not trendup thentrendup = 1endif// 1.1 bullish trend is endingif Close < boty thentrendup=0endif// 2 bearish trend is startingif topy<prevtop and close<boty and lasty<>lasty[1] and not trenddown thentrenddown = 1endif// 2.1 bearish trend is endingif Close > topy thentrenddown=0endif10/28/2020 at 2:47 PM #148791 -
AuthorPosts
Find exclusive trading pro-tools on