Gamestudio Links
Zorro Links
Newest Posts
Zorro plugin for Hyperliquid.xyz
by MikeHe. 01/13/25 14:50
Zorro Trader GPT
by TipmyPip. 01/13/25 05:33
Trying To Make Sense of WED Scripting
by VoroneTZ. 01/07/25 17:34
Initial RithmicZorroPlugin Release.
by kzhao. 01/07/25 04:10
Rithmic connection?
by kzhao. 01/07/25 04:07
Illegal Indirection in Matrix
by AndrewAMD. 01/06/25 17:05
AUM Magazine
Latest Screens
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Zeal-X2
Who's Online Now
0 registered members (), 391 guests, and 15 spiders.
Key: Admin, Global Mod, Mod
Newest Members
eckaw, isshokenmei, shahbaziakbar135, k_ivan, Parallax
19099 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Zorro Gives Wrong Calculation During Backtest #488474
12/10/24 13:40
12/10/24 13:40
Joined: Apr 2023
Posts: 47
V
vicknick Offline OP
Newbie
vicknick  Offline OP
Newbie
V

Joined: Apr 2023
Posts: 47
Zorro calculated correctly the value I wanted during backtest.

However, in the middle of the backtest (after years of daily data), Zorro suddenly seem to gives the wrong value. I tried running the backtest several times, but Zorro always gives the wrong value starting from the same date.

Here is the code:
Code
printf("#\ntotalLots: %i", totalLots);
printf("#\nMultiplier: %i", Multiplier);
printf("#\nPrice: %.8f", Prices[0]);
var CurrentExposure = totalLots*Multiplier*Prices[0];


Log result:
Code
[6351: Mon 14-06-30 15:40] 137988181 +7744915 10410/7546 
Asset: JPYUSDeod
totalLots: 171
Multiplier: 12500000
Price: 0.00987120
CurrentExposure = 21099689.4

[6352: Tue 14-07-01 15:40] 138542189 +8123764 10413/7547
Asset: JPYUSDeod
totalLots: 171
Multiplier: 12500000
Price: 0.00984730
CurrentExposure = 21048604.0

[6353: Wed 14-07-02 15:40] 137908707 +7468570 10409/7555 
Asset: JPYUSDeod
totalLots: 190
Multiplier: 12500000
Price: 0.00982590
CurrentExposure = -18865407.0

[6354: Thu 14-07-03 15:40] 137791508 +7353988 10405/7562
Asset: JPYUSDeod
totalLots: 194
Multiplier: 12500000
Price: 0.00978450
CurrentExposure = -18296695.2


As you can see, after running years of daily data, Zorro seems to suddenly give the wrong "CurrentExposure" value starting from 2014-07-02, by turning into negative all of the sudden. The previous values before this date are all correct.

Not sure why it went wrong here.

Re: Zorro Gives Wrong Calculation During Backtest [Re: vicknick] #488475
12/10/24 15:06
12/10/24 15:06
Joined: Jul 2000
Posts: 28,005
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,005
Frankfurt
Question to the audience: What's wrong with the code snippet that (barely) works with 171, but not anymore with 190? You can find a hint here: https://zorro-project.com/manual/en/aarray.htm

Re: Zorro Gives Wrong Calculation During Backtest [Re: vicknick] #488476
12/10/24 17:02
12/10/24 17:02
Joined: Feb 2017
Posts: 1,763
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,763
Chicago
Hint #2: The max integer value is 2147483647. grin

Re: Zorro Gives Wrong Calculation During Backtest [Re: vicknick] #488477
12/11/24 06:31
12/11/24 06:31
Joined: Apr 2023
Posts: 47
V
vicknick Offline OP
Newbie
vicknick  Offline OP
Newbie
V

Joined: Apr 2023
Posts: 47
Ah, didn't realize that.

I will try to do type conversion from int to var.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1