7 registered members (oldflatop, AndrewAMD, AdamWu, Quad, Hajoha, jenGs, 1 invisible),
409
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Number of trades in an asset loop
#482623
03/08/21 10:46
03/08/21 10:46
|
Joined: Mar 2017
Posts: 13
edu
OP
Newbie
|
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 individuallyNumber of trades: EURUSD: 281 GBPUSD: 298 USDCAD: 271 AUDUSD: 304 ---------------------------- Sum: 1154 Script run using an asset loopNumber of trades: 964 Here's the code I used Thanks in advance
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
OP
Newbie
|
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. 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: jcl]
#482787
03/29/21 07:55
03/29/21 07:55
|
Joined: Mar 2017
Posts: 13
edu
OP
Newbie
|
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:
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;
}
}
|
|
|
|