Finding last two Fractals position
Forums › ProRealTime English forum › ProBuilder support › Finding last two Fractals position
- This topic has 8 replies, 4 voices, and was last updated 4 years ago by robertogozzi.
-
-
06/27/2017 at 4:39 AM #39154
Hi Guys,
I am trying to write some code to find the time (index) when the last two low Fractals occurred, or the last two High Fractals occurred.
I want to use their positional information to calculate Fractal divergence against an indicator.
I am struggling as the normal Fractal code uses the “lowest” function which works for the last Fractal, but does not allow an offset to find the 2nd to last Fractal.
Any help much appreciated.
B.
06/27/2017 at 1:49 PM #3922206/27/2017 at 8:02 PM #39248Thanks Nicolas,
I am having trouble with how to store the previous Fractal, in the code snippet (just the low Fractal):
Previous Fractal123456789cp = 2 //(default)PreviousLF = -1if low[cp] <= lowest[2*cp+1](low) thenCurrentLF = barindexelseCurrentLF = -1endifI don’t know how/when to save the CurrentLF to PreviousLF
Cheers
06/28/2017 at 10:15 AM #3927906/28/2017 at 8:01 PM #3933710/13/2020 at 10:41 PM #147345Hi im trying to find the values of the previous THREE factals. Having trouble.
12345678910111213141516171819cp = 20if high[cp] >= highest[2*cp+1](high) thenpprevioushf = PrevioushFPrevioushF = CurrentHFCurrentHF = barindexendifif low[cp] <= lowest[2*cp+1](low) thenppreviouslf = PreviousLFPreviousLF = CurrentLFCurrentLF = barindexendifTOPy = high[currenthf]TOPy1 = high[previoushF]TOPy2 = high[pprevioushF]BOTy = low[currentLF]BOTy1 = low[previousLF]BOTy2 = low[ppreviouslfCan somebody help me?
10/14/2020 at 12:13 AM #147351This Nicolas’code modified to accomodate for another two places:
123456if low[cp] <= lowest[2*cp+1](low) thenPrevious3LF = Previous2LFPrevious2LF = Previous1LFPrevious1LF = CurrentLFCurrentLF = barindexendifso you can now access Previous1LF, Previous2LF and Previous3LF.
1 user thanked author for this post.
10/14/2020 at 12:19 AM #147353Thankyou for your reply.
If i want to find the value(high or low) of a previous factal such as ‘previous3LF’, is this code correct?
1Top3 = high[previous3LF]10/14/2020 at 12:42 AM #147356No, you should write:
1Top3 = high[BarIndex - previous3LF]Because if now it’s BarIndex 100 and previous3LF is 81, then you have to access the 19th previous bar to get the correct value.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on