|
Re: Donchian Channel Indicator
[Re: Guiom]
#409863
10/23/12 12:36
10/23/12 12:36
|
Joined: Oct 2012
Posts: 75
hughbriss
OP
Junior Member
|
OP
Junior Member
Joined: Oct 2012
Posts: 75
|
|
|
|
Re: Donchian Channel Indicator
[Re: hughbriss]
#409868
10/23/12 15:36
10/23/12 15:36
|
Joined: Oct 2012
Posts: 22
Guiom
Newbie
|
Newbie
Joined: Oct 2012
Posts: 22
|
Here it is. Basic donchian channel trading, enter one position on breakout of long period channel and exit when crossing the shorther channel. Not sure how to code the add ons the way you've done it with your DC trading method tho... Guiom
function run()
{
set(PARAMETERS|LOGFILE|TESTNOW); // generate and use optimized parameters
StartDate = 2006;
BarPeriod = 1440; // daily bars
NumWFOCycles = 8; // activate WFO
NumBarCycles = 4; // 4 times oversampling
var *Price_Close = series(priceClose());
var *Donchian_Entry = series(DChannel(optimize(30,35,70,5)));
var *DE_Up = series(rRealUpperBand);
var *DE_Down = series(rRealLowerBand);
var *Donchian_Exit = series(DChannel(optimize(5,5,30,5)));
var *DEx_Up = series(rRealUpperBand);
var *DEx_Down = series(rRealLowerBand);
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")))
{
Stop = optimize(2,1,10)*ATR(20);
if(Train)
Lots = 1;
else if(OptimalFLong > 0) {
Lots = 1;
Margin = clamp((WinLong-LossLong) * OptimalFLong/2, 50, 10000);
} else if(OptimalFShort > 0) {
Lots = 1;
Margin = clamp((WinShort-LossShort) * OptimalFShort/2, 50, 10000);
} else
Lots = 0; // switch off trading
if(crossOver(Price_Close,DE_Up[1]) and numLong(0)==0)
enterLong();
else if(crossUnder(Price_Close,DE_Down[1]) and numShort(0)==0)
enterShort();
else if(crossOver(Price_Close,DEx_Up[1]) and numShort(0)>=1)
exitShort();
else if(crossUnder(Price_Close,DEx_Down[1]) and numLong(0)>=1)
exitLong();
}
}
|
|
|
Re: Donchian Channel Indicator
[Re: jcl]
#409872
10/23/12 17:27
10/23/12 17:27
|
Joined: Oct 2012
Posts: 22
Guiom
Newbie
|
Newbie
Joined: Oct 2012
Posts: 22
|
Thanks for posting - and some remarks if you don't mind:
I don't mind at all, thanks for highlighting the obvious errors... - CrossOver/Under checks the crossing of the price not with a curve, but with a horizontal line. I'm not sure if that is what you intended. If you want to compare the price curve with the Donchian curve delayed by 1 bar, use instead:
if(crossOver(Price_Close,DE_Up+1)...
DE_Up[1] = the Donchian up value at the previous bar DE_Up+1 = the Donchian up series delayed by 1 bar. Is crossOver(Price_Close,DE_Up[1]) the same as Price_Close>DE_Up[1]? Thanks
|
|
|
Re: Donchian Channel Indicator
[Re: jcl]
#409933
10/25/12 04:29
10/25/12 04:29
|
Joined: Sep 2012
Posts: 99
TankWolf
Junior Member
|
Junior Member
Joined: Sep 2012
Posts: 99
|
Thought I would just post this here to avoid starting another thread. With the ADX() indicator when I check the help manual it says the following: ADX(int TimePeriod): var Average Directional Movement Index. Moving average of the DX (see below). The returned values range from 0 to 100.
I have some trading strategies that uses the ADX but also the +DI and -DI values. By looking at what the ADX indicator returns it would seem that those values arn't returned is this true and if they arnt is there any way to return them?
|
|
|
|