Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 652 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: for(all_trades) inverse order [Re: Zheka] #470640
01/26/18 09:59
01/26/18 09:59
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.
Can you post the coded used for the test?

Ciao

Re: for(all_trades) inverse order [Re: MatPed] #470641
01/26/18 11:23
01/26/18 11:23
Joined: Jul 2017
Posts: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
Here it is.
Quote:
if (is(EXITRUN))
{
int ii=0;
for(closed_trades)
{
ii++;
printf("# Asset: %s, Algo=%s, Trade Profit=%f, ii=%i",TradeAsset,TradeAlgo, TradeProfit,ii);

if (ii>20) break_trades;
}
}

Re: for(all_trades) inverse order [Re: Zheka] #470643
01/26/18 14:46
01/26/18 14:46
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
For the moment, better use

if(ii>20) { break_trades; }

Re: for(all_trades) inverse order [Re: jcl] #470675
01/29/18 23:39
01/29/18 23:39
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,
trying to build up an array with trade results for further calculation. My understanding is that I have to filter by Algo/Asset the trades in the loop. This is the code:

Code:
#define MaxRolling 50
var rer(int ii){
// rolling expectancy ratio: ((AvgWin / AvgLoss) * WinRate) – (1 – WinRate)

	bool debug = TRUE;
	var resultAA[MaxRolling];
	int i=0; for (i=0; i<MaxRolling; i++) resultAA[i] = 0; // Init the Array

	string myAsset = Asset;
	string myAlgo = Algo;
	i=0;
	for(closed_trades) {
		if( TradeIsPhantom &&  myAsset==TradeAsset && myAlgo==TradeAlgo) {
			resultAA[i] = TradeProfit/TradeUnits/PIP;
			if(debug) {
				print(TO_ANY, "n Asset: %s - ALGO: %s - #Trades: %d - PIP: %.2f", Asset, Algo, i, resultAA[i]);	
			}
			i++;	
			if (i >= ii) {break_trades;}
		}
}
	return .0;
}



nothing happens. Trade results ar printed if the last condition in the IF statement is removed. I do not understand what I am missing.

Thank you

Re: for(all_trades) inverse order [Re: MatPed] #470677
01/30/18 03:50
01/30/18 03:50
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
Hmm, I'm thinking that bool is case sensitive perhaps?
Try
bool debug = true;

Re: for(all_trades) inverse order [Re: Dalla] #470679
01/30/18 07:47
01/30/18 07:47
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Nice try Dalla laugh but it does not change the behavior o the script.
the weird things is that the the error seems to be
&& myAlgo==TradeAlgo
if removed the array is printed.

by the way, I am calling the rer function just before of the enter command in workshop 6, for test purposes
Ciao

Last edited by MatPed; 01/30/18 07:50.
Re: for(all_trades) inverse order [Re: MatPed] #470681
01/30/18 10:11
01/30/18 10:11
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
OK, instead of doing
Code:
myAlgo==TradeAlgo


try
Code:
strstr(myAlgo,TradeAlgo)



You should probably do this for TradeAsset as well.
Comparing strings with == and != is usually not a good idea.

Last edited by Dalla; 01/30/18 10:13.
Re: for(all_trades) inverse order [Re: MatPed] #470682
01/30/18 10:15
01/30/18 10:15
Joined: Jul 2017
Posts: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
This is because "strings" are elusive animals (constants?):-)

This works:

char* myAsset[16]; myAsset =strcpy(myAsset,Asset);
char* myAlgo[16]; myAlgo = strcpy(myAlgo,Algo);
....
if( !strcmp(myAsset,TradeAsset) && !strcmp(myAlgo,TradeAlgo))


Dalla's suggestion also works.

Last edited by Zheka; 01/30/18 10:22.
Re: for(all_trades) inverse order [Re: Zheka] #470684
01/30/18 11:08
01/30/18 11:08
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Dalla, Zheka. You are my heroes! Thank you

Page 2 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