pdrhParticipant
Average
LFlag=0
ignored, indicator1 = CALL "HARKO_Fractals BW"[5](close)
c1=close crosses over indicator1
If c1 then
LFlag=1
Entry=indicator1
ENDIF
c2=low<Entry
IF c2 AND LFlag=1 AND LT<1 And timeEnterBefore AND timeEnterAfter THEN
BUY 1 CONTRACT AT Entry Limit
LT=LT+1
ENDIF
I am wanting to set a flag that stays for a number of bars .
With the code above , the flag resets to zero after the bar that triggered it so that I cannot get a limit entry .
Hi pdrh – The base of the solution you ask for is chaning the first line into
Once LFlag=0
Now its value will stay because only at the first call of your code it is set to 0.
This is not the complete solution, because somewhere you will need to reset it. This will come down to
If OnMarket then
LFlag = 0
endif
I think this is still not correct, because you’d want to set FLag each new call, which could be done like this :
LFlag=close crosses over indicator1
Of course you’d need to adjust the remainder somewhat. This is not easy to see because it depends on what you want. For example, letting LFlag be on lways after this crssing happened once, does not seem the correct solution to me. This would rather be to reset LFlag at each call … but … (this is what the last by me shown line does and which makes the first line’s adjustment redundant).