Help with limiting strategy to one trade per day

Forums ProRealTime English forum ProOrder support Help with limiting strategy to one trade per day

Viewing 11 posts - 1 through 11 (of 11 total)
  • #139465

    Morning,

    I’m very new to PRT coding (though not the markets in general) and have been trying to work on a 15-minute trend reversal strategy for the US 500.

    I’ve pulled several examples of very useful code (mostly from Nicolas) but tonight I’ve become stuck trying to limit the system to just taking one trade per day.  I’ve found multiple examples of how to fix the problem in the forums but when I try to institute each and every one of these (which are all similar), the strategy still occasionally takes 2 trades per day when I backtest (via IG) over the past 6 months and I can’t work out what I’m doing wrong.

    Any help would be much appreciated.

    Here is the code I’ve cobbled together so far (in the attachments).

    Mark

    * Accidentally uploaded the first pic twice – apologies as it didn’t seem to work initially

    #139473

    There you go:

    use TradeON as an additional condition to enter a trade.

     

     

    1 user thanked author for this post.
    #139483

    Many thanks for your swift reply Roberto!

    I’ll give that a whirl later this morning.

    Greatly appreciated.

    Mark

    #139484

    @robertogozzi

    Hi Roberto,

    I’ve just integrated that nice piece of code you sent me this am but frustratingly the order list indicates the strategy is still occasionally taking 2 trades in the same day (12 June, 1st July and 8th July).  See attached pics with updated code.

    Any idea how to get around this?

    Mark

    #139493

    Please paste the code using the “Insert PRT code” button, not pics of it, otherwise I cannot use it.

    Thank you 🙂

     

    #139496

    Moreover, use “@” only when there are so many users posting and you absolutely need to reference one of them. In this case it’s just the two of us. Because everytime you put that sign in front of a username, that user will receive an email.

    Thank you 🙂

     

    #139516

    Hi Roberto,

    Thanks for letting me know how things work and apologies for using ‘@’ .  I hadn’t even realised there was an ‘insert PRT code’ button!

    As requested, please find the code attached.

    Any ideas how to ensure the strategy only takes 1 trade/day?

    Many thanks

    Mark

    #139518

    It’s because at line 62 you are using BUY to exit a Short trade. No, you’ll have to replace it with EXITSHORT.

    To recap:

    • BUY opens a Long trade
    • SELL exits a Long trade
    • SELLSHORT opens a Short trade
    • EXITSHORT exits a Short trade

    using BUY at line 62 implies a Stop & Reverse, since the Short trade is first closed and new Long one is subsequently opened.

     

    1 user thanked author for this post.
    #139519

    Ahhh silly me.  I knew it had to be be something fundamental I was doing wrong.

    Have now corrected this and it works perfectly.

    Hugely appreciate your help with this Roberto!

    Many thanks again

    Mark

    #143596

    is there a different way to limit to ONE trade a day then: IntraDayBarIndex

    When my position ends before the first bar, it does not work. if my position closes at 0 bars.. it takes a new position.

    #143705

    Have a look how this code is used

    Taken from this strategy here:

    https://www.prorealcode.com/prorealtime-trading-strategies/optimization-ma-cross-machine-learning/

    1 user thanked author for this post.
Viewing 11 posts - 1 through 11 (of 11 total)

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