forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Software

Create and Test Forex Strategies

You are not logged in. Please login or register.


(Page 1 of 3)

Forex Software → Technical Indicators → Gann 2-bars indicator

Pages 1 2 3 Next

You must login or register to post a reply

RSS topic feed

Posts: 1 to 25 of 60

Topic: Gann 2-bars indicator

Any luck to have any one to code gann 2-bars indicator

the idea : trend is up if we have two consecutive higher highs and it is down if we have consecutive lower lows   

see this link to illustrate the indicator
http://www.tradingmarkets.com/.site/forex/how_to/articles/Using-Gann-to-Trade-the-Main-Trend-80152.cfm

My idea of the logic used
1- Trend is up
2- trend is down
3- Trend changes its direction up
4- trend changes its direction down
5- trend change from up to " no trend/ consolidation "
6- trend changes from down to consolidation
7- trend changes from consolidation to up
8- trend changes from consolidation to down

Indicator to be used as opening logic / closing logic / opening point / closing point

The default gann use two price bars , we could make it use 3 or 4... bars

to make more than one version of it " weekly gann' " daily gann" and ' current time frame gann" 


======================================================================

Also we can use the calculations of the 1st indicator to build gann swing indicator




ANY Help

Regards

Re: Gann 2-bars indicator

The best luck I have had to simulate this is:
Try 2 sets of Donchian Channels:
1) with period = 2 (or 3 or 4)
2) with period = 24 (or 36 or 48)

Short period Donchian will show swing high and lows. The Long period Donchian will show the main tops and bottoms.

For the Long Donchian, you will have to try different periods to get the main tops and bottoms.

The Gann indicator from the link is not good for Bar Open logic. It is calculated from Highs and Lows of the last 2 bars, but sometimes in real trading, it is impossible to know the highest and the lowest. I think Mr Popov used to include a demo strategy with the Zig Zag indicator to show this type of problem.

This picture from linked page also shows an example:

http://s10.postimage.org/fvcxr4xbp/Not_To_End.jpg

If the code is not careful in the indicator, it will probably have the "Repainting Bug". The Donchian Channels are better, they avoid this kind of bug because they use a value from the previous bars to draw.

Re: Gann 2-bars indicator

Dear krog , thnx for reply and nice approach using Donchian Channels but the gan 2-bar indicator not like the swing indicator and it will not repaint because we will not use the last move " last 2 bars" until it fully completed also the only factor used in the 2-bar indicator is the price only



Note; i cannot use http://postimage.org any more  because they blocked it here sad  so kindly could you attach your picture as a file .. thanks

Re: Gann 2-bars indicator

Ok, picture attached below.
I agree -- if careful, the indicator can avoid the repaint bug. Sometimes it will have 1 or 2 bars at the end with no indicator values. They have to wait for the price event to happen.

Post's attachments

NotToEnd.jpg 152.89 kb, 1 downloads since 2011-11-13 

You don't have the permssions to download the attachments of this post.

Re: Gann 2-bars indicator

krog wrote:

Ok, picture attached below.
I agree -- if careful, the indicator can avoid the repaint bug. Sometimes it will have 1 or 2 bars at the end with no indicator values. They have to wait for the price event to happen.

in that picture the 2 days low is adjusted to 3 days low , if you apply the 3 bars count instead of 2 bars it will make sense  , and as i said before it will use highs and lows so it will not repaint " i think" smile

Re: Gann 2-bars indicator

hmm, it repaints in that way that it adjusts the recent low point as new bars come in. It will be tough to incorporate the logics properly, otherwise backtest and real trade will not match.

Ahmed, consolidation is when the swing line is not extended for some time?

Re: Gann 2-bars indicator

footon wrote:

hmm, it repaints in that way that it adjusts the recent low point as new bars come in. It will be tough to incorporate the logics properly, otherwise backtest and real trade will not match.

Where is the repaint !!!!!

footon wrote:

Ahmed, consolidation is when the swing line is not extended for some time?

and when the price bars start to be narrow range bars and keep closing inside the previous bar before the rule or " No. of bars selected 2,3,....." is complete to be able to draw the last swing

Re: Gann 2-bars indicator

ahmedalhoseny wrote:
footon wrote:

