Limits of Zorro S 1.16 Z5

Posted By: Mangal

Limits of Zorro S 1.16 Z5 - 12/07/13 11:08

In version S 1.16, Z5, I read somewhere that with a capital of 6000 it gives around 1000 pe month. I started with a live capital of 3000 and then I increased to 6000 with Margin 100, Stop 5000 and Mode 1. More than that doesn't seem to be possible. However, it seems that it is stopping trading. Account now is close to 6700 with an open position of - 433. Any glue on this? Any limit?
Posted By: Sundance

Re: Limits of Zorro S 1.16 Z5 - 12/07/13 13:20

Yepp. The maximum amount of money you can trade with the standard Zorro version is 7000€. You can read it somewhere at the beginning of the manual...
Posted By: Sundance

Re: Limits of Zorro S 1.16 Z5 - 12/07/13 13:40

Oh. Sorry. I see you have the S version!
Then I must admit that I don't know why it doesn't trade anymore...
You are sure you have copied your license file to the Zorro folder?
Posted By: jcl

Re: Limits of Zorro S 1.16 Z5 - 12/07/13 14:19

If trades are skipped because you're over the capital limit, or for other reasons, you'll see this in the message window. Zorro S has no capital limit though.

If you're using Z5, definitely update to Zorro 1.20. It has a new Z5 version that opens more trades.
Posted By: Sundance

Re: Limits of Zorro S 1.16 Z5 - 12/07/13 15:28

erased
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 12/08/13 10:28

Thank you to both of you. I am going to update to 1.20 and let you know.
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 12/08/13 13:53

I installed the 1.20, however it gives some problem with real account. It allow to do backtesting in the same account but when pushing the "Trade" button to continue trading with open positions it comes message saying that can't open MT4 bridge. Can't connect. If it can connect to do backtesting how is it that it can not connect for trading?

I have replaced the Zorro.mq4 ZorroMT4.ex4 and ZorroMT4.dll as instructed.

Any glue?
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 12/09/13 09:39


ok, now is working. For some reason when you replace the dll file and the ex4 file, it really doesn't replace them. You have to do it several times and make sure that the modifications dates of the files are those that correspond.

It might be that it was during weekend and MT4 had some problem. In any case, fro Real account the replacement of the files worked correctly meanwhile yesterday Sunday was not working. But now today Monday, meanwhile the Real account is working, the demo account even with the replaced files accepted by MT4, keeps not working, Keeps saying Broker: can't open MT4 bridge. Can't connect.
Posted By: jcl

Re: Limits of Zorro S 1.16 Z5 - 12/09/13 10:12

If you installed MT4 with UAC enabled, it creates a shadow copy of its experts folder in the VirtualStore directory - it's the same as with Zorro.
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 12/09/13 10:23

Anyway, coming back to the issue of limits of Zorro S, Z5, when trying to do backtesting in the demo, it allows to do it by default Margin 50 and capital 5000. Once you have done one time, it doesn't allow to do it with further increases of Margin to see how it behaves. Is there anyway to be able to increase the Margin to see how it behaves in backtesting?
Posted By: jcl

Re: Limits of Zorro S 1.16 Z5 - 12/09/13 12:21

Unfortunately not. I've just noticed this too - executable scripts run only once in test mode. Afterwards you must change the strategy and then change back. This will be fixed in the next Zorro version.

A temporary solution would be temporarily renaming your key.dta file in the Zorro folder for testing. The problem only affects Zorro S.
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 12/29/13 10:33

Second thought is to find out what is the maximum "productive" capital one can have in the account. In other words, since the margin is restricted to 100 (in Zorro 1.20 S, Z5) there is an upper limit in terms of capital that will actually will be used for trading in the account. (Am I right here? or apart from the amount of lots, the number of trades is sensitive to the capital in the account if keeps on increasing?)

Let's try to find out the upper limit of capital taking as granted that only the number of lots increase rather than the number of trades. And let's take the rule of SQR to increase the margin you give somewhere. Let's also take as base line a 3000 capital and 50 of margin as it is as default in the backtests.

Supose one makes a profit of 3000 and now the account has grown to 6000. Applying the rule of SQR to find out what new margin I have to increase instead of blindly multiply by 2:

6000 = 3000 x (1 + 3000/3000) = 3000 x (2)

SQR (2) = 1,41, so instead of multiply by 2, that is, instead of increasing the margin from 50 to 100, I shall increase the margin to:

50 x 1,41 = 70 aprox.

So, for a profit of 100% from 3000 to 6000, the margin increase goes to 70 from 50.

Applying the same rule, one can deduce that the maximum productive capital for a margin of 100 is 12.000. To have more capital than this in the account doesn't make any sense and better get a new license and open a new account. Am I right with this logic?

There is also a third though when comparing with version 1.16. There, in the backtests for a capital of around 6000 was giving an income of around 1000 per month with 100 of margin. In version 1.20, you can see that now the capital necessary to use 100 as margin has gone up to 12.000. Or can we apply the same rule as 1.16 and for a capital of 6000 apply margin 100?



Posted By: jcl

Re: Limits of Zorro S 1.16 Z5 - 12/30/13 08:44

There is no capital limit for Zorro S; you can set the maximum margin in the .ini file.

Although Z4 and Z5 are special strategies, the square root rule does still apply because there is no hard limit for the upper border of the EUR/USD rate. So your calculation is correct.

The backtests determine the initial capital only. The longer you traded and the more profit you made, the higher is the likeliness of a drawdown that exceeds the capital determined in the backtest - therefore the square root rule.
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 12/31/13 19:27

Then, the increase the margin the sooner the better accompanying the increase of capital because less time trading means less chances that the drawdown exceeds the capital determined in the backtest. In this way, profit may be mounting sooner before it reaches the situation of a strong drawdown. Does it make sense?

By the way, where is the .ini file? I have been looking in Zorro folder but no success till now. Sorry about this... I am completely new.
Posted By: Anonymous

Re: Limits of Zorro S 1.16 Z5 - 12/31/13 19:59

Originally Posted By: Mangal
Then, the increase the margin the sooner the better accompanying the increase of capital because less time trading means less chances that the drawdown exceeds the capital determined in the backtest. In this way, profit may be mounting sooner before it reaches the situation of a strong drawdown. Does it make sense?


That drawdown increases in time is just a statistical phenomena. You can of course get in a very deep drawdown right after the start of strategy, and especially so if you apply too high risk.

Originally Posted By: Mangal

By the way, where is the .ini file? I have been looking in Zorro folder but no success till now. Sorry about this... I am completely new.


Look for it in the Strategy folder.
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 01/01/14 16:52

Thank you acidburn. I have been looking into the Strategy Folder but there I can only find .c files.
Posted By: Anonymous

Re: Limits of Zorro S 1.16 Z5 - 01/01/14 16:56

Originally Posted By: Mangal
Thank you acidburn. I have been looking into the Strategy Folder but there I can only find .c files.


Then I see only 2 possibilities:

- Zorro S keeps it in another folder?
- you have been bitten by Windows UAC, and Z.ini somehow ended in your shadow directory?
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 01/01/14 17:19

Is the following the content of the Z.ini file?

NFA = 0
FXOnly = 0
MMax = 100
Phantom = 0
Comma = 0
Mute = 0
Weekend = 2
Verbose = 2
BrokerPatch = 0
Preload = 0

It comes as Z file where it just says configuration. Does MMax refers to the slide responsible for the Margin?
Posted By: Anonymous

Re: Limits of Zorro S 1.16 Z5 - 01/01/14 17:26

Yes, that's Z.ini. About MMax, you should probably consult the manual.
Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 01/01/14 18:06

Thank you, Aciburn. I wonder why the .ini gets erased when installing it in my VPS.

Another issue you may help is regarding the re-test. Supose you write some script which gives some positive results and you want to make a few changes and re-test it. What happens to me is that usually the re-test gives as result the message "backtest... " but it does not really compile and execute it. However, from time to time it does it. Do you know what to do so that every time one click the "Test" button it really compiles and gives a result?



Posted By: Mangal

Re: Limits of Zorro S 1.16 Z5 - 01/01/14 19:31

Another issue that has poped up. I have increased the margin level. Then I have stopped the running Zorro with real money and when asked closing open trades, I clicked NO. And when asked to "Stop Trading" I also answered NO.

When installing again Zorro to the real account, now the color of the band is all red when before closing it was green and red. I am just wondering if it will resume the open trades and will continue monitoring them or if it will start from scratch. In case it does not monitor the open trades, does it mean I will have to monitor them manually? there are 9 open trades.

Now the slide of Margin has increased to what I have indicated in the MMax configuration.
Posted By: jcl

Re: Z5 - 01/02/14 09:21

The meaning of the red/green band is described here:

http://manual.zorro-trader.com/trading.htm

The left segment of the band is the closed profit so far. Which is of course zero directly after starting a strategy.
Posted By: Mangal

Re: Z5 - 01/02/14 10:14

Thank you jcl, that is clear. And bytheway, Zorro undertook the monitoring of the open trades.

Regarding the re-test issue, does anyone have a glue why sometimes it works and some times not? It can not be to the UAC business because it is set to "off" since the beginning.

Can it be due to VPS constrains?
Posted By: DMB

Re: Z5 - 01/02/14 11:22

You know the word is 'clue', right? And you are just being quirky?
Posted By: Mangal

Re: Z5 - 01/02/14 15:31

Thank you for the correction, DMB.

Coming back to the re-Test issue. I jus read in the forum somewhere that for the S version it gives this problem so it can not be because of the VPS. Could it be because of overloading the system of Zorro S at certain moments? I am just shooting...
Posted By: jcl

Re: Z5 - 01/02/14 17:16

Your system is always tested when you click "Test". But it is only compiled when you clicked "Edit" or when you changed something in the code. As long as the code is unchanged, Zorro has no need to compile it again.

If your system behaves differently every time you test it, the most likely reason is a bug of your script. You should then debug it and find out where the different behavior comes from.
Posted By: Mangal

Re: Z5 - 01/03/14 01:42

Thank you for your patience, jcl. The script is a simple script which depending on the parameters of Stop Loss and Target gives around 100% Anual Return for EUCHF:


A1,A2,A3 Ar62% compiling...............
Error 055: EUR/CHF 2009 price history missing
Error 055: EUR/CHF 2010 price history missing
Error 055: EUR/CHF 2014 price history missing
BackTest: A1,A2,A3 Ar62% EUR/CHF 2009..2014
Profit 4013$ MI 118$ DD 1015$ Capital 3554$
Trades 4280 Win 42% Avg +11.6p Bars 56
AR 107% PF 1.55 SR 0.78 UI 9.3% Error 12%

The script is the following:

function run()
{
BarPeriod = 240;

vars A1 = series(priceClose(2));
vars A2 = series(priceClose(1));
vars A3 = series(price(0));
//Vlr = 10*PIP


if (A1 < A2 and A3 < A1) enterLong();
if (A1 > A2 and A3 > A1) enterShort();

Stop = 35*PIP;
TakeProfit = 80*PIP;
//ExitTime = 1;

}

I have been testing it with different values of stop loss and target, and after your clarification I understand that when Test doesn't give any result it is because some previous result was the same as present one. The trick I had to do for keep on giving results is to change slightly the values of Stop Loss and Target, like one more figure or so, and after some runs, I can put back the values which I was interested to know and then it picks them up and gives a result. Result which I forgot from the first run it gives it back again doing this trick.
Posted By: Mangal

Re: Z5 - 01/03/14 02:05

Let me ask another question. Is there any way to know if the backtests really perform what is instructed in the script?

Let me clarify this question. In Metatrader, when doing backtests you could check if the trades performed where done according to the instructions. Most of the cases, even when the indicator upon which the EA was build up indicated perfectly the moments when to enter and exit, the trades were not performed according to the what one would expect from the indicator, making the backtest very unreliable.

In the case of Zorro, is there any place where one could look, even for some short period of tested time, to see if trades are performed according to the instructions of the script?
Posted By: jcl

Re: Z5 - 01/03/14 08:29

The bug was writing A1 instead of A1[0]. So your script trades random and can't produce a result. Using series is explained in Workshop 4. Also you're testing an asset with some history data missing.

I do not understand your second problem, though. MT4 backtests are not unreliable because MT4 would not perform trades. They are unreliable for other reasons related to the tick-based execution, to the MQL4 structure and to in-sample testing.
Posted By: Mangal

Re: Z5 - 01/03/14 16:41

Allrigth, then I rewrite the script as follows and apply it to the EURUSD that has no problem of history data.


function run()
{
BarPeriod = 1440;

vars A1 = series(priceClose(2));
vars A2 = series(priceClose(1));
vars A3 = series(price(0));
//Vlr = 10*PIP


if (A1[0] < A2[0] and A3[0] < A1[0]) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]) enterShort();

Stop = 30*PIP;
TakeProfit = 500*PIP;
//ExitTime = 1;

}

This gives the following results:


A1,A2,A3 Ar62% compiling...............
Error 055: EUR/USD 2014 price history missing
BackTest: A1,A2,A3 Ar62% EUR/USD 2009..2014
Profit 173$ MI 3$ DD 61$ Capital 60$
Trades 176 Win 18% Avg +12.9p Bars 3
AR 74% PF 1.48 SR 0.75 UI 13.3% Error 54%

That is, an annual return of 74%, which is not a big deal though the script can be refined and get better and more robust results. It is just an exemple for the sake of the discussion here. The main thing is that the re-Test problem seem to have been solved. I re-tested many times and now it gives results every time, so I assume that the script has now no bug, isn't it?
Posted By: Anonymous

Re: Z5 - 01/03/14 22:33

You should set Stop & TakeProfit before entering trade(s), not after, I believe. Also I would not create 2 series of priceClose() data, but only one. Finally, I'd name the series a little better, so it's easier to parse the algo for humans. Comes handy later when you have to debug some issue and your eyes hurt. So, here's how I'd do it:

Code:
function run()
{
	BarPeriod = 1440;

	vars Close = series(priceClose());
	vars Price = series(price());

	Stop = 30 * PIP;
	TakeProfit = 500 * PIP;

	if (Close[2] < Close[1] && Price[0] < Close[2])
		enterLong();

	if (Close[2] > Close[1] && Price[0] > Close[2])
		enterShort();
}



Of course, I can't verify if your strategy does what you want it to do. You could try optimizing it now (Stop & TakeProfit, probably). One problem I see is that it can be dormant for a very long periods of time (month or maybe even two without a single trade), so it would not be easy to trade it for real. But, it's a good start for learning Lite-C. wink
Posted By: jcl

Re: Z5 - 01/06/14 09:04

For closing prices it's normally better to use the price at a certain hour. By default, 1-day bars go from midnight to midnight, so they don't align to a certain market.
Posted By: Mangal

Re: Z5 - 01/07/14 02:31

Probably 17:00 NY time, if it is a major pair, it will be best. I will include later on this correction.

Just continuing with the idea of the previous script. I will keep as A1,A2,A3 for the time being because it allows to make several trials changing the Close for the High or Low and so on as well as increasing to A4, A5, and so on.

As with the parameters set as above, If we ad and "Exit Time = 5" the Anual Return goes to 126%. Then, when optimizing it goes down to 110% and then when doing Walk Forward Analisis for 3 cycles it goes down to -23%.

Supose now I want to introduce some filter, as it is written below and make optimization:


function run()
{
BarPeriod = 1440;
set (PARAMETERS);
vars A1 = series(priceClose(2));
vars A2 = series(priceClose(1));
vars A3 = series(price(0));
var per = optimize(0.000, 0.001,0.01);
var Vlr;

Vlr = A1[0] * per;
printf("Result=%.f",Vlr);


if (A1[0] < A2[0] and A3[0] < A1[0]-Vlr) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+Vlr) enterShort();

Stop = optimize(30,20,100)*PIP;
TakeProfit = optimize(500,200,700)*PIP;
ExitTime = 5;

}


When doing this optimization it popes up "error 043:EURUSD: wrong parameter!". I assume something is wrong in the script but I can not figure out where it can be, since before trying to optimize it seems to be working fine.
Posted By: Mangal

Re: Z5 - 01/09/14 09:20

I found that the "optimize(0.00,0.001,0.01);" is the responsible for this message.

So, setting it up to a fix value of 0.01 gives an Anual Return of 732%. But there must be something wrong because when generating the Results Charts, it doesn't show them properly .

The script now looks like:

function run()
{
BarPeriod = 1440;

set (PARAMETERS);
vars A1 = series(priceClose(2));
vars A2 = series(priceClose(1));
vars A3 = series(price(0));
var percentage = 0.01;
var Vlr;

Vlr = A1[0] * percentage;



if (A1[0] < A2[0] and A3[0] < A1[0]-Vlr) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+Vlr) enterShort();

Stop = optimize(30, 20, 200)*PIP;
TakeProfit = optimize(500, 150, 700)*PIP;
ExitTime = 5;

}

and its results:

A1,A2,A3 Ar62% run..
Error 055: EUR/USD 2014 price history missing
BackTest: A1,A2,A3 Ar62% EUR/USD 2009..2014
Read A1,A2,A3 Ar62%_EURUSD.par
Profit 61$ MI 1$ DD 2$ Capital 7$
Trades 3 Win 67% Avg +267.7p Bars 4
AR 732% PF 30.89 SR 1.13 UI 1.7% Error 291%


Any clue why when clicking to Results don't show the charts with diferente values for optimization?

And then when adding the Walk Forward Analysis, "NumWFOCycles = 3;" it doesn't give results either:


A1,A2,A3 Ar62% run..
Error 055: EUR/USD 2014 price history missing
Walk-Forward Test: A1,A2,A3 Ar62% EUR/USD 2009..2014
Read A1,A2,A3 Ar62%_EURUSD_1.par A1,A2,A3 Ar62%_EURUSD_2.par

Is it due to the small number of trades that can not generate any statistics for Walk Forward Analysis and then it gives this message?






Posted By: jcl

Re: Z5 - 01/09/14 10:08

You can see that your system only enters 3 trades, so its results are random. The WFO version will most likely not enter a single trade, so the system does not produce a result.

For WFO you should aim for about 50..100 trades per cycle when you optimize 2 parameters.

For avoiding the warning about missing 2014 data, either download it from FXCM or put "EndDate = 2013;" in your script.
Posted By: Mangal

Re: Z5 - 01/11/14 09:21

Thank you jcl. When adding "EndDate = 2013" the number of trades increase to 5 instead of 3 when giving 2014 data missing. I assume this is not something to worry about, though common sense says number of trades should be the other way around, that is less number of trades when ending in 2013.

Regarding data download from FXCM (or Alpari), it is data from Metatrader in both cases?. Some analysts suggest that data from Metatrader has plenty of gaps and errors so it may not be so reliable for backtesting?
Posted By: Mangal

Re: Z5 - 02/10/14 08:58

I have been cheking the historical data from metatrader and in principle it is the same data that appears on the screen in the charts which in turns when executing trades appears to be reliable. So, the problems that appear in backtesting in Metatrader, like testing same EA in the same period and giving completely different results, must be due to diferente reasons, like architecture of EA or other reasons as you were pointing out somewhere.
Posted By: Mangal

Re: Z5 - 02/10/14 08:59

I got now this message from my VPS provider which mentions that Metatrader will undergo some changes and may require some update from EA's. Is this going to affect Zorro?

RE: Autoboot v3.0.36 Update Available & Important Information about MT4 v600+ Update

Please be advised Meta Quotes has released a new MT4 update that may cause your software, including CNS Autoboot and many EA's, to stop functioning until they are also updated.

We have released CNS Autoboot v3.0.60 to resolve the issue with CNS Autoboot. MT4 terminals should be expected to auto update at some point in the near future, and so we recommend all subscribers install the CNS Autoboot update as soon as possible to retain compatibility. A reboot may be required to install this update.

We also recommend that you contact your EA publishers now to receive their software update and any further specific instructions.
Posted By: Mangal

Re: Z5 - 02/10/14 09:01

By the way, so far so good with Zorro Z5 real money and inside the results of the backtest essays with Zorro. Four months now runing.
Posted By: jcl

Re: Z5 - 02/10/14 14:45

It's probably correct that MT4 v600+ will cause many EAs to stop functioning, but as far as we see - we've tested it with v604 - the Zorro EA is not affected.
Posted By: Mangal

Re: Z5 - 02/17/14 11:27

When doing backtests, some questions pop up regarding the WFO analysis. Checking the same script in different periods of time I get the following results:

2000-2005, WFO 3 cycles, Anual Return = -58%, nr of trades 55
2000-2005, WFO 10 cycles, Anual Return = 37%, nr of trades 137

Is the result with larger number of trades with 10 cycles rather than with 3 cycles more realiable?

Backtesting the same script through other periods of time:
2005-2010, WFO 3 cycles, AR = 93%, nr of trades 93
2008-2013, WFO 3 cycles, AR = 79%, nr of trades 83.

The results are different depending on the period of time considered. Would that be in backtesting standards a reasonable result?

In the three tested periods of time it gives different results.

Do the Zorro estrategias, Z5, Z12, and so on, have been tested in different periods of time than those one can test by default?
Posted By: jcl

Re: Z5 - 02/18/14 17:17

Yes, different test periods will produce different results. This also applies to the Z systems, for which the test periods have been selected for best significance. Due to the slow change of markets, the longest possible test period is normally not the best.
Posted By: Mangal

Re: Z5 - 02/18/14 21:10

When you say test periods have been selected for best significance, do you follow some specific rule to select them, like uptrend, downtrend and sideways, or you just consider a 10% aleatory sample of, say, 10 -20 year period?

In physical sciences the rule of 10% sample works reasonable well, though nobody knows why, but I don't know if same rule applies to the market.
Posted By: jcl

Re: Z5 - 02/19/14 07:16

We normally select the test period so that it covers about 50..100 trades per degree of freedom of the strategy. This is an empirical rule - shorter test periods tend to produce less significant results.

There are exceptions, for instance Z4 and Z5 were only tested with data after 2011.
Posted By: Mangal

Re: Z5 - 02/20/14 08:36

The fact that the backtests are based on WFO analysis, if one develops an strategy which results are based on the results obtained in recent period backwards, then one has to keep on optimizing it every certain period of time, say every month or couple of weeks, right? Though in Z5 this is not necessary as you were mentioning somewhere.

Would you advice to keep on optimizing a particular script every certain period of time or rather any number of 50-100 trades backwards for degree of freedom?

This brings the question also that better keep changing the script every certain period of time?. Some particular script adapts better in the inmediate 5 years back than in the 5 years old back in the past. For instante, in one script I get with 10 cycles WFO:

2000-2005, AR = 4 % , nr trades 193 for two degrees of freedom
2005-2010, AR = 191 %, nr trades 313
2008-2013, AR = 77 %, nr trades 282

As far as I understand, if a script doesn't consider the trend and it behaves in a similar way in an upward, downward and sideways period, then it gives more confidence. Other reasons, like periods of less volatility may be also behind the different behaviour.
Posted By: jcl

Re: Z5 - 02/21/14 09:31

200 trades should be ok for 2 DOF, so the WFO period is good. Re-optimization should happen in the same time interval as the WFO test period. It can happen that a system does not work on old data, due to the change of markets. For the same reason, very long simulation periods, such as 15 or 25 years, make not much sense. The lifetime of a system is normally in the 5 years range.
Posted By: Mangal

Re: Z5 - 02/23/14 02:05

Thank you, Jcl.

One question I have is regarding the function ExitTime = 1. Does it close the position at the Close of the present Bar?
Posted By: jcl

Re: Z5 - 02/24/14 14:29

No, at the Open of the next bar AFAIK.
Posted By: Mangal

Re: Z5 - 02/25/14 02:07

There is something that escapes to my understanding here. Supose you take the following script:

function run()
{
BarPeriod = 1440;

vars A1 = series(priceClose(2));
vars A2 = series(priceClose(1));
vars A3 = series(price(0));
//Vlr = 10*PIP


if (A1[0] < A2[0] and A3[0] < A1[0]) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]) enterShort();

//Stop = 30*PIP;
//TakeProfit = 500*PIP;
ExitTime = 1;

}

It gives the following results:

A1,A2,A3 compiling................
Error 055: EUR/USD 2014 price history missing
BackTest: A1,A2,A3 EUR/USD 2009..2014
Profit -33$ MI -1$ DD 33$ Capital 32$
Trades 176 Win 0% Avg -2.4p Bars 2
AR -26% PF 0.00 SR -8.92 UI 0.0% Error 64%


As you can see there is Win 0% and this can not be. If it really would close at the Close of present bar or Open of next bar, there should be some % of win. It could be small but not 0%.

So ExitTime = 1, I don't know exactly where it closes the open position. Or the entry point doesn't happen exactly at the moment indicated in the script. Any light about this?
Posted By: jcl

Re: Z5 - 02/26/14 07:21

Well, from what I've learned, a trade is a loser when its profit is negative, or does not cover its costs.

If you don't understand why your trades are losing, just examine the trade list. There you can see the entrty and exit of every trade, and check why, when, and how much you lost. You should do that anyway all the time while developing a strategy.
Posted By: Mangal

Re: Z5 - 02/26/14 08:33

Allright. So I include the line
set(LOGFILE);
in the script. I run it and look into the log folder of Zorro and what I get is:

[79: Fri 24.04. 00:00] 1.30081
[80: Mon 27.04. 00:00] 1.31242
[81: Tue 28.04. 00:00] 1.32141
[EUR/USD::L8101] Long 1@1.3025 Risk 10 at 00:00
[EUR/USD::L8101] Sell 1@1.3025: -0.17 at 00:00


and all trades similar to this one, like:

[EUR/USD::S8502] Short 1@1.3291 Risk 10 at 00:00
[EUR/USD::S8502] Cover 1@1.3291: -0.21 at 00:00

And this bothers me because I can't figure out what is doing:

1. It opens position at 00:00 in all of them, which shouldn't be according to the conditions requested. Though this may be understood if we consider that it refers to the bar 00:00

2. It gives risk US$ 10 or US$ 11 by default when there is no risk limit since there is no stop loss.

3. It closes position at 00:00 same day when it should close at 00:00 of next day, since ExitTime is set to 1.
Posted By: jcl

Re: Z5 - 02/26/14 08:56

You enter your trades at midnight and immediately close them at the Open of the next bar. So of course you're always losing due to trading costs. If you wanted to close them at the Open of the day after tomorrow, you must wait 2 bars for exiting, so set ExitTime to 2. This may be a little confusing, but it's because a trade closes at the Open. If you don't set a stop, the risk is estimated and has no further meaning.

A script just does what you tell it to do, the task is to tell it the right thing.
Posted By: Mangal

Re: Z5 - 02/26/14 09:06

I get it. So it should be ExitTime = 2
Posted By: Mangal

Re: Z5 - 03/04/14 04:14

I am trying a multitimeframe strategy and it doesn't work. Anyone can tell me where is the mistake in the following script?

function trenta()
{
TimeFrame = 1;

vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var VlrH;

VlrH = A1[0] * percentage;



if (A1[0] < A2[0] and A3[0] < A1[0]-VlrH) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrH) enterShort();

vars B1 = series(priceLow(2));
vars B2 = series(priceLow(1));
vars B3 = series(price(0));
var percentage = 0.001;
var VlrL;

VlrL = B1[0] * percentage;



if (B1[0] < B2[0] and B3[0] < B1[0]-VlrL) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrL) enterShort();


Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 25;


}

function doscents()
{
TimeFrame = 8;

vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var VlrH;

VlrH = A1[0] * percentage;



if (A1[0] < A2[0] and A3[0] < A1[0]-VlrH) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrH) enterShort();

vars B1 = series(priceLow(2));
vars B2 = series(priceLow(1));
vars B3 = series(price(0));
var percentage = 0.001;
var VlrL;

VlrL = B1[0] * percentage;



if (B1[0] < B2[0] and B3[0] < B1[0]-VlrL) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrL) enterShort();


Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 10;

}

function run()
{

set (PARAMETERS);
BarPeriod = 30;
StartDate = 2011;
EndDate = 2013;
function trenta();
function doscents();
NumWFOCycles = 3;

}

The two functions used, individually they run fine but when trying to run them together, don't work.
Posted By: jcl

Re: Z5 - 03/04/14 07:55

User quiz: Who can see where the two functions interfere with each other? Solution tomorrow.
Posted By: jcl

Re: Z5 - 03/05/14 08:28

No takers, so here the solution: You're setting trade parameters in function A for trades in function B, and vice versa - that is probably not what you intended.

Just as in real life, you must set stop, exit etc. _before_ entering a trade. When the trade is already entered, it's a little too late.
Posted By: Mangal

Re: Z5 - 03/06/14 10:58

Sorry, jcl, I don't pick it up. Even if I cancel all B functions keeps without compiling. I put now the stop loss and target in front and paréntesis to separate. Is it now that the A functions for one Time Frame interfer with the A functions of the other TimeFrame?



function trenta()
{
Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 25;
TimeFrame = 1;
{
vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var VlrH;

VlrH = A1[0] * percentage;

if (A1[0] < A2[0] and A3[0] < A1[0]-VlrH) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrH) enterShort();
}
{
//vars B1 = series(priceLow(2));
//vars B2 = series(priceLow(1));
//vars B3 = series(price(0));
//var percentage = 0.001;
//var VlrL;

//VlrL = B1[0] * percentage;


//if (B1[0] < B2[0] and B3[0] < B1[0]-VlrL) enterLong();
//if (B1[0] > B2[0] and B3[0] > B1[0]+VlrL) enterShort();

}

}

function doscents()
{

Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 10;
TimeFrame = 8;
{

vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var VlrH;

VlrH = A1[0] * percentage;

if (A1[0] < A2[0] and A3[0] < A1[0]-VlrH) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrH) enterShort();
}

{
//vars B1 = series(priceLow(2));
//vars B2 = series(priceLow(1));
//vars B3 = series(price(0));
//var percentage = 0.001;
//var VlrL;

//VlrL = B1[0] * percentage;

//if (B1[0] < B2[0] and B3[0] < B1[0]-VlrL) enterLong();
//if (B1[0] > B2[0] and B3[0] > B1[0]+VlrL) enterShort();
}

}

function run()
{
set(PARAMETERS);
BarPeriod = 30;
StartDate = 2011;
EndDate = 2013;
function trenta();
function doscents();
NumWFOCycles = 3;
}


When training it gives:


A1,A2,A3 Multitime trialF compiling................
WFO: A1,A2,A3 Multitime trialF 2011..2013
Posted By: dusktrader

Re: Z5 - 03/06/14 11:09

Inside your run() function, I believe it's a syntax error to use the word "function" ... just get rid of that and then it will complete the Test.

Like this:
Code:
function run()
{
set(PARAMETERS);
BarPeriod = 30;
StartDate = 2011;
EndDate = 2013;
trenta();
doscents();
NumWFOCycles = 3;
}

Posted By: Mangal

Re: Z5 - 03/14/14 07:36

Thank you, dusktrader. Together with the changes in parenthesis and other indications from jcl, now it runs.
Posted By: Mangal

Re: Z5 - 06/26/14 21:24

I wouldn't put money on the following script because it gives negative results in different periods of time than 2011-2013. However for the sake to know if there is some mistake since it gives CAGR 3174%, can anyone have a look and see if there is mistake?

#include <profile.c>
function run()

{

BarPeriod = 60;
Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 25;
NumWFOCycles = 4;
set(PARAMETERS+FACTORS);
Capital = 500;
StartDate = 2011;
EndDate = 2013;
set(LOGFILE);
plotTradeProfile(-100);

vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var Vlr;
Vlr = A1[0] * percentage;


Margin = OptimalF * Capital * sqrt(1 + ProfitClosed/Capital);
if (A1[0] < A2[0] and A3[0] < A1[0]-Vlr) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+Vlr) enterShort();

vars B1 = series(priceLow(2));
vars B2 = series(priceLow(1));
vars B3 = series(price(0));
var percentage = 0.001;
var Vlr;
Vlr = B1[0] * percentage;



//if (B1[0] < B2[0] and B3[0] < B1[0]-Vlr) enterLong();
//if (A1[0] > A2[0] and A3[0] > A1[0]+Vlr) enterShort();


}

------------------------------------------------------
It gives the following result with two degres of freedom:

Read A1,2,3 60'_EURUSD_1.par A1,2,3 60'_EURUSD_2.par A1,2,3 60'_EURUSD_3.par
Factors stored in A1,2,3 60'_EURUSD.fac

A1,2,3 60' run..
Walk-Forward Test: A1,2,3 60' EUR/USD 2011..2013
Read A1,2,3 60'_EURUSD.fac A1,2,3 60'_EURUSD_1.par A1,2,3 60'_EURUSD_2.par A1,2,3 60'_EURUSD_3.par
Monte Carlo Analysis... Median AR 168%
Profit 18772$ MI 1494$ DD 5127$ Capital 2719$
Trades 326 Win 60% Avg +801.8p Bars 21
CAGR 3174% PF 1.53 SR 2.10 UI 11% R2 0.69 ok
Generate Chart - please wait... ok
Posted By: jcl

Re: Z5 - 06/27/14 08:56

Your initial capital is too low. You need to invest at least the required capital, which is $2719 here. Add 50% for safety.
Posted By: Mangal

Re: Z5 - 06/27/14 16:19

Thanks jcl.
Posted By: Mangal

Re: Z5 - 07/30/14 11:42

When runing a script for simple Anual Return it gives AR 197% but when doing it for compound, reinvesting money according to Optimal F, CAGR gives -1%. Is this an output considered to be possible? Probably the answer is trivial, though...

A1,2,3, 30 minutes run..
Walk-Forward Test: A1,2,3, 30 minutes EUR/USD 2008..2013
Read A1,2,3, 30 minutes_EURUSD_1.par A1,2,3, 30 minutes_EURUSD_2.par
Monte Carlo Analysis... Median AR 279%
Profit 1996$ MI 106$ DD 385$ Capital 647$
Trades 533 Win 51% Avg +52.1p Bars 292
AR 197% PF 2.25 SR 1.75 UI 17% R2 0.66

BUT CAGR gives -1%
[72370] Error 010: Invalid Margin == -1$
[72391] Error 010: Invalid Margin == -1$
[72424] Error 010: Invalid Margin == -1$
[72448] Error 010: Invalid Margin == -1$
[72474] Error 010: Invalid Margin == -1$
[72722] Error 010: Invalid Margin == -1$
Monte Carlo Analysis... Median AR -10%
Profit -521$ MI -28$ DD 1450$ Capital 1161$
Trades 216 Win 21% Avg +2.9p Bars 92
CAGR -1% PF 0.91 SR -0.22 UI 108% R2 0.38 ok
Copied to Clipboard!
Copied to Clipboard!
Posted By: jcl

Re: Z5 - 07/30/14 12:01

Yes, investing negative money is not such a good idea when you're after positive profit.

How to invest is dealt with in workshop 6.
© 2024 lite-C Forums