|
Re: Z5
[Re: Mangal]
#435218
01/03/14 22:33
01/03/14 22:33
|
acidburn
Unregistered
|
acidburn
Unregistered
|
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:
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.
|
|
|
Re: Z5
[Re: jcl]
#435377
01/07/14 02:31
01/07/14 02:31
|
Joined: Sep 2013
Posts: 73
Mangal
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2013
Posts: 73
|
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.
|
|
|
Re: Z5
[Re: Mangal]
#435568
01/09/14 09:20
01/09/14 09:20
|
Joined: Sep 2013
Posts: 73
Mangal
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2013
Posts: 73
|
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?
Last edited by Mangal; 01/09/14 09:24.
|
|
|
|