Max Positions per strategy in multi-strategy code

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #171789 quote
    deletedaccount051022deletedaccount051022
    Participant
    New

    Hi,

    I have a multi-strat piece of code that runs a few different strategies in one, looking at the formation of three candle patterns.  I want the multi strategy to allow 1 position per each of the three different candle patterns within the overall multi-strat code.  Is there a way to limit the max number of positions per candle pattern strategy within the code please?

    I have obviously tried tweaking the DEFPARAM CUMULATEORDERS but this applies to the whole multi-strat.

    Thank you very much

    #171793 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    With reference to my post https://www.prorealcode.com/topic/multiple-strategies-within-one-trading-system/, you can achieve your goal with this modified version. I only coded strategy #2, but you need to apply the same logic to strategy #1 and #3:

    DEFPARAM CumulateOrders = TRUE        //Allow multiple trades at a time
    IF NOT OnMarket THEN                  //Make sure you reset these variables to ZERO when not trading
       P1 = 0
       P2 = 0
       P3 = 0
    ENDIF
    //--------------------------------------------------------------------------------------------------
    IF P1 < 1 THEN					                               //Strategy 1
       .
       .
    ENDIF
    //--------------------------------------------------------------------------------------------------
    IF P2 < 1 THEN					                               //Strategy 2
       s2Avg = Average[20](close)
       s2Rsi = Rsi[14]
       .
       .
       .
       //************************************************************************
       //                                 LONG
       //************************************************************************
       IF close CROSSES OVER  s2Avg THEN
          SET TARGET PPROFIT 20
          SET STOP PLOSS     10
          BUY nLots CONTRACT AT MARKET
          P2 = 1                            //set P2 to 1 to disable further trading this strategy
       ENDIF
       //************************************************************************
       //                                 SHORT
       //************************************************************************
       IF close CROSSES UNDER s2Avg  THEN
          SET TARGET PPROFIT 20
          SET STOP PLOSS     10
          SELLSHORT nLots CONTRACT AT MARKET
          P2 = 1                            //set P2 to 1 to disable further trading this strategy
       ENDIF
       .
       .
       .
       .
    ENDIF
    //--------------------------------------------------------------------------------------------------
    IF P3 < 1 THEN					                               //Strategy 3
       .
       .
       .
    ENDIF
    #171801 quote
    deletedaccount051022deletedaccount051022
    Participant
    New

    Grazie mille! That worked perfectly, super happy.

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Max Positions per strategy in multi-strategy code


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/15/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...