Advertisement
saisri

xtl fibo rj with time

Aug 17th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.86 KB | None | 0 0
  1. _SECTION_BEGIN("XTL");
  2. periods = Param( "Periods", 20, 2, 200, 1 );
  3. //Plot( CCI( periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
  4.  
  5. CCI20=CCI(20);
  6.  
  7. _SECTION_END();
  8.  
  9. _SECTION_BEGIN("PriceBars");
  10. SetChartOptions(0,chartShowArrows|chartShowDates);
  11. _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
  12.  
  13.  
  14. Colorbar=IIf(CCI20>35,colorBrightGreen,IIf(CCI20<-35,colorRed,colorWhite));
  15.  
  16. Plot( C, "Close", Colorbar, styleNoTitle| styleThick | styleCandle );
  17. _SECTION_END();
  18.  
  19. _SECTION_BEGIN("Large Triggers");
  20. p3 = Param("TL 3 Periods", 80, 5, 100, 1);
  21. p4 = Param("TL 4 Periods", 20, 3, 100, 1);
  22. TL3 = LinearReg(C, p3);
  23. TL4 = EMA(TL3, p4);
  24. Col1 = IIf(TL3 > TL4, ParamColor("TLL Up Colour", colorBlue), ParamColor("TLL Dn Colour", colorRed));
  25. Plot(TL3, "TriggerLine 3", Col1, styleDots|styleThick|styleNoLabel);
  26. Plot(TL4, "TriggerLine 4", Col1, styleDots|styleThick|styleNoLabel);
  27. _SECTION_END();
  28.  
  29. _SECTION_BEGIN("Fibo Retrace and Extensions");
  30. fibs = ParamToggle("Plot Fibs","Off|On",1);
  31. pctH = Param ("Pivot Hi %", 0.325,0.001,2.0,0.002);
  32. HiLB = Param ("Hi LookBack",1,1,BarCount-1,1);
  33. pctL = Param ("Pivot Lo %", 0.325,0.001,2.0,0.002);
  34. LoLB = Param ("Lo LookBack",1,1,BarCount-1,1);
  35. Back = Param ("Extend Left = 2",1,1,500,1);
  36. Fwd = Param("Plot Forward", 0, 0, 500, 1);
  37. text = ParamToggle("Plot Text","Off|On",1);
  38. hts = Param ("Text Shift", -33.5,-50,50,0.10);
  39. style =ParamStyle("Line Style",styleLine,styleNoLabel);
  40. x = BarIndex();
  41. pRp = PeakBars( H, pctH, 1) == 0;
  42. yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
  43. xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));
  44. pSp = TroughBars( L, pctL, 1) == 0;
  45. ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
  46. xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
  47. Delta = yRp0 - ySp0;
  48.  
  49. function fib(ret)
  50. {
  51. retval = (Delta * ret);
  52. Fibval = IIf(ret < 1.0
  53. AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0
  54. AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0
  55. AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0
  56. AND xSp0 > xRp0, ySp0 + retval, Null))));
  57. return FibVal;
  58. }
  59.  
  60. x0 = Min(xSp0,xRp0)-Back;
  61. x1 = (BarCount -1);
  62.  
  63. r236 = fib(0.236); r236I = LastValue (r236,1);
  64. r382 = fib(0.382); r382I = LastValue (r382,1);
  65. r050 = fib(0.50); r050I = LastValue (r050,1);
  66. r618 = fib(0.618); r618I = LastValue (r618,1);
  67. r786 = fib(0.786); r786I = LastValue (r786,1);
  68. e127 = fib(1.27); e127I = LastValue (e127,1);
  69. e162 = fib(1.62); e162I = LastValue (e162,1);
  70. e200 = fib(2.00); e200I = LastValue (e200,1);
  71. e262 = fib(2.62); e262I = LastValue (e262,1);
  72. e424 = fib(4.24); e424I = LastValue (e424,1);
  73.  
  74. p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00,1);
  75. p100 = IIf(xSp0 < xRp0,ySp0,yRp0); p100I = LastValue (p100,1);
  76. color00 =IIf(xSp0 > xRp0,colorLime,colorRed);
  77. color100 =IIf(xSp0 < xRp0,colorLime,colorRed);
  78.  
  79. numbars = LastValue(Cum(Status("barvisible")));
  80. fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
  81.  
  82. if(fibs==1)
  83. {
  84. Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",32,8|styleNoRescale,Null, Null,Fwd);
  85. Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27,8|styleNoRescale,Null, Null,Fwd);
  86. Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",45,style|styleNoRescale,Null, Null,Fwd);
  87. Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",44,style|styleNoRescale,Null, Null,Fwd);
  88. Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",41,style|styleNoRescale,Null, Null,Fwd);
  89. Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",43,style|styleNoRescale,Null, Null,Fwd);
  90. Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",42,style|styleNoRescale,Null, Null,Fwd);
  91. Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",47,style|styleNoRescale,Null, Null,Fwd);
  92. Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",47,style|styleNoRescale,Null, Null,Fwd);
  93. Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",47,style|styleNoRescale,Null, Null,Fwd);
  94. Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",47,style|styleNoRescale,Null, Null,Fwd);
  95. Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",25,style|styleNoRescale,Null, Null,Fwd);
  96. }
  97.  
  98. if(text==1)
  99. {
  100. PlotText(" 0% = " + WriteVal(p00,fraction), LastValue(BarIndex())-(numbars/hts), p00I + 0.05, color00);
  101. PlotText("23% = " + WriteVal(r236,fraction), LastValue(BarIndex())-(numbars/hts), r236I + 0.05, 45);
  102. PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, 44);
  103. PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, 41);
  104. PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, 43);
  105. PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, 42);
  106. PlotText("100% = " + WriteVal(p100,fraction), LastValue(BarIndex())-(numbars/hts),p100I + 0.05, color100);
  107. PlotText("127% = " + WriteVal(e127,fraction), LastValue(BarIndex())-(numbars/hts),e127I + 0.05, 47);
  108. PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, 47);
  109. PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, 47);
  110. PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, 47);
  111. PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, 25);
  112. }
  113. _SECTION_END();
  114.  
  115. _SECTION_BEGIN("traing sl");
  116.  
  117. function vstop_func(trBull,trBear)
  118. {
  119. trailArray[ 0 ] = C[ 0 ]; // initialize
  120. for( i = 1; i < BarCount; i++ )
  121. {
  122. prev = trailArray[ i - 1 ];
  123.  
  124. if (C[ i ] > prev AND C[ i - 1 ] > prev)
  125. {
  126. trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
  127. }
  128. else if (C[ i ] < prev AND C[ i - 1 ] < prev)
  129. {
  130. trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
  131. }
  132. else if (C[ i ] > prev)
  133. {
  134. trailArray[ i ] = C[ i ] - trBull[ i ];
  135. }
  136. else
  137. {
  138. trailArray[ i ] = C[ i ] + trBear[ i ];
  139. }
  140. }
  141. return trailArray;
  142. }
  143.  
  144. per = Param("per",20, 1, 150, 1);
  145. multBull = Param("multBull",2, 1, 4, 0.05);
  146. multBear = Param("multBear",2, 1, 4, 0.05);
  147.  
  148. trBull = multBull * ATR(per);
  149. trBear = multBear * ATR(per);
  150.  
  151. trailArray = vstop_func(trBull,trBear);
  152. s0=trailArray;
  153.  
  154. s1= s0 > C ;
  155. s2= s0 <C ;
  156. ccresult1 = WriteIf( s1,"cu", "");
  157. ccresult2 = WriteIf( s2,"cd", "");
  158.  
  159. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorRed);
  160. GfxSetTextColor( ParamColor("Color",colorRed) );
  161. Hor=Param("Horizontal Position",40,10,1200,1);
  162. Ver=Param("Vertical Position",90,100,50,50);
  163.  
  164. if ( ccresult1 =="cu")
  165.  
  166.  
  167. {
  168. GfxTextOut(""+s0,Hor , Ver );
  169. }
  170. else
  171.  
  172. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorGreen );
  173. GfxSetTextColor( ParamColor("Color",colorGreen) );
  174. Hor=Param("Horizontal Position",75,10,1200,1);
  175. Ver=Param("Vertical Position",185,100,50,50);
  176.  
  177. if ( ccresult2 =="")
  178.  
  179. {
  180. GfxTextOut(""+s0,Hor , Ver );
  181. }
  182. _SECTION_END();
  183.  
  184. _SECTION_BEGIN("traing s2");
  185.  
  186. s0=trailArray;
  187.  
  188. s1= s0 > C ;
  189. s2= s0 <C ;
  190. ccresult1 = WriteIf( s1,"cu", "");
  191. ccresult2 = WriteIf( s2,"cd", "");
  192.  
  193. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorBrightGreen );
  194. GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
  195. Hor=Param("Horizontal Position",40,10,1200,1);
  196. Ver=Param("Vertical Position",60,100,50,50);
  197.  
  198. if ( ccresult2 =="cd")
  199.  
  200.  
  201. {
  202. GfxTextOut(""+s0,Hor , Ver );
  203. }
  204. else
  205.  
  206. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
  207. GfxSetTextColor( ParamColor("Color",colorWhite) );
  208. Hor=Param("Horizontal Position",75,10,1200,1);
  209. Ver=Param("Vertical Position",185,100,50,50);
  210.  
  211. if ( ccresult1 =="")
  212.  
  213. {
  214. GfxTextOut(""+s0,Hor , Ver );
  215. }
  216.  
  217. _SECTION_END();
  218.  
  219.  
  220.  
  221. _SECTION_END();
  222.  
  223. _SECTION_BEGIN("buycircle");
  224. GfxSelectFont( "Arial", 1, 100 );
  225. GfxSetBkMode( 1 );
  226. GfxSetTextColor( colorBlack );
  227. GfxSelectPen( colorBlack, 1 );
  228. if ( ccresult2 =="cd")
  229. {
  230. GfxSelectSolidBrush( ColorRGB(0,255,0) );
  231. }
  232. else
  233. {
  234. GfxSelectSolidBrush( ColorRGB(0,0,94) );
  235. }
  236. GfxCircle( 20,70,7 );
  237.  
  238. _SECTION_END();
  239. _SECTION_BEGIN("sellcircle");
  240. GfxSelectFont( "Arial", 10, 100 );
  241. GfxSetBkMode( 1 );
  242. GfxSetTextColor( colorBlue );
  243. GfxSelectPen( colorBlue, 1 );
  244. if ( ccresult1 =="cu")
  245. {
  246. GfxSelectSolidBrush( ColorRGB(255,0,0) );
  247. }
  248. else
  249. {
  250. GfxSelectSolidBrush( ColorRGB(0,0,94) );
  251. }
  252.  
  253. GfxCircle( 20,100,7 );
  254. _SECTION_END();
  255.  
  256. _SECTION_BEGIN("system Ticker");
  257. function GetSecondNum()
  258. {
  259. Time = Now( 4 );
  260. Seconds = int( Time % 100 );
  261. Minutes = int( Time / 100 % 100 );
  262. Hours = int( Time / 10000 % 100 );
  263. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  264. return SecondNum;
  265. }
  266. RequestTimedRefresh( 1 );
  267. //----------------------------------------------------------------------------
  268. //----------------------------------------------------------------------------
  269. TimeFrame = Interval();
  270. SecNumber = GetSecondNum();
  271. Newperiod = SecNumber % TimeFrame == 0;
  272. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  273. SecsToGo = TimeFrame - SecsLeft;
  274.  
  275. x=Param(" xposn",10,100,1000,1000);
  276. y=Param(" yposn",15,40,1000,1);
  277.  
  278. GfxSelectSolidBrush( colorPink );
  279. GfxSelectPen( colorBlack, 2 );
  280. if ( NewPeriod )
  281. {
  282. GfxSelectSolidBrush( colorBlack );
  283. GfxSelectPen( colorBlack, 2 );
  284. Say( "New candle" );
  285. }
  286. GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
  287. GfxSetBkMode(1);
  288. GfxSelectFont( "Arial", 9, 700, False );
  289. GfxSetTextColor( colorBlack );
  290. GfxTextOut( "" +SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
  291. _SECTION_END();
  292.  
  293. _SECTION_BEGIN("Magnified Market Price");
  294. FS=Param("Font Size",30,30,100,1);
  295. GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
  296. GfxSetBkMode( colorGreen );
  297. GfxSetTextColor( ParamColor("Color",colorGreen) );
  298. Hor=Param("Horizontal Position",10,800,800,800);
  299. Ver=Param("Vertical Position",120,27,27,27);
  300. GfxTextOut(""+C,Hor , Ver );
  301. YC=TimeFrameGetPrice("C",inDaily,-1);
  302. DD=Prec(C-YC,2);
  303. xx=Prec((DD/YC)*100,2);
  304. GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
  305. GfxSetBkMode( colorGreen );
  306. GfxSetTextColor(ParamColor("Color",colorGreen) );
  307. GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
  308. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement