Gamestudio Links
Zorro Links
Newest Posts
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
folder management functions
by 7th_zorro. 04/15/24 10:10
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
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
SGT_FW
by Aku_Aku. 04/10/24 16:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, Quad), 373 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How works Zorro ? Im going crazy... #478801
12/21/19 08:15
12/21/19 08:15
Joined: Apr 2018
Posts: 37
S
sdelatorre Offline OP
Newbie
sdelatorre  Offline OP
Newbie
S

Joined: Apr 2018
Posts: 37
Hello,

I have download 1 minute from script Download . Asset ("NZD/CHF") from OANDA

My code does :


BarPerdiod=60;

if (lhour(tUTC)==22 && minute(timezone)==0){
enterShort(profit);
}


and when I change the BarPeriod 15 or 1 …. is different totally…...why ?



My function profit:


int profit

if(TradeIsOpen and (TradeProfit/TradeUnits/PIP < -10))){exitTrade();

}
if(TradeIsOpen and (TradeProfit/TradeUnits/PIP >10)){exitTrade();

}


return 0;
}


Thanks in advance

Last edited by sdelatorre; 12/21/19 08:16.
Re: How works Zorro ? Im going crazy... [Re: sdelatorre] #478815
12/23/19 15:39
12/23/19 15:39
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
I can see from your code why it's different, but you should be able to find that out yourself. Follow the mighty manual:

"Unexpected results: If backtest results seem not to be right, first look into the log (LOGFILE must be set). Select one or two trades and check them from begin to end. Many parameters can affect trade results in many different ways - make sure to check them all."


By comparing two trades, you should see immediately why your script is sensitive on different bar periods.

Re: How works Zorro ? Im going crazy... [Re: jcl] #478818
12/25/19 17:44
12/25/19 17:44
Joined: Apr 2018
Posts: 37
S
sdelatorre Offline OP
Newbie
sdelatorre  Offline OP
Newbie
S

Joined: Apr 2018
Posts: 37
Thanks jcl,

By comparing two trades….but before that , my complete code


int profit(){

if(TradeIsOpen and (TradeProfit/TradeUnits/PIP < -10)&& TradeIsShort){exitTrade();}
if(TradeIsOpen and (TradeProfit/TradeUnits/PIP >10)&& TradeIsShort){exitTrade();}
return 0;
}


function run() {

set(PARAMETERS+TICKS+LOGFILE);

StartDate = 20191215;
EndDate = 20191220;
BarPeriod = 60; //BarPeriod=1;

asset("NZD/CHF");

if (lhour(WET)==22 && minute(WET)==0){enterShort(profit);}

if (lhour(WET)==06 && minute(WET)==0){exitTrade();}

}

I can oberve that the prices entershort and exit are different if I use different barPeriod, but Ithought that it will be the same because :

"In the backtest, the result of entering a trade can be either a pending trade, an opened trade, or a skipped trade. If no Entry limit is given, trades are opened at the current price or at the next open price, dependent on Fill mode. If a trade is pending, Zorro continues to attempt opening the trade within the time period given by EntryTime."


"A trade management function (TMF) is automatically called every tick - i.e. whenever the price changes - with the the optional variables (v0 .. v7) as arguments. It can evaluate the current price and other trade variables for closing the position or adjusting stop and profit limits"



Every tick is called function TMF and the trades open at the current Price...isn't it ? So why the difference ?


Another question..with my code only I want to know if the 22:00 is a good hour for openShort and get 10 PIPS, how could I do that ? Can you explain me that my code is doing ?

Maybe I don't understand all but Im going crazy.

Thanks a lot and I wait your answer.




Last edited by sdelatorre; 12/25/19 17:55.
Re: How works Zorro ? Im going crazy... [Re: sdelatorre] #478829
12/27/19 23:12
12/27/19 23:12
Joined: Dec 2019
Posts: 53
ozgur Offline
Junior Member
ozgur  Offline
Junior Member

Joined: Dec 2019
Posts: 53
Hi sdelatorre,

I am a newbie as well so take everything with a pinch of salt. I am able to replicate similar backtest results with both 60 and 5 minute BarPeriod using the modified code below. Have a look and compare against your original code and deep dive into manual. I guess you also need to handle LOOKBACK to ensure backtest start at the same time.

Not sure why 1 minute is producing different results though.

Code
int profit()
{
	if(TradeIsOpen && (TradeProfit/TradeUnits/PIP < -10) && TradeIsShort)
	{
		exitTrade();
	}

	if(TradeIsOpen && (TradeProfit/TradeUnits/PIP > 10) && TradeIsShort)
	{
		exitTrade();
	}

	return 0;
}

function run() 
{
	set(LOGFILE,PLOTNOW,TICKS);
	
	Fill = 0; // For the sake of comparison, not realistic otherwise
	
	StartDate = 20191215;
	EndDate = 20191220;

	BarMode = BR_FLAT; // To handle potential missing M1 data which would screw up time comparisons below...
	
	//BarPeriod=60;
	BarPeriod=5;
	
	asset("EUR/USD");

	if(hour()==22 && minute()==0)
	{
		enterShort(profit);
	}

	if(hour()==06 && minute()==0)
	{
		exitTrade();
	}
}



Last edited by ozgur; 12/27/19 23:39.
Re: How works Zorro ? Im going crazy... [Re: ozgur] #478834
12/28/19 21:53
12/28/19 21:53
Joined: Apr 2018
Posts: 37
S
sdelatorre Offline OP
Newbie
sdelatorre  Offline OP
Newbie
S

Joined: Apr 2018
Posts: 37


Thanks ozgur,

the LOOPBACK I think is not the problema because the data loopback is until the epecified date. Looking the results the loopback ends at same hour and date.

With Fill=0 the results are more similar but I think the problem is with the prices and bars in barPeiod.



Thanks for you helping If I find the solution I Will share it and I wait jcl tell us a bit …...……. :-)

Re: How works Zorro ? Im going crazy... [Re: sdelatorre] #478845
12/31/19 12:55
12/31/19 12:55
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
With naive filling and with entering at the same time, I think the entry prices can hardly be different. What is still different?

Re: How works Zorro ? Im going crazy... [Re: sdelatorre] #478869
01/02/20 21:40
01/02/20 21:40
Joined: Apr 2018
Posts: 37
S
sdelatorre Offline OP
Newbie
sdelatorre  Offline OP
Newbie
S

Joined: Apr 2018
Posts: 37
Hello again,

with Fill=0 the results are similar but Why I have to use Fill=0 if is for special purposes ??? .
The tutorial says :

1 Realistic order filling (default). Trades open or close at the current price quote plus extra Slippage. When Slippage is set to 0, this mode simulates a latency-free connection to the market that immediately reacts on any price quote

I have tested and Really with Fill=1 and barPeriod different is very different the results…....maybe have I use Fill=0 for my backtests ? This is the part that I can't understand…..Realistic =Fill 1 ...but different results with barPerdiod and Fill=0 special purposes but results similar.


Another question is if I use a TMF the exit trade must be the same if the Price open is the same independtly of the barPerdiod,..this is ok, true ??

Thanks in advance

Last edited by sdelatorre; 01/02/20 21:43.
Re: How works Zorro ? Im going crazy... [Re: sdelatorre] #478872
01/03/20 10:15
01/03/20 10:15
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
A backtest is for simulating real trading. In real trading, two systems connected to a real broker will normally get different results due to slippage. If you want identical results in a backtest for some reason, you need to set up order filling with no slippage.

In a TMF of an open trade, the exit price is the current price at the time when the TMF was run.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1