Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Gann Squar of Nine for Amibroker (AFL)

Rating:
3 / 5 (Votes 6)
Tags:
amibroker

found afl on net and modified with new look of text…….!

Screenshots

Similar Indicators / Formulas

Kavach Of Karna v2
Submitted by hbkwarez over 5 years ago
Advanced Elliott Waves
Submitted by MarcosEn almost 8 years ago
3_6Day GuaiLiLv
Submitted by motorfly almost 8 years ago
Williams Alligator System
Submitted by durgesh1712 almost 8 years ago
*Level Breakout system*
Submitted by Tinych almost 8 years ago
Horizontal Live Priceline Tool
Submitted by northstar almost 8 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("GaNN Square of Nine");

BarsToday = 1 + BarsSince( Day() != Ref(Day(), -1));

StartBar =Open;

TodayVolume = Sum(V,BarsToday);

RefOpen = ValueWhen(TimeNum() == 092000, Open,1);

BaseNum = (int(sqrt(RefOpen))-1);
sBelow = BaseNum + BaseNum;
sBelowI = 1;


//Calculate levels for GANN Square of Nine

for( i = 1; i < 50; i++ ) 
{ 
VarSet( "GANN"+i, (BaseNum * BaseNum) ); 
BaseNum = BaseNum + 0.125;
sBelowI = IIf( VarGet("GANN"+i)< RefOpen, i, sBelowI);
bAboveI = sBelowI + 1;
sBelow = round(VarGet("GANN"+sBelowI));
bAbove = round(VarGet("GANN"+bAboveI));
}

// Resistance Levels (or Targets for Buy trade)
BTgt1 = round(0.9995 * VarGet("Gann"+(bAboveI+1)));
BTgt2 = round(0.9995 * VarGet("Gann"+(bAboveI+2)));
BTgt3 = round(0.9995 * VarGet("Gann"+(bAboveI+3)));
BTgt4 = round(0.9995 * VarGet("Gann"+(baboveI+4)));
BTgt5 = round(0.9995 * VarGet("Gann"+(bAboveI+5)));
BTgt6 = round(0.9995 * VarGet("Gann"+(baboveI+6)));
// Support Levels (or Targets for Short trade)
STgt1 = round(1.0005 * VarGet("Gann"+(sBelowI-1)));
STgt2 = round(1.0005 * VarGet("Gann"+(sBelowI-2)));
STgt3 = round(1.0005 * VarGet("Gann"+(sBelowI-3)));
STgt4 = round(1.0005 * VarGet("Gann"+(sbelowI-4)));
STgt5 = round(1.0005 * VarGet("Gann"+(sBelowI-5)));
STgt6 = round(1.0005 * VarGet("Gann"+(sBelowI-6)));

Sstop= round(babove-((babove-sbelow)/3)) ;
Bstop= round(sbelow+((babove-sbelow)/3)) ;

BuySignal = TimeNum()>092000 AND  Cross(C,babove);
ShortSignal = TimeNum()>092000 AND  Cross(Sbelow,C); 

BuySignal = ExRem(BuySignal,ShortSignal);
ShortSignal = ExRem(ShortSignal,BuySignal);

ShortProfitStop= (STgt1 AND L<=Stgt1 AND C>Stgt1) OR (STgt2 AND L<=Stgt2 AND C>Stgt2) OR (STgt3 AND L<=Stgt3 AND C>Stgt3) OR (STgt4 AND L<=Stgt4 AND C>Stgt4) OR (STgt5 AND L<=Stgt5 AND C>Stgt5) OR (STgt6 AND L<=Stgt6 AND C>Stgt6);

BuyProfitStop= (Btgt1 AND H>=btgt1 AND C<Btgt1) OR (Btgt2 AND H>=Btgt2 AND C<btgt2) OR (Btgt3 AND H>=Btgt3 AND C<btgt3) OR (Btgt4 AND H>=Btgt4 AND C<btgt4) OR (Btgt5 AND H>=Btgt5 AND C<btgt5) OR (Btgt6 AND H>=Btgt6 AND C<btgt6);


Buy = BuySignal;
Sell = C<Bstop ;
Short = ShortSignal;
Cover = C>SStop ;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);



Sstop= round(babove) ;
Bstop= round(sbelow) ;
_SECTION_BEGIN("Background text");
SetChartBkColor(colorBlack);
strWeekday = StrMid("---SUNDAY---MONDAY--TUESDAYWEDNESDAY-THURSDAY--FRIDAY--SATURDAY", SelectedValue(DayOfWeek())*9,9);
GraphXSpace=Param("GraphXSpace",0,-55,200,1);
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Candara", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15+240);
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor(ColorRGB (217,217,213));
GfxTextOut( "L.T.P. : "+ C +"", Status("pxwidth")/C14, Status("pxheight")/C15*2+240 );
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( ""+DD+ " ( "+xx+"%)", Status("pxwidth")/C14, Status("pxheight")/C15*2.5+250);
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (0,265,0));
GfxTextOut( "Buy Above :"+sstop+"", Status("pxwidth")/C14-450, Status("pxheight")/C15*6);
GfxSetTextColor( ColorRGB (265,0,0));
GfxTextOut( "Buy S/L :"+Bstop+"", Status("pxwidth")/C14-350, Status("pxheight")/C15*7);
GfxSetTextColor( ColorRGB (265,0,0));
GfxTextOut( "Sell Below :"+bstop+"", Status("pxwidth")/C14+450, Status("pxheight")/C15*6);
GfxSetTextColor( ColorRGB (0,265,0));
GfxTextOut( "Sell S/L :"+sstop+"", Status("pxwidth")/C14+350, Status("pxheight")/C15*5);
GfxSetTextColor( ColorRGB (0,265,0));
GfxTextOut( "Buy TGT 1 : "+BTgt1+"", Status("pxwidth")/C14-350, Status("pxheight")/C15*5);
GfxTextOut( "Buy TGT 6 : "+BTgt6+"", Status("pxwidth")/C14+225, Status("pxheight")/C15*4);
GfxTextOut( "Buy TGT 2 : "+BTgt2+"", Status("pxwidth")/C14-225, Status("pxheight")/C15*4);
GfxTextOut( "Buy TGT 5 : "+BTgt5+"", Status("pxwidth")/C14+125, Status("pxheight")/C15*3);
GfxTextOut( "Buy TGT 3 : "+BTgt3+"", Status("pxwidth")/C14-125, Status("pxheight")/C15*3);
GfxTextOut( "Buy TGT 4 : "+BTgt4+"", Status("pxwidth")/C14, Status("pxheight")/C15*2);
GfxSetTextColor( ColorRGB (265,0,0));
GfxTextOut( "Sell TGT 1 : "+STgt1+"", Status("pxwidth")/C14+350, Status("pxheight")/C15*7);
GfxTextOut( "Sell TGT 6 : "+STgt6+"", Status("pxwidth")/C14-225, Status("pxheight")/C15*8);
GfxTextOut( "Sell TGT 2 : "+STgt2+"", Status("pxwidth")/C14+225, Status("pxheight")/C15*8);
GfxTextOut( "Sell TGT 5 : "+STgt5+"", Status("pxwidth")/C14-125, Status("pxheight")/C15*9);
GfxTextOut( "Sell TGT 3 : "+STgt3+"", Status("pxwidth")/C14+125, Status("pxheight")/C15*9);
GfxTextOut( "Sell TGT 4 : "+STgt4+"", Status("pxwidth")/C14, Status("pxheight")/C15*10);

_SECTION_END();

_SECTION_BEGIN("Title");

DODay = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily); 
DLoDay = TimeFrameGetPrice("L", inDaily); 
Title = EncodeColor(colorWhite)+EncodeColor(colorWhite)+ "Sai Stock Broking - 09825340778"+ 
"\n" + Interval(2) + ", " + Date() + "   -  "+strWeekday + "  - " +
EncodeColor(colorWhite)   +  "\nOpen " + EncodeColor(colorWhite) + O + 

 ",   High :  "   + H + 
 ",   Low  :  " + L + 
 ",   Close  :  "  + C +
"\n"+EncodeColor(colorWhite)+ " Day-Open : " +DODay + "  Day-High : " +DHiDay + "  Day-Low : " + DLoDay 
;

43 comments

1. shizma14

result:buy, sell empty…..

2. elango6557

result:buy, sell empty….. Result is emptyyyyyyyyyyyyyyyyy

3. Divyesh

@shizma14,elango6557,
use TF 5 min and stock & future only no commodity……….!

4. krishna9260

result:buy, sell empty….. Result is emptyyyyyyyyyyyyyyyyy
not working ammi5.5
Divyesh test you AFl

5. cjsheth41

Hello, result buy and sell both empty

6. Divyesh

@krishna9260, cjsheth41 and all,
i dont know why this happns to you all…!
many friends had called me regarding this but in my Ami it is working very well….!
otherwise how can i post photo….?
if anyone want to see, can call me and take Team Viewer and see it is working with my Ami……..!

7. prakash2009

I cannot control my laugh.

stupid nifty range is only 20 pts per day.

How it will reach your 9 targets.

8. Divyesh

even i could not stop & control my laugh……..!
on the person who says “stupid nifty range is only 20 pts per day……..!”
how many friends agree with this………?

dear prakash2009, this is Gann Squar of Nine….!
tgts are new Gann level according to 5Min chart….!

9. vjaisridharan

Sir,
Why don’t you add commodity also and post?

10. ma9019

Hello Divyesh,
Its really fantastic work. Whatever the comments has posted its nothing when compared to other indicators. Really nice work. The only concern now is all are round figures and most of the cases it reaches its tgt. due to round fig. unable to catch the tgt and entry. Please work on this.

Viswanath and Anand sirs please share your opinions.
11. Divyesh

@ma9019
thank you very much dear.
i dint get what you want to say regarding Tgt and entry ?

12. ma9019

Recommendation:

Buy at / above: 5909.76 Targets: 5926.03 – 5945.29 – 5964.57 – 5983.89

Stoploss : 5890.56

Sell at / below: 5890.56 Targets: 5874.32 – 5855.17 – 5836.05 – 5816.96

Stoploss : 5909.76

The above recommendations are in exact figures like 5909.76, 5926.03, 5945.29. But in chart it comes round figures like 5910, 5926, 5945.

Many Cases it doesn’t make any impact. But some trades are missing with 0.2 or 0.1 points. So pls make it possible.Once again its a great work.

13. Divyesh

@ma9019,
ok got it…..
NOW COPY PASTE THIS TO ORIGINAL……..!
u will get what you want…….

// Resistance Levels (or Targets for Buy trade)
BTgt1 = 0.9995 * VarGet("Gann"+(bAboveI+1));
BTgt2 = 0.9995 * VarGet("Gann"+(bAboveI+2));
BTgt3 = 0.9995 * VarGet("Gann"+(bAboveI+3));
BTgt4 = 0.9995 * VarGet("Gann"+(baboveI+4));
BTgt5 = 0.9995 * VarGet("Gann"+(bAboveI+5));
BTgt6 = 0.9995 * VarGet("Gann"+(baboveI+6));
// Support Levels (or Targets for Short trade)
STgt1 = 1.0005 * VarGet("Gann"+(sBelowI-1));
STgt2 = 1.0005 * VarGet("Gann"+(sBelowI-2));
STgt3 = 1.0005 * VarGet("Gann"+(sBelowI-3));
STgt4 = 1.0005 * VarGet("Gann"+(sbelowI-4));
STgt5 = 1.0005 * VarGet("Gann"+(sBelowI-5));
STgt6 = 1.0005 * VarGet("Gann"+(sBelowI-6));

Sstop= babove-((babove-sbelow)/3) ;
Bstop= sbelow+((babove-sbelow)/3) ;
14. anandnst

Thanx you divyesh for solving my problem to plot Gann afl in amibroker 5.6.
Well will test level in real time from monday.

Happy trading

15. Divyesh

@ anandnst,

you are allways wellcome dear…….!

16. Divyesh

@vjaishridharan,
please change below given code for commodity….!

RefOpen = ValueWhen(TimeNum() == 092959, Open,1);
BuySignal = TimeNum()>092959 AND Cross(C,babove);
ShortSignal = TimeNum()>092959 AND Cross(Sbelow,C); 

as time are differents…….!

17. ford7k

hi friend

At the end of the day,most traders are looking for lines-as lines form visible ready reference. here the lines are missing.They need to be plotted.

hope it can be attended.
regards

18. ma9019

Today i have traded 8 trades out of that 7 0f them achieved tgts. One SL hit in nifty. 3 out of 7 hit 3 tgts. Overall profit is Rs.8820 after all deductions. Thank you sir.Request you to share ur mail id.

19. ma9019

Also pls make positional chart which will be very useful

20. Divyesh

@ma9019,

dear here we cant post our Email….!

if Admin permits i have no issue…….!

u can contect me if u see the AFL clearlly….!!!

Waiting……!

21. administrator

Dibyesh you can if you want. I’ll delete it after 48 hours.

22. vjaisridharan

Sir,
Thank you very much, i will check in the market hours and update the result.

23. vjaisridharan

Sir,
After changing formula also it is not working for commodities, so why don’t you check and post total formula.

24. Divyesh

@vajaishridharan,

16. Divyesh

@vjaishridharan,
please change below given code for commodity….!

RefOpen = ValueWhen(TimeNum() == 092959, Open,1);
BuySignal = TimeNum()>092959 AND Cross(C,babove);
ShortSignal = TimeNum()>092959 AND Cross(Sbelow,C);

as time are differents…….!

i said you to change this thing in AFl because GANN is based n time factor and comodity starts at 10….so plz change the thing in above given AFL…..!

25. Divyesh

Thnx Admin…..!

My Email is removed

anyone want to note plz Admin will remove after 48 hours……!

my contect Number is available in AFL posted……!

26. Divyesh

@vjaishridharan,
please change below given code for commodity….!

RefOpen = ValueWhen(TimeNum() == 100500, Open,1);
BuySignal = TimeNum()>100500 AND Cross(C,babove);
ShortSignal = TimeNum()>100500 AND Cross(Sbelow,C);

this will defenatelly work in Commodity…..!

i have chacked……!

27. raj_usb

Hi,

I was also facing Empty issue then I changed time format to 091959 and magic happened. Now it is working very fine. New lines should in below format

RefOpen = ValueWhen(TimeNum() == 091959, Open,1);

BuySignal = TimeNum()>091959 AND Cross(C,babove);
ShortSignal = TimeNum()>091959 AND Cross(Sbelow,C);
28. Divyesh

@raj_usb,

dear friend that time formate indicates 9:19:59 A.M.

so there must be setting problem in Amibroker….!

TIME of first Tick inside bar must be chacked in your computer…!

29. Divyesh

@Dear Ma9019
i have solved your query……!

Plz copy past below given code at the place of 9 Line

RefOpen = ValueWhen(TimeNum() == Param("Time Zone",092000,092000,100500,8500), Open,1);

you will get changed from Stock market to comodity market……!

enjoy……….!!

Happy earning……

30. ma9019

But its not working showing error 31
syntax error,unexpected $end, expecting’)’or",

31. Divyesh

Even Change 46 and 47 Line with below given code…..

BuySignal = TimeNum()>Param("Buy Signal @",092000,092000,100500,8500) AND  Cross(C,babove);
ShortSignal = TimeNum()>Param("Sell Signal @ ",092000,092000,100500,8500) AND  Cross(Sbelow,C); 
32. Divyesh

@ admin,

Sir, what are the Rewards Points in view My Profile….?

!!!

33. ma9019

Thank you so much sir now its working really well. Thanks a lots sir.

34. samkum

@Divyesh

Sir, I had tried all the Possibilities you mentioned here.. But still the result is empty…

the time frame (092959) is only working for equites….
but for commodities, i tried all the time frames u posted here…
but still am getting the empty result..

Plz, guide me the settings for Amiborker, System time format, etc..

Thanks in advance, waiting for the reply..

35. ma9019

Hi Samkum,

Replace the following lines in the existing afl.

line 11.
RefOpen = ValueWhen(TimeNum() == 100500, Open,1);

Line 48and 49
BuySignal = TimeNum()>100500 AND Cross(C,babove);
ShortSignal = TimeNum()100500 AND Cross(Sbelow,C);

36. Divyesh

@ma9019,
thanx dear….!

although i m posting with all changes what everyone needs…..!

37. samkum

@ ma9019 & @ Divyesh

Dears…

It had already changed and tried these lines…….

RefOpen = ValueWhen(TimeNum() == Param("Time Zone",092000,092000,100500,8500), Open,1);
RefOpen = ValueWhen(TimeNum() == 092000, Open,1);
RefOpen = ValueWhen(TimeNum() == 092959, Open,1);
RefOpen = ValueWhen(TimeNum() == 091959, Open,1);
RefOpen = ValueWhen(TimeNum() == 100500, Open,1);

and………..

BuySignal = TimeNum()>Param("Buy Signal @",092000,092000,100500,8500) AND Cross(C,babove);
ShortSignal = TimeNum()>Param("Sell Signal @",092000,092000,100500,8500) AND Cross(Sbelow,C);

BuySignal = TimeNum()>091959 AND Cross(C,babove);
ShortSignal = TimeNum()>091959 AND Cross(Sbelow,C);

BuySignal = TimeNum()>100500 AND Cross(C,babove);
ShortSignal = TimeNum()>100500 AND Cross(Sbelow,C);

BuySignal = TimeNum()>092959 AND Cross(C,babove);
ShortSignal = TimeNum()>092959 AND Cross(Sbelow,C);

BuySignal = TimeNum()>092000 AND  Cross(C,babove);
ShortSignal = TimeNum()>092000 AND  Cross(Sbelow,C); 

still no positive results.. :(
I don’t know where i am wrong…
weather system time format, or database setting…

Am using amibroker 5.60….

Help needed..

Thanks & Regards..

38. ma9019

Dear Samkum

RefOpen = ValueWhen(TimeNum() == Param(“Time Zone”,092000,092000,100500,8500), Open,1);
RefOpen = ValueWhen(TimeNum() == 092000, Open,1);- remove this line
RefOpen = ValueWhen(TimeNum() == 092959, Open,1);- remove this line
RefOpen = ValueWhen(TimeNum() == 091959, Open,1);- remove this line
RefOpen = ValueWhen(TimeNum() == 100500, Open,1);- remove this line

and………..

BuySignal = TimeNum()>Param(“Buy Signal @”,092000,092000,100500,8500) AND Cross(C,babove);
ShortSignal = TimeNum()>Param(“Sell Signal @”,092000,092000,100500,8500) AND Cross(Sbelow,C);

BuySignal = TimeNum()>091959 AND Cross(C,babove);- remove this line
ShortSignal = TimeNum()>091959 AND Cross(Sbelow,C);- remove this line

BuySignal = TimeNum()>100500 AND Cross(C,babove);- remove this line
ShortSignal = TimeNum()>100500 AND Cross(Sbelow,C);- remove this line

BuySignal = TimeNum()>092959 AND Cross(C,babove);- remove this line
ShortSignal = TimeNum()>092959 AND Cross(Sbelow,C);- remove this line

BuySignal = TimeNum()>092000 AND Cross(C,babove);- remove this line
ShortSignal = TimeNum()>092000 AND Cross(Sbelow,C); – remove this line

If you do this it works.

39. samkum

@ ma9019

Dear Friend,

I tried all those lines separately, Sorry to not mention it before..
still empty result….
:(

40. samkum

Now it works………. please change below given code

RefOpen = ValueWhen(TimeNum() > 092959, Open,1);

BuySignal = TimeNum()>092959 AND Cross(C,babove);
ShortSignal = TimeNum()>092959 AND Cross(Sbelow,C);
41. Ram23

After all corrections done still I am getting empty values.

42. StockJock

Could you code this to work with US stock prices?

43. Gopakumar

Pld do as following it will work perfectly…

Delete line no.13 and copy paste this command

RefOpen = ValueWhen(TimeNum() > 092959, Open,1);

Delete line no.48 & 49 and copy paste these command

BuySignal = TimeNum()>092959 AND Cross(C,babove);
ShortSignal = TimeNum()>092959 AND Cross(Sbelow,C);

Leave Comment

Please login here to leave a comment.

Back