Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 03/28/26 14:01
TMFs on options in live trading
by Spirit. 03/26/26 19:52
TDAmeritrade plugin with new Schwab accountt?
by AndrewAMD. 03/24/26 17:11
Black Book, 4th edition
by jcl. 03/17/26 09:28
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (Quad, TipmyPip, James168), 7,328 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
mredit, vestriaa, Lukudo, mldenoiser, the1
19204 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,814
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,814
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