Advertisement
saisri

sr c new

Feb 2nd, 2013
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.13 KB | None | 0 0
  1. _SECTION_BEGIN("Background");
  2. tchoice=Param("Title Selection ",2,1,2,1);
  3.  
  4. Plot(C, "", IIf(O>=C, colorWhite, colorBrightGreen), ParamStyle("Price Style",styleCandle,maskPrice));
  5. //////////////////////////////////////////////////////////////////
  6.  
  7. _SECTION_BEGIN("Background text");
  8. SetChartBkColor(colorBlack);
  9. strWeekday = StrMid("---sunday---Monday--TuesdayWednesday-Thursday--Friday--Saturday", SelectedValue(DayOfWeek())*9,9);
  10. GraphXSpace=Param("GraphXSpace",0,-55,200,1);
  11. C13=Param("fonts",20,10,30,1 );
  12. C14=Param("left-right",2.1,1.0,5.0,0.1 );
  13. C15=Param("up-down",12,1,20,1 );
  14. Miny = Status("axisminy");
  15. Maxy = Status("axismaxy");
  16. lvb = Status("lastvisiblebar");
  17. fvb = Status("firstvisiblebar");
  18. pxwidth = Status("pxwidth");
  19. pxheight = Status("pxheight");
  20. GfxSetBkMode(transparent=1);
  21. GfxSetOverlayMode(1);
  22. GfxSelectFont("Candara", Status("pxheight")/C13 );
  23. GfxSetTextAlign( 6 );
  24. GfxSetTextColor( ColorRGB (217,217,213));
  25. GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
  26. GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
  27. GfxSetTextColor( ColorRGB (103,103,103));
  28. GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
  29. GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
  30. GfxSetTextColor( ColorRGB (103,103,103));
  31. GfxTextOut( "Saisri2320", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
  32. GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
  33. _SECTION_END();
  34.  
  35.  
  36.  
  37. _SECTION_BEGIN("ZZZ Zig type");
  38. // Amibroker AFL code by Edward Pottasch, Oct 2012
  39. // alternative ZIG type function based on the ATR and VSTOP functions
  40. // added multiple timeframes. Maximum timeframe set to 1440 minutes
  41. x=xx=BarIndex();
  42. tc="ZIG";//ParamList("Display Mode","Zig|VSTOP|Zig&VSTOP",0);
  43. disp=1;//ParamToggle("Display labels","Off|On",1);
  44. tf=Param("Time Frame (min)",5,1,1440,1);
  45. tfrm=in1Minute*tf;
  46. perBull=20;//Param("perBull",20,1,150,1);
  47. perBear=20;//Param("perBear",20,1,150,1);
  48. multBull=2;//Param("multBull",2,0.05,4,0.05);
  49. multBear=2;//Param("multBear",2,0.05,4,0.05);
  50.  
  51. TimeFrameSet(tfrm);
  52. function vstop_func(trBull,trBear)
  53. {
  54. trailArray[0]=C[0];
  55. for(i=1;i<BarCount;i++)
  56. {
  57. prev=trailArray[i-1];
  58.  
  59. if(C[i]>prev AND C[i-1]>prev)
  60. {
  61. trailArray[i]=Max(prev,C[i]-trBull[i]);
  62. }
  63. else if(C[i]<prev AND C[i-1]< prev)
  64. {
  65. trailArray[i]=Min(prev,C[i]+trBear[i]);
  66. }
  67. else if (C[i]>prev)
  68. {
  69. trailArray[i]=C[i]-trBull[i];
  70. }
  71. else
  72. {
  73. trailArray[i]=C[i]+trBear[i];
  74. }
  75. }
  76. return trailArray;
  77. }
  78.  
  79. trBull=multBull*ATR(perBull);
  80. trBear=multBear*ATR(perBear);
  81. trailArray = vstop_func(trBull,trBear);
  82. ts=IIf(trailArray>C,trailArray,Null);
  83. tl=IIf(trailArray<C,trailArray,Null);
  84. TimeFrameRestore();
  85.  
  86. ts=TimeFrameExpand(ts,tfrm,expandLast);
  87. tl=TimeFrameExpand(tl,tfrm,expandLast);
  88.  
  89. //GraphXSpace=5;
  90. //SetChartOptions(0, chartShowDates);
  91. //SetBarFillColor(IIf(C>O,ParamColor("Candle Up Color", colorBrightGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
  92. //Plot(C,"Price",IIf(C>O,ParamColor("Shadow Up Color", colorBrightGreen),IIf(C<=O,ParamColor("Shadow Color", colorRed),colorLightGrey)),64,0,0,0,0);
  93.  
  94. lll=LLV(L,BarsSince(!IsEmpty(tl)));lll=IIf(ts,lll,Null);llls=lll;
  95. ttt1=IIf((!IsEmpty(ts) AND IsEmpty(Ref(ts,1))) OR BarIndex()==BarCount-1,1,Null);
  96. ttt=ValueWhen(ttt1,lll,0);ttt=IIf(ts,ttt,Null);ttt=IIf(ttt1,Ref(ttt,-1),ttt);
  97. tr=L==ttt;lll=Sum(tr,BarsSince(!IsEmpty(tl)));
  98. qqq=ValueWhen(ttt1,lll,0);qqq=IIf(ts,qqq,Null);qqq=IIf(ttt1,Ref(qqq,-1),qqq);tr=tr AND lll==qqq;
  99. tr=IIf((!IsEmpty(ts) AND IsEmpty(Ref(ts,1)) AND IsEmpty(Ref(ts,-1))),1,tr);//exception
  100. hhh=HHV(H,BarsSince(!IsEmpty(ts)));hhh=IIf(tl,hhh,Null);hhhs=hhh;
  101. ttt1=IIf((!IsEmpty(tl) AND IsEmpty(Ref(tl,1))) OR BarIndex()==BarCount-1,1,Null);
  102. ttt=ValueWhen(ttt1,hhh,0);ttt=IIf(tl,ttt,Null);ttt=IIf(ttt1,Ref(ttt,-1),ttt);
  103. pk=H==ttt;hhh=Sum(pk,BarsSince(!IsEmpty(ts)));
  104. sss=ValueWhen(ttt1,hhh,0);sss=IIf(tl,sss,Null);sss=IIf(ttt1,Ref(sss,-1),sss);pk=pk AND hhh==sss;
  105. pk=IIf((!IsEmpty(tl) AND IsEmpty(Ref(tl,1)) AND IsEmpty(Ref(tl,-1))),1,pk);//exception
  106.  
  107. px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
  108. px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
  109. px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
  110. ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
  111. ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
  112. ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
  113.  
  114. switch(tc)
  115. {
  116. case("ZIG"):
  117. aa1=IIf(px0>tx1,(ph0-tl1)/(px0-tx1),0);aa1=IIf(pk,Ref(aa1,-1),aa1);ls1=aa1*(xx-tx1)+tl1;
  118. bb1=IIf(px0>tx1 AND px1<tx1,1,0);bb1=bb1+Ref(bb1,-1);bb1=IIf(bb1,1,0);ls1=IIf(bb1,ls1,Null);
  119. aa1=IIf(tx0>px1,(tl0-ph1)/(tx0-px1),0);aa1=IIf(tr,Ref(aa1,-1),aa1);ls1=aa1*(xx-px1)+ph1;
  120. bb1=IIf(tx0>px1 AND tx1<px1,1,0);bb1=bb1+Ref(bb1,-1);bb1=IIf(bb1,1,0);ls1=IIf(bb1,ls1,Null);
  121. break;
  122.  
  123. case("VSTOP"):
  124. Plot(ts,"\ntrailShort",colorRed,styleLine,0,0,0,1,1);
  125. Plot(llls,"",colorRed,styleDashed,0,0,0,1,1);
  126. Plot(tl,"\ntrailLong",colorGreen,styleLine,0,0,0,1,1);
  127. Plot(hhhs,"",colorGreen,styleDashed,0,0,0,1,1);
  128. break;
  129. case("ZIG&VSTOP"):
  130. aa1=IIf(px0>tx1,(ph0-tl1)/(px0-tx1),0);aa1=IIf(pk,Ref(aa1,-1),aa1);ls1=aa1*(xx-tx1)+tl1;
  131. bb1=IIf(px0>tx1 AND px1<tx1,1,0);bb1=bb1+Ref(bb1,-1);bb1=IIf(bb1,1,0);ls1=IIf(bb1,ls1,Null);
  132. Plot(ls1,"",colorBlue,styleLine,0,0,0,2,3);
  133. aa1=IIf(tx0>px1,(tl0-ph1)/(tx0-px1),0);aa1=IIf(tr,Ref(aa1,-1),aa1);ls1=aa1*(xx-px1)+ph1;
  134. bb1=IIf(tx0>px1 AND tx1<px1,1,0);bb1=bb1+Ref(bb1,-1);bb1=IIf(bb1,1,0);ls1=IIf(bb1,ls1,Null);
  135. Plot(ls1,"",colorOrange,styleLine,0,0,0,2,3);
  136. Plot(ts,"\ntrailShort",colorRed,styleLine,0,0,0,1,1);
  137. Plot(llls,"",colorRed,styleDashed,0,0,0,1,1);
  138. Plot(tl,"\ntrailLong",colorGreen,styleLine,0,0,0,1,1);
  139. Plot(hhhs,"",colorGreen,styleDashed,0,0,0,1,1);
  140. break;
  141. }
  142.  
  143. PlotShapes(shapeSmallCircle*tr,colorGreen,0,L,-10);
  144. PlotShapes(shapeSmallCircle*pk,colorRed,0,H,10);
  145.  
  146. qq=Interval()/60;
  147. if(qq < 60){tf=" min";tt=qq;}
  148. else if(qq >= 60 AND qq < 1440){tf=" hrs";tt=qq/60;}
  149. else if(qq >= 1440){tf=" days";tt=(qq/60)/24;}
  150. qq=Max(tfrm/60,Interval()/60);
  151. if(qq < 60){tfa=" min";tta=qq;}
  152. else if(qq >= 60 AND qq < 1440){tfa=" hrs";tta=qq/60;}
  153. else if(qq >= 1440){tfa=" days";tta=(qq/60)/24;}
  154.  
  155. //Title = Name() +
  156. //"\nChart TF: " + tt + tf +
  157. //"\nZig TF: " + tta + tfa;
  158.  
  159. dxhm=14;dxlm=10;dxh=0;dxl=0;dyhm=5;dylm=3;dyh=18;dyl=29;hm=30;lm=30;
  160. function GetVisibleBarCount()
  161. {
  162. lvb=Status("lastvisiblebar");
  163. fvb=Status("firstvisiblebar");
  164. return Min(lvb-fvb,BarCount-fvb);
  165. }
  166. function GfxConvertPixelsToBarX(Pixels)
  167. {
  168. lvb=Status("lastvisiblebar");
  169. fvb=Status("firstvisiblebar");
  170. pxchartleft=Status("pxchartleft");
  171. pxchartwidth=Status("pxchartwidth");
  172. fac=pxchartwidth/Pixels;
  173. bar=(lvb-fvb)/fac;
  174. return bar;
  175. }
  176. function GfxConvertPixelToValueY(Pixels)
  177. {
  178. local Miny,Maxy,pxchartbottom,pxchartheight;
  179. Miny=Status("axisminy");
  180. Maxy=Status("axismaxy");
  181. pxchartbottom=Status("pxchartbottom");
  182. pxchartheight=Status("pxchartheight");
  183. fac=pxchartheight/Pixels;
  184. Value=(Maxy-Miny)/fac;
  185. return Value;
  186. }
  187. if(disp)
  188. {
  189. ll=tr AND tl1<tl2;
  190. hl=tr AND tl1>tl2;
  191. hh=pk AND ph1>ph2;
  192. lh=pk AND ph1<ph2;
  193. dt=pk AND ph1==ph2;
  194. db=tr AND tl1==tl2;
  195.  
  196. miny=Status("axisminy");
  197. maxy=Status("axismaxy");
  198. AllVisibleBars=GetVisibleBarCount();
  199. fvb=Status("firstvisiblebar");
  200. LowMargin=Miny+GfxConvertPixelToValueY(lm);
  201. HighMargin=Maxy-GfxConvertPixelToValueY(hm);
  202. dyllm=GfxConvertPixelToValueY(dylm);
  203. dyhhm=GfxConvertPixelToValueY(dyhm);
  204. dyll=GfxConvertPixelToValueY(dyl);
  205. dyhh=GfxConvertPixelToValueY(dyh);
  206. dxllm=GfxConvertPixelsToBarX(dxlm);
  207. dxhhm=GfxConvertPixelsToBarX(dxhm);
  208. dxll=GfxConvertPixelsToBarX(dxl);
  209. dxhh=GfxConvertPixelsToBarX(dxh);
  210.  
  211. for(i=0;i<AllVisibleBars;i++)
  212. {
  213. if(ll[i+fvb] AND L[i+fvb]>LowMargin) PlotText("LL",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
  214. if(ll[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("LL",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorWhite,colorBlack);
  215. if(hl[i+fvb] AND L[i+fvb]>LowMargin) PlotText("HL",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
  216. if(hl[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("HL",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorWhite,colorBlack);
  217. if(db[i+fvb] AND L[i+fvb]>LowMargin) PlotText("DB",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
  218. if(db[i+fvb] AND L[i+fvb]<=LowMargin) PlotText("DB",i+fvb+dxll+dxllm,L[i+fvb]-dyllm,colorWhite,colorBlack);
  219. if(hh[i+fvb] AND H[i+fvb]<HighMargin) PlotText("HH",i+fvb+dxhh,H[i+fvb]+dyhh,colorWhite,colorBlack);
  220. if(hh[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("HH",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
  221. if(lh[i+fvb] AND H[i+fvb]<HighMargin) PlotText("LH",i+fvb+dxhh,H[i+fvb]+dyhh,colorWhite,colorBlack);
  222. if(lh[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("LH",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
  223. if(dt[i+fvb] AND H[i+fvb]<HighMargin) PlotText("DT",i+fvb+dxhh,H[i+fvb]+dyhh,colorWhite,colorBlack);
  224. if(dt[i+fvb] AND H[i+fvb]>=HighMargin) PlotText("DT",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
  225. }
  226. }
  227. _SECTION_END();
  228.  
  229. _SECTION_BEGIN( "RAJA" );
  230. /*RAJA*/
  231. "========";
  232. H1 = SelectedValue( TimeFrameGetPrice( "H", inDaily, -1 ) );
  233. L1 = SelectedValue( TimeFrameGetPrice( "L", inDaily, -1 ) );
  234. C1 = SelectedValue( TimeFrameGetPrice( "C", inDaily, -1 ) );
  235. H2 = SelectedValue( TimeFrameGetPrice( "H", inDaily, 0 ) );
  236. L2 = SelectedValue( TimeFrameGetPrice( "L", inDaily, 0 ) );
  237. O1 = SelectedValue( TimeFrameGetPrice( "open", inDaily, 0 ) );
  238.  
  239. /*PIVOT Calculation*/
  240. D1 = ( H1 - L1 );
  241. D2 = ( H2 - L2 );
  242. F1 = D1 * 0.433;
  243. F2 = D1 * 0.766;
  244. F3 = D1 * 1.35;
  245.  
  246. F4 = 0;
  247.  
  248. if ( D2 <= F1 )
  249. F4 = F1;
  250. else
  251. if ( D2 <= F2 )
  252. F4 = F2;
  253. else
  254. F4 = F3;
  255.  
  256. p = ( H1 + L1 + C1 ) / 3;
  257.  
  258. s1 = ( H1 );
  259.  
  260. r1 = ( L1 );
  261.  
  262. r2 = SelectedValue( L2 );
  263.  
  264. s2 = SelectedValue( H2 );
  265.  
  266. //CONDITION
  267.  
  268. S = ( C > p );
  269.  
  270. SS = ( C < P );
  271.  
  272. //Plot
  273.  
  274. Plot ( p , "PIVOT", 25, 1 );PlotText( "PIVOT" , BarCount-25, p+0, 25 );
  275.  
  276. Plot ( r1, "PRE_LOW", 28, 1 );PlotText( "PreDay LOW" , BarCount-25, r1+0, 28 );
  277.  
  278. Plot ( s1, "PRE_HIGH", 28, 1 );PlotText( "PreDay HIGH" , BarCount-25, s1+0, 28 );
  279.  
  280.  
  281.  
  282.  
  283. _SECTION_BEGIN("Parameters");
  284. LB1= Param("Long LookBack Periods",42,1,60,1);
  285. LB3= Param("Mid LookBack Periods",18,1,30,1);
  286. LB2= Param("Short LookBack Periods",6,1,30,1);
  287.  
  288. _SECTION_END();
  289.  
  290. _SECTION_BEGIN("ResistanceLong");
  291.  
  292. RsColor=ParamColor("LongResColor",colorRed);
  293. BrCount=Param("LongBarLength",65,1,500,1);
  294. for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
  295. {
  296. RsColor[i] = colorRed;
  297. }
  298.  
  299. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  300. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  301. Temp = Max(High, flowerOpen);
  302. flowerHigh = EMA(Max(Temp, flowerClose),3);
  303. Temp = Min(Low,flowerOpen);
  304. flowerLow = EMA(Min(Temp, flowerClose),3);
  305.  
  306. R=ValueWhen(Cross(MA(flowerClose,LB1),C),HHV(flowerHigh,LB1),-1);
  307. Plot(R,"Resistance",RsColor,ParamStyle("LongResStyle",styleNoTitle|styleLine|styleDots|styleStaircase|styleThick,maskAll));
  308. _SECTION_END();
  309.  
  310. _SECTION_BEGIN("ResistanceMid");
  311. Rs3Color=ParamColor("MidResColor",colorOrange);
  312. BrCount3=Param("MidBarLength",40,1,500,1);
  313. for (i=0;i<BarCount-BrCount3;i++) //hide the line except most recent 10 bars
  314. {
  315. Rs3Color[i] =colorOrange;
  316. }
  317.  
  318. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  319. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  320. Temp = Max(High, flowerOpen);
  321. flowerHigh = EMA(Max(Temp, flowerClose),3);
  322. Temp = Min(Low,flowerOpen);
  323. flowerLow = EMA(Min(Temp, flowerClose),3);
  324.  
  325. RM2=ValueWhen(Cross(EMA(flowerClose,LB3),C),HHV(flowerHigh,LB3),-1);
  326. Plot(RM2,"MidRes",Rs3Color,ParamStyle("MidResStyle",styleLine|styleStaircase|styleNoTitle,maskAll));
  327. _SECTION_END();
  328.  
  329. _SECTION_BEGIN("ResistanceShort");
  330. Rs2Color=ParamColor("ShortResColor",colorCustom12);
  331. BrCount2=Param("ShortResLength",12,1,500,1);
  332. for (i=0;i<BarCount-BrCount2;i++) //hide the line except most recent 10 bars
  333. {
  334. Rs2Color[i] = colorBlack;
  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. RM=ValueWhen(Cross(TEMA(flowerClose,LB2),C),HHV(flowerHigh,LB2),-1);
  345. Plot(RM,"ShortRes",Rs2Color,ParamStyle("ShortResStyle",styleDashed|styleThick|styleNoTitle|styleStaircase,maskAll));
  346. _SECTION_END();
  347.  
  348.  
  349.  
  350.  
  351. _SECTION_BEGIN("SupportLong");
  352. Sup1Color=ParamColor("LongSupColor",colorGreen);
  353. BrCount4=Param("LongSupBarLength",65,1,500,1);
  354. for (i=0;i<BarCount-BrCount4;i++) //hide the line except most recent 10 bars
  355. {
  356. Sup1Color[i] =colorGreen;
  357. }
  358.  
  359. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  360. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  361. Temp = Max(High, flowerOpen);
  362. flowerHigh = EMA(Max(Temp, flowerClose),3);
  363. Temp = Min(Low,flowerOpen);
  364. flowerLow = EMA(Min(Temp, flowerClose),3);
  365.  
  366. S=ValueWhen(Cross(MA(flowerClose,LB1),C),LLV(flowerLow,LB1),-1);
  367. Plot(s,"Support",Sup1Color,ParamStyle("SupStyle",styleLine|styleDots|styleStaircase|styleThick|styleNoTitle,maskAll));
  368. _SECTION_END();
  369.  
  370. _SECTION_BEGIN("SupportMid");
  371. Sup3Color=ParamColor("MidSupColor",colorBlue);
  372. BrCount6=Param("MidBarLength",40,1,500,1);
  373. for (i=0;i<BarCount-BrCount6;i++) //hide the line except most recent 10 bars
  374. {
  375. Sup3Color[i] =colorBlue;
  376. }
  377.  
  378. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  379. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  380. Temp = Max(High, flowerOpen);
  381. flowerHigh = EMA(Max(Temp, flowerClose),3);
  382. Temp = Min(Low,flowerOpen);
  383. flowerLow = EMA(Min(Temp, flowerClose),3);
  384.  
  385. SM2=ValueWhen(Cross(EMA(flowerClose,LB3),C),LLV(flowerLow,LB3),-1);
  386. Plot(SM2,"MidSup",Sup3Color,ParamStyle("MidSupStyle",styleLine|styleStaircase|styleNoTitle,maskAll));
  387. _SECTION_END();
  388.  
  389. _SECTION_BEGIN("SupportShort");
  390. Sup2Color=ParamColor("ShortSupColor",colorPink);
  391. BrCount5=Param("ShortSupBarLength",12,1,500,1);
  392. for (i=0;i<BarCount-BrCount5;i++) //hide the line except most recent 10 bars
  393. {
  394. Sup2Color[i] =colorBlack;
  395. }
  396.  
  397.  
  398. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  399. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  400. Temp = Max(High, flowerOpen);
  401. flowerHigh = EMA(Max(Temp, flowerClose),3);
  402. Temp = Min(Low,flowerOpen);
  403. flowerLow = EMA(Min(Temp, flowerClose),3);
  404.  
  405. SM=ValueWhen(Cross(TEMA(flowerClose,LB2),C),LLV(flowerLow,LB2),-1);
  406. Plot(SM,"ShortSup",Sup2Color,ParamStyle("ShortSupStyle",styleDashed|styleThick|styleNoTitle|styleStaircase,maskAll));
  407. _SECTION_END();
  408.  
  409. TimeFrameSet(inDaily);
  410. DayHigh = LastValue(H);
  411. DayLow = LastValue(L);
  412. TimeFrameRestore();
  413.  
  414.  
  415.  
  416. prev=AMA2(C,1,0);
  417. 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))),
  418. 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));
  419. a=Cross(Close,d);
  420. b=Cross(d,Close);
  421. state=IIf(BarsSince(a)<BarsSince(b),1,0);
  422. s=state>Ref(state,-1);
  423. ss=state<Ref(state,-1);
  424. sss=state==Ref(state,-1);
  425. col=IIf(state == 1 ,51,IIf(state ==0,4,1));
  426. Buy = s;
  427. Sell = ss;
  428. shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
  429. PlotShapes( shapeUpArrow * s ,colorBlue,0,L, Offset=s);
  430. PlotShapes( shapeHollowCircle * s ,colorOrange,0,L, Offset=s-12);
  431.  
  432.  
  433. PlotShapes( shapeHollowCircle *ss ,colorPink,0,H, Offset=s);
  434. PlotShapes( shapeDownArrow *ss ,colorYellow,0,H, Offset=s+12);
  435.  
  436. PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));
  437. PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
  438. PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);
  439. PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15);
  440. PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
  441. PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);
  442. PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
  443.  
  444. //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)+" ,","");
  445. //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)+",","");
  446. //WriteIf( sss ,"No trading signals today.","") ;
  447.  
  448.  
  449. dist = 0.8*ATR(10);
  450. dist1 = 2*ATR(10);
  451. for( i = 0; i < BarCount; i++ )
  452. {
  453. if( Buy[i] )
  454. {
  455. }
  456. if( Sell[i] )
  457. {
  458. }
  459. }
  460.  
  461.  
  462. Filter = s OR sss OR sss ;
  463. AddColumn(C,"close",1.2);
  464. AddColumn( IIf( s, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (s,colorYellow, colorPink ));
  465. AddColumn( IIf( Ss, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (Ss,colorPink, colorWhite ));
  466. AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));
  467. //---------------Color------------------------
  468. per1=6;
  469. per2=2;
  470. Om=MA(O,per1);
  471. hm=MA(H,per1);
  472. lm=MA(L,per1);
  473. Cm=MA(C,per1);
  474.  
  475. HACLOSE=(Om+Hm+Lm+Cm)/4;
  476. HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
  477. HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
  478. HaLow = Min( Lm, Min( HaClose, HaOpen ) );
  479.  
  480. Of=MA(Haopen,per2);
  481. Cf=MA(Haclose,per2);
  482. Lf=IIf(haOpen<haClose,MA(Halow,per2),MA(Hahigh,per2));
  483. Hf=IIf(haOpen<haClose,MA(Hahigh,per2),MA(Halow,per2));
  484. //Color = IIf( Cf > Of, colorGreen, colorRed );
  485.  
  486.  
  487. //----------------------------------------------------
  488.  
  489.  
  490. TrailStop = HHV( C - 2 * ATR(10), 15 );
  491. ProfitTaker = EMA( H, 13 ) + 2 * ATR(10);
  492.  
  493.  
  494. /* **********************************
  495.  
  496. Code to automatically identify pivots
  497.  
  498. ********************************** */
  499.  
  500. // -- what will be our lookback range for the hh and ll?
  501. farback=140; //How Far back to go
  502. nBars = 12; //Number of bars
  503.  
  504. // -- Create 0-initialized arrays the size of barcount
  505.  
  506. aHPivs = H - H;
  507.  
  508. aLPivs = L - L;
  509.  
  510. // -- More for future use, not necessary for basic plotting
  511.  
  512. aHPivHighs = H - H;
  513.  
  514. aLPivLows = L - L;
  515.  
  516. aHPivIdxs = H - H;
  517.  
  518. aLPivIdxs = L - L;
  519.  
  520. nHPivs = 0;
  521.  
  522. nLPivs = 0;
  523.  
  524. lastHPIdx = 0;
  525.  
  526. lastLPIdx = 0;
  527.  
  528. lastHPH = 0;
  529.  
  530. lastLPL = 0;
  531.  
  532. curPivBarIdx = 0;
  533.  
  534. // -- looking back from the current bar, how many bars
  535.  
  536. // back were the hhv and llv values of the previous
  537.  
  538. // n bars, etc.?
  539.  
  540. aHHVBars = HHVBars(H, nBars);
  541.  
  542. aLLVBars = LLVBars(L, nBars);
  543.  
  544. aHHV = HHV(H, nBars);
  545.  
  546. aLLV = LLV(L, nBars);
  547.  
  548. // -- Would like to set this up so pivots are calculated back from
  549.  
  550. // last visible bar to make it easy to "go back" and see the pivots
  551.  
  552. // this code would find. However, the first instance of
  553.  
  554. // _Trace output will show a value of 0
  555.  
  556. aVisBars = Status("barvisible");
  557.  
  558. nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
  559.  
  560. _TRACE("Last visible bar: " + nLastVisBar);
  561.  
  562. // -- Initialize value of curTrend
  563.  
  564. curBar = (BarCount-1);
  565.  
  566. curTrend = "";
  567.  
  568. if (aLLVBars[curBar] <
  569.  
  570. aHHVBars[curBar]) {
  571.  
  572. curTrend = "D";
  573.  
  574. }
  575.  
  576. else {
  577.  
  578. curTrend = "U";
  579.  
  580. }
  581.  
  582. // -- Loop through bars. Search for
  583.  
  584. // entirely array-based approach
  585.  
  586. // in future version
  587.  
  588. for (i=0; i<BarCount; i++) {
  589.  
  590. curBar = (BarCount - 1) - i;
  591.  
  592. // -- Have we identified a pivot? If trend is down...
  593.  
  594. if (aLLVBars[curBar] < aHHVBars[curBar]) {
  595.  
  596. // ... and had been up, this is a trend change
  597.  
  598. if (curTrend == "U") {
  599.  
  600. curTrend = "D";
  601.  
  602. // -- Capture pivot information
  603.  
  604. curPivBarIdx = curBar - aLLVBars[curBar];
  605.  
  606. aLPivs[curPivBarIdx] = 1;
  607.  
  608. aLPivLows[nLPivs] = L[curPivBarIdx];
  609.  
  610. aLPivIdxs[nLPivs] = curPivBarIdx;
  611.  
  612. nLPivs++;
  613.  
  614. }
  615.  
  616. // -- or current trend is up
  617.  
  618. } else {
  619.  
  620. if (curTrend == "D") {
  621.  
  622. curTrend = "U";
  623.  
  624. curPivBarIdx = curBar - aHHVBars[curBar];
  625.  
  626. aHPivs[curPivBarIdx] = 1;
  627.  
  628. aHPivHighs[nHPivs] = H[curPivBarIdx];
  629.  
  630. aHPivIdxs[nHPivs] = curPivBarIdx;
  631.  
  632. nHPivs++;
  633.  
  634. }
  635.  
  636. // -- If curTrend is up...else...
  637.  
  638. }
  639.  
  640. // -- loop through bars
  641.  
  642. }
  643.  
  644. // -- Basic attempt to add a pivot this logic may have missed
  645.  
  646. // -- OK, now I want to look at last two pivots. If the most
  647.  
  648. // recent low pivot is after the last high, I could
  649.  
  650. // still have a high pivot that I didn't catch
  651.  
  652. // -- Start at last bar
  653.  
  654. curBar = (BarCount-1);
  655.  
  656. candIdx = 0;
  657.  
  658. candPrc = 0;
  659.  
  660. lastLPIdx = aLPivIdxs[0];
  661.  
  662. lastLPL = aLPivLows[0];
  663.  
  664. lastHPIdx = aHPivIdxs[0];
  665.  
  666. lastHPH = aHPivHighs[0];
  667.  
  668. if (lastLPIdx > lastHPIdx) {
  669.  
  670. // -- Bar and price info for candidate pivot
  671.  
  672. candIdx = curBar - aHHVBars[curBar];
  673.  
  674. candPrc = aHHV[curBar];
  675.  
  676. if (
  677.  
  678. lastHPH < candPrc AND
  679.  
  680. candIdx > lastLPIdx AND
  681.  
  682. candIdx < curBar) {
  683.  
  684.  
  685. // -- OK, we'll add this as a pivot...
  686.  
  687. aHPivs[candIdx] = 1;
  688.  
  689. // ...and then rearrange elements in the
  690.  
  691. // pivot information arrays
  692.  
  693. for (j=0; j<nHPivs; j++) {
  694.  
  695. aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-
  696.  
  697. (j+1)];
  698.  
  699. aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];
  700.  
  701. }
  702.  
  703. aHPivHighs[0] = candPrc ;
  704.  
  705. aHPivIdxs[0] = candIdx;
  706.  
  707. nHPivs++;
  708.  
  709. }
  710.  
  711. } else {
  712.  
  713.  
  714. // -- Bar and price info for candidate pivot
  715.  
  716. candIdx = curBar - aLLVBars[curBar];
  717.  
  718. candPrc = aLLV[curBar];
  719.  
  720. if (
  721.  
  722. lastLPL > candPrc AND
  723.  
  724. candIdx > lastHPIdx AND
  725.  
  726. candIdx < curBar) {
  727.  
  728.  
  729. // -- OK, we'll add this as a pivot...
  730.  
  731. aLPivs[candIdx] = 1;
  732.  
  733. // ...and then rearrange elements in the
  734.  
  735. // pivot information arrays
  736.  
  737. for (j=0; j<nLPivs; j++) {
  738.  
  739. aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
  740.  
  741. aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
  742.  
  743. }
  744.  
  745. aLPivLows[0] = candPrc;
  746.  
  747. aLPivIdxs[0] = candIdx;
  748.  
  749. nLPivs++;
  750.  
  751. }
  752.  
  753. }
  754.  
  755.  
  756. //============== EXPLORATION ==============
  757. Buy=Cover=aLPivs==1;
  758. Sell=Short=aHPivs==1;
  759. SellPrice=ValueWhen(Sell,C,1);
  760. BuyPrice=ValueWhen(Buy,C,1);
  761. Long=Flip(Buy,Sell);
  762. Shrt=Flip(Sell,Buy );
  763.  
  764. //============== Plot price ==============
  765.  
  766. n = 15;
  767. a = C > (MA(H,n)+MA(L,n))/2;// then Buy next bar at market;
  768. b = C < (MA(H,n)+MA(L,n))/2;// then Sell Short next bar at market;
  769.  
  770. state=IIf(BarsSince(a)<BarsSince(b),1,0);
  771.  
  772. Longs=state==1;
  773. shorts=state==0;
  774.  
  775. //Chart
  776. Colorbar = IIf(Longs, colorGreen, IIf(Shorts, colorRed, colorGrey40));
  777.  
  778. Plot( C, "Close", colorbar, styleCandle = 64 | styleNoTitle );
  779.  
  780.  
  781. //============== Plot Shape ==============
  782.  
  783. PlotShapes(
  784.  
  785.  
  786. High, Offset=-12);
  787.  
  788. PlotShapes(
  789.  
  790. Low, Offset=-12);
  791.  
  792. //============== EMA(13) ==============
  793.  
  794. Plot(EMA(C, 13), "", colorWhite,
  795. styleLine+styleNoRescale);
  796.  
  797. //============== TRENDING ==============
  798.  
  799. DTL=150; // DTL = Define Trend Long
  800. DTM=70; // DTM = Define Trend Medium
  801. DTS=14; // DTS = Define Trend Short
  802.  
  803. TL=LinRegSlope(MA(C, DTL),2); // TL = Trend Long
  804. TM=LinRegSlope(MA(C, DTM),2); // TM = Trend Medium
  805. TS=LinRegSlope(MA(C, DTS),2); // TS = Trend Short
  806.  
  807. TLL=IIf(LinRegSlope(MA(C, DTL),2) > 0,True, False);
  808. TMM=IIf(LinRegSlope(MA(C, DTM),2) > 0,True, False);
  809. TSS=IIf(LinRegSlope(MA(C, DTS),2) > 0,True, False);
  810.  
  811.  
  812. //============== VOLUME ==============
  813. Vlp=30; //Volume lookback period
  814. Vrg=MA(V,Vlp);
  815. St = StDev(Vrg,Vlp);
  816. Vp3 = Vrg + 3*st;
  817. Vp2 = Vrg + 2*st;;
  818. Vp1 = Vrg + 1*st;;
  819. Vn1 = Vrg -1*st;
  820. Vn2 = Vrg -2*st;
  821.  
  822. //============== WILLIAM'S %R ==============
  823. WR = ((HHV(H,14) - C) /(HHV (H,14) -LLV (L,14))) *-100;
  824.  
  825. //============== A/D ==============
  826. TRH = IIf(Ref(C, -1) > H, Ref(C, -1), H);
  827. TRL = IIf(Ref(C, -1) < L, Ref(C, -1), L);
  828. ad = IIf(C > Ref(C, -1), C - TRL, IIf(C < Ref(C, -1), C - TRH, 0));
  829. WAD = Cum(ad);
  830. wu = wad > Ref(wad,-1);
  831. wd = wad < Ref(wad,-1);
  832.  
  833. //============== MACD ==============
  834. MB= Cross (MACD(), Signal());
  835. MS = Cross( Signal(), MACD());
  836. MB = ExRem(MB, MS);
  837. MS = ExRem(MS, MB);
  838. MB1= MACD() > Signal();
  839. MS1= MACD() < Signal();
  840.  
  841. //============== STOCH ==============
  842. StochKval = StochK(10,5);
  843. StochDval = StochD(10,5,5);
  844. StochBuy = Cross(StochK(10,5), StochD(10,5,5));
  845. StochSell = Cross (StochD(10,5,5), StochK(10,5));
  846. StBuy=StochK(10,5)>StochD(10,5,5);
  847. StSell=StochK(10,5)<StochD(10,5,5);
  848.  
  849. //============== ADX ==============
  850. adxBuy = Cross(PDI(14), MDI(14));
  851. adxSell = Cross(MDI(14), PDI(14));
  852. adxBuy = ExRem(adxBuy, adxSell);
  853. adxSell = ExRem(adxSell, adxBuy);
  854. adxbuy1 = PDI(14) > MDI(14);
  855. adxsell1 = MDI(14)> PDI(14);
  856.  
  857.  
  858. //============== TMA ==============
  859. function ZeroLagTEMA( array, period )
  860. {
  861. TMA1 = TEMA( array, period );
  862. TMA2 = TEMA( TMA1, period );
  863. Diff = TMA1 - TMA2;
  864. return TMA1 + Diff ;
  865. }
  866. haClose = ( haClose + haOpen + haHigh + haLow )/4;
  867. periodtm = 55;
  868. ZLHa = ZeroLagTEMA( haClose, periodtm );
  869. ZLTyp = ZeroLagTEMA( Avg, periodtm );
  870. TMBuy = Cross( ZLTyp, ZLHa );
  871. TMSell = Cross( ZLHa, ZLTyp );
  872. TMBuy1= ZLTyp> ZLHa ;
  873. TMSell1=ZLHa> ZLTyp ;
  874.  
  875. //============== ZLW ==============
  876. R = ((HHV(H,14) - C) /(HHV (H,14) -LLV (L,14))) *-100;
  877. MaxGraph=10;
  878. PeriodZ= 10;
  879. EMA1= EMA(R,PeriodZ);
  880. EMA2= EMA(EMA1,5);
  881. Difference= EMA1 - EMA2;
  882. ZeroLagEMA= EMA1 + Difference;
  883. PR=100-abs(ZeroLagEMA);
  884. MoveAvg=MA(PR,5);
  885. ZBuy = Cross(PR,moveAvg) AND PR<30;
  886. ZSell = Cross(moveAvg,PR) AND PR>70;
  887. ZBuy1= PR>= MoveAvg AND PR>= Ref(PR,-1) ;
  888. ZSell1=(PR < MoveAvg) OR PR>= MoveAvg AND PR< Ref(PR,-1) ;
  889.  
  890. //============== RS ==============
  891. p = (H+L+C)/3;
  892. r1 = (2*p)-L;
  893. s1 = (2*p)-H;
  894. r2 = p +(r1 - s1);
  895. s2 = p -(r2 - s1);
  896. R3 = P + (R2 - S2);
  897. S3 = P - (R3 - S2);
  898.  
  899. //============== IBUY ==============
  900. Ibuy = Cross(RSI(14), EMA(RSI(14),9));
  901. Isell = Cross(EMA(RSI(14),9), RSI(14));
  902. Ibuy = ExRem(Ibuy, ISell);
  903. Isell = ExRem(ISell, Ibuy);
  904. BlRSI = RSI(14) > EMA(RSI(14),9);
  905. BrRSI = RSI(14) < EMA(RSI(14),9);
  906.  
  907. //============== TITLE ==============
  908. _SECTION_BEGIN("Title");
  909.  
  910. DODay = TimeFrameGetPrice("O", inDaily);
  911. DHiDay = TimeFrameGetPrice("H", inDaily);
  912. DLoDay = TimeFrameGetPrice("L", inDaily);
  913. Title = EncodeColor(colorBlue)+"* SAISRI2320 * "+EncodeColor(colorBrightGreen)+ Name() + ", " + Interval(2) + ", " + Date() + " - "+strWeekday + " - " +
  914. EncodeColor(colorWhite) + "\nO " + EncodeColor(colorWhite) + O +
  915.  
  916. ", H : " + H +
  917. ", L : " + L +
  918. ", C : " + C +
  919. "\n"+EncodeColor(colorAqua)+ " Day-Open : " +DODay + " Day-High : " +DHiDay + " Day-Low : " + DLoDay
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926. +"\n"+EncodeColor(colorGrey50)+"--------------------------------------"
  927.  
  928.  
  929.  
  930. +
  931. WriteIf(TS>0 AND TS<0.3,EncodeColor(colorLime)+"Weak Up Trend",
  932. WriteIf(TS>=0.3 AND TS<0.6 ,EncodeColor(colorBrightGreen)+"Medium Up Trend",
  933. WriteIf(TS>=0.6,EncodeColor(colorGreen)+"Strong Up Trend",
  934. WriteIf(TS<0 AND TS>-0.3,EncodeColor(colorPink)+"Weak Down Trend",
  935. WriteIf(TS<=-0.3 AND TS>-0.6 ,EncodeColor(ColorRGB(255,0,128))+"Medium Down Trend",
  936. WriteIf(TS<=-0.6,EncodeColor(colorRed)+"Strong Down Trend",EncodeColor(colorGrey50)+"Sideways"))))))
  937.  
  938. +"\n"+EncodeColor(colorGold)+"•
  939. Mid Term: "+
  940. WriteIf(TM>0 AND TM<0.3,EncodeColor(colorLime)+"Weak Up Trend",
  941. WriteIf(TM>=0.3 AND TM<0.6 ,EncodeColor(colorBrightGreen)+"Medium Up Trend",
  942. WriteIf(TM>=0.6,EncodeColor(colorGreen)+"Strong Up Trend",
  943. WriteIf(TM<0 AND TM>-0.3,EncodeColor(colorPink)+"Weak Down Trend",
  944. WriteIf(TM<=-0.3 AND TM>-0.6 ,EncodeColor(ColorRGB(255,0,128))+"Medium Down Trend",
  945. WriteIf(TM<=-0.6,EncodeColor(colorRed)+"Strong Down Trend",EncodeColor(colorGrey50)+"Sideways"))))))
  946.  
  947. +"\n"+EncodeColor(colorGold)+"• Long Term: "+
  948. WriteIf(TL>0 AND TL<0.3,EncodeColor(colorLime)+"Weak Up Trend",
  949. WriteIf(TL>=0.3 AND TL<0.6 ,EncodeColor(colorBrightGreen)+"Medium Up Trend",
  950. WriteIf(TL>=0.6,EncodeColor(colorGreen)+"Strong Up Trend",
  951. WriteIf(TL<0 AND TL>-0.3,EncodeColor(colorPink)+"Weak Down Trend",
  952. WriteIf(TL<=-0.3 AND TL>-0.6 ,EncodeColor(ColorRGB(255,0,128))+"Medium Down Trend",
  953. WriteIf(TL<=-0.6,EncodeColor(colorRed)+"Strong Down Trend",EncodeColor(colorGrey50)+"Sideways"))))))
  954.  
  955. +"\n"+EncodeColor(colorGrey50)+"--------------------------------------"
  956.  
  957. +"\n"+EncodeColor(47)+"• AccDist(): " + WriteIf(wu,EncodeColor(colorBrightGreen)+"Accumula tion",WriteIf(wd,EncodeColor(colorRed)+"Distributi on","Neutral"))
  958.  
  959. +"\n"+ EncodeColor(47) +"• RSI(14): " +WriteIf(RSI(14)>30 AND RSI(14)<70,EncodeColor(colorBrightGreen),WriteIf(RSI(14)<30 ,EncodeColor(07),EncodeColor(colorRed))) + WriteVal(RSI(14),format=1.1)
  960. +WriteIf(RSI(14)>30 AND RSI(14)<70," Range"+EncodeColor(colorBrightGreen),WriteIf(RSI(14)<30 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(colorRed)))
  961.  
  962. +"\n"+ EncodeColor(47) +"• CCI(14): " +WriteIf(CCI(14)>-100 AND CCI(14)<100,EncodeColor(colorBrightGreen),WriteIf( CCI(14)<-100 ,EncodeColor(07),EncodeColor(colorRed))) + WriteVal(CCI(14),format=1.1)
  963. +WriteIf(CCI(14)>-100 AND CCI(14)<100," Range"+EncodeColor(colorBrightGreen),WriteIf(CCI(14)<-100 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(colorRed)))
  964.  
  965. +"\n"+ EncodeColor(47) +"• ROC(C,14): " +WriteIf(ROC(C,14)>-10 AND ROC(C,14)<10,EncodeColor(colorBrightGreen),WriteIf (ROC(C,14)<-10 ,EncodeColor(07),EncodeColor(colorRed))) + WriteVal(ROC(C,14),format=1.1)
  966. +WriteIf(ROC(C,14)>-10 AND ROC(C,14)<10," Range"+EncodeColor(colorBrightGreen),WriteIf(ROC(C ,14)<-10 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(colorRed)))
  967.  
  968. +"\n"+ EncodeColor(47) +"• Wm%R(14): " +WriteIf(WR>-80 AND WR<-20,EncodeColor(colorBrightGreen),WriteIf(WR<-80 ,EncodeColor(07),EncodeColor(colorRed))) + WriteVal(WR,format=1.1)
  969. +WriteIf(WR>-80 AND WR<-20," Range"+EncodeColor(colorBrightGreen),WriteIf(WR<-80 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(colorRed)))
  970.  
  971.  
  972. +"\n"+EncodeColor(colorGrey50)+"--------------------------------------"
  973.  
  974. +"\n"+EncodeColor(colorGold)+"• Signal(IBuy): " + WriteIf(Ibuy,EncodeColor(colorBrightGreen)+"BuyWar ning",WriteIf(Isell,EncodeColor(colorRed)+"SellWar ning",WriteIf(BlRSI,EncodeColor(colorBrightGreen)+ "BullishZone",WriteIf(BrRSI,EncodeColor(colorRed)+ "BearishZone","Neutral"))))
  975.  
  976. +"\n"+EncodeColor(colorGold)+"• Signal(TMA): " + WriteIf(TMBuy,EncodeColor(colorBrightGreen)+"Buy", WriteIf(TMSell,EncodeColor(colorRed)+"Sell",WriteIf(TMBuy1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(TMSell1,EncodeColor(colorRed)+"Bearish","Ne utral"))))
  977.  
  978. +"\n"+EncodeColor(colorGold)+"• Signal(MACD): " + WriteIf(MB,EncodeColor(colorBrightGreen)+"Buy",WriteIf(MS,EncodeColor(colorRed)+"Sell",WriteIf(MB1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(MS1 ,EncodeColor(colorRed)+"Bearish","Neutral"))))
  979.  
  980. +"\n"+EncodeColor(colorGold)+"• Signal(Stoch): " + WriteIf(StochBuy,EncodeColor(colorBrightGreen)+"Bu y",WriteIf(StochSell,EncodeColor(colorRed)+"Sel l", WriteIf(StBuy,EncodeColor(colorBrightGreen)+"Bulli sh",WriteIf(StSell,EncodeColor(colorRed)+"Bearis h" ,"Neutral"))))
  981.  
  982. +"\n"+EncodeColor(colorGold)+"• Signal(ADX): " + WriteIf(adxBuy,EncodeColor(colorBrightGreen)+"Buy" ,WriteIf(adxSell,EncodeColor(colorRed)+"Sell",WriteIf(adxBuy1,EncodeColor(colorBrightGreen)+"Bullish ",WriteIf(adxSell1,EncodeColor(colorRed)+"Bear ish" ,"Neutral"))))
  983.  
  984. +"\n"+EncodeColor(colorGrey50)+"--------------------------------------"
  985.  
  986. +"\n"+ EncodeColor(47) +"• TrStop: " +EncodeColor(colorLime)+ WriteVal(TrailStop,format=1.0)
  987. + EncodeColor(47) +" TrgPrice: " + EncodeColor(colorLime)+WriteVal(Profittaker,format =1.0)
  988. +"\n"+ EncodeColor(47) +"• R1: " +EncodeColor(colorOrange)+ WriteVal(r1,format=1.0)
  989. + EncodeColor(47) +" R2: " + EncodeColor(colorOrange)+WriteVal(r2,format=1.0)
  990. + EncodeColor(47) +" R3: " + EncodeColor(colorOrange)+WriteVal(r3,format=1.0)
  991. +"\n"+ EncodeColor(47) +"• S1: " +EncodeColor(colorOrange)+ WriteVal(s1,format=1.0)
  992. + EncodeColor(47) +" S2: " + EncodeColor(colorOrange)+WriteVal(s2,format=1.0)
  993. + EncodeColor(47) +" S3: " + EncodeColor(colorOrange)+WriteVal(s3,format=1.0)
  994.  
  995. +"\n"+EncodeColor(colorGrey50)+"--------------------------------------"
  996.  
  997. ;
  998. _SECTION_END();
  999.  
  1000.  
  1001. _SECTION_BEGIN("Isfandi Technical Viewer");
  1002.  
  1003. DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
  1004. DayL = TimeFrameGetPrice("L", inDaily, -1);//low
  1005. DayC = TimeFrameGetPrice("C", inDaily, -1);//close
  1006. DayO = TimeFrameGetPrice("O", inDaily);// current day open
  1007. HiDay = TimeFrameGetPrice("H", inDaily);
  1008. LoDay = TimeFrameGetPrice("L", inDaily);
  1009. PP = (DayH + DayL + DayO + DayO) / 4 ;
  1010. R1 = (2 * PP) - DayL;
  1011. S1 = (2 * PP) - DayH;
  1012. R2 = PP + R1 - S1;
  1013. S2 = PP + S1 - R1;
  1014. R3 = R2 + (R1 - PP);
  1015. S3 = S2 - (PP - S1);
  1016.  
  1017.  
  1018.  
  1019. //-Paint Background
  1020.  
  1021. GfxSelectSolidBrush( colorBlack);
  1022. GfxSelectPen( colorRed);
  1023. GfxRoundRect( 2, 0, 930, 51, 30, 32);
  1024. GfxSetBkMode( 1 );
  1025.  
  1026. GfxSelectFont("Arial", 8, 900);
  1027.  
  1028.  
  1029. // OTHER INDICATOR
  1030. MOMETUM =RSI(14);
  1031. radius = 0.1 * Status("pxheight"); // get pixel height of the chart and use 45% for pie chart radius
  1032. textoffset = 0.1 * radius;
  1033. GfxSelectFont("Arial", 9, 500, True );
  1034. GfxSelectFont("Arial", 9 );
  1035. GfxSetTextColor( colorLime);
  1036. GfxTextOut( "R1 =" + R1, textoffset + 740, 32 );
  1037. GfxSetTextColor( colorLime );
  1038. GfxTextOut( "R2 = " +R2, textoffset + 820, 32);
  1039. GfxSetTextColor( colorPink );
  1040. GfxTextOut( "PP = " +PP, textoffset + 660, 32);
  1041. GfxSetTextColor( colorOrange );
  1042. GfxTextOut( "S1 = " +S1, textoffset + 500, 32);
  1043. GfxSetTextColor( colorRed );
  1044. GfxTextOut( "S2 = " +S2, textoffset + 580, 32);
  1045. GfxSelectFont("Arial", 9 );
  1046. _SECTION_END();
  1047.  
  1048.  
  1049. //-Paint Background
  1050.  
  1051. GfxSelectSolidBrush( colorBlack);
  1052. GfxSelectPen( colorPink);
  1053. GfxRoundRect( 500, 1, 930, 27, 32, 32 );
  1054. GfxSetBkMode( 1 );
  1055.  
  1056. GfxSelectFont("Arial", 8, 900);
  1057.  
  1058. _SECTION_BEGIN("Magnified Market Price");
  1059. FS=Param("Font Size",12,30,100,1);
  1060. GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
  1061. GfxSetBkMode( colorRose );
  1062. GfxSetTextColor( ParamColor("Color",colorRose) );
  1063. Hor=Param("Horizontal Position",650,800,800,800);
  1064. Ver=Param("Vertical Position",5,27,27,27);
  1065. GfxTextOut("CMP: "+C,Hor , Ver );
  1066. YC=TimeFrameGetPrice("C",inDaily,-1);
  1067. DD=Prec(C-YC,2);
  1068. xx=Prec((DD/YC)*100,2);
  1069. GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
  1070. GfxSetBkMode( colorGreen );
  1071. GfxSetTextColor(ParamColor("Color",colorGreen) );
  1072. GfxTextOut("change ("+DD+") ("+xx+"%)", Hor+130, Ver+0 );
  1073. _SECTION_END();
  1074.  
  1075.  
  1076. _SECTION_BEGIN("system Ticker");
  1077. function GetSecondNum()
  1078. {
  1079. Time = Now( 4 );
  1080. Seconds = int( Time % 100 );
  1081. Minutes = int( Time / 100 % 100 );
  1082. Hours = int( Time / 10000 % 100 );
  1083. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  1084. return SecondNum;
  1085. }
  1086. RequestTimedRefresh( 1 );
  1087. //----------------------------------------------------------------------------
  1088. //----------------------------------------------------------------------------
  1089. TimeFrame = Interval();
  1090. SecNumber = GetSecondNum();
  1091. Newperiod = SecNumber % TimeFrame == 0;
  1092. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  1093. SecsToGo = TimeFrame - SecsLeft;
  1094.  
  1095. x=Param(" xposn",540,100,1000,1000);
  1096. y=Param(" yposn",7,40,1000,1);
  1097.  
  1098. GfxSelectSolidBrush( colorBlack );
  1099. GfxSelectPen( colorBlack, 2 );
  1100. if ( NewPeriod )
  1101. {
  1102. GfxSelectSolidBrush( colorBlack );
  1103. GfxSelectPen( colorBlack, 2 );
  1104. }
  1105. GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
  1106. GfxSetBkMode(1);
  1107. GfxSelectFont( "Arial", 9, 700, False );
  1108. GfxSetTextColor( colorBlue );
  1109. GfxTextOut( "" +SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
  1110. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement