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
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
Grazie mille! That worked perfectly, super happy.