Retrieve the level of a past High / Low
Forums › ProRealTime English forum › ProBuilder support › Retrieve the level of a past High / Low
- This topic has 5 replies, 2 voices, and was last updated 4 years ago by Ichimoku Reading.
-
-
10/02/2020 at 2:28 PM #146194
Hello,
I created a peak and valley indicator for a more complex use.
The first objective would be to determine if the last peak is higher or lower than the previous one, same thing for the troughs.
So I would like to know the variable that would allow me to find the price level of the previous trough or peak, that’s the object of my request.
The other objectives will be simple to implement once this problem is corrected.
Secondary objective that is not part of the request :
Determine the average price level over the X last peak
Create segments on the X last vertex with possible extensionAnd maybe other objectives…
In any case, the idea would be to know the trend in progress via the peaks and troughs or if we are in a row.
Once the indicator is finished, it will be made available in the library.
Thank you in advance for your help!
Translated, sorry for the errors12345678910111213141516171819202122232425262728////============================== Indicateur Sommet / Creuxif close > close[1] and close > close[2] thensommet = 1creux = 0if sommet = 1 and sommet[1] = 0 and low =< low[1] and low =< low[2] thendrawarrowup(barindex,low)elsif sommet = 1 and sommet[1] = 0 and low[1] < low and low[1] =< low[2] thendrawarrowup(barindex[1],low[1])elsif sommet = 1 and sommet[1] = 0 and low[2] < low[1] and low[2] < low thendrawarrowup(barindex[2],low[2])endifendifif close < close[1] and close < close[2] thencreux = 1sommet = 0if creux= 1 and creux[1] = 0 and high => high[1] and high => high[2] thendrawarrowdown(barindex,high)elsif creux= 1 and creux[1] = 0 and high[1] > high and high[1] => high[2] thendrawarrowdown(barindex[1],high[1])elsif creux= 1 and creux[1] = 0 and high[2] > high[1] and high[2] > high thendrawarrowdown(barindex[2],high[2])endifendifreturn1234567891011121314////============================== Indicateur Sommet / Creuxif close > close[1] and close > close[2] thensommet = 1creux = 0endifif close < close[1] and close < close[2] thencreux = 1sommet = 0endifreturn sommet,creux10/02/2020 at 2:48 PM #146197Useful snippets about the Dow theory / peaks and troughs:
Tops/bottoms (fractals) average:
https://www.prorealcode.com/topic/fractals-average-using-arrays/
1 user thanked author for this post.
10/02/2020 at 6:06 PM #146224Well, I managed to code a channel and points according to my definition of a peak or trough.
The problem is the following, I would like to draw two lines, a high line that joins the last two peaks and a low line that joins the last two troughs.
The barindex of the line must be the same as that of the points drawn by the indicator, for my part, I can’t determine the barindex in time .
I would like to have a hand with this problem x)10/02/2020 at 6:07 PM #146225Sommet / Creux123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051////============================== Indicateur Sommet / Creux//Calcul de distanceMX = 2*WeightedAverage[round(200/2)](close) - WeightedAverage[200](close)MMX = WeightedAverage[round(SQRT(200))](MX)UX = MMX+STD[200]*0.05DX = MMX-STD[200]*0.05ST = (UX-DX)//============================== Definition des sommet//Calcul des sommetif close < close[1] and close < close[2] thensommet = 1creux = 0if sommet= 1 and sommet[1] = 0 and high => high[1] and high => high[2] thendrawtext("•",barindex,high+ST)Lsommet = highelsif sommet= 1 and sommet[1] = 0 and high[1] > high and high[1] => high[2] thendrawtext("•",barindex[1],high[1]+ST)Lsommet = high[1]elsif sommet= 1 and sommet[1] = 0 and high[2] > high[1] and high[2] > high thendrawtext("•",barindex[2],high[2]+ST)Lsommet = high[2]endifendif//============================== Definition des creux//Calcul des creuxif close > close[1] and close > close[2] thencreux = 1sommet = 0if creux = 1 and creux[1] = 0 and low =< low[1] and low =< low[2] thendrawtext("•",barindex,low-ST)Lcreux = lowelsif creux = 1 and creux[1] = 0 and low[1] < low and low[1] =< low[2] thendrawtext("•",barindex[1],low[1]-ST)Lcreux = low[1]elsif creux = 1 and creux[1] = 0 and low[2] < low[1] and low[2] < low thendrawtext("•",barindex[2],low[2]-ST)Lcreux = low[2]endifendifTG = (Lsommet+Lcreux)/2return Lsommet,Lcreux,TG10/04/2020 at 4:07 PM #146393The code has changed, I’ve simplified it, I’ve overworked the definition of a peak or a trough.
On the other hand, the problem remains the same, how could I flip the bar index of the previous peak or trough?
12345678910111213141516171819202122232425262728////================================================= Indicator Top & Bottom//================================================= Top//===== TopTop1 = high[2] < high[1] and high[1] > highTop2 = high[3] < high[2] and high[2] =< high[1] and high[1] > highXTop = Top1 or Top2if XTop thenDrawarrowDown(Barindex[1],high[1])endif//================================================= Bottom//===== BottomBottom1 = low[2] > low[1] and low[1] < lowBottom2 = low[3] > low[2] and low[2] => low[1] and low[1] < lowXBottom = Bottom1 or Bottom2if XBottom thenDrawarrowUp(Barindex[1],low[1])endifreturn10/04/2020 at 4:44 PM #146398Answer in the learning videos, as much for me…
Thank you Nicolas -
AuthorPosts
Find exclusive trading pro-tools on