Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, AndrewAMD), 833 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
Donchian Channel Indicator #409857
10/23/12 08:12
10/23/12 08:12
Joined: Oct 2012
Posts: 75
H
hughbriss Offline OP
Junior Member
hughbriss  Offline OP
Junior Member
H

Joined: Oct 2012
Posts: 75
Hi JCL,

I am having trouble getting some indicators to work, could you run through with me how to use them?

DChannel(int TimePeriod): var
Donchian Channel; from the minimum and maximum value of the High and Low var* over the time period. Returns: rRealUpperBand, rRealLowerBand. The function internally creates series and thus must be called in a fixed order in the script

So I have tried to declare the value of DChannel as 55 for the upper band but then I can't seem to use rRealUpperBand in the script?

Also stochastics is another one I have trouble with. Could you please show me how to use this type of indicator? Thanks.

Maybe a short script using them would help?

Re: Donchian Channel Indicator [Re: hughbriss] #409862
10/23/12 11:37
10/23/12 11:37
Joined: Oct 2012
Posts: 22
G
Guiom Offline
Newbie
Guiom  Offline
Newbie
G

Joined: Oct 2012
Posts: 22
Hi hughbriss,

I have written a script to deal with the basic donchian channel strategy and I will post it when i am back home in a few hours, unless someones posts something before then

Guiom

Re: Donchian Channel Indicator [Re: Guiom] #409863
10/23/12 12:36
10/23/12 12:36
Joined: Oct 2012
Posts: 75
H
hughbriss Offline OP
Junior Member
hughbriss  Offline OP
Junior Member
H

Joined: Oct 2012
Posts: 75
Excellent, thank you.

Re: Donchian Channel Indicator [Re: hughbriss] #409868
10/23/12 15:36
10/23/12 15:36
Joined: Oct 2012
Posts: 22
G
Guiom Offline
Newbie
Guiom  Offline
Newbie
G

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

Code:
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: Guiom] #409869
10/23/12 16:26
10/23/12 16:26
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Thanks for posting - and some remarks if you don't mind:

- The Donchian_Entry series is not needed, it is identical to DE_Up (same for Donchian_Exit)

- For the entry series, the default optimize value is below its lower limit.

- OptimalF is always 1 because you have FACTORS not set.

- 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.

Re: Donchian Channel Indicator [Re: jcl] #409870
10/23/12 17:06
10/23/12 17:06
Joined: Oct 2012
Posts: 75
H
hughbriss Offline OP
Junior Member
hughbriss  Offline OP
Junior Member
H

Joined: Oct 2012
Posts: 75
Thanks Guiom and JCL, the plan is coming together. I will attempt to code it and see how I go.

By the way 55/20 is the most profitable all round settings for the donch channels. The add ons I have found to be profitable are every time the 55 is broken and the donch channel has been flat for at least 3 bars although I think I will probably have to look into some sort of ATR entry for 3 or 4 entries and then stop adding on, very much like the original turtle rules.

Re: Donchian Channel Indicator [Re: jcl] #409872
10/23/12 17:27
10/23/12 17:27
Joined: Oct 2012
Posts: 22
G
Guiom Offline
Newbie
Guiom  Offline
Newbie
G

Joined: Oct 2012
Posts: 22
Originally Posted By: jcl
Thanks for posting - and some remarks if you don't mind:

I don't mind at all, thanks for highlighting the obvious errors...

Quote:
- 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: Guiom] #409893
10/24/12 08:33
10/24/12 08:33
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
No, it's not the same. It's the crossing of the Price_Close curve with a horizontal line that has the position of DE_Up at the previous bar.

Price_Close>DE_Up[1] would be a wrong expression. For comparing two variables from two series, use for instance Price_Close[0]>DE_Up[1].

Re: Donchian Channel Indicator [Re: jcl] #409933
10/25/12 04:29
10/25/12 04:29
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

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:
Quote:

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?

Re: Donchian Channel Indicator [Re: TankWolf] #409936
10/25/12 07:14
10/25/12 07:14
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You can see the the description and source code of all those old indicators at http://tadoc.org/. The +DI and -DI are indeed internally calculated, but apparently nowhere stored, so that you have no access on them.

Page 1 of 4 1 2 3 4

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1