Advertisement
saisri

2 time

Jan 30th, 2013
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.41 KB | None | 0 0
  1. _SECTION_BEGIN("2 Timeframes Candlestick Bar Chart");
  2. // Specially designed for use in day trading and to save chart space. This chart will displays 2 sets
  3. // of candlestick bars. One for the time interval set for your chart- for example 1 minute.
  4. // The higher timeframe candlestick bars are created by using gfx low-level graphics and will display
  5. // according to the parameters you set- for example 5 minutes.
  6.  
  7. // I got the idea from David's (dbwyatt_1999) 2 Timeframe chart code which was shared by him on the AmiBroker List.
  8. // It uses TimeFrame functions with the PlotOHLC function using styleCloud. So I was thinking it would look
  9. // very nice using low-level graphics instead. Little bit more complicated, but I got a few great pointers from Herman!
  10.  
  11. // If your chart background turns pink- please read the error message in the upper left corner of the chart.
  12. // Then please observe this AFL code uses ColorBlend(ColorFrom, ColorTo, Factor) which was introduced in version 5.21 beta.
  13. // The rules are simple- time frames from 1 up to 60 minutes AND Lower time frame must be smaller than the Higher time frame.
  14.  
  15. _SECTION_BEGIN("Background text");
  16. SetChartBkColor(colorWhite);
  17. strWeekday = StrMid("---sunday---Monday--TuesdayWednesday-Thursday--Friday--Saturday", SelectedValue(DayOfWeek())*9,9);
  18. GraphXSpace=Param("GraphXSpace",0,-55,200,1);
  19. C13=Param("fonts",20,10,30,1 );
  20. C14=Param("left-right",2.1,1.0,5.0,0.1 );
  21. C15=Param("up-down",12,1,20,1 );
  22. Miny = Status("axisminy");
  23. Maxy = Status("axismaxy");
  24. lvb = Status("lastvisiblebar");
  25. fvb = Status("firstvisiblebar");
  26. pxwidth = Status("pxwidth");
  27. pxheight = Status("pxheight");
  28. GfxSetBkMode(transparent=1);
  29. GfxSetOverlayMode(1);
  30. GfxSelectFont("Candara", Status("pxheight")/C13 );
  31. GfxSetTextAlign( 6 );
  32. GfxSetTextColor( ColorRGB (217,217,213));
  33. GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
  34. GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
  35. GfxSetTextColor( ColorRGB (103,103,103));
  36. GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
  37. GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
  38. GfxSetTextColor( ColorRGB (103,103,103));
  39. GfxTextOut( "Saisri2320", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
  40. GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
  41. _SECTION_END();
  42.  
  43. _SECTION_BEGIN("Title");
  44.  
  45. DODay = TimeFrameGetPrice("O", inDaily);
  46. DHiDay = TimeFrameGetPrice("H", inDaily);
  47. DLoDay = TimeFrameGetPrice("L", inDaily);
  48. Title = EncodeColor(colorBlue)+"* SAISRI2320 * "+EncodeColor(colorGreen)+ Name() + ", " + Interval(2) + ", " + Date() + " - "+strWeekday + " - " +
  49. EncodeColor(colorBlue) + "\nO " + EncodeColor(colorRed) + O +
  50.  
  51. ", H : " + H +
  52. ", L : " + L +
  53. ", C : " + C +
  54. "\n"+EncodeColor(colorBlue)+ " Day-Open : " +DODay + " Day-High : " +DHiDay + " Day-Low : " + DLoDay
  55.  
  56.  
  57. ;
  58.  
  59. _SECTION_END();
  60.  
  61. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
  62. // PARAMETERS AND SETTINGS:
  63. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
  64. ChartLum = Param("Chart Background Color Intensity", 0.40, 0, 1, 0.01);
  65. TFMinShort = Param("Short Timeframe (Minutes)", 5, 1, 1440, 1);
  66. TFMinLong = Param("Long Timeframe (Minutes)", 30, 1, 1500, 1);
  67. OnSTFBars = ParamToggle("Short TF Bars", "Off, On", 1);
  68. OnLTFBars = ParamToggle("Long TF Bars", "Off, On", 1);
  69. BarLum1 = Param("Short TF Bar Color Intensity", 0, 0, 1, 0.01);
  70. BarLum2 = Param("Long TF Bar Color Intensity", 0.70, 0, 1, 0.01);
  71.  
  72. SetChartBkColor(ColorBlend(colorWhite, colorWhite, ChartLum));
  73. // Bar Colors for the Short Timeframe candlestick bars:
  74. LineColor = ColorBlend(colorBlack, colorWhite, BarLum1);
  75. UpBarColor = ColorBlend(colorBrightGreen, colorWhite, BarLum1);
  76. DnBarColor = ColorBlend(colorRed, colorWhite, BarLum1);
  77. // Bar Colors For The Long Timeframe candlestick bars:
  78. TFLineColor = ColorBlend(colorBlack, colorWhite, BarLum2 - 0.1);
  79. TFUpBarColor = ColorBlend(colorBrightGreen, colorWhite, BarLum2);
  80. TFDnBarColor = ColorBlend(colorRed, colorWhite, BarLum2);
  81. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
  82. // FUNCTIONS:
  83. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
  84. function GetVisibleBarCount()
  85. {
  86. lvb = Status("lastvisiblebar");
  87. fvb = Status("firstvisiblebar");
  88. return Min( Lvb - fvb, BarCount - fvb );
  89. }
  90.  
  91. function GfxConvertBarToPixelX( bar )
  92. {
  93. lvb = Status("lastvisiblebar");
  94. fvb = Status("firstvisiblebar");
  95. pxchartleft = Status("pxchartleft");
  96. pxchartwidth = Status("pxchartwidth");
  97. return pxchartleft + bar * pxchartwidth / ( Lvb - fvb + 1 );
  98. }
  99.  
  100. function GfxConvertValueToPixelY( Value )
  101. {
  102. local Miny, Maxy, pxchartbottom, pxchartheight;
  103. Miny = Status("axisminy");
  104. Maxy = Status("axismaxy");
  105. pxchartbottom = Status("pxchartbottom");
  106. pxchartheight = Status("pxchartheight");
  107. return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight/ ( Maxy - Miny ) );
  108. }
  109.  
  110. StaticVarKey = Name();
  111. procedure xStaticVarSet(SName, SValue)
  112. {
  113. global StaticVarKey;
  114. if (StaticVarKey != "")
  115. StaticVarSet(Sname + StaticVarKey, Svalue);
  116. }
  117. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
  118. // MAIN PROGRAM:
  119. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
  120. if(Interval() != TFMinShort * 60)
  121. {
  122. Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "Set the chart time interval to: " + NumToStr(TFMinShort, 1.0, 1) +
  123. " Minute(s) or change the Short Timeframe Parameter setting.";
  124. OnSTFBars = 0;
  125. OnLTFBars = 0;
  126. SetChartBkColor(colorRose);
  127. }
  128.  
  129. if(TFMinShort >= TFMinLong)
  130. {
  131. Title = Title + "\n" + "\n" + "ALERT, ALERT, ALERT!!!" + "\n" + "The Long Timeframe setting must be longer than the Short Timeframe!";
  132. OnSTFBars = 0;
  133. OnLTFBars = 0;
  134. SetChartBkColor(colorRose);
  135. }
  136.  
  137. if(OnSTFBars)
  138. {
  139. BarColor = IIf(Close > Open, UpBarColor, DnBarColor);
  140. SetBarFillColor(BarColor);
  141. Plot(Close, "", LineColor, styleCandle);
  142. }
  143. else
  144. Plot(Close, "", colorBlack, styleCandle | styleNoDraw);
  145.  
  146. TFSec = in1Minute * TFMinLong;
  147. TimeFrameSet(TFSec);
  148. TFOpen = Open;
  149. TFHigh = High;
  150. TFLow = Low;
  151. TFClose = Close;
  152. TFBarIndex = BarIndex();
  153. TFLastBarIndex = LastValue(BarIndex());
  154. TimeFrameRestore();
  155.  
  156. TFOpen = TimeFrameExpand(TFOpen, TFSec, expandFirst);
  157. TFHigh = TimeFrameExpand(TFHigh, TFSec, expandFirst);
  158. TFLow = TimeFrameExpand(TFLow, TFSec, expandFirst);
  159. TFClose = TimeFrameExpand(TFClose, TFSec, expandFirst);
  160. TFBarIndex = TimeFrameExpand(TFBarIndex, TFSec, expandLast + 1);
  161. TFLastBarIndex = TimeFrameExpand(TFLastBarIndex, TFSec, expandLast + 1);
  162.  
  163. CandleTop = Max(TFOpen, TFClose);
  164. CandleBottom = Min(TFOpen, TFClose);
  165. //================================================== ==========================
  166. // GFX LOW-LEVEL GRAPHICS SECTION.
  167. // DRAWING THE LONG TIMEFRAME CANDLESTICK BARS:
  168. //================================================== ==========================
  169. if(OnLTFBars)
  170. {
  171. GfxSetOverlayMode(1);
  172. AllVisibleBars = GetVisibleBarCount();
  173. fvb = Status("firstvisiblebar");
  174. ChartWidth = GfxConvertBarToPixelX(AllVisibleBars );
  175. PixBar = ChartWidth / AllVisibleBars;
  176. Adjust = Pixbar * 0.35;
  177. TFMinutes = TFMinLong / TFMinShort;
  178. NewTFBar = IIf(TFBarIndex != Ref(TFBarIndex, -1), 1, 0);
  179. BarInd = BarIndex();
  180. TFLastBarIndex = LastValue(TFLastBarIndex);
  181.  
  182. // DRAW BAR HISTORY AND THE CURRENT BAR:
  183. for(i = 0; i < AllVisibleBars; i++)
  184. {
  185. x1 = GfxConvertBarToPixelX(i) * NewTFBar[i + fvb] - Adjust;
  186. if(BarInd[i + fvb] < TFLastBarIndex AND NewTFBar[i + fvb] == 1)
  187. {
  188. Counter = 0;
  189. for(n = i + 1; NewTFBar[n + fvb] == 0 AND n + fvb < BarCount-1; n++)
  190. Counter++;
  191. x2 = GfxConvertBarToPixelX(i + Counter) * NewTFBar[i + fvb] + 1 + Adjust;
  192. }
  193.  
  194. if(TFBarIndex[i + fvb] == TFLastBarIndex)
  195. x2 = GfxConvertBarToPixelX(i + TFMinutes - 1) * NewTFBar[i + fvb] + 1 + Adjust;
  196.  
  197. y1 = GfxConvertValueToPixelY(CandleTop[i + fvb]);
  198. y2 = GfxConvertValueToPixelY(CandleBottom[i + fvb]);
  199. yH = GfxConvertValueToPixelY(TFHigh[i + fvb]);
  200. yL = GfxConvertValueToPixelY(TFLow[i + fvb]);
  201.  
  202. // Candle Body:
  203. GfxSelectPen(TFLineColor, 0);
  204. FillColor = IIf(TFOpen[i + fvb] < TFClose[i + fvb], TFUpBarColor, TFDnBarColor);
  205. GfxSelectSolidBrush(FillColor);
  206. if(y1 == y2){y1 = y1 - Adjust; y2 = y2 + Adjust; GfxSelectSolidBrush(TFLineColor);}
  207. if(x1 > 0){
  208. GfxRectangle( x1, y1, x2, y2);
  209. // Candle High and Low:
  210. GfxSelectPen(TFLineColor, 2);
  211. GfxMoveTo(x2+(x1-x2)/2, y1);
  212. GfxLineTo(x2+(x1-x2)/2, yH);
  213. GfxMoveTo(x2+(x1-x2)/2, y2);
  214. GfxLineTo(x2+(x1-x2)/2, yL);
  215. RequestTimedRefresh(0);
  216. }
  217. }
  218. }
  219. _SECTION_END();
  220.  
  221.  
  222. _SECTION_BEGIN("Parameters");
  223. LB1= Param("Long LookBack Periods",42,1,60,1);
  224. LB3= Param("Mid LookBack Periods",18,1,30,1);
  225. LB2= Param("Short LookBack Periods",6,1,30,1);
  226.  
  227. _SECTION_END();
  228.  
  229. _SECTION_BEGIN("ResistanceLong");
  230.  
  231. RsColor=ParamColor("LongResColor",colorRed);
  232. BrCount=Param("LongBarLength",65,1,500,1);
  233. for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
  234. {
  235. RsColor[i] = colorBlack;
  236. }
  237.  
  238. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  239. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  240. Temp = Max(High, flowerOpen);
  241. flowerHigh = EMA(Max(Temp, flowerClose),3);
  242. Temp = Min(Low,flowerOpen);
  243. flowerLow = EMA(Min(Temp, flowerClose),3);
  244.  
  245. R=ValueWhen(Cross(MA(flowerClose,LB1),C),HHV(flowerHigh,LB1),-1);
  246. Plot(R,"Resistance",RsColor,ParamStyle("LongResStyle",styleNoTitle|styleLine|styleDots|styleStaircase|styleThick,maskAll));
  247. _SECTION_END();
  248.  
  249. _SECTION_BEGIN("ResistanceMid");
  250. Rs3Color=ParamColor("MidResColor",colorOrange);
  251. BrCount3=Param("MidBarLength",40,1,500,1);
  252. for (i=0;i<BarCount-BrCount3;i++) //hide the line except most recent 10 bars
  253. {
  254. Rs3Color[i] =colorBlack;
  255. }
  256.  
  257. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  258. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  259. Temp = Max(High, flowerOpen);
  260. flowerHigh = EMA(Max(Temp, flowerClose),3);
  261. Temp = Min(Low,flowerOpen);
  262. flowerLow = EMA(Min(Temp, flowerClose),3);
  263.  
  264. RM2=ValueWhen(Cross(EMA(flowerClose,LB3),C),HHV(flowerHigh,LB3),-1);
  265. Plot(RM2,"MidRes",Rs3Color,ParamStyle("MidResStyle",styleLine|styleStaircase|styleNoTitle,maskAll));
  266. _SECTION_END();
  267.  
  268. _SECTION_BEGIN("ResistanceShort");
  269. Rs2Color=ParamColor("ShortResColor",colorCustom12);
  270. BrCount2=Param("ShortResLength",12,1,500,1);
  271. for (i=0;i<BarCount-BrCount2;i++) //hide the line except most recent 10 bars
  272. {
  273. Rs2Color[i] = colorBlack;
  274. }
  275.  
  276. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  277. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  278. Temp = Max(High, flowerOpen);
  279. flowerHigh = EMA(Max(Temp, flowerClose),3);
  280. Temp = Min(Low,flowerOpen);
  281. flowerLow = EMA(Min(Temp, flowerClose),3);
  282.  
  283. RM=ValueWhen(Cross(TEMA(flowerClose,LB2),C),HHV(flowerHigh,LB2),-1);
  284. Plot(RM,"ShortRes",Rs2Color,ParamStyle("ShortResStyle",styleDashed|styleThick|styleNoTitle|styleStaircase,maskAll));
  285. _SECTION_END();
  286.  
  287.  
  288.  
  289.  
  290. _SECTION_BEGIN("SupportLong");
  291. Sup1Color=ParamColor("LongSupColor",colorGreen);
  292. BrCount4=Param("LongSupBarLength",65,1,500,1);
  293. for (i=0;i<BarCount-BrCount4;i++) //hide the line except most recent 10 bars
  294. {
  295. Sup1Color[i] =colorBlack;
  296. }
  297.  
  298. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  299. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  300. Temp = Max(High, flowerOpen);
  301. flowerHigh = EMA(Max(Temp, flowerClose),3);
  302. Temp = Min(Low,flowerOpen);
  303. flowerLow = EMA(Min(Temp, flowerClose),3);
  304.  
  305. S=ValueWhen(Cross(MA(flowerClose,LB1),C),LLV(flowerLow,LB1),-1);
  306. Plot(s,"Support",Sup1Color,ParamStyle("SupStyle",styleLine|styleDots|styleStaircase|styleThick|styleNoTitle,maskAll));
  307. _SECTION_END();
  308.  
  309. _SECTION_BEGIN("SupportMid");
  310. Sup3Color=ParamColor("MidSupColor",colorBlue);
  311. BrCount6=Param("MidBarLength",40,1,500,1);
  312. for (i=0;i<BarCount-BrCount6;i++) //hide the line except most recent 10 bars
  313. {
  314. Sup3Color[i] =colorBlack;
  315. }
  316.  
  317. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  318. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  319. Temp = Max(High, flowerOpen);
  320. flowerHigh = EMA(Max(Temp, flowerClose),3);
  321. Temp = Min(Low,flowerOpen);
  322. flowerLow = EMA(Min(Temp, flowerClose),3);
  323.  
  324. SM2=ValueWhen(Cross(EMA(flowerClose,LB3),C),LLV(flowerLow,LB3),-1);
  325. Plot(SM2,"MidSup",Sup3Color,ParamStyle("MidSupStyle",styleLine|styleStaircase|styleNoTitle,maskAll));
  326. _SECTION_END();
  327.  
  328. _SECTION_BEGIN("SupportShort");
  329. Sup2Color=ParamColor("ShortSupColor",colorPink);
  330. BrCount5=Param("ShortSupBarLength",12,1,500,1);
  331. for (i=0;i<BarCount-BrCount5;i++) //hide the line except most recent 10 bars
  332. {
  333. Sup2Color[i] =colorBlack;
  334. }
  335.  
  336.  
  337. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  338. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  339. Temp = Max(High, flowerOpen);
  340. flowerHigh = EMA(Max(Temp, flowerClose),3);
  341. Temp = Min(Low,flowerOpen);
  342. flowerLow = EMA(Min(Temp, flowerClose),3);
  343.  
  344. SM=ValueWhen(Cross(TEMA(flowerClose,LB2),C),LLV(flowerLow,LB2),-1);
  345. Plot(SM,"ShortSup",Sup2Color,ParamStyle("ShortSupStyle",styleDashed|styleThick|styleNoTitle|styleStaircase,maskAll));
  346. _SECTION_END();
  347.  
  348. TimeFrameSet(inDaily);
  349. DayHigh = LastValue(H);
  350. DayLow = LastValue(L);
  351. TimeFrameRestore();
  352.  
  353.  
  354.  
  355. prev=AMA2(C,1,0);
  356. d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
  357. IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
  358. a=Cross(Close,d);
  359. b=Cross(d,Close);
  360. state=IIf(BarsSince(a)<BarsSince(b),1,0);
  361. s=state>Ref(state,-1);
  362. ss=state<Ref(state,-1);
  363. sss=state==Ref(state,-1);
  364. col=IIf(state == 1 ,51,IIf(state ==0,4,1));
  365. Buy = s;
  366. Sell = ss;
  367. shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
  368. PlotShapes( shapeUpArrow * s ,colorBlue,0,L, Offset=s);
  369. PlotShapes( shapeHollowCircle * s ,colorOrange,0,L, Offset=s-12);
  370.  
  371.  
  372. PlotShapes( shapeHollowCircle *ss ,colorPink,0,H, Offset=s);
  373. PlotShapes( shapeDownArrow *ss ,colorBlack,0,H, Offset=s+12);
  374.  
  375. PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));
  376. PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
  377. PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);
  378. PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15);
  379. PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
  380. PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);
  381. PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
  382.  
  383. //WriteIf(s,"EXIT all Short positions\nif trading long positions, enter long Now-\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(L+.75*ATR(5),1.4)+" ,","");
  384. //WriteIf(ss,"exit all long positions today with a Market On Close (MOC) order\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(Ref(H+.75*ATR(5), -1),1.4)+",","");
  385. //WriteIf( sss ,"No trading signals today.","") ;
  386.  
  387.  
  388. dist = 0.8*ATR(10);
  389. dist1 = 2*ATR(10);
  390. for( i = 0; i < BarCount; i++ )
  391. {
  392. if( Buy[i] )
  393. {
  394. }
  395. if( Sell[i] )
  396. {
  397. }
  398. }
  399.  
  400.  
  401. Filter = s OR sss OR sss ;
  402. AddColumn(C,"close",1.2);
  403. AddColumn( IIf( s, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (s,colorYellow, colorPink ));
  404. AddColumn( IIf( Ss, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (Ss,colorPink, colorWhite ));
  405. AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));
  406.  
  407. _SECTION_BEGIN("Isfandi Technical Viewer");
  408.  
  409. DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
  410. DayL = TimeFrameGetPrice("L", inDaily, -1);//low
  411. DayC = TimeFrameGetPrice("C", inDaily, -1);//close
  412. DayO = TimeFrameGetPrice("O", inDaily);// current day open
  413. HiDay = TimeFrameGetPrice("H", inDaily);
  414. LoDay = TimeFrameGetPrice("L", inDaily);
  415. PP = (DayH + DayL + DayO + DayO) / 4 ;
  416. R1 = (2 * PP) - DayL;
  417. S1 = (2 * PP) - DayH;
  418. R2 = PP + R1 - S1;
  419. S2 = PP + S1 - R1;
  420. R3 = R2 + (R1 - PP);
  421. S3 = S2 - (PP - S1);
  422. //-Paint Background
  423.  
  424. GfxSelectSolidBrush( colorWhite);
  425. GfxSelectPen( colorRed);
  426. GfxRoundRect( 2, 0, 930, 51, 30, 32);
  427. GfxSetBkMode( 1 );
  428.  
  429. GfxSelectFont("Arial", 8, 900);
  430. // OTHER INDICATOR
  431. MOMETUM =RSI(14);
  432. radius = 0.1 * Status("pxheight"); // get pixel height of the chart and use 45% for pie chart radius
  433. textoffset = 0.1 * radius;
  434. GfxSelectFont("Arial", 9, 500, True );
  435. GfxSelectFont("Arial", 9 );
  436. GfxSetTextColor( colorLime);
  437. GfxTextOut( "R1 =" + R1, textoffset + 740, 32 );
  438. GfxSetTextColor( colorLime );
  439. GfxTextOut( "R2 = " +R2, textoffset + 820, 32);
  440. GfxSetTextColor( colorBlue );
  441. GfxTextOut( "PP = " +PP, textoffset + 660, 32);
  442. GfxSetTextColor( colorOrange );
  443. GfxTextOut( "S1 = " +S1, textoffset + 500, 32);
  444. GfxSetTextColor( colorRed );
  445. GfxTextOut( "S2 = " +S2, textoffset + 580, 32);
  446. GfxSelectFont("Arial", 9 );
  447. _SECTION_END();
  448. //-Paint Background
  449.  
  450. GfxSelectSolidBrush( colorWhite);
  451. GfxSelectPen( colorPink);
  452. GfxRoundRect( 500, 1, 930, 27, 32, 32 );
  453. GfxSetBkMode( 1 );
  454.  
  455. GfxSelectFont("Arial", 8, 900);
  456.  
  457. _SECTION_BEGIN("Magnified Market Price");
  458. FS=Param("Font Size",12,30,100,1);
  459. GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
  460. GfxSetBkMode( colorGreen );
  461. GfxSetTextColor( ParamColor("Color",colorGreen) );
  462. Hor=Param("Horizontal Position",650,800,800,800);
  463. Ver=Param("Vertical Position",5,27,27,27);
  464. GfxTextOut("CMP: "+C,Hor , Ver );
  465. YC=TimeFrameGetPrice("C",inDaily,-1);
  466. DD=Prec(C-YC,2);
  467. xx=Prec((DD/YC)*100,2);
  468. GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
  469. GfxSetBkMode( colorGreen );
  470. GfxSetTextColor(ParamColor("Color",colorGreen) );
  471. GfxTextOut("change ("+DD+") ("+xx+"%)", Hor+130, Ver+0 );
  472. _SECTION_END();
  473. _SECTION_BEGIN("system Ticker");
  474. function GetSecondNum()
  475. {
  476. Time = Now( 4 );
  477. Seconds = int( Time % 100 );
  478. Minutes = int( Time / 100 % 100 );
  479. Hours = int( Time / 10000 % 100 );
  480. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  481. return SecondNum;
  482. }
  483. RequestTimedRefresh( 1 );
  484. //----------------------------------------------------------------------------
  485. //----------------------------------------------------------------------------
  486. TimeFrame = Interval();
  487. SecNumber = GetSecondNum();
  488. Newperiod = SecNumber % TimeFrame == 0;
  489. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  490. SecsToGo = TimeFrame - SecsLeft;
  491.  
  492. x=Param(" xposn",540,100,1000,1000);
  493. y=Param(" yposn",7,40,1000,1);
  494.  
  495. GfxSelectSolidBrush( colorWhite );
  496. GfxSelectPen( colorWhite, 2 );
  497. if ( NewPeriod )
  498. {
  499. GfxSelectSolidBrush( colorWhite );
  500. GfxSelectPen( colorWhite, 2 );
  501. }
  502. GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
  503. GfxSetBkMode(1);
  504. GfxSelectFont( "Arial", 9, 700, False );
  505. GfxSetTextColor( colorBlue );
  506. GfxTextOut( "" +SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
  507. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement