Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by jcl. 02/12/26 14:05
MarginCost discrepancy?
by jcl. 02/12/26 14:02
Hedge on FXCM, 4 or 5?
by qin. 02/11/26 14:12
CMC MT4 CFD vs FX Active - what's better?
by mayarik. 02/11/26 11:00
print a "still alive" log
by qin. 02/10/26 12:16
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (TipmyPip), 7,786 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon, mayarik
19198 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Zorro Mistakenly Changes Another Assets Parameter in Loop #488238
05/06/24 09:28
05/06/24 09:28
Joined: Apr 2023
Posts: 61
V
vicknick Offline OP
Junior Member
vicknick  Offline OP
Junior Member
V

Joined: Apr 2023
Posts: 61
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:

Code
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:

Code
[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.

Last edited by vicknick; 05/06/24 09:33.
Re: Zorro Mistakenly Changes Another Assets Parameter in Loop [Re: vicknick] #488239
05/06/24 12:10
05/06/24 12:10
Joined: Feb 2017
Posts: 1,811
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,811
Chicago
Your code is wrong. You need to explicitly select trades to get their info. Try trade loops or TMFs.

Re: Zorro Mistakenly Changes Another Assets Parameter in Loop [Re: vicknick] #488240
05/06/24 18:24
05/06/24 18:24
Joined: Aug 2016
Posts: 66
D
dr_panther Offline
Junior Member
dr_panther  Offline
Junior Member
D

Joined: Aug 2016
Posts: 66
You are looping for two instruments, there is no reference to any of your trades. Please have a look at : https://zorro-project.com/manual/en/fortrades.htm, eg. for(current_trades)


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1