I am running a portfolio of 2 assets with the same strategy. For each assets, I need to know whether the asset is in Long or Short position with the function
TradeIsLong and
TradeIsShort.
However, I noticed that when changing position, Zorro will also change the other asset parameter as well. For example, if both Asset A and Asset B are long, and Asset A changes to Short, Zorro will also change the parameter of Asset B to short, even though Asset B remains Long.
Here is the script that has this error, with Corn (ZC) and Natural Gas (NG) as the assets:
while(asset(loop("ZC","NG")))
{
//... other code here
if(TradeIsLong)
{
printf("#Trade is Long.");
}
else if(TradeIsShort)
{
printf("#Trade is Short.");
}
}
Log message that show the unintended error, where NG changed to Long even though it doesn't switch position or have any trades:
[1664: Tue 91-07-30 15:40] 1117542 +682 250/383 (6.55750)
Asset: ZC
[ZC::S65017] Cover 1@6.55750: -1538 at 15:40:00 Tue
[ZC::L66417] Long 1@6.55750 at 15:40:00 Tue
Trade is Short.
Asset: NG
Trade is Short.
[1665: Wed 91-07-31 15:40] 1115115 -208 250/384 (6.60250)
Asset: ZC
[ZC::L66517] Long 1@6.60250 at 15:40:00 Wed
Trade is Long.
Asset: NG
Trade is Long.