hmm, it repaints in that way that it adjusts the recent low point as new bars come in. It will be tough to incorporate the logics properly, otherwise backtest and real trade will not match.

Where is the repaint !!!!!

footon wrote:

Ahmed, consolidation is when the swing line is not extended for some time?

and when the price bars start to be narrow range bars and keep closing inside the previous bar before the rule or " No. of bars selected 2,3,....." is complete to be able to draw the last swing

I think I understand now. The indicator will not have a value -- until the second new high or second new low. Before then, like the screenshot, it does not have a value.

Upon completion of the second new high or low, the indicator draws the line to that bar. We don't always see the diagonal line crossing through the bars, crossing from swing high to swing low. And, that is ok,  those middle values are not used anyway, they are only drawn to help use see the the line.

Re: Gann 2-bars indicator

These idea of indicators not mine smile they are belongs to Mr Gann

I said indicators because there are three indicators i think they add a value if we manage to code them

Gann Trend  which we discus it here now it is helpful to identify early trend reversals , also it confirms the trend momentum

Gan swing which use the confirmed turning points in Gann trend to build a fixed swings using the price highs and lows only

And the third one is Gann hi-lo indicator which is used as a stop loss indicator , also as an entry point as well

i could attach here MT4 , metastock codes for them to give some ideas " i know iam no coder at all " smile

and some of you guys have already coded other indicators more difficult than these indicators , just say it and i will post these indicator here to be coded

Re: Gann 2-bars indicator

ahmedalhoseny wrote:

Where is the repaint !!!!!

I searched info on this, and I stumbled upon this: http://fxcodebase.com/code/download/fil … 33&t=1

Based on the screenshot above, I see following problem. Sure, it is a matter of definition, but I consider it a repaint.

http://s8.postimage.org/g9ml320ip/gann.jpg

Difficult to make my point here, but I'll try.

At the beginning of the 3rd bar we have a value in the bar "L" and 2, according to the black trendline, if data would end after bar 3, FSB would enter into long position if logic "Trend is up" is used. If there's more data, it changes the trendline, see red and lime trendlines. What I'm trying to say here is data points are shifted and FSB would use only the last one, therefore backtest would be absolutely useless.

Tell me Ahmed, is the first screenshot correct or not? Can the Gann trendline be like a chain, so to speak, which follows the price precisely step by step (ie up-down-up-up-up), or more like the the zigzag (up-down-up-down)?

Keep these ideas going, I often find your posts useful! smile

Re: Gann 2-bars indicator

Thanks for detailed reply

i need you to make some exercise 

select moving average indicator as opening logic and make it use period =1  , and use high instead of close and look to charts you will find something like gann trend " sure its not the same " but you will find the moving average keep rising or falling when we add a new bar  and still FSB use all available points that match strategy not only the last one  ,  Why we don't consider that Moving average repaint !!!!!!!


For Me Gann trend is a normal moving average using highs and lows with a small twist " it keep you out of market in bars not connected with the trend line 

I think the problem here guys you keep thinking about it as a swing not as a trend line smile

Re: Gann 2-bars indicator

Thanks for the feedback, I've been trying to figure out how to get a trend out of Donchians for a long time. This might be it.

I see your point, the repaint can be avoided. Gann draws from lowest to 2nd consecutive high, then to 3rd consecutive high. Repaint would happen if draw from lowest to 2nd consecutive high, then redraw from lowest to 3rd consecutive high.

It's like draw the upper donchian when there are new highs; then switch to draw lower donchian when there are new lows. Don't draw if the latest bars are in between.

Re: Gann 2-bars indicator

fantastic   , when we expect to see the indicator smile

Re: Gann 2-bars indicator

I'll try to do it, maybe 2 -3 days.

Re: Gann 2-bars indicator

Many thanks  krog

this site a nice and simple educative site about gann stuff

http://www.solarmatrix.com/lessons/LESSON1.htm

Re: Gann 2-bars indicator

ahmedalhoseny wrote:

i could attach here MT4 , metastock codes for them to give some ideas " i know iam no coder at all " smile
just say it and i will post these indicator here

If it's not too much trouble, share them please!

Thanks!

Re: Gann 2-bars indicator

Amibroker code


GANN-Swing

