Gamestudio Links
Zorro Links
Newest Posts
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
Release 2.68 replacement of the .par format
by Martin_HH. 09/23/25 20:48
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,046 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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: 60
V
vicknick Offline OP
Junior Member
vicknick  Offline OP
Junior Member
V

Joined: Apr 2023
Posts: 60
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,806
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

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