Only one trade per day

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #222658 quote
    897148
    Participant
    Average

    Only one trade per day.

    My auto system trades between 09h00 & 15h00 and can take several trades per day.

    I now wish to only take one trade per day, the first one.

    How do I code this requirement?

    #222663 quote
    robertogozzi
    Moderator
    Master

    As posted in https://www.prorealcode.com/topic/help-with-limiting-strategy-to-one-trade-per-day/#post-143705, you can use

    OTD = Barindex - TradeIndex(1) > IntradayBarIndex

    then you can add OTD to your entry conditions, like the example in the link above.

    897148 thanked this post
    #222676 quote
    897148
    Participant
    Average

    Thank you so much Roberto.

    I could hardly believe the speed of response !

    OTD worked like a charm.

    #222683 quote
    897148
    Participant
    Average

    Spoke too soon.

    OTD worked perfectly on back test but when live didnt enter trade when it should have.
    I have taken this up with PRT as per norm but no solution as yet. Any suggestions ??

    #222703 quote
    robertogozzi
    Moderator
    Master

    These 2 snippets seem to work as expected (one uses OTD, the other one doesn’t):

    DEFPARAM CumulateOrders = False
    OTD = Barindex - TradeIndex(1) > IntradayBarIndex
    Bulls = summation[3](close >= open) = 3
    Bears = summation[3](close <= open) = 3
    IF Bulls AND Bears[3] AND Not OnMarket AND OTD THEN
       BUY AT MARKET
    ENDIF
    SET TARGET pPROFIT 6
    SET STOP   pLOSS   6
    DEFPARAM CumulateOrders = False
    Bulls = summation[3](close >= open) = 3
    Bears = summation[3](close <= open) = 3
    IF Bulls AND Bears[3] AND Not OnMarket THEN
       BUY AT MARKET
    ENDIF
    SET TARGET pPROFIT 6
    SET STOP   pLOSS   6

    anyway, I’ll keep testing them next Monday.

    #222717 quote
    JS
    Participant
    Senior

    Hi @897148

    Note that the TradeIndex(1) gives both a value when a position is opened and also when a position is closed…

    With “If OnMarket and OTD” you know that a position was opened yesterday (or earlier) that is currently still open…

    With “If NOT OnMarket and OTD” you know that a position was closed yesterday (or earlier) and that a position can now be opened again…

    As Roberto also points out, use the OTD in combination with NOT OnMarket….

    If Conditions and NOT OnMarket and OTD then

    “Buy or SellShort”

    897148 thanked this post
    #222823 quote
    robertogozzi
    Moderator
    Master
    My two snippets work correctly, the one using OTD opens only 1 trade per day, while the other one opens tens of trades.
    897148 thanked this post
    #222846 quote
    897148
    Participant
    Average
    I need to give a very big thankyou to Roberto and JS. The OTD and Not OnMarket worked perfectly today when I ran live along with the original, multi trade version which took two trades in the allocated time but OTD only one as desired. I still find it hard to believe how helpful some people are. Restores some much needed faith in mankind .
    JS and robertogozzi thanked this post
    #232578 quote
    iococcobill
    Participant
    New
    OTD = Barindex - TradeIndex(1) > IntradayBarIndex
    
    If myConditions AND NOT onmarket Then
    If marketposition < 1 AND OTD Then
    BUY AT MARKET
    marketposition = 1
    EndIf
    If marketposition > -1 AND OTD Then
    SELLSHORT AT MARKET
    marketposition = -1
    EndIf
    EndIf
    Hi, I’ve used this old post to solve the problem of not having more than one trade on the same day, unfortunately, I still could have one trade long and another one short, can you suggest to me how to solve that? Many thanks for considering my request. Stefano
    #232579 quote
    fifi743
    Participant
    Master
    and like this    
    if IntradayBarIndex =0 THEN 
    NBtrade=0
    ENDIF 
    if (longonmarket[1]=0 and longonmarket )or(SHORTONMARKET[1]=0 and SHORTONMARKET )THEN 
    NBtrade=1
    endif
    if condition and nbtrade<1 THEN 
    buy 1 CONTRACTS AT MARKET 
    ENDIF 
    if condition and nbtrade<1 THEN 
    SELLSHORT 1 CONTRACTS AT MARKET 
    endif
    robertogozzi thanked this post
    #232585 quote
    iococcobill
    Participant
    New
    Thanks
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Only one trade per day


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
897148 @897148 Participant
Summary

This topic contains 10 replies,
has 5 voices, and was last updated by iococcobill
1 year, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/19/2023
Status: Active
Attachments: No files
Logo Logo
Loading...