Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (TipmyPip, AndrewAMD, Quad, aliswee, degenerate_762), 970 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
for(all_trades) inverse order #470605
01/24/18 11:01
01/24/18 11:01
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Hi,
has anybody found a way to browse the trades in the inverse order? Last trades first?
I need to identify the last n trades that respect some conditions.

Thank you

Re: for(all_trades) inverse order [Re: MatPed] #470606
01/24/18 13:08
01/24/18 13:08
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
Depends what exectly you are after.

These arrays contain the results for the 20 most recent trades. index 0 = most recent trade.

ResultLong[0] .. ResultLong[19]
ResultShort[0] .. ResultShort[19]

More info
http://zorro-trader.com/manual/en/winloss.htm

Re: for(all_trades) inverse order [Re: Dalla] #470607
01/24/18 13:42
01/24/18 13:42
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Thank You Dalla,
that was exactly my starting point, but it did not work.
I want to calculate the Rolling Expectancy Ratio. Basically I need the Result of the last N trades the mentioned arrays does not provide such information.

the for(all_trade) macro could be used, but unfortunately its sort the trades from the first opened one. Reversing a growing array is not trivial for my coding capabilities, so I was blessing for some help laugh.

Ciao

Re: for(all_trades) inverse order [Re: MatPed] #470616
01/25/18 07:40
01/25/18 07:40
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Another macro could be defined for reverse order. Do you need it for all or only for closed trades?

Re: for(all_trades) inverse order [Re: jcl] #470617
01/25/18 09:12
01/25/18 09:12
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Thank you,
For the specific task only closed would be enough. For general purposes I guess that all trades would be better. I know that this will be an easy task for you, but when you write it can you explain of how it works?

I've tried to read the for(all_trade) macro definition but, I admit, is quite obscure to me...

Ciao

Last edited by MatPed; 01/25/18 09:17.
Re: for(all_trades) inverse order [Re: MatPed] #470618
01/25/18 10:29
01/25/18 10:29
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Ok, try this: get the latest version 1.74.8 and use for(closed_trades). It is undocumented, but is supposed to enumerate closed trades in backwards order. For aborting the loop, as you probably don't want to go through all trades, use break_trades; instead of break;.

Re: for(all_trades) inverse order [Re: jcl] #470624
01/25/18 11:23
01/25/18 11:23
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
ok, thank you. I guess that The code inside the loop has access to all trade variables. Am I right?

Re: for(all_trades) inverse order [Re: MatPed] #470626
01/25/18 13:51
01/25/18 13:51
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
laugh
- Zorro seems to maintain one single list of all trades in a portfolio.
Will it make sense to add a field to Trade struct with a pointer to the previous trade of the same algo/asset component?
Then traversing such a linked list backwards for a component would be quicker, and such backwards looping is mostly needed for a component, not the full portfolio.
- break_trades for some reason does not work; break- does

It would really help if Zorro exposed a variable/pointer to the last closed trade of the current asset/algo combination (without asking a user to go into the for(trades)loop.
Or is there a way?

Re: for(all_trades) inverse order [Re: Zheka] #470638
01/26/18 08:42
01/26/18 08:42
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Hi Zheka,
I am fine with the For() approach I can filter and selecting the trades I need.
Did you already tried for(closed_trades)with version 1.78 and discovered a bug using break_trades ?

I guess that a specific exit from the loop is required in order to proper reset pointers and other stuff or the following for(closed_trades) will not work properly.

Please report your findings.

Thank You

Re: for(all_trades) inverse order [Re: MatPed] #470639
01/26/18 09:57
01/26/18 09:57
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
Hi, MatPed,

Suggestion to extend a Trade struct was to improve speed and flexibility of looping - both internally by Zorro and/or for a user; with or without a for()macro.

Quote:
Did you already tried for(closed_trades)with version 1.78 and discovered a bug using break_trades ?
Yes, I did. A simple for(closed_trades)loop with a counter to print details of last 20 trades only printed for 1 trade with break_trades and all 20 with a normal break.
If more complex scenaria would work properly with a normal "break" - I did not test.

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1