Advertisement
saisri

murray with pivot

Feb 6th, 2013
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.89 KB | None | 0 0
  1.  
  2. _SECTION_BEGIN("Background");
  3. tchoice=Param("Title Selection ",2,1,2,1);
  4.  
  5. Plot(C, "", IIf(O>=C, colorRed, colorGreen), ParamStyle("Price Style",styleCandle,maskPrice));
  6. //////////////////////////////////////////////////////////////////
  7.  
  8. _SECTION_BEGIN("Background text");
  9. SetChartBkColor(colorBlack);
  10. strWeekday = StrMid("---sunday---Monday--TuesdayWednesday-Thursday--Friday--Saturday", SelectedValue(DayOfWeek())*9,9);
  11. GraphXSpace=Param("GraphXSpace",0,-55,200,1);
  12. C13=Param("fonts",50,10,30,1 );
  13. C14=Param("left-right",2.1,1.0,5.0,0.1 );
  14. C15=Param("up-down",12,1,20,1 );
  15. Miny = Status("axisminy");
  16. Maxy = Status("axismaxy");
  17. lvb = Status("lastvisiblebar");
  18. fvb = Status("firstvisiblebar");
  19. pxwidth = Status("pxwidth");
  20. pxheight = Status("pxheight");
  21. GfxSetBkMode(transparent=1);
  22. GfxSetOverlayMode(1);
  23. GfxSelectFont("Candara", Status("pxheight")/C13 );
  24. GfxSetTextAlign( 6 );
  25. GfxSetTextColor( ColorRGB (217,217,213));
  26. GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
  27. GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
  28. GfxSetTextColor( ColorRGB (103,103,103));
  29. GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
  30. GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
  31. GfxSetTextColor( ColorRGB (103,103,103));
  32. GfxTextOut( "Saisri2320", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
  33. GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
  34. _SECTION_END();
  35. Title = Date()+" Normal Chart "+Interval(format=2)+" "+Name()+" Open:"+WriteVal(O,1.2)+" High: "+WriteVal(H,1.2)+" Low: "+WriteVal(L,1.2)+" Close "+
  36. WriteVal(C,1.2);
  37. /* MURREY MATH HORIZONTAL LINES Formula for Amibroker
  38. based on Excel spreadsheet by Jacek */
  39. //Plot(C,"CLose",colorWhite,styleCandle);
  40.  
  41. function splround(x)
  42. {
  43. y=int(x)+round(x%int(x)*100)/100;
  44. return y;
  45. }
  46.  
  47.  
  48. up=Study("UP",GetChartID());
  49. dm=Study("DN",GetChartID());
  50.  
  51. Color=IIf(C>O,colorGreen,colorRed);
  52. //Graph0=Close; Graph0Color=1; Graph0Style=64;
  53. //Plot(C,"close",color,styleBar);
  54. // Colored bars starts
  55.  
  56. _SECTION_BEGIN("Carl_ASC");
  57. function PercentR( periods )
  58. {
  59. return -100 * ( HHV( H, periods ) - C )/( HHV( H, periods ) - LLV( L, periods ) );
  60. }
  61.  
  62. periods= Param("periodes",14,1,100,1);
  63. PR=PercentR( periods );
  64.  
  65. SetChartOptions(0,chartShowArrows|chartShowDates);
  66.  
  67. //if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
  68. //{
  69. //ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
  70. //}
  71. _SECTION_END();
  72.  
  73. // Colored bars ends
  74.  
  75. Period=Param("MM_Period", 32, 4, 256, 1) ;
  76. TYpe=ParamList("Intraday/Rolling","Intraday|Rolling") ;
  77. PER = Period;
  78. dn=DateNum();
  79. tn=TimeNum();
  80. Lox=Hix=0;
  81. Lox = LLV(Min(H,L),PER ) ;
  82. Hix = HHV(Max(H,L),PER ) ;
  83. avp=(O+C)/2;
  84. Line0=Line1=Line2=Line3=Line4=Line5=Line6=Line7=Line8=Lineplus2=Lineminus2=0;
  85. Lo=L[0];Hi=H[0];
  86. for (i=0;i<BarCount;i++)
  87. {
  88. //if (i>0 AND i<BarCount)PlotText(WriteVal(dm[i],1.0),i,L[i]-15,colorWhite);
  89.  
  90. if (Type=="Intraday")
  91. {
  92. if(I>1)
  93. {
  94. if(dn[i]!=dn[i-1])
  95. {
  96. Lo=L[i];
  97. Hi=H[i];
  98. }
  99. }
  100. if (L[i]<Lo)Lo=L[i];
  101. if (H[i]>Hi)Hi=H[i];
  102. }
  103. else if (type=="Rolling")
  104. {
  105. Hi=Hix[i];
  106. Lo=Lox[i];
  107. }
  108.  
  109. if (up[i]>hi)Hi=up[i];
  110. if (dm[i]<lo)Lo=dm[i];
  111. //PlotText(WriteVal(Lo,1.0),colorWhite,i,H[i]+15);
  112.  
  113. Fractal = IIf(Hi<=250,100, IIf(Hi<=2500,1000, IIf(Hi<=25000,10000, IIf(Hi<=250000,100000, 0 )))) ;
  114. int_Log = int( log(Fractal/(Hi-Lo))/log(2) ) ;
  115. Oct = Fractal * ( exp(ln(1/2)* int_Log ) ) ;
  116.  
  117.  
  118. Min_1 = int( Lo / Oct ) * Oct ;
  119.  
  120. Max_1 = IIf( (Min_1 + Oct) > Hi, Min_1 + Oct, Min_1 + 2*Oct ) ;
  121.  
  122. Min_2 = IIf( (Min_1 + 1/8*(Max_1-Min_1)) <= Lo AND Hi <= (Max_1 - 1/8*(Max_1-Min_1)) ,
  123. (Min_1 + 1/4*(Max_1-Min_1)) , Min_1 ) ;
  124.  
  125. Max_2 = IIf( (Min_1 + 1/8*(Max_1-Min_1)) <= Lo AND Hi <= (Max_1 - 1/8*(Max_1-Min_1)) ,
  126. (Max_1 - 1/4*(Max_1-Min_1)) , Max_1 ) ;
  127.  
  128. /******************************/
  129.  
  130. Diff = Max_2 - Min_2 ;
  131.  
  132. H1 = IIf( (Min_2 + 3/16*Diff) <= Lo AND Hi <= (9/16*Diff + Min_2) ,
  133. Min_2 + 1/2*Diff, 0) ;
  134.  
  135. H2 = IIf( (Min_2 - 1/8*Diff) <= Lo AND Hi <= (5/8*Diff + Min_2) AND H1==0,
  136. Min_2 + 1/2*Diff, 0) ;
  137.  
  138. H3 = IIf( (Min_2 + 7/16*Diff) <= Lo AND Hi <= (Min_2 + 13/16*Diff), Min_2 + 3/4*Diff, 0 ) ;
  139.  
  140. H4 = IIf( (Min_2 + 3/8*Diff) <= Lo AND Hi <= (Min_2 + 9/8*Diff) AND H3==0,
  141. Max_2, 0 ) ;
  142.  
  143. H5 = IIf( (Min_2 + 1/8*Diff)<=Lo AND Hi <= (Min_2 + 7/8*Diff) AND H1==0 AND H2==0 AND H3==0 AND H4==0,
  144. Min_2 + 3/4*Diff , 0 ) ;
  145.  
  146. H6 = IIf( ( H1 + H2 + H3 + H4 + H5 ) == 0, Max_2, 0 ) ;
  147.  
  148. /**************************/
  149.  
  150. L1 = IIf(H1>0, Min_2 + 1/4*Diff, 0) ;
  151.  
  152. L2 = IIf(H2>0, Min_2, 0) ;
  153.  
  154. L3 = IIf(H3>0, Min_2 + 1/2*Diff, 0) ;
  155.  
  156. L4 = IIf(H4>0, Min_2 + 1/2*Diff, 0) ;
  157.  
  158. L5 = IIf(H5>0, Min_2 + 1/4*Diff, 0) ;
  159.  
  160. L6 = IIf(H6>0, Min_2, 0 ) ;
  161.  
  162.  
  163. M_8 = ( H1 + H2 + H3 + H4 + H5 + H6 ) ;
  164.  
  165. M_0 = ( L1 + L2 + L3 + L4 + L5 + L6 ) ;
  166.  
  167. /**************************************/
  168. Line0[i] = M_0 ;
  169.  
  170. Line1[i] = M_0 + (1*(0.125*(M_8-M_0)));
  171.  
  172. Line2[i] = M_0 + (2*(0.125*(M_8-M_0)));
  173.  
  174. Line3[i] = M_0 + (3*(0.125*(M_8-M_0)));
  175.  
  176. Line4[i] = M_0 + (4*(0.125*(M_8-M_0)));
  177.  
  178. Line5[i] = M_0 + (5*(0.125*(M_8-M_0)));
  179.  
  180. Line6[i] = M_0 + (6*(0.125*(M_8-M_0)));
  181.  
  182. Line7[i] = M_0 + (7*(0.125*(M_8-M_0)));
  183.  
  184.  
  185.  
  186. Line8[i] = M_8 ;
  187.  
  188. Lineplus2[i] = M_8 + (2*(0.125*(M_8-M_0)));
  189.  
  190. Lineminus2[i] = M_0 - (2*(0.125*(M_8-M_0)));
  191.  
  192.  
  193. }
  194.  
  195. Plot(Line0,"Line0",6,styleLine);//0/8
  196. Plot(Line1,"Line1",7,styleLine);//1/8
  197. Plot(Line2,"Line2",4,styleLine);//2/8
  198. Plot(Line3,"Line3",5,styleLine|styleDashed);//3/8
  199. Plot(Line4,"Line4",6,styleLine);//4/8
  200. Plot(Line5,"Line5",5,styleLine|styleDashed);//5/8
  201. Plot(Line6,"Line6",4,styleLine);//6/8
  202. Plot(Line7,"Line7",7,styleLine);//7/8
  203. Plot(Line8,"Line8",6,styleLine);//8/8
  204. Plot(Lineplus2,"Lineplus2",4,styleLine);//+2/8
  205. Plot(Lineminus2,"Lineminus2",4,styleLine);//-2/8
  206.  
  207.  
  208. /**************************************************************/
  209.  
  210. //Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorPink ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram ), 2 );
  211.  
  212. _SECTION_BEGIN("Volume");
  213.  
  214. cx = Param("cxposn",1000,0,1200,1);
  215. cy = Param("cyposn", 6,0,1000,10 );
  216.  
  217. GfxSelectFont( " Arial ", 18, 98, False );
  218. GfxSetTextColor( colorWhite );
  219. GfxTextOut("Volume " +Volume+ "", cx-300,cy +555);
  220.  
  221.  
  222. _SECTION_END();
  223. _SECTION_BEGIN("Title");
  224.  
  225. DDayO = TimeFrameGetPrice("O", inDaily);
  226. DHiDay = TimeFrameGetPrice("H", inDaily);
  227. DLoDay = TimeFrameGetPrice("L", inDaily);
  228. prvC = TimeFrameGetPrice("C", inDaily, -1);//close
  229.  
  230. _SECTION_BEGIN("Title");
  231.  
  232. DDayO = TimeFrameGetPrice("O", inDaily);
  233. DHiDay = TimeFrameGetPrice("H", inDaily);
  234. DLoDay = TimeFrameGetPrice("L", inDaily);
  235. prvC = TimeFrameGetPrice("C", inDaily, -1);//close
  236. Title =EncodeColor(colorYellow)+ Date()+EncodeColor(colorPink)+" "+Interval(format=2)+EncodeColor(colorOrange)+" "+Name()+EncodeColor(colorBrightGreen)+" Open:"+WriteVal(O,1.2)+EncodeColor(colorBrightGreen)+" High: "+WriteVal(H,1.2)+EncodeColor(colorWhite)+" Low: "+WriteVal(L,1.2)+EncodeColor(colorYellow)+" Close "+
  237. WriteVal(C,1.2) +
  238. " ~ Prev Close : " + EncodeColor(colorYellow) + prvC +EncodeColor(colorGold)+
  239. "\n Day-Open : " +DDayO + " Day-High : " +DHiDay + " Day-Low : "+ DLoDay ;
  240.  
  241.  
  242.  
  243.  
  244. _SECTION_END();
  245. _SECTION_END();/*
  246. Title = Name()
  247. + "=" + WriteIf( round(C)== C, NumToStr(C,1) , WriteVal(C) ) + " " + "\\c17"
  248. + WriteIf( Interval()==86400, "Daily ", WriteIf(Interval()==3600,"Hourly ",
  249. WriteIf(Interval()==900,"15 Min ", WriteIf(Interval()==300,"5 Min ",
  250. WriteIf(Interval()==60,"1 Min ", "" ) ) ) ) )
  251. + Date() + "\\c12" + WriteIf(Volume>0," Turnover=","")
  252. + WriteIf(Volume>0, WriteVal(Volume*Close/1000), "" ) ;
  253. */
  254. Filter = 1 ;
  255. AddColumn(Lineminus2,"Limit1",1.2);
  256. AddColumn(IIf(C>Lineminus2 AND C<Line0,C,Null),"Close",1.2, Null);
  257. AddColumn(Line0,"Supp1",1.2);
  258. AddColumn(IIf(C>Line0 AND C<Line1,C,Null),"Close",1.2, Null);
  259. AddColumn(Line1,"Reversal1",1.2);
  260. AddColumn(IIf(C>Line1 AND C<Line2,C,Null),"Close",1.2, Null);
  261. AddColumn(Line2,"Trend",1.2);
  262. AddColumn(IIf(C>Line2 AND C<Line3,C,Null),"Close",1.2, Null);
  263. AddColumn(Line3,"Short",1.2);
  264. AddColumn(IIf(C>Line3 AND C<Line4,C,Null),"Close",1.2, Null);
  265. AddColumn(Line4,"Supp/Res",1.2);
  266. AddColumn(IIf(C>Line4 AND C<Line5,C,Null),"Close",1.2, Null);
  267. AddColumn(Line5,"Long",1.2);
  268. AddColumn(IIf(C>Line5 AND C<Line6,C,Null),"Close",1.2, Null);
  269. AddColumn(Line6,"Trend",1.2);
  270. AddColumn(IIf(C>Line6 AND C<Line7,C,Null),"Close",1.2, Null);
  271. AddColumn(Line7,"Reversal2",1.2);
  272. AddColumn(IIf(C>Line7 AND C<Line8,C,Null),"Close",1.2, Null);
  273. AddColumn(Line8,"Res2",1.2);
  274. AddColumn(IIf(C>Line8 AND C<Lineplus2,C,Null),"Close",1.2, Null);
  275. AddColumn(Lineplus2,"Limit2",1.2);
  276.  
  277.  
  278.  
  279. ppl = ParamToggle("","Off|On",0);
  280. numbars = LastValue(Cum(Status("barvisible")));
  281. fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
  282. hts = -33.5;
  283. _SECTION_BEGIN("Indicators");
  284. RSI_Periods = Param("RSI Periods", 2, 1, 100, 1);
  285. MA_Periods = Param("Periods for MAV", 50, 1, 200, 1);
  286. Daily_Trend_MA_Pds = Param("Periods for Trend EMA", 6, 1, 100, 1);
  287. MAV_Value = V/EMA(V, MA_Periods);
  288. _SECTION_END();
  289. // Check if previous day's close is above its 6-day EMA
  290. DailyClose = TimeFrameCompress(Close, inDaily);
  291. DailyEMA = EMA( DailyClose, Daily_Trend_MA_Pds);
  292. DailyClose = TimeFrameExpand(DailyClose, inDaily, expandFirst);
  293. DailyEma = TimeFrameExpand(DailyEMA, inDaily, expandFirst);
  294. //Plot(DailyEma,"DailEma",colorCustom12,styleLine);
  295.  
  296. // Trend detection based on 6EMA for Daily
  297. Daily_Trend_UP = DailyClose > DailyEMA;
  298. Daily_Trend_DOWN = DailyClose < DailyEMA;
  299. Trend_UP_Text = WriteIf(Daily_Trend_UP, "Daily Trend UP", "");
  300. Trend_DOWN_Text = WriteIf(Daily_Trend_DOWN, "Daily Trend DOWN", "");
  301. Trend_Neutral_Text = WriteIf(NOT Daily_Trend_DOWN AND NOT Daily_Trend_UP, "Neutral", "");
  302. TrendCol = IIf(Daily_Trend_UP, colorGreen, IIf(Daily_Trend_DOWN, colorRed, colorLightGrey));
  303. _SECTION_END();
  304.  
  305.  
  306.  
  307. _SECTION_BEGIN("Price");
  308. pds = 20;
  309. MAFAST = EMA( Close, 20 );
  310. MASLOW = EMA( Close, 40 );
  311.  
  312. DonchianUpper = HHV( Ref( H, -1 ), pds ); // Highest high value of highs in last 20 periods
  313. DonchianLower = LLV( Ref( L, -1 ), pds ); // Lowest low value of low in last 20 periods
  314. DonchianMiddle = ( DonchianUpper + DonchianLower ) / 2;
  315.  
  316. UpTrend = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ) AND EMA( Close, 20 ) > EMA( Close, 40 );
  317. DnTrend = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ) AND EMA( Close, 20 ) < EMA( Close, 40 );
  318. Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorRed, colorYellow) );
  319.  
  320. // Plots a 20 period Donchian channel
  321. Plot( C, "Price", Color, styleCandle | styleThick );
  322. NewDay = IIf(Day() != Ref(Day(), -1) OR BarIndex() == LastValue(BarIndex()), 1, 0);
  323. //Plot(NewDay, "", 47, 2 + 32768 + 4096, Minvalue = 0, Maxvalue = 1);
  324. _SECTION_END();
  325.  
  326. _SECTION_BEGIN("PIVOT POINTS");
  327.  
  328. /* This code calculates the previous days high, low and close */
  329. Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
  330. Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
  331. Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
  332. Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
  333. Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
  334. C1 = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
  335. wHi=TimeFrameGetPrice("H",inWeekly,-1);
  336. wLo=TimeFrameGetPrice("L",inWeekly,-1);
  337. wCl=TimeFrameGetPrice("C",inWeekly,-1);
  338. mHi=TimeFrameGetPrice("H",inMonthly,-1);
  339. mLo=TimeFrameGetPrice("L",inMonthly,-1);
  340. mCl=TimeFrameGetPrice("C",inMonthly,-1);
  341.  
  342. //----------------------------------------------------------------------------------
  343.  
  344. /* This code calculates Daily Piovts */
  345.  
  346. rg = (Hi - Lo);
  347. bp = (Hi + Lo + C1)/3; bpI = LastValue (bp,1);
  348. r1 = (bp*2)-Lo; r1I = LastValue (r1,1);
  349. s1 = (bp*2)-Hi; s1I = LastValue (s1,1);
  350. r2 = bp + r1 - s1; r2I = LastValue (r2,1);
  351. s2 = bp - r1 + s1; s2I = LastValue (s2,1);
  352. r3 = bp + r2 - s1; r3I = LastValue (r3,1);
  353. s3 = bp - r2 + s1; s3I = LastValue (s3,1);
  354. r4 = bp + r2 - s2; r4I = LastValue (r4,1);
  355. s4 = bp - r2 + s2; s4I = LastValue (s4,1);
  356. wrg = (wHi - wLo);
  357. wbp = (wHi + wLo + wCl)/3; wbpI = LastValue (wbp,1);
  358. wr1 = (wbp*2)-wLo; wr1I = LastValue (wr1,1);
  359. ws1 = (wbp*2)-wHi; ws1I = LastValue (ws1,1);
  360. wr2 = wbp + wr1 - ws1; wr2I = LastValue (wr2,1);
  361. ws2 = wbp - wr1 + ws1; ws2I = LastValue (ws2,1);
  362. wr3 = wbp + wr2 - ws1; wr3I = LastValue (wr3,1);
  363. ws3 = wbp - wr2 + ws1; ws3I = LastValue (ws3,1);
  364. wr4 = wbp + wr2 - ws2; wr4I = LastValue (wr4,1);
  365. ws4 = wbp - wr2 + ws2; ws4I = LastValue (ws4,1);
  366. mrg = (mHi - mLo);
  367. mobp = (mHi + mLo + mCl)/3; mobpI = LastValue (mobp,1);
  368. mr1 = (mobp*2)-mLo; mr1I = LastValue (mr1,1);
  369. ms1 = (mobp*2)-mHi; ms1I = LastValue (ms1,1);
  370. mr2 = mobp + mr1 - ms1; mr2I = LastValue (mr2,1);
  371. ms2 = mobp - mr1 + ms1; ms2I = LastValue (ms2,1);
  372.  
  373. if(ppl==1) {
  374. Plot(bp,"",colorWhite,styleLine|styleLine|styleNoRescale);
  375. Plot(s1,"",colorRed,styleDashed|styleNoRescale);
  376. Plot(s2,"",colorRed,styleDashed|styleNoRescale);
  377. Plot(s3,"",colorRed,styleDashed|styleNoRescale);
  378. Plot(s4,"",colorRed,styleDashed|styleNoRescale);
  379. Plot(r1,"",colorBrightGreen,styleDashed|styleNoRescale);
  380. Plot(r2,"",colorBrightGreen,styleDashed|styleNoRescale);
  381. Plot(r3,"",colorBrightGreen,styleDashed|styleNoRescale);
  382. Plot(r4,"",colorBrightGreen,styleDashed|styleNoRescale);
  383. Plot(wbp,"",colorTan,styleDashed|styleLine|styleNoRescale);
  384. Plot(ws1,"",colorPaleGreen,styleDashed|styleNoRescale);
  385. Plot(ws2,"",colorPaleGreen,styleDashed|styleNoRescale);
  386. //Plot(ws3,"",colorPaleGreen,styleDashed|styleNoRescale);
  387. //Plot(ws4,"",colorPaleGreen,styleDashed|styleNoRescale);
  388. Plot(wr1,"",colorPaleBlue,styleDashed|styleNoRescale);
  389. Plot(wr2,"",colorPaleBlue,styleDashed|styleNoRescale);
  390. //Plot(wr3,"",colorPaleBlue,styleDashed|styleNoRescale);
  391. //Plot(wr4,"",colorPaleBlue,styleDashed|styleNoRescale);
  392. Plot(mobp,"",colorTan,styleDashed|styleLine|styleNoRescale);
  393. Plot(ms1,"",colorPaleGreen,styleDashed|styleNoRescale);
  394. Plot(mr1,"",colorPaleBlue,styleDashed|styleNoRescale);
  395. PlotText(" Pivot = " + WriteVal(bp,fraction), LastValue(BarIndex())-(numbars/Hts), bpI +0.05, colorWhite);
  396. PlotText(" Resistance 1 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorGreen);
  397. PlotText(" Support 1 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorRed);
  398. PlotText(" Resistance 2 = " + WriteVal(r2,fraction), LastValue(BarIndex())-(numbars/Hts), r2I +0.05, colorGreen);
  399. PlotText(" Support 2 = " + WriteVal(s2,fraction), LastValue(BarIndex())-(numbars/Hts), s2I +0.05, colorRed);
  400. PlotText(" Resistance 3 = " + WriteVal(r3,fraction), LastValue(BarIndex())-(numbars/Hts), r3I +0.05, colorGreen);
  401. PlotText(" Support 3 = " + WriteVal(s3,fraction), LastValue(BarIndex())-(numbars/Hts), s3I +0.05, colorRed);
  402. PlotText(" Resistance 4 = " + WriteVal(r4,fraction), LastValue(BarIndex())-(numbars/Hts), r4I +0.05, colorGreen);
  403. PlotText(" Support 4 = " + WriteVal(s4,fraction), LastValue(BarIndex())-(numbars/Hts), s4I +0.05, colorRed);
  404. PlotText(" W Pivot = " + WriteVal(wbp,fraction), LastValue(BarIndex())-(numbars/Hts), wbpI +0.05, colorTan);
  405. PlotText(" W Resistance 1 = " + WriteVal(wr1,fraction), LastValue(BarIndex())-(numbars/Hts), wr1I +0.05, colorPaleBlue);
  406. PlotText(" W Support 1 = " + WriteVal(ws1,fraction), LastValue(BarIndex())-(numbars/Hts), ws1I +0.05, colorPaleGreen);
  407. PlotText(" W Resistance 2 = " + WriteVal(wr2,fraction), LastValue(BarIndex())-(numbars/Hts), wr2I +0.05, colorPaleBlue);
  408. PlotText(" W Support 2 = " + WriteVal(ws2,fraction), LastValue(BarIndex())-(numbars/Hts), ws2I +0.05, colorPaleGreen);
  409. //PlotText(" W Resistance 3 = " + WriteVal(wr3,fraction), LastValue(BarIndex())-(numbars/Hts), wr3I +0.05, colorPaleBlue);
  410. //PlotText(" W Support 3 = " + WriteVal(ws3,fraction), LastValue(BarIndex())-(numbars/Hts), ws3I +0.05, colorPaleGreen);
  411. //PlotText(" W Resistance 4 = " + WriteVal(wr4,fraction), LastValue(BarIndex())-(numbars/Hts), wr4I +0.05, colorPaleBlue);
  412. //PlotText(" W Support 4 = " + WriteVal(ws4,fraction), LastValue(BarIndex())-(numbars/Hts), ws4I +0.05, colorPaleGreen);
  413. PlotText(" M Pivot = " + WriteVal(mobp,fraction), LastValue(BarIndex())-(numbars/Hts), mobpI+0.05, colorTan);
  414. PlotText(" M Resistance 1 = " + WriteVal(mr1,fraction), LastValue(BarIndex())-(numbars/Hts), mr1I+0.05, colorPaleBlue);
  415. PlotText(" M Support 1 = " + WriteVal(ms1,fraction), LastValue(BarIndex())-(numbars/Hts), ms1I+0.05, colorPaleGreen);
  416. }
  417.  
  418.  
  419. _SECTION_END();
  420.  
  421.  
  422. _SECTION_BEGIN("PIVOTS Hourly");
  423. TimeFrameSet(inHourly);
  424. HourlyH= LastValue(Ref(H,-1));
  425. HourlyL= LastValue(Ref(L,-1));
  426. HourlyC= LastValue(Ref(C,-1));
  427. TimeFrameRestore();
  428.  
  429. //Daily
  430. HPP = (HourlyL + HourlyH + HourlyC)/3;HPPI = LastValue (HPP,1);
  431. HR1 = (2 * HPP) - HourlyL;HR1I = LastValue (HR1,1);
  432. HS1 = (2 * HPP) - HourlyH;HS1I = LastValue (HS1,1);
  433. HR2 = HPP + (HourlyH - HourlyL);HR2I = LastValue (HR2,1);
  434. HS2 = HPP - (HourlyH - HourlyL);HS2I = LastValue (HS2,1);
  435. HR3 = HourlyH + 2*(HPP - HourlyL);HR3I = LastValue (HR3,1);
  436. HS3 = HourlyL - 2*(HourlyH - HPP);HS3I = LastValue (HS3,1);
  437. SHOWDPIVOTS = ParamToggle("Daily Pivots", "No|Yes",0);
  438. SHOW3 = ParamToggle("3rd Line", "No|Yes",0);
  439.  
  440. if (SHOWDPIVOTS & SHOW3)
  441. {
  442. Plot(HS3, "S3",ColorR);
  443. Plot(HR3, "R3",ColorG);
  444. PlotText(" H Resis 3 = " + WriteVal(HR3,fraction), LastValue(BarIndex())-(numbars/Hts), HR3I +0.05, colorGreen);
  445. PlotText(" H Sup 3 = " + WriteVal(HS3,fraction), LastValue(BarIndex())-(numbars/Hts), HS3I +0.05, colorRed);
  446.  
  447. }
  448.  
  449.  
  450.  
  451. for (i=BarCount-2;i>(BarCount-13);i--)//set the last bars to the final PP value
  452. {
  453. HPP[i] = HPP[BarCount-1];
  454. HR1[i] = HR1[BarCount-1];
  455. HR2[i] = HR2[BarCount-1];
  456. HS1[i] = HS1[BarCount-1];
  457. HS2[i] = HS2[BarCount-1];
  458.  
  459. ColorG[i] = colorGreen;
  460. ColorB[i] = colorBlue;
  461. ColorR[i] = colorRed;
  462. }
  463.  
  464. //
  465. // Conceal all but the trailing portion of the line
  466. //
  467. for (i=0;i<BarCount-15;i++) //hide the line except most recent 15 bars
  468. {
  469. ColorR[i] = ColorG[i] = ColorB[i] = colorBlack;
  470. }
  471.  
  472.  
  473. if (SHOWDPIVOTS) {
  474. Plot(HR2, "R2",ColorG);
  475. Plot(HR1, "R1",ColorG);
  476. Plot(HPP, "PP",ColorB);
  477. Plot(HS1, "S1",ColorR);
  478. Plot(HS2, "S2",ColorR);
  479. PlotText(" H Pivot = " + WriteVal(HPP,fraction), LastValue(BarIndex())-(numbars/Hts), HPPI +0.05, colorBlue);
  480. PlotText(" H Resis 1 = " + WriteVal(HR1,fraction), LastValue(BarIndex())-(numbars/Hts), HR1I +0.05, colorGreen);
  481. PlotText(" H Sup 1 = " + WriteVal(HS1,fraction), LastValue(BarIndex())-(numbars/Hts), HS1I +0.05, colorRed);
  482. PlotText(" H Resis 2 = " + WriteVal(HR2,fraction), LastValue(BarIndex())-(numbars/Hts), HR2I +0.05, colorGreen);
  483. PlotText(" H Sup 2 = " + WriteVal(HS2,fraction), LastValue(BarIndex())-(numbars/Hts), HS2I +0.05, colorRed);
  484.  
  485. }
  486.  
  487. if (SHOWDPIVOTS & SHOW3)
  488. {
  489. Plot(S3, "S3",ColorR);
  490. Plot(R3, "R3",ColorG);
  491. PlotText(" H Resis 3 = " + WriteVal(HR3,fraction), LastValue(BarIndex())-(numbars/Hts), HR3I +0.05, colorGreen);
  492. PlotText(" H Sup 3 = " + WriteVal(HS3,fraction), LastValue(BarIndex())-(numbars/Hts), HS3I +0.05, colorRed);
  493.  
  494. }
  495.  
  496.  
  497. _SECTION_END();
  498.  
  499.  
  500. _SECTION_BEGIN("Time Left");
  501. function GetSecondNum()
  502. {
  503. Time = Now( 4 );
  504. Seconds = int( Time % 100 );
  505. Minutes = int( Time / 100 % 100 );
  506. Hours = int( Time / 10000 % 100 );
  507. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  508. return SecondNum;
  509. }
  510. RequestTimedRefresh( 1 );
  511. TimeFrame = Interval();
  512. SecNumber = GetSecondNum();
  513. Newperiod = SecNumber % TimeFrame == 0;
  514. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  515. SecsToGo = TimeFrame - SecsLeft;
  516.  
  517. x=Param("xposn",0,0,1000,1);
  518. y=Param("yposn",900,0,1000,1);
  519.  
  520. GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
  521. GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
  522. if ( NewPeriod )
  523. {
  524. GfxSelectSolidBrush( colorYellow );
  525. GfxSelectPen( colorYellow, 2 );
  526. Say( "New time stick start" );
  527. }
  528.  
  529. cx = Param( "cxposn", 730, 0, 1250, 1 );
  530. cy = Param( "cyposn", 15, 0, 500, 1 );
  531. GfxSelectFont( "Candara", 10, 98, False );
  532. //gfxcup = SelectedValue(C > Ref(C,-1));
  533. //gfxpcolor = IIf(gfxcup,colorBrightGreen,colorRed);
  534. GfxSetTextColor(colorBrightGreen);
  535. //GfxSetTextColor( colorWhite );
  536. GfxTextOut( "Time left for candle close " + SecsToGo + " ", cx, cy );
  537. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement