3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: for(all_trades) inverse order
[Re: MatPed]
#470641
01/26/18 11:23
01/26/18 11:23
|
Joined: Jul 2017
Posts: 785
Zheka
User
|
User
Joined: Jul 2017
Posts: 785
|
Here it is. 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: jcl]
#470675
01/29/18 23:39
01/29/18 23:39
|
Joined: Feb 2015
Posts: 652 Milano, Italy
MatPed
OP
User
|
OP
User
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:
#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: Dalla]
#470679
01/30/18 07:47
01/30/18 07:47
|
Joined: Feb 2015
Posts: 652 Milano, Italy
MatPed
OP
User
|
OP
User
Joined: Feb 2015
Posts: 652
Milano, Italy
|
Nice try Dalla 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
Dalla
Senior Member
|
Senior Member
Joined: Feb 2017
Posts: 369
|
OK, instead of doing try 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: 785
Zheka
User
|
User
Joined: Jul 2017
Posts: 785
|
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.
|
|
|
|