Advertisement
saisri

normal candle with pivot,,, use murray and this afl at a tim

Feb 6th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.42 KB | None | 0 0
  1. _SECTION_BEGIN("Title");
  2.  
  3. DDayO = TimeFrameGetPrice("O", inDaily);
  4. DHiDay = TimeFrameGetPrice("H", inDaily);
  5. DLoDay = TimeFrameGetPrice("L", inDaily);
  6. prvC = TimeFrameGetPrice("C", inDaily, -1);//close
  7. 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(colorRose)+" Close "+
  8. WriteVal(C,1.2) +
  9. " ~ Prev Close : " + EncodeColor(colorPink) + prvC +EncodeColor(colorGold)+
  10. "\n Day-Open : " +DDayO + " Day-High : " +DHiDay + " Day-Low : "+ DLoDay ;
  11.  
  12.  
  13.  
  14.  
  15. _SECTION_END();
  16. _SECTION_BEGIN("Background");
  17. tchoice=Param("Title Selection ",2,1,2,1);
  18.  
  19. Plot(C, "", IIf(O>=C, colorRed, colorGreen), ParamStyle("Price Style",styleCandle,maskPrice));
  20. //////////////////////////////////////////////////////////////////
  21.  
  22. _SECTION_BEGIN("Background text");
  23. SetChartBkColor(colorBlack);
  24. strWeekday = StrMid("---sunday---Monday--TuesdayWednesday-Thursday--Friday--Saturday", SelectedValue(DayOfWeek())*9,9);
  25. GraphXSpace=Param("GraphXSpace",0,-55,200,1);
  26. C13=Param("fonts",50,10,30,1 );
  27. C14=Param("left-right",2.1,1.0,5.0,0.1 );
  28. C15=Param("up-down",12,1,20,1 );
  29. Miny = Status("axisminy");
  30. Maxy = Status("axismaxy");
  31. lvb = Status("lastvisiblebar");
  32. fvb = Status("firstvisiblebar");
  33. pxwidth = Status("pxwidth");
  34. pxheight = Status("pxheight");
  35. GfxSetBkMode(transparent=1);
  36. GfxSetOverlayMode(1);
  37. GfxSelectFont("Candara", Status("pxheight")/C13 );
  38. GfxSetTextAlign( 6 );
  39. GfxSetTextColor( ColorRGB (217,217,213));
  40. GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
  41. GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
  42. GfxSetTextColor( ColorRGB (103,103,103));
  43. GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
  44. GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
  45. GfxSetTextColor( ColorRGB (103,103,103));
  46. GfxTextOut( "Saisri2320", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
  47. GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
  48. _SECTION_END();
  49. ppl = ParamToggle("","Off|On",1);
  50. numbars = LastValue(Cum(Status("barvisible")));
  51. fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
  52. hts = -33.5;
  53. _SECTION_BEGIN("Indicators");
  54. RSI_Periods = Param("RSI Periods", 2, 1, 100, 1);
  55. MA_Periods = Param("Periods for MAV", 50, 1, 200, 1);
  56. Daily_Trend_MA_Pds = Param("Periods for Trend EMA", 6, 1, 100, 1);
  57. MAV_Value = V/EMA(V, MA_Periods);
  58. _SECTION_END();
  59. // Check if previous day's close is above its 6-day EMA
  60. DailyClose = TimeFrameCompress(Close, inDaily);
  61. DailyEMA = EMA( DailyClose, Daily_Trend_MA_Pds);
  62. DailyClose = TimeFrameExpand(DailyClose, inDaily, expandFirst);
  63. DailyEma = TimeFrameExpand(DailyEMA, inDaily, expandFirst);
  64. //Plot(DailyEma,"DailEma",colorCustom12,styleLine);
  65.  
  66. // Trend detection based on 6EMA for Daily
  67. Daily_Trend_UP = DailyClose > DailyEMA;
  68. Daily_Trend_DOWN = DailyClose < DailyEMA;
  69. Trend_UP_Text = WriteIf(Daily_Trend_UP, "Daily Trend UP", "");
  70. Trend_DOWN_Text = WriteIf(Daily_Trend_DOWN, "Daily Trend DOWN", "");
  71. Trend_Neutral_Text = WriteIf(NOT Daily_Trend_DOWN AND NOT Daily_Trend_UP, "Neutral", "");
  72. TrendCol = IIf(Daily_Trend_UP, colorGreen, IIf(Daily_Trend_DOWN, colorRed, colorLightGrey));
  73. _SECTION_END();
  74.  
  75.  
  76.  
  77. _SECTION_BEGIN("Price");
  78. pds = 20;
  79. MAFAST = EMA( Close, 20 );
  80. MASLOW = EMA( Close, 40 );
  81.  
  82. DonchianUpper = HHV( Ref( H, -1 ), pds ); // Highest high value of highs in last 20 periods
  83. DonchianLower = LLV( Ref( L, -1 ), pds ); // Lowest low value of low in last 20 periods
  84. DonchianMiddle = ( DonchianUpper + DonchianLower ) / 2;
  85.  
  86. UpTrend = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ) AND EMA( Close, 20 ) > EMA( Close, 40 );
  87. DnTrend = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ) AND EMA( Close, 20 ) < EMA( Close, 40 );
  88. Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorRed, colorYellow) );
  89.  
  90. // Plots a 20 period Donchian channel
  91. Plot( C, "Price", Color, styleCandle | styleThick );
  92. NewDay = IIf(Day() != Ref(Day(), -1) OR BarIndex() == LastValue(BarIndex()), 1, 0);
  93. //Plot(NewDay, "", 47, 2 + 32768 + 4096, Minvalue = 0, Maxvalue = 1);
  94. _SECTION_END();
  95.  
  96. _SECTION_BEGIN("PIVOT POINTS");
  97.  
  98. /* This code calculates the previous days high, low and close */
  99. Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
  100. Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
  101. Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
  102. Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
  103. Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
  104. C1 = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
  105. wHi=TimeFrameGetPrice("H",inWeekly,-1);
  106. wLo=TimeFrameGetPrice("L",inWeekly,-1);
  107. wCl=TimeFrameGetPrice("C",inWeekly,-1);
  108. mHi=TimeFrameGetPrice("H",inMonthly,-1);
  109. mLo=TimeFrameGetPrice("L",inMonthly,-1);
  110. mCl=TimeFrameGetPrice("C",inMonthly,-1);
  111.  
  112. //----------------------------------------------------------------------------------
  113.  
  114. /* This code calculates Daily Piovts */
  115.  
  116. rg = (Hi - Lo);
  117. bp = (Hi + Lo + C1)/3; bpI = LastValue (bp,1);
  118. r1 = (bp*2)-Lo; r1I = LastValue (r1,1);
  119. s1 = (bp*2)-Hi; s1I = LastValue (s1,1);
  120. r2 = bp + r1 - s1; r2I = LastValue (r2,1);
  121. s2 = bp - r1 + s1; s2I = LastValue (s2,1);
  122. r3 = bp + r2 - s1; r3I = LastValue (r3,1);
  123. s3 = bp - r2 + s1; s3I = LastValue (s3,1);
  124. r4 = bp + r2 - s2; r4I = LastValue (r4,1);
  125. s4 = bp - r2 + s2; s4I = LastValue (s4,1);
  126. wrg = (wHi - wLo);
  127. wbp = (wHi + wLo + wCl)/3; wbpI = LastValue (wbp,1);
  128. wr1 = (wbp*2)-wLo; wr1I = LastValue (wr1,1);
  129. ws1 = (wbp*2)-wHi; ws1I = LastValue (ws1,1);
  130. wr2 = wbp + wr1 - ws1; wr2I = LastValue (wr2,1);
  131. ws2 = wbp - wr1 + ws1; ws2I = LastValue (ws2,1);
  132. wr3 = wbp + wr2 - ws1; wr3I = LastValue (wr3,1);
  133. ws3 = wbp - wr2 + ws1; ws3I = LastValue (ws3,1);
  134. wr4 = wbp + wr2 - ws2; wr4I = LastValue (wr4,1);
  135. ws4 = wbp - wr2 + ws2; ws4I = LastValue (ws4,1);
  136. mrg = (mHi - mLo);
  137. mobp = (mHi + mLo + mCl)/3; mobpI = LastValue (mobp,1);
  138. mr1 = (mobp*2)-mLo; mr1I = LastValue (mr1,1);
  139. ms1 = (mobp*2)-mHi; ms1I = LastValue (ms1,1);
  140. mr2 = mobp + mr1 - ms1; mr2I = LastValue (mr2,1);
  141. ms2 = mobp - mr1 + ms1; ms2I = LastValue (ms2,1);
  142.  
  143. if(ppl==1) {
  144. Plot(bp,"",colorWhite,styleLine|styleLine|styleNoRescale);
  145. Plot(s1,"",colorGreen,styleDashed|styleNoRescale);
  146. Plot(s2,"",colorBrightGreen,styleDashed|styleNoRescale);
  147. Plot(s3,"",colorBrightGreen,styleDashed|styleNoRescale);
  148. Plot(s4,"",colorBrightGreen,styleDashed|styleNoRescale);
  149. Plot(r1,"",colorRed,styleDashed|styleNoRescale);
  150. Plot(r2,"",colorDarkRed,styleDashed|styleNoRescale);
  151. Plot(r3,"",colorDarkRed,styleDashed|styleNoRescale);
  152. Plot(r4,"",colorDarkRed,styleDashed|styleNoRescale);
  153. Plot(wbp,"",colorTan,styleDashed|styleLine|styleNoRescale);
  154. Plot(ws1,"",colorPaleGreen,styleDashed|styleNoRescale);
  155. Plot(ws2,"",colorPaleGreen,styleDashed|styleNoRescale);
  156. //Plot(ws3,"",colorPaleGreen,styleDashed|styleNoRescale);
  157. //Plot(ws4,"",colorPaleGreen,styleDashed|styleNoRescale);
  158. Plot(wr1,"",colorPaleBlue,styleDashed|styleNoRescale);
  159. Plot(wr2,"",colorPaleBlue,styleDashed|styleNoRescale);
  160. //Plot(wr3,"",colorPaleBlue,styleDashed|styleNoRescale);
  161. //Plot(wr4,"",colorPaleBlue,styleDashed|styleNoRescale);
  162. Plot(mobp,"",colorTan,styleDashed|styleLine|styleNoRescale);
  163. Plot(ms1,"",colorPaleGreen,styleDashed|styleNoRescale);
  164. Plot(mr1,"",colorPaleBlue,styleDashed|styleNoRescale);
  165. PlotText(" Pivot = " + WriteVal(bp,fraction), LastValue(BarIndex())-(numbars/Hts), bpI +0.05, colorWhite);
  166. PlotText(" Resistance 1 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorRed);
  167. PlotText(" Support 1 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorGreen);
  168. PlotText(" Resistance 2 = " + WriteVal(r2,fraction), LastValue(BarIndex())-(numbars/Hts), r2I +0.05, colorDarkRed);
  169. PlotText(" Support 2 = " + WriteVal(s2,fraction), LastValue(BarIndex())-(numbars/Hts), s2I +0.05, colorBrightGreen);
  170. PlotText(" Resistance 3 = " + WriteVal(r3,fraction), LastValue(BarIndex())-(numbars/Hts), r3I +0.05, colorGreen);
  171. PlotText(" Support 3 = " + WriteVal(s3,fraction), LastValue(BarIndex())-(numbars/Hts), s3I +0.05, colorRed);
  172. PlotText(" Resistance 4 = " + WriteVal(r4,fraction), LastValue(BarIndex())-(numbars/Hts), r4I +0.05, colorGreen);
  173. PlotText(" Support 4 = " + WriteVal(s4,fraction), LastValue(BarIndex())-(numbars/Hts), s4I +0.05, colorRed);
  174. PlotText(" W Pivot = " + WriteVal(wbp,fraction), LastValue(BarIndex())-(numbars/Hts), wbpI +0.05, colorTan);
  175. PlotText(" W Resistance 1 = " + WriteVal(wr1,fraction), LastValue(BarIndex())-(numbars/Hts), wr1I +0.05, colorPaleBlue);
  176. PlotText(" W Support 1 = " + WriteVal(ws1,fraction), LastValue(BarIndex())-(numbars/Hts), ws1I +0.05, colorPaleGreen);
  177. PlotText(" W Resistance 2 = " + WriteVal(wr2,fraction), LastValue(BarIndex())-(numbars/Hts), wr2I +0.05, colorPaleBlue);
  178. PlotText(" W Support 2 = " + WriteVal(ws2,fraction), LastValue(BarIndex())-(numbars/Hts), ws2I +0.05, colorPaleGreen);
  179. //PlotText(" W Resistance 3 = " + WriteVal(wr3,fraction), LastValue(BarIndex())-(numbars/Hts), wr3I +0.05, colorPaleBlue);
  180. //PlotText(" W Support 3 = " + WriteVal(ws3,fraction), LastValue(BarIndex())-(numbars/Hts), ws3I +0.05, colorPaleGreen);
  181. //PlotText(" W Resistance 4 = " + WriteVal(wr4,fraction), LastValue(BarIndex())-(numbars/Hts), wr4I +0.05, colorPaleBlue);
  182. //PlotText(" W Support 4 = " + WriteVal(ws4,fraction), LastValue(BarIndex())-(numbars/Hts), ws4I +0.05, colorPaleGreen);
  183. PlotText(" M Pivot = " + WriteVal(mobp,fraction), LastValue(BarIndex())-(numbars/Hts), mobpI+0.05, colorTan);
  184. PlotText(" M Resistance 1 = " + WriteVal(mr1,fraction), LastValue(BarIndex())-(numbars/Hts), mr1I+0.05, colorPaleBlue);
  185. PlotText(" M Support 1 = " + WriteVal(ms1,fraction), LastValue(BarIndex())-(numbars/Hts), ms1I+0.05, colorPaleGreen);
  186. }
  187.  
  188.  
  189. _SECTION_END();
  190.  
  191.  
  192. _SECTION_BEGIN("PIVOTS Hourly");
  193. TimeFrameSet(inHourly);
  194. HourlyH= LastValue(Ref(H,-1));
  195. HourlyL= LastValue(Ref(L,-1));
  196. HourlyC= LastValue(Ref(C,-1));
  197. TimeFrameRestore();
  198.  
  199. //Daily
  200. HPP = (HourlyL + HourlyH + HourlyC)/3;HPPI = LastValue (HPP,1);
  201. HR1 = (2 * HPP) - HourlyL;HR1I = LastValue (HR1,1);
  202. HS1 = (2 * HPP) - HourlyH;HS1I = LastValue (HS1,1);
  203. HR2 = HPP + (HourlyH - HourlyL);HR2I = LastValue (HR2,1);
  204. HS2 = HPP - (HourlyH - HourlyL);HS2I = LastValue (HS2,1);
  205. HR3 = HourlyH + 2*(HPP - HourlyL);HR3I = LastValue (HR3,1);
  206. HS3 = HourlyL - 2*(HourlyH - HPP);HS3I = LastValue (HS3,1);
  207. SHOWDPIVOTS = ParamToggle("Daily Pivots", "No|Yes",0);
  208. SHOW3 = ParamToggle("3rd Line", "No|Yes",0);
  209.  
  210. if (SHOWDPIVOTS & SHOW3)
  211. {
  212. Plot(HS3, "S3",ColorR);
  213. Plot(HR3, "R3",ColorG);
  214. PlotText(" H Resis 3 = " + WriteVal(HR3,fraction), LastValue(BarIndex())-(numbars/Hts), HR3I +0.05, colorGreen);
  215. PlotText(" H Sup 3 = " + WriteVal(HS3,fraction), LastValue(BarIndex())-(numbars/Hts), HS3I +0.05, colorRed);
  216.  
  217. }
  218.  
  219.  
  220.  
  221. for (i=BarCount-2;i>(BarCount-13);i--)//set the last bars to the final PP value
  222. {
  223. HPP[i] = HPP[BarCount-1];
  224. HR1[i] = HR1[BarCount-1];
  225. HR2[i] = HR2[BarCount-1];
  226. HS1[i] = HS1[BarCount-1];
  227. HS2[i] = HS2[BarCount-1];
  228.  
  229. ColorG[i] = colorGreen;
  230. ColorB[i] = colorBlue;
  231. ColorR[i] = colorRed;
  232. }
  233.  
  234. //
  235. // Conceal all but the trailing portion of the line
  236. //
  237. for (i=0;i<BarCount-15;i++) //hide the line except most recent 15 bars
  238. {
  239. ColorR[i] = ColorG[i] = ColorB[i] = colorBlack;
  240. }
  241.  
  242.  
  243. if (SHOWDPIVOTS) {
  244. Plot(HR2, "R2",ColorG);
  245. Plot(HR1, "R1",ColorG);
  246. Plot(HPP, "PP",ColorB);
  247. Plot(HS1, "S1",ColorR);
  248. Plot(HS2, "S2",ColorR);
  249. PlotText(" H Pivot = " + WriteVal(HPP,fraction), LastValue(BarIndex())-(numbars/Hts), HPPI +0.05, colorBlue);
  250. PlotText(" H Resis 1 = " + WriteVal(HR1,fraction), LastValue(BarIndex())-(numbars/Hts), HR1I +0.05, colorGreen);
  251. PlotText(" H Sup 1 = " + WriteVal(HS1,fraction), LastValue(BarIndex())-(numbars/Hts), HS1I +0.05, colorRed);
  252. PlotText(" H Resis 2 = " + WriteVal(HR2,fraction), LastValue(BarIndex())-(numbars/Hts), HR2I +0.05, colorGreen);
  253. PlotText(" H Sup 2 = " + WriteVal(HS2,fraction), LastValue(BarIndex())-(numbars/Hts), HS2I +0.05, colorRed);
  254.  
  255. }
  256.  
  257. if (SHOWDPIVOTS & SHOW3)
  258. {
  259. Plot(S3, "S3",ColorR);
  260. Plot(R3, "R3",ColorG);
  261. PlotText(" H Resis 3 = " + WriteVal(HR3,fraction), LastValue(BarIndex())-(numbars/Hts), HR3I +0.05, colorGreen);
  262. PlotText(" H Sup 3 = " + WriteVal(HS3,fraction), LastValue(BarIndex())-(numbars/Hts), HS3I +0.05, colorRed);
  263.  
  264. }
  265.  
  266.  
  267. _SECTION_END();
  268.  
  269.  
  270.  
  271. _SECTION_BEGIN("Time Left");
  272. function GetSecondNum()
  273. {
  274. Time = Now( 4 );
  275. Seconds = int( Time % 100 );
  276. Minutes = int( Time / 100 % 100 );
  277. Hours = int( Time / 10000 % 100 );
  278. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  279. return SecondNum;
  280. }
  281. RequestTimedRefresh( 1 );
  282. TimeFrame = Interval();
  283. SecNumber = GetSecondNum();
  284. Newperiod = SecNumber % TimeFrame == 0;
  285. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  286. SecsToGo = TimeFrame - SecsLeft;
  287.  
  288. x=Param("xposn",0,0,1000,1);
  289. y=Param("yposn",900,0,1000,1);
  290.  
  291. GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
  292. GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
  293. if ( NewPeriod )
  294. {
  295. GfxSelectSolidBrush( colorYellow );
  296. GfxSelectPen( colorYellow, 2 );
  297. Say( "New time stick start" );
  298. }
  299.  
  300. cx = Param( "cxposn", 745, 0, 1250, 1 );
  301. cy = Param( "cyposn", 15, 0, 500, 1 );
  302. GfxSelectFont( "Candara", 10, 98, False );
  303. //gfxcup = SelectedValue(C > Ref(C,-1));
  304. //gfxpcolor = IIf(gfxcup,colorBrightGreen,colorRed);
  305. GfxSetTextColor(colorBrightGreen);
  306. //GfxSetTextColor( colorWhite );
  307. GfxTextOut( "Time left for candle close " + SecsToGo + " ", cx, cy );
  308. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement