Advertisement
saisri

2 time frame at atime

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