{Market swing is defined as:
Up = 2 higher highs,
Down = 2 lower highs.}
Us:=BarsSince((H > Ref(H,-1)) AND (Ref(H,-1) >
Ref(H,-2)));
Ds:=BarsSince((L < Ref(L,-1)) AND (Ref(L,-1) <
Ref(L,-2)));
Sd1:=If(Us=0,
{then}If(Ref(L,-1)<>LowestSince(1,Ds=0,L),
{then}1,
{else}0),
{else}If(Ds=0,
{then}If(Ref(H,-1)<>
HighestSince(1,Us=0,H),
{then}-1,
{else}0),
{else}0));
Sd2:=If(Sd1=1,
{then} If(Ref(BarsSince(Sd1=1),-1) >
Ref(BarsSince(Sd1=-1),-1),
{then}1,
{else}0),
{else} If(Sd1=-1,
{then}If(Ref(BarsSince(Sd1=1),-1) <
Ref(BarsSince(Sd1=-1),-1),
{then}-1,
{else}0),
{else}0));
TD1:=ValueWhen(1,Sd2<>0,Sd2);
Td1;
-------------------------------------------------------------
GANN-Trend

{Swing Direction}
Sd:= FmlVar("GANN-Swing","TD1") ;
{Swing Change High}
Sch:=If(Sd=1 AND Ref(sd,-1)=-1,
{then}1,
{else}0);
{Swing Change Low}
Scl:=If(Sd=-1 AND Ref(Sd,-1)=1,
{then}1,
{else}0);
{Peak Value}
Pv:=If(Scl=1,
{then}HighestSince(1,Sch=1,H),
{else}0);
{Trough Value}
Tv:=If(Sch=1,
{then}LowestSince(1,Scl=1,L),
{else}0);
{Trend Direction}
Td:=If(H>ValueWhen(1,Pv>0,Pv),
{then}1,
{else}If(L<ValueWhen(1,Tv>0,Tv),
{then}-1,
{else}0));
{UpTrend=1 DownTrend =-1}
Tdv:=ValueWhen(1,Td<>0,Td);
Tdv;

Re: Gann 2-bars indicator

metastock:

Gann-Trend

{Swing Direction}
Sd:= FmlVar("GANN-Swing","TD1") ;
{Swing Change High}
Sch:=If(Sd=1 AND Ref(sd,-1)=-1,
{then}1,
{else}0);
{Swing Change Low}
Scl:=If(Sd=-1 AND Ref(Sd,-1)=1,
{then}1,
{else}0);
{Peak Value}
Pv:=If(Scl=1,
{then}HighestSince(1,Sch=1,H),
{else}0);
{Trough Value}
Tv:=If(Sch=1,
{then}LowestSince(1,Scl=1,L),
{else}0);
{Trend Direction}
Td:=If(H>ValueWhen(1,Pv>0,Pv),
{then}1,
{else}If(L<ValueWhen(1,Tv>0,Tv),
{then}-1,
{else}0));
{UpTrend=1 DownTrend =-1}
Tdv:=ValueWhen(1,Td<>0,Td);
Tdv;

Re: Gann 2-bars indicator

Gann Swing
MetaStock Indicator

Us:=BarsSince((H > Ref(H,-1)) AND (Ref(H,-1) > Ref(H,-2)));
Ds:=BarsSince((L < Ref(L,-1)) AND (Ref(L,-1) < Ref(L,-2)));
Sd1:=If(Us=0,
{then}If(Ref(L,-1)<>LowestSince(1,Ds=0,L),
{then}1,
{else}0),
{else}If(Ds=0,
{then}If(Ref(H,-1)<>HighestSince(1,Us=0,H),
{then}-1,
{else}0),
{else}0));
Sd2:=If(Sd1=1,
{then} If(Ref(BarsSince(Sd1=1),-1) > Ref(BarsSince(Sd1=-1),-1),
{then}1,
{else}0),
{else} If(Sd1=-1,
{then}If(Ref(BarsSince(Sd1=1),-1) < Ref(BarsSince(Sd1=-1),-1),
{then}-1,
{else}0),
{else}0));
TD1:=ValueWhen(1,Sd2<>0,Sd2);
Td1;



