Hi all,
I saw the Lowest fonction can find a lowest of a variable on the last X periodes for exemple, but how to find a lowest between 2 barindex for exemple between Y1 and Y2 ?
for exemple on this photo how to find the lowest Low between Candle[5] and Candle[36] ( Y2=36 / Y1=5) ?
entre ces 2 valeurs
From 5 to 36, there are 36-5+1 = 32 candles, we simply ask what was 5 candles ago the lowest among 32:
a=lowest[32](low)
b=a[5]
return b
or if you want to easily change Y1 and Y2 (with Y2>Y1 implied, haven’t added an IF statement to protect against the opposite):
Y1=5
Y2=36
a=lowest[Y2-Y1+1](low)
b=a[Y1]
return b
JSParticipant
Senior
Lowest Low between candle[5] and candle[36]:
a = Lowest[36](Low[5])
tks to all for your answers,
and how to get the barindex number of this lowest candle ?
I saw some solution like doing a For y = 0 to 38 for exemple and compare the Lowest we get before with your solution with the Low[y] of each candle for get the barindex, but maybe they have other short soluttion ?
There you go:
x = LowestBars[36](low[5]) //HighestBars for the highest
tks for your answer but I’m totaly confused, I don’t understand why it’s not working or mabt I don’t know how to use it, with my result I find the barindex 21 the blue cyrcle but with yous I find barindex = 8 the red cyrcle, where I’m wrong ? I want the fast solution for using less of computer ic
Defparam drawonlastbaronly = true
a = Lowest[36](Low[13])
// Roberto Solution
x = LowestBars[36](low[13])
For i = 0 to 36 Do
IF Low[i] = a Then
X1 = i
drawtext("Barindex = #i#",barindex[i],Low[i])
// Roberto Barindex
drawtext("Barindex = #x#",barindex[x],Low[x])
break
ENDIF
Next
Return
Best Reguards
This is my Elder Triple screen now and headache, I’m sure your solution will be on 2 or 3 lines 🤣🤣🤣
I don’t know why I don’t know to use you solution, but I found this one :
Defparam drawonlastbaronly = true
a = Lowest[36](Low[13])
// Roberto Solution
x = LowestBars[36](low[13])
Roberto = 13 + x
IF X Then
drawtext("RobertoIndex = #Roberto#",barindex[Roberto],Low[Roberto])
ENDIF
Return
if I the drawtext fonction with out IF condition, I get error because the LowestBars fonction can get -1 as a result
now the good barindex is 22 instead 21 because I got one candle more in H4 TF
Because the 13th bar is bar 12 (0 to 12 is 13 bars), so you will have to adjust your calculations.
JSParticipant
Senior
From 0 to 13 is 14 bars so use:
Roberto = 14 + x
It is of course possible I misunderstood the initial query, or even if I hadn’t I would easily concede perhaps I made the explanation too short alongside my proposal. But I would have to respectfully disagree with the other proposal.
If you write: a = Lowest[36](Low[5]) , it doesn’t give you the lowest low between candle[5] and candle[36], it would give the lowest low below candle[5] and candle[41], because at candle[36] what was lowest[5] at that time is a lowest[41] seen from now. So on one hand yes it would easily get rid of unwanted candles[0] through [4] in the search, but on the other hand it adds unwanted extra 5 candles [37] through [41] beyond [36].
Which is why I suggested: to first assess the span of the search (Y2–Y1+1 = 36-5+1 = 32 candles wide), to search that span for lowest low (that’s “a”), and from there to offset it by Y1=5 (that’s “b”), with:
Y1=5
Y2=36
a=lowest[Y2-Y1+1](low)
b=a[Y1]
as a way of eliminating candles [0] through [4] and simultaneously avoiding addition of unwanted extra candles beyond Y2 at the other end of the spectrum in the search interval.
JSParticipant
Senior
Hi @JC_Bywan,
You are right about adding 5 extra candles…
The starting point is low[5] and from there your look back period is [36] = 5 + 36
So this must also give the right answer: a = Lowest[Y2-Y1+1](Low[Y1])
JSParticipant
Senior
Perhaps a system can be made of this?
When you know where the Lowest Low (LL) and the Highest High (HH) occur, you can say in the simplest form;
When the HH occurs after the LL then you are in an ascending phase and vice versa when the LL occurs after the HH then you are in a downward phase.
With the formulas:
LLBar = LowestBars[n](Low) you determine the bar where the LL occurs
HHBar = HighestBars[n](High) you determine the bar where the HH occurs
When LLBar > HHBar (Bullish)
When LLBar < HHBar (Bearish)
Of course, this is the simplest form but maybe with MTF, SL, TP, etc. we can improve this system.
DefParam CumulateOrders = False
LLBar = LowestBars[n](Low)
HHBar = HighestBars[n](High)
If LLBar > HHBar then
Buy 1 Contracts at Market
ElsIf LlBar < HHBar then
SellShort 1 Contracts at Market
EndIf
Graph LLBar as "LowestBar"
Graph HHBar as "HighestBar"