Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, 1 invisible), 858 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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: 22
V
vicknick Offline OP
Newbie
vicknick  Offline OP
Newbie
V

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

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