Advertisement
saisri

gann9

Jul 27th, 2013
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.78 KB | None | 0 0
  1. _SECTION_BEGIN("Price");
  2. SetChartOptions(0,chartShowArrows|chartShowDates);
  3. _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
  4.  
  5. SD = StochD(8, 3, 3);
  6. MH = MACD(8, 21) - Signal(8, 21, 5);
  7.  
  8. trendup = IIf(MH > 0 OR (MH > 0 AND MH > Ref(MH, -1)) AND RSI(3) >50 AND SD < 80 AND SD > Ref(SD, -1) AND ValueWhen(C,O<C), colorBlue, colorWhite);
  9. trendcolor = IIf(MH < 0 OR (MH < 0 AND MH < Ref(MH, -1)) AND RSI(3) <50 AND SD > 20 AND SD < Ref(SD, -1) AND ValueWhen(C,O>C), colorRed, trendup);
  10. Plot( C, "Close", trendcolor, styleCandle | styleThick );
  11.  
  12. _SECTION_END();
  13.  
  14. BarsToday = 1 + BarsSince( Day() != Ref(Day(), -1));
  15.  
  16. StartBar =Open;
  17.  
  18.  
  19. RefOpen = ValueWhen(TimeNum() > 092959, Open,1);
  20. BaseNum = (int(sqrt(RefOpen))-1);
  21. sBelow = BaseNum + BaseNum;
  22. sBelowI = 1;
  23.  
  24.  
  25. //Calculate levels for GANN Square of Nine
  26.  
  27. for( i = 1; i < 50; i++ )
  28. {
  29. VarSet( "GANN"+i, (BaseNum * BaseNum) );
  30. BaseNum = BaseNum + 0.125;
  31. sBelowI = IIf( VarGet("GANN"+i)< RefOpen, i, sBelowI);
  32. bAboveI = sBelowI + 1;
  33. sBelow = round(VarGet("GANN"+sBelowI));
  34. bAbove = round(VarGet("GANN"+bAboveI));
  35. }
  36.  
  37. // Resistance Levels (or Targets for Buy trade)
  38. BTgt1 = 0.9995 * VarGet("Gann"+(bAboveI+1));
  39. BTgt2 = 0.9995 * VarGet("Gann"+(bAboveI+2));
  40. BTgt3 = 0.9995 * VarGet("Gann"+(bAboveI+3));
  41. BTgt4 = 0.9995 * VarGet("Gann"+(baboveI+4));
  42. BTgt5 = 0.9995 * VarGet("Gann"+(bAboveI+5));
  43. BTgt6 = 0.9995 * VarGet("Gann"+(baboveI+6));
  44. // Support Levels (or Targets for Short trade)
  45. STgt1 = 1.0005 * VarGet("Gann"+(sBelowI-1));
  46. STgt2 = 1.0005 * VarGet("Gann"+(sBelowI-2));
  47. STgt3 = 1.0005 * VarGet("Gann"+(sBelowI-3));
  48. STgt4 = 1.0005 * VarGet("Gann"+(sbelowI-4));
  49. STgt5 = 1.0005 * VarGet("Gann"+(sBelowI-5));
  50. STgt6 = 1.0005 * VarGet("Gann"+(sBelowI-6));
  51.  
  52. Sstop= babove-((babove-sbelow)/3) ;
  53. Bstop= sbelow+((babove-sbelow)/3) ;
  54.  
  55. BuySignal = TimeNum()>092959 AND Cross(C,babove);ShortSignal = TimeNum()>092000 AND Cross(Sbelow,C);
  56.  
  57. BuySignal = ExRem(BuySignal,ShortSignal);
  58. ShortSignal = TimeNum()>092959 AND Cross(Sbelow,C);
  59. 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);
  60.  
  61. 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);
  62. Buy = BuySignal;
  63. Sell = C<Bstop ;
  64. Short = ShortSignal;
  65. Cover = C>SStop ;
  66.  
  67. Buy = ExRem(Buy,Sell);
  68. Sell = ExRem(Sell,Buy);
  69. Short = ExRem(Short,Cover);
  70. Cover = ExRem(Cover,Short);
  71.  
  72.  
  73.  
  74. Sstop= round(babove) ;
  75. Bstop= round(sbelow) ;
  76. _SECTION_BEGIN("Background text");
  77. SetChartBkColor(colorBlack);
  78. strWeekday = StrMid("---SUNDAY---MONDAY--TUESDAYWEDNESDAY-THURSDAY--FRIDAY--SATURDAY", SelectedValue(DayOfWeek())*9,9);
  79. GraphXSpace=Param("GraphXSpace",0,-55,200,1);
  80. C13=Param("fonts",20,10,30,1 );
  81. C14=Param("left-right",2.1,1.0,5.0,0.1 );
  82. C15=Param("up-down",12,1,20,1 );
  83. Miny = Status("axisminy");
  84. Maxy = Status("axismaxy");
  85. lvb = Status("lastvisiblebar");
  86. fvb = Status("firstvisiblebar");
  87. pxwidth = Status("pxwidth");
  88. pxheight = Status("pxheight");
  89. YC=TimeFrameGetPrice("C",inDaily,-1);
  90. DD=Prec(C-YC,2);
  91. xx=Prec((DD/YC)*100,2);
  92. GfxSetBkMode(transparent=1);
  93. GfxSetOverlayMode(1);
  94. GfxSelectFont("Candara", Status("pxheight")/C13 );
  95. GfxSetTextAlign( 6 );
  96. GfxSetTextColor( ColorRGB (217,217,213));
  97. GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15+200);
  98. GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
  99. GfxSetTextColor(ColorRGB (217,217,213));
  100. GfxTextOut( "L.T.P. : "+ C +"", Status("pxwidth")/C14, Status("pxheight")/C15*2+200 );
  101. GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
  102. GfxSetTextColor( ColorRGB (103,103,103));
  103. GfxTextOut( ""+DD+ " ( "+xx+"%)", Status("pxwidth")/C14, Status("pxheight")/C15*2.5+200);
  104. GfxTextOut( "", Status("pxwidth")/C14, Status("pxheight")/C15*2.5+220);
  105. GfxTextOut( "", Status("pxwidth")/C14, Status("pxheight")/C15*2.5+240);
  106. GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
  107. GfxSetTextColor( ColorRGB (0,265,0));
  108. GfxTextOut( "Buy Above :"+sstop+"", Status("pxwidth")/C14-450, Status("pxheight")/C15*6);
  109. GfxSetTextColor( ColorRGB (255,74,74));
  110. GfxTextOut( "Buy S/L :"+Bstop+"", Status("pxwidth")/C14-350, Status("pxheight")/C15*7);
  111. GfxSetTextColor( ColorRGB (265,0,0));
  112. GfxTextOut( "Sell Below :"+bstop+"", Status("pxwidth")/C14+450, Status("pxheight")/C15*6);
  113. GfxSetTextColor( ColorRGB (100,255,100));
  114. GfxTextOut( "Sell S/L :"+sstop+"", Status("pxwidth")/C14+350, Status("pxheight")/C15*5);
  115. GfxSetTextColor( ColorRGB (0,265,0));
  116. GfxTextOut( "Buy TGT 1 : "+BTgt1+"", Status("pxwidth")/C14-350, Status("pxheight")/C15*5);
  117. GfxTextOut( "Buy TGT 6 : "+BTgt6+"", Status("pxwidth")/C14+225, Status("pxheight")/C15*4);
  118. GfxTextOut( "Buy TGT 2 : "+BTgt2+"", Status("pxwidth")/C14-225, Status("pxheight")/C15*4);
  119. GfxTextOut( "Buy TGT 5 : "+BTgt5+"", Status("pxwidth")/C14+125, Status("pxheight")/C15*3);
  120. GfxTextOut( "Buy TGT 3 : "+BTgt3+"", Status("pxwidth")/C14-125, Status("pxheight")/C15*3);
  121. GfxTextOut( "Buy TGT 4 : "+BTgt4+"", Status("pxwidth")/C14, Status("pxheight")/C15*2);
  122. GfxSetTextColor( ColorRGB (265,0,0));
  123. GfxTextOut( "Sell TGT 1 : "+STgt1+"", Status("pxwidth")/C14+350, Status("pxheight")/C15*7);
  124. GfxTextOut( "Sell TGT 6 : "+STgt6+"", Status("pxwidth")/C14-225, Status("pxheight")/C15*8);
  125. GfxTextOut( "Sell TGT 2 : "+STgt2+"", Status("pxwidth")/C14+225, Status("pxheight")/C15*8);
  126. GfxTextOut( "Sell TGT 5 : "+STgt5+"", Status("pxwidth")/C14-125, Status("pxheight")/C15*9);
  127. GfxTextOut( "Sell TGT 3 : "+STgt3+"", Status("pxwidth")/C14+125, Status("pxheight")/C15*9);
  128. GfxTextOut( "Sell TGT 4 : "+STgt4+"", Status("pxwidth")/C14, Status("pxheight")/C15*10);
  129.  
  130. _SECTION_END();
  131.  
  132. _SECTION_BEGIN("Title");
  133.  
  134. DODay = TimeFrameGetPrice("O", inDaily);
  135. DHiDay = TimeFrameGetPrice("H", inDaily);
  136. DLoDay = TimeFrameGetPrice("L", inDaily);
  137. Title = EncodeColor(colorWhite)+EncodeColor(colorCustom8)+ " "+EncodeColor(colorCustom10)+ Interval(2) + ", " + EncodeColor(colorCustom11)+Date() + EncodeColor(colorCustom14)+" - "+strWeekday + " - " +
  138. EncodeColor(colorBlue) + "Open " + EncodeColor(colorWhite) + O +
  139.  
  140. EncodeColor(colorRed)+ " High : " +EncodeColor(colorWhite) + H +
  141. EncodeColor(colorBrightGreen)+ " Low : " +EncodeColor(colorWhite) + L +
  142. EncodeColor(colorCustom16) +" Close : " + EncodeColor(colorWhite) +C +
  143. EncodeColor(colorBlue)+ " Day-Open : " +DODay + EncodeColor(colorBrightGreen)+" Day-High : " +DHiDay +EncodeColor(colorRed)+ " Day-Low : " + DLoDay
  144. ;
  145.  
  146. _SECTION_BEGIN("Time Left");
  147. function GetSecondNum()
  148. {
  149. Time = Now( 4 );
  150. Seconds = int( Time % 100 );
  151. Minutes = int( Time / 100 % 100 );
  152. Hours = int( Time / 10000 % 100 );
  153. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  154. return SecondNum;
  155. }
  156. RequestTimedRefresh( 1 );
  157. TimeFrame = Interval();
  158. SecNumber = GetSecondNum();
  159. Newperiod = SecNumber % TimeFrame == 0;
  160. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  161. SecsToGo = TimeFrame - SecsLeft;
  162.  
  163. x=Param("xposn",0,0,1000,1);
  164. y=Param("yposn",900,0,1000,1);
  165.  
  166. GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
  167. GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
  168. if ( NewPeriod )
  169. {
  170. GfxSelectSolidBrush( colorYellow );
  171. GfxSelectPen( colorYellow, 2 );
  172. Say( "New time CANDLE start" );
  173. }
  174.  
  175. cx = Param( "cxposn", 516, 0, 1250, 1 );
  176. cy = Param( "cyposn", 15, 0, 500, 1 );
  177. GfxSelectFont( "bold", 10, 98, False );
  178. //gfxcup = SelectedValue(C > Ref(C,-1));
  179. //gfxpcolor = IIf(gfxcup,colorBrightGreen,colorRed);
  180. GfxSetTextColor(colorBrightGreen);
  181. //GfxSetTextColor( colorWhite );
  182. GfxTextOut( "Time left for candle close " + SecsToGo + " ", cx, cy );
  183. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement