Indicator for Close > highest and Close < lowest
Forums › ProRealTime English forum › ProOrder support › Indicator for Close > highest and Close < lowest
- This topic has 12 replies, 4 voices, and was last updated 10 months ago by RichardVeen.
-
-
01/30/2024 at 10:22 AM #227079
I want to create an indicator which create a signal when the Close > highest (of 10 candles) and when the Close < lowest (of 10 candles)
The code I wrote is:
LL= (low=lowest[10](low))
HH=(high=Highest[10](high))If Close>HH then
DRAW…..
elsif Close>LL then
DRAW….
EndIf
ReturnBut when I add this code to my screen then the indicator appear for all candles which are higher or lower than the previous candle, so it doesn’t look at the highest/lowest of the previous 10 candles.
What is wrong with the code?
01/30/2024 at 10:43 AM #227082Add this line at the very beginning:
1DEFPARAM DrawOnLastBarOnly = True1 user thanked author for this post.
01/30/2024 at 10:56 AM #227085Hi,
2 separate errors.
1) First you defined HH and LL and boolean variables equal to 0 if false, or 1 if true, but later used them for comparison with close, suggesting what you really expect from HH and LL is a level, not a 0 or 1 boolean.
You wrote:
LL= (low=lowest[10](low))
HH=(high=Highest[10](high))but you want:
LL= lowest[10](low)
HH= Highest[10](high)2) Second, you checked above LL instead of below
You wrote:
elsif close > LL then
but according to text description, you meant:
elsif close < LL then
01/30/2024 at 7:32 PM #227112Thanks for your feedback.
I followed your advised and the code is now:
DEFPARAM DrawOnLastBarOnly = True
LL= lowest[10](low)
HH= Highest[10](high)If Close>HH then
DRAWARROWdown(barindex,high + 2.5 ) COLOURED(“Blue”,255)
elsif Close<LL then
DRAWARROWup(barindex,low – 2.5 ) COLOURED(“Yellow”,255)
EndIf
ReturnBut now, the indicator doesn’t work at all, I don’t see any arrow on my screen.
Please help.
01/30/2024 at 7:37 PM #227113I don’t see any arrow on my screen.
Is it possible that price is between your 2 conditions and so no arrow would be generated?
01/30/2024 at 7:44 PM #227114You’re right, there was a third error in the code, if latest close is part of the set of 10 candles, it can’t be higher or lower than itself. So when you considered a set of 10 candles, it depends if you included current one in it, or wanted the 10 previous ones.
If your 10 includes current one, you have to allow for equality and use: close>=HH , close<=LL
If your 10 are the 10 previous ones, you can use strictly above or below with: close>HH[1] , close<LL[1] ,
01/30/2024 at 7:44 PM #227115There is a situation where I expect to see the indicator.
See attachement.
01/30/2024 at 7:57 PM #227117Hi Graham,
What do you mean exactly?
01/30/2024 at 7:58 PM #227118I changed the code (see below) but nothing happened:
DEFPARAM DrawOnLastBarOnly = True
LL= lowest[10](low)
HH= Highest[10](high)If Close>=HH[1] then
DRAWARROWdown(barindex,high + 2.5 ) COLOURED(“Blue”,255)
elsif Close<=LL[1] then
DRAWARROWup(barindex,low – 2.5 ) COLOURED(“Yellow”,255)
EndIf
Return01/30/2024 at 8:09 PM #227121No defparam line, just:
123456789LL= lowest[10](low)HH= Highest[10](high)If Close>=HH[1] thenDRAWARROWdown(barindex,high + 2.5 ) COLOURED(“Blue”,255)elsif Close<=LL[1] thenDRAWARROWup(barindex,low – 2.5 ) COLOURED(“Yellow”,255)EndIfReturn(or Close>HH[1], Close<LL[1] if you don’t want your arrow when equal to highest or lowest of previous 10)
1 user thanked author for this post.
01/30/2024 at 8:16 PM #227128Yes, it’s working!
Thanks JC_Bywan!
01/30/2024 at 8:19 PM #227130What do you mean exactly?
If …
- Price / close of the current bar is less than the highest high of the 10 previous bars
and at the same time …
2. Price / close of the current bar is greater than the lowest low of the 10 previous bars
then
3. There will not be an arrow drawn above or below the current bar.
1 user thanked author for this post.
01/30/2024 at 8:33 PM #227131Thank you for your explanation!
The code that JC_Bywan wrote is working.
- Price / close of the current bar is less than the highest high of the 10 previous bars
-
AuthorPosts
Find exclusive trading pro-tools on