hi,
is there a way i can link 2 or more systems trading the same instrument. example:
trading system 1
if not onmarket then
buy 2 contract at market
endif
trading system 2
if longonmarket then
sellshort 1 contract at market
endif
the trading system 2 cannot detect if there a longs on the market.
I’m afraid that link doesn’t work, that’s a copy of that post:
You can assembly all of your strategies into a bigger file.
“DEFPARAM CumulateOrders = false” will do the hard job!
Of course you may need to name variables in different ways, say, a1s1 or cond1s1 for the first strategy, then a2s1/cond2s1….. a1s2/cond1s2 for the second strategy etc….
You may name a variable StrategyID = 0 when NOT ONMARKET, then set it to any number you want each buy/sell is executed so you know which strategy was triggered.
Example:
DEFPARAM CumulateOrders = False //Only 1 trade at a time
IF NOT OnMarket THEN //Make sure you reset this variable to ZERO when not trading
StrategyID = 0
ENDIF
//-----------------------------------------------------------------------------------------------------------------
IF (StrategyID = 0) OR (StrategyID = 1) THEN //Strategy 1
s1.... = ......
.
.
ENDIF
//-----------------------------------------------------------------------------------------------------------------
IF (StrategyID = 0) OR (StrategyID = 2) THEN //Strategy 2
s2Avg = Average[20](close)
s2Rsi = Rsi[14]
.
.
.
//************************************************************************
// LONG
//************************************************************************
IF close CROSSES OVER s2Avg THEN
StrategyID = 2
SET TARGET PPROFIT 20
SET STOP PLOSS 10
BUY nLots CONTRACT AT MARKET
ENDIF
//************************************************************************
// SHORT
//************************************************************************
IF close CROSSES UNDER s2Avg THEN
StrategyID = 2
SET TARGET PPROFIT 20
SET STOP PLOSS 10
SELLSHORT nLots CONTRACT AT MARKET
ENDIF
.
.
.
.
ENDIF
//-----------------------------------------------------------------------------------------------------------------
IF (StrategyID = 0) OR (StrategyID = 3) THEN //Strategy 3
s3.... = ......
.
.
.
ENDIF