Can I set a flag wich stays over a number of bars

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #194366 quote
    pdrh
    Participant
    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 .

    #194379 quote
    PeterSt
    Participant
    Master

    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).

    Nicolas and pdrh thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Can I set a flag wich stays over a number of bars


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
pdrh @pdrh Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by PeterSt
3 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/01/2022
Status: Active
Attachments: No files
Logo Logo
Loading...