1 TRADE PER DAY

Viewing 12 posts - 1 through 12 (of 12 total)
  • #179862

    Hi there,

     

    This forum has been incredibly useful so far for a lot of things so thank you.

    I have seen a couple of posts regarding the 1 trade per day coding but non of them seem to work for me so I was wondering if there was just a standard code you can input into the strategy?

    Many thanks

    #179863

    Try to add this to your code:

    singleDayTrade = (barIndex-tradeIndex(1)>intradayBarIndex)

     

     

     

    #179873

    Thanks for trying but it doesn’t seem to work.

    #179876

    Very strange, it should work.

    In any case, try this snippet (Nicolas):

    if intradaybarindex=0 or day<>day[1] then
    count=0
    endif

    if ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) or (not onmarket and onmarket[1])) then
    count=count+1
    endif

    Then:

    if “myConditions” and count<1 then

     

    #179879

    Unfortunately that doesn’t work either. I’ll put the code below to see if anyone can figure out why…

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    // Conditions to enter long positions
    indicator1 = (DHigh(1) + DLow(1) + DClose(1))/3-(DHigh(1)-DLow(1))
    c1 = (close <= indicator1)
    indicator2 = RSI[14](close)
    c2 = (indicator2 <= 30)
    indicator3 = MACDline[12,26,9](close)
    c3 = (indicator3 <= -0.0015)
    indicator4 = DLow(1)-2*(DHigh(1)-(DHigh(1) + DLow(1) + DClose(1))/3)
    c4 = (close >= indicator4)

    if intradaybarindex=0 or day<>day[1] then
    count=0
    endif

    if ( (not onmarket and onmarket[1] and not onmarket[2]) or (tradeindex(1)=tradeindex(2) and tradeindex(1)=barindex[1] and tradeindex(1)>0) or (not onmarket and onmarket[1])) then
    count=count+1
    endif

    // initiate a new BUY order
    if c1 AND c2 AND c3 AND c4 and count<1 THEN
    BUY 10 CONTRACT AT MARKET
    endif

     

    // Conditions to exit long positions
    indicator5 = MACDline[12,26,9](close)
    c5 = (indicator5 >= 0)

    IF c5 THEN
    SELL AT MARKET
    ENDIF

    // Conditions to enter short positions
    indicator6 = MACDline[12,26,9](close)
    c6 = (indicator6 >= 0.0015)
    indicator7 = RSI[14](close)
    c7 = (indicator7 >= 70)
    indicator8 = (DHigh(1) + DLow(1) + DClose(1))/3+(DHigh(1)-DLow(1))
    c8 = (close >= indicator8)
    indicator9 = DHigh(1)+2*((DHigh(1) + DLow(1) + DClose(1))/3-DLow(1))
    c9 = (close <= indicator9)

    IF c6 AND c7 AND c8 AND c9 and count<1 THEN
    SELLSHORT 10 CONTRACT AT MARKET
    ENDIF

    // Conditions to exit short positions
    indicator10 = MACDline[12,26,9](close)
    c10 = (indicator10 <= -0.0015)

    IF c10 THEN
    EXITSHORT AT MARKET
    ENDIF

     

    // Stops and targets
    SET STOP pLOSS 6
    SET TARGET pPROFIT 32

    #179884

    OTD (One Trade per Day) works fine for me:

    try backtesting the same code, just removing the two comment slashes from line 21.

    #179888

    Hi Roberto,

    Really appreciate you integrating the code for me!

    It is quite strange because I backtested the code you sent back as well as the code I had previously and over 6 years yours bankrupted the account and the other made £4k haha. I tested again with a larger account size and it just had a steady stream of losses till money lost again. Is there something in the code that perhaps makes it sell? Again, I’m still very much learning but something doesn’t seem quite right! 🙂

    #179894

    No matter the origin, if you code like that (above), it becomes unreadable for yourself. Also, the result will be unpredictable (which is almost the same ;-)).

    If you code like the above, you depict mutual exclusive situations, which with the first example are not mutually exclusive at all.

    A bit more tightly coded would be like this :

    But this still would leave you with all kind of doubts, and it should be like this :

    This leaves no doubt about what is happening and “what you are doing”;
    Try to rebuild the code like this and you may automatically run into the culprit(s) why it is not working out, even before running your re-coded program.
    Never think this is long-winded and a waste of time, because clarity above all !

    Good luck now !

    #179895

    I found a bug !
    🙂

    1 user thanked author for this post.
    #179939

    Wow, that has worked. I’m really grateful thank you.

    #188013

    Thx, Roberto

    but really dont know what you are meaning,

    thx for your support

     

    #188014

    Thx, Roberto

    but really dont know what you are meaning,

    thx for your support

    Why are you answering here? Please do NO scatter infor all over the forum! Keep posting in your own topic. Thanks 🙂

     

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

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