How to use CumulateOrders=True and prevent opening new positions in the same TF

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #131417 quote
    ronit79
    Participant
    New
    DEFPARAM CumulateOrders = True
    timeframe(default)
    S1 = 23000
    S2 = 21000
    Res1 = 28000
    
    c1 = (close <= S1)
    o1 = (open >= S2)
    IF c1 AND o1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    closeCon1 = (close >= Res1)
    IF closeCon1 THEN
    SELL AT MARKET
    ENDIF

    Dear All,

    I’m trying a very simple code and I’m running in a little trouble.

    I’d like to open the orders in the code just once a month while other positions are still open in previous months preventing the code to open multiple positions in the same month.

    Your advice would be much appreciated.

    Thank you

    #131425 quote
    robertogozzi
    Moderator
    Master

    Try this (not tested):

    DEFPARAM CumulateOrders = True
    timeframe(default)
    S1 = 23000
    S2 = 21000
    Res1 = 28000
    If Month <> Month[1] then
       m1 = 1
    Endif
    c1 = (close <= S1)
    o1 = (open >= S2)
    IF c1 AND o1  and m1 THEN
       BUY 1 CONTRACT AT MARKET
       m1 = 0
    ENDIF
     
    closeCon1 = (close >= Res1)
    IF closeCon1 THEN
       SELL AT MARKET
    ENDIF
    #131426 quote
    ronit79
    Participant
    New

    Thank you Roberto,

    I will give it a try.

    Cheers

    #131433 quote
    ronit79
    Participant
    New

    Roberto,

    it worked beautifully

    Thank you very much for your help.

    Renzo

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

How to use CumulateOrders=True and prevent opening new positions in the same TF


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ronit79 @ronit79 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by ronit79
5 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/13/2020
Status: Active
Attachments: No files
Logo Logo
Loading...