Gann High Low
MetaStock Indicator

HLd:=If(CLOSE>Ref(Mov(H,3,S),-1),
{then}1,
{else}If(CLOSE<Ref(Mov(L,3,S),-1),
{then}-1,
{else}0));
HLv:=ValueWhen(1,HLd<>0,HLd);
HiLo:=If(HLv=-1,
{then}Mov(H,3,S),
{else}Mov(L,3,S));
HiLo;

20 (edited by ahmedalhoseny 2011-11-14 22:34:21)

Re: Gann 2-bars indicator

Some Mt4 indicator attached here


see also:

http://www.expertadvisordownloads.com/gann-2/?lang=is



links show   gann indicators for fxcm charts software in lua
http://fxcodebase.com/code/viewtopic.php?f=17&t=3845&p=9400&hilit=gann#p9400
http://fxcodebase.com/code/search.php?st=0&sk=t&sd=d&keywords=gann&fid%5B%5D=17&start=10
http://fxcodebase.com/code/viewtopic.php?f=17&t=227&p=8544&hilit=gann#p8544
http://fxcodebase.com/code/viewtopic.php?f=17&t=294&p=7235&hilit=gann#p7235

Post's attachments

Some gann indicators MT4.zip 7.63 kb, 53 downloads since 2011-11-14 

You don't have the permssions to download the attachments of this post.

Re: Gann 2-bars indicator

Also i find that non repainting zigzag indicator used in MT5 station

http://www.mql5.com/en/code/56

http://www.mql5.com/en/code/279

It is promising   i think smile

regards

Re: Gann 2-bars indicator

Thanks Ahmed! The very last thing is interesting indeed, I tried to see what "A-la Clyde Lee Patterns" are, but all I found was http://commons.wikimedia.org/wiki/File: … otball.jpg

Have you tried that last ZZ on MT5? I wonder does it work similarly like an ordinary ZZ in terms of speed etc. I will give it a shot someday, hopefully I can crack the code.

Re: Gann 2-bars indicator

Hi ahmedalhoseny,
Here is first draft. Let me know if this is close to your indicator.
Info:
Gann Line - the Gann Line drawn on chart
Trend Up -- 1 if trend is up; 0 if not
Consolidation -- 1 if no up trend and no down trend;
Trend Down -- 0 if trend is down

Period - period of the Donchian band, tells if making new highs or lows
Hits -- how many higher highs or lower lows to be up/down trend (eg, 2 -- must be 2 consecutive higher highs)

Do you have a version for MT 4 you like? That would be best -- check your MT4 indicator values against my indicator values. If they are the same, good; if the are different, indicator needs more work.

thanks
krog

24 (edited by ahmedalhoseny 2011-11-16 07:45:18)

Re: Gann 2-bars indicator

Many Thanks krog

I have two indicators in MT4 formate for gann swing , but didn't find all over the Internet any gann trend indicators to be drawn to connect all candles  so we have to make our test without comparison 

but regarding gann swings or gann zigzag we could compare the result with some MT4 indicators ,

1-GannZigZag

2-GannSwingsXV  " i think this one is the nearest one to be true" this indicator has an additional option " shows highs and lows" which spot some highs and lows with dots if we connect the dots visually i think it will draw indicator line like you have done " i will check and try to make the comparison"

They are in the attached Zip file " with another nice indicators "

Post's attachments

Some gann indicators MT4.zip 7.63 kb, 39 downloads since 2011-11-16 

You don't have the permssions to download the attachments of this post.

Re: Gann 2-bars indicator

footon wrote:

Thanks Ahmed! The very last thing is interesting indeed, I tried to see what "A-la Clyde Lee Patterns" are, but all I found was http://commons.wikimedia.org/wiki/File: … otball.jpg

Have you tried that last ZZ on MT5? I wonder does it work similarly like an ordinary ZZ in terms of speed etc. I will give it a shot someday, hopefully I can crack the code.

I downloaded MT5 station especially to test that zigzag and i will give it a look on 1 minute charts to see if it is repainting or not  i will let you know my results

Posts: 1 to 25 of 60

Pages 1 2 3 Next

You must login or register to post a reply

Forex Software → Technical Indicators → Gann 2-bars indicator

Similar topics in this forum