Preventing re-entry

Forums ProRealTime English forum ProOrder support Preventing re-entry

Viewing 7 posts - 1 through 7 (of 7 total)
  • #118265

    I’m sure this will be simple for any of the experts on here, so if you could spare a minute I’d be very grateful…

    I have a program that only enters trades in pre-defined time zones. I want it to only enter once during each time zone. I’ve tried very hard to read the manual and understand ONCE statements but I can’t seem to make them work. I also think there might be a simple solution to make my “entered=1” flag work at the right times, without needing a ONCE.

    I’ve attached a screengrab of what my entered flag is currently doing. In short, I want “entered” to remain at 1 until the end of the current time zone (in this case, until 100600). It currently dips to zero once the first entry is finished and allows another entry, which I don’t want. Or alternatively I’d be happy for it to remain at 1 and be reset by the new time zone (in this case, 155200).

    Any ideas?

     

    #118270

    Lines 28-29 are a bit odd, starting time is AFTER ending time.

    You should define a flag variable for each TZ, say tueFlag1, tueFlag2,… then wedFlag1, wedFlag2,… and set them to 1 each new day (when IntraDayBarIndex = 0).

    Then whenever you enter a trade, be it Long or Short, set each one of them (according to correct TZ at that moment) to 0. You’ll have to use multiple IF…ENDIF blocks to achieve that.

    Finally you’ll have to add each one of those flags to your conditions to open a trade.

    You will have to add tens of lines of code (with IF…ENDIF) to your code to achieve that.

    If you are patient enough to wait a few months you will take advantage of the upcoming ARRAY support (now in the works) which will make this job way too esier!

    1 user thanked author for this post.
    #118287

    Thanks for the suggestion. I’ll try it out later.

    Yes, I must say I was surprised that there wasn’t a specific array function when I first looked through the PRT manual. I think it will shorten a lot of our code once it comes out!

    #118360

    Roberto,

    I’ve tried to follow your instructions but I still can’t get it right. I’ve simplified the code to be just one time zone so it is easier for us to understand.

    As you can see from the screengrab, tueflag1 correctly becomes 1 at the beginning of the time zone and then correctly becomes 0 when I enter the market. But the problem is that the flag resets itself to 1 on the next bar. How can I stop the flag reseting itself to 1?

     

     

     

    #118375

    Only switch the flag at the beginning and end. Change lines 24 to 28 to:

     

    2 users thanked author for this post.
    #118386

    Thank you!

    Oh man I was so stupid! I now realise that “time >=X and time <=X” creates a constant positive loop within that zone.

    #118524

    there wasn’t a specific array function when I first looked through the PRT manual. I think it will shorten a lot of our code once it comes out!

    Indeed! and i’m currently testing it. Array works very well so far as an alpha version and it’s pleasant now to know that we can almost code anything with them.

Viewing 7 posts - 1 through 7 (of 7 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login