Gamestudio Links
Zorro Links
Newest Posts
AssetsSP50.csv
by oldflatop. 04/19/21 10:21
Experience with Dukascopy plugin
by Hajoha. 04/19/21 09:11
OANDA-US No Balance Showing
by nullantechamber. 04/18/21 10:24
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/17/21 15:55
Script Template
by DdlV. 04/17/21 15:07
Sierra Chart Plugin
by AndrewAMD. 04/16/21 13:21
AUM Magazine
Latest Screens
Hecknex World
Scheherazade's Journey
Paradox Vector
The Space Between
Who's Online Now
7 registered members (AndrewAMD, oldflatop, AdamWu, Quad, Hajoha, 2 invisible), 415 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
nayan, taygeezy, dadbean, VizTra, simonkrebs
18629 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Number of trades in an asset loop #482623
03/08/21 10:46
03/08/21 10:46
Joined: Mar 2017
Posts: 13
edu Offline OP
Newbie
edu  Offline OP
Newbie

Joined: Mar 2017
Posts: 13
Hi everyone

I dont understand why the number of trades that I get when I run a script with an asset loop is not equal to the sum of trades that I get when I run the same script on each asset individually.

Shouldn’t they be the same?

For example:

Script run for each pair individually
Number of trades:
EURUSD: 281
GBPUSD: 298
USDCAD: 271
AUDUSD: 304
----------------------------
Sum: 1154

Script run using an asset loop
Number of trades: 964

Here's the code I used
Thanks in advance

Code
function run() 
{
StartDate = 2010;
EndDate = 2020;
BarMode = BR_FLAT;
set(PARAMETERS+TESTNOW);

BarPeriod=60;
NumWFOCycles=3;
LookBack = 500;

Capital = 1000000;
while(asset(loop("EUR/USD","GBP/USD","USD/CAD","AUD/USD")))
	
{
vars Price = series(price());

int MMP = optimize(300,200,400,40);
vars MM1 = series(LowPass(Price, MMP));
int MMIP = 300;
vars MMI_Raw = series(MMI(Price,MMIP));
vars MSmooth = series(LowPass(MMI_Raw,300));

if(
NumOpenLong < 1 
and valley(MM1)
and falling(MSmooth) 
) enterLong();

if(
NumOpenShort < 1 
and peak(MM1) 
and falling(MSmooth) 
) enterShort();

Stop = ATR(25)*3;
Trail = ATR(25)*3;
}

}


Re: Number of trades in an asset loop [Re: edu] #482667
03/15/21 11:29
03/15/21 11:29
Joined: Mar 2017
Posts: 13
edu Offline OP
Newbie
edu  Offline OP
Newbie

Joined: Mar 2017
Posts: 13
It seems that the problem is the WFO

When I comment this part out, the number of trades match.
Code
NumWFOCycles=3;



Why are the WFO results different when I optimize the whole portfolio with an asset loop and when I optimize for each asset independently?

Re: Number of trades in an asset loop [Re: edu] #482702
03/18/21 15:07
03/18/21 15:07
Joined: Jul 2000
Posts: 27,479
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,479
Frankfurt
This is probably not what you intended:

BarMode = BR_FLAT;

BR_WEEKEND is missing, so you're getting flat candles all weekend, which will affect your indicators. I don't know if that's the reason of the different trades, but it does not look right. You can see the reason of the different trades when you look in the logs and compare a few trades with all assets vs. a single asset.

Re: Number of trades in an asset loop [Re: jcl] #482787
03/29/21 07:55
03/29/21 07:55
Joined: Mar 2017
Posts: 13
edu Offline OP
Newbie
edu  Offline OP
Newbie

Joined: Mar 2017
Posts: 13
Thank you jcl, it gets better with BR_WEEKEND, now I get the same number of trades, but I still get different results.
When I compare the logs with a single asset vs all assets, I see that all trades have the same entries, but in some of them the exit is different. Same thing happens when I change the order of the assets inside the loop. Any idea why this could happen?

I simplified the script, here's the version I'm using:

Code
function run() 

{

BarMode = BR_WEEKEND+BR_FLAT;

set(LOGFILE);

BarPeriod=60;
LookBack = 500;
StartDate = 2016;
EndDate = 2017;

while(asset(loop("EUR/USD","GBP/USD")))
	
{	
vars Price = series(price());

vars MM1 = series(LowPass(Price, 100));

if(NumOpenLong < 1 and valley(MM1)) 
	enterLong();

if(NumOpenShort < 1 and peak(MM1) ) 
	enterShort();

Stop = ATR(25)*3;
Trail = ATR(25)*3;
}

}

Re: Number of trades in an asset loop [Re: edu] #482797
03/30/21 10:02
03/30/21 10:02
Joined: Jul 2000
Posts: 27,479
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,479
Frankfurt
Look closely at your code. Where do you set the stop?

Re: Number of trades in an asset loop [Re: edu] #482842
04/05/21 10:29
04/05/21 10:29
Joined: Mar 2017
Posts: 13
edu Offline OP
Newbie
edu  Offline OP
Newbie

Joined: Mar 2017
Posts: 13
Thank you for the hint jcl, I set the stop before the entry logic and it works fine. I don't know why this happens.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1