|
CCI Hook from extreme
#409687
10/20/12 21:26
10/20/12 21:26
|
Joined: Oct 2012
Posts: 75
hughbriss
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2012
Posts: 75
|
Here is a fun little script that I put together. It trades the hook from an extreme reading on the cci so when the cci prints above the extreme level and then drops back below it or drops below the lower level and then trades above it you enter a trade with an atr stop and an adjustable atr profit multiple. I have tried a few variations and 20, 100, 3 seems quite good. I am using this as a learning tool to learn how to use the optimisation features. I will try to include optimisation for one parameter to start with and then increase from there. If I get stuck I will ask for help! I would be grateful for any help if you can see anything wrong with the script? I have set it to trade all possible instruments but of course they are not all profitable. With the losing instruments taken out it would probably be quite good.
function run()
{
while(asset(loop("AUD/USD","EUR/USD","GBP/USD","GER30","NAS100","SPX500","UK100","UKOil","US30","USD/CAD","USD/CHF","USD/JPY","USDOLLAR","USOil","XAG/USD","XAU/USD")))
{
var *ClosePrice = series(priceClose());
var ccilength = slider(1,20,5,100,"Length",0);
var cciextreme = slider(2,100,50,300,"Extreme",0);
var cciextremen = (cciextreme*-1);
var profatr = slider(3,2,1,5,"Profit ATR",0);
var *cci = series(CCI(ccilength));
Stop = ATR(20);
Profit = profatr*ATR(20);
if(cci[1] > cciextreme && cci[0] < cciextreme)
enterShort();
if(cci[1] < cciextremen && cci[0] > cciextremen)
enterLong();
}
}
|
|
|
Re: CCI Hook from extreme
[Re: hughbriss]
#409692
10/20/12 22:08
10/20/12 22:08
|
Joined: Oct 2012
Posts: 75
hughbriss
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2012
Posts: 75
|
Ok, here is my first attempt at using optimisation. If I use the train button it does test the parameters and the test then comes out with a higher profit figure so I am guessing that it did something but I don't get a graph from the test function with the parameters on like you do in the tutorials. Am I doing something wrong? What should the LookBack period be set to?
function run()
{
set(PARAMETERS);
BarPeriod = 1440;
LookBack = 500;
while(asset(loop("AUD/USD","EUR/USD","GBP/USD","GER30","NAS100","SPX500","UK100","UKOil","US30","USD/CAD","USD/CHF","USD/JPY","USDOLLAR","USOil","XAG/USD","XAU/USD")))
{
var *ClosePrice = series(priceClose());
var ccilength = slider(1,20,5,100,"Length",0);
var cciextreme = slider(2,100,50,300,"Extreme",0);
var cciextremen = (cciextreme*-1);
var profatr = optimize(3,1,5,0.5,0);
var *cci = series(CCI(ccilength));
Stop = ATR(20);
Profit = profatr*ATR(20);
if(cci[1] > cciextreme && cci[0] < cciextreme)
enterShort();
if(cci[1] < cciextremen && cci[0] > cciextremen)
enterLong();
}
}
|
|
|
Re: CCI Hook from extreme
[Re: hughbriss]
#409694
10/20/12 22:19
10/20/12 22:19
|
Joined: Oct 2012
Posts: 75
hughbriss
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2012
Posts: 75
|
Ok, I've worked it out. You don't get the optimisation charts if you are training more than one instrument. Here is the script with all parameters optimised. This is probably over optimised but it comes out with 162% 15757 pips/yr.
function run()
{
set(PARAMETERS);
BarPeriod = 1440;
LookBack = 500;
while(asset(loop("AUD/USD","EUR/USD","GBP/USD","GER30","NAS100","SPX500","UK100","UKOil","US30","USD/CAD","USD/CHF","USD/JPY","USDOLLAR","USOil","XAG/USD","XAU/USD")))
{
var *ClosePrice = series(priceClose());
var ccilength = optimize(20,5,200,5,0);
var cciextreme = optimize(100,50,250,25,0);
var cciextremen = (cciextreme*-1);
var profatr = optimize(3,1,5,0.5,0);
var *cci = series(CCI(ccilength));
var stopatr = optimize(1,0.5,5,0.5,0);
Stop = stopatr*ATR(20);
Profit = profatr*ATR(20);
if(cci[1] > cciextreme && cci[0] < cciextreme)
enterShort();
if(cci[1] < cciextremen && cci[0] > cciextremen)
enterLong();
}
}
Does this optimise all parameters for each instrument seperately? I think it would be best to run the optimisation on one pair and then use the optimal settings for all pairs. This would be more robust and less curve fitted.
|
|
|
Re: CCI Hook from extreme
[Re: hughbriss]
#409706
10/21/12 09:41
10/21/12 09:41
|
Joined: Oct 2012
Posts: 22
Guiom
Newbie
|
Newbie
Joined: Oct 2012
Posts: 22
|
Does this optimise all parameters for each instrument seperately? I think it would be best to run the optimisation on one pair and then use the optimal settings for all pairs. This would be more robust and less curve fitted.
When you optimize there is a .par file in C:\Program Files\Zorro\Data which contains the optimized parameters. I optimized the strategy with only EU and AU and the parameter file shows that each asset is optimized on its own: AUD/USD: 24.6 99.0 4.03 +0.790=> 4.114 EUR/USD: 80.2 97.9 4.02 +0.760=> 2.318 So here for AUD/USD, ccilength=24.6, cciextreme=99.0, profatr=4.03 and stopatr=0.79. Not sure how Zorro handles CCI(24.6) tho? Does is use CCI(24) or CCI(25)? If I am wrong I would appreciate if jcl could correct me. Thanks Guiom
|
|
|
Re: CCI Hook from extreme
[Re: hughbriss]
#409756
10/22/12 07:10
10/22/12 07:10
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
I think it would be best to run the optimisation on one pair and then use the optimal settings for all pairs. This would be more robust and less curve fitted. Using settings from one pair for a different pair is not recommended. It would not be any more robust, it would just be less profitable or probably not work at all. For checking if the strategy is overfitted, test out of sample. Use either:
if(Train) set(PARAMETERS+SKIP3);
if(Test) set(PARAMETERS+SKIP1+SKIP2);
for horizontal splitting, or for the final test,
set(PARAMETERS);
DataSplit = ... // 75% to 90%
NumWFOCycles = ... // 6 to 12 cycles
for WFO. Look in the manual under "Training" for details.
|
|
|
|