Advertisement
saisri

rocketjet by ami bro

Jul 15th, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.88 KB | None | 0 0
  1. _SECTION_BEGIN("Chart Settings");
  2. SetChartOptions(0,chartShowArrows|chartShowDates);
  3. SetChartBkColor(ParamColor("Outer Panel",colorBlack));
  4. SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkTeal),ParamColor("Lower Chart",colorBlack));
  5. GraphXSpace=Param("GraphXSpace",10,0,100,1);
  6. dec = (Param("Decimals",2,0,7,1)/10)+1;
  7. bi = BarIndex();
  8. Lbi = LastValue(BarIndex());
  9. sbi = SelectedValue(bi);
  10. x1= BarCount-1;
  11. Title = EncodeColor(55)+ Title = Name() + " " + EncodeColor(32) + Date() +
  12. " " + EncodeColor(5) + "{{INTERVAL}} " +
  13. EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) +
  14. EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
  15. EncodeColor(55)+ " Low = "+ EncodeColor(32)+ WriteVal(L,dec) +
  16. EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
  17. EncodeColor(55)+ " Volume = "+ EncodeColor(52)+ WriteVal(V,1);
  18. _SECTION_END();
  19. _SECTION_BEGIN( "BASERECTANGEL" );
  20.  
  21. GfxSelectFont( "Arial", 10, 100 );
  22. GfxSetBkMode( 1 );
  23. GfxSetTextColor( colorBlue );
  24. GfxSelectSolidBrush( colorBlue );
  25. GfxSelectPen( colorBlue, 1 );
  26. // broader color
  27. GfxRectangle(0,15,203,400);
  28.  
  29. _SECTION_END();
  30. _SECTION_BEGIN( "BASERECTANGEL" );
  31.  
  32. GfxSelectFont( "Arial", 10, 100 );
  33. GfxSetBkMode( 1 );
  34. GfxSetTextColor( colorBlue );
  35. GfxSelectSolidBrush( colorBlue );
  36. GfxSelectPen( colorBlue, 1 );
  37. // broader color
  38. GfxRectangle(202,15,300,400);
  39.  
  40. _SECTION_END();
  41.  
  42. _SECTION_BEGIN("res/sup-s1");
  43.  
  44. DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
  45. DayL = TimeFrameGetPrice("L", inDaily, -1);//low
  46. DayC = TimeFrameGetPrice("C", inDaily, -1);//close
  47. DayO = TimeFrameGetPrice("O", inDaily);// current day open
  48. HiDay = TimeFrameGetPrice("H", inDaily);
  49. LoDay = TimeFrameGetPrice("L", inDaily);
  50. PP = (DayH + DayL + DayO + DayO) / 4 ;
  51. R1 = (2 * PP) - DayL;
  52. S1 = (2 * PP) - DayH;
  53. R2 = PP + R1 - S1;
  54. S2 = PP + S1 - R1;
  55. R3 = R2 + (R1 - PP);
  56. S3 = S2 - (PP - S1);
  57. style = styleLine | styleThick + styleNoRescale;
  58. rcolor = colorBlue;
  59. scolor = colorRed;
  60. pcolor = colorGreen;
  61.  
  62. GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
  63. GfxSetTextColor( ParamColor("Color",colorRed) );
  64. Hor=Param("Horizontal Position",230,10,1200,1);
  65. Ver=Param("Vertical Position",230,300,500,500);
  66.  
  67. GfxTextOut(""+s1,Hor , Ver );
  68.  
  69. _SECTION_END();
  70.  
  71. _SECTION_BEGIN("res/sup-s2");
  72.  
  73. GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
  74. GfxSetTextColor( ParamColor("Color",colorRed) );
  75. Hor=Param("Horizontal Position",230,10,1200,1);
  76. Ver=Param("Vertical Position",260,300,500,500);
  77. GfxTextOut(""+s2,Hor , Ver );
  78. _SECTION_END();
  79.  
  80. _SECTION_BEGIN("res/sup-s3");
  81.  
  82. GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
  83. GfxSetTextColor( ParamColor("Color",colorRed) );
  84. Hor=Param("Horizontal Position",230,10,1200,1);
  85. Ver=Param("Vertical Position",290,300,600,600);
  86. GfxTextOut(""+s3,Hor , Ver );
  87. _SECTION_END();
  88.  
  89. _SECTION_BEGIN("res/sup-r1");
  90.  
  91. GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
  92. GfxSetTextColor( ParamColor("Color",colorGreen) );
  93. Hor=Param("Horizontal Position",230,10,1200,1);
  94. Ver=Param("Vertical Position",320,300,500,500);
  95. GfxTextOut(""+r1,Hor , Ver );
  96. _SECTION_END();
  97. _SECTION_BEGIN("res/sup-r2");
  98.  
  99. GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
  100. GfxSetTextColor( ParamColor("Color",colorGreen) );
  101. Hor=Param("Horizontal Position",230,10,1200,1);
  102. Ver=Param("Vertical Position",350,300,500,500);
  103. GfxTextOut(""+r2,Hor , Ver );
  104. _SECTION_END();
  105.  
  106. _SECTION_BEGIN("res/sup-r3");
  107.  
  108. GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
  109. GfxSetTextColor( ParamColor("Color",colorGreen) );
  110. Hor=Param("Horizontal Position",230,10,1200,1);
  111. Ver=Param("Vertical Position",380,300,500,500);
  112. GfxTextOut(""+r3,Hor , Ver );
  113. _SECTION_END();
  114.  
  115. _SECTION_BEGIN("MACD");
  116. r1 = Param( "Fast avg", 12, 2, 200, 1 );
  117. r2 = Param( "Slow avg", 26, 2, 200, 1 );
  118. r3 = Param( "Signal avg", 9, 2, 200, 1 );
  119. r4 = Param( "Wk slow", 17, 2, 200, 1 );
  120. r5 = Param( "Wk fast", 8, 2, 200, 1 );
  121. m1=MACD(r1,r2);
  122. s1=Signal(r1,r2,r3);
  123.  
  124.  
  125.  
  126. _SECTION_END();
  127.  
  128. _SECTION_BEGIN("WRITE");
  129.  
  130. GfxSelectFont("arial", 8, 700 ); GfxSetBkMode( colorLightBlue );
  131. GfxSetTextColor( ParamColor("Color",colorLightBlue) );
  132. Hor=Param("Horizontal Position",0,10,1200,1);
  133. Ver=Param("Vertical Position",385,100,50,50);
  134.  
  135. GfxTextOut(" R O C K E T J E T",Hor , Ver );
  136. _SECTION_END();
  137.  
  138.  
  139.  
  140.  
  141. _SECTION_BEGIN("Forex_Main_mrtq13");
  142. ///////////////////////////////////
  143. Title =
  144. EncodeColor(colorWhite)+ Title = Name () + " | "
  145. +EncodeColor(colorYellow) + Date() + " | "
  146.  
  147. +EncodeColor(colorTurquoise)+ "O : "+ EncodeColor(colorLightGrey)+ O + " | "
  148. +EncodeColor(colorTurquoise)+ "H : "+ EncodeColor(colorLightGrey)+ H + " | "
  149. +EncodeColor(colorTurquoise)+ "L : "+ EncodeColor(colorLightGrey)+ L + " | "
  150. +EncodeColor(colorTurquoise)+ "C : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
  151. +EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
  152. +EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
  153. +EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1)
  154. ;
  155.  
  156. _SECTION_END();
  157.  
  158.  
  159.  
  160. _SECTION_BEGIN("Flower");
  161. Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
  162. r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
  163. r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
  164. r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );
  165.  
  166. Prd1=Param("ATR Period",4,1,20,1);
  167. Prd2=Param("Look Back",7,1,20,1);
  168. green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
  169. red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
  170. flowerClose = EMA((Open+High+Low+Close)/4,3) ;
  171. flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
  172. Temp = Max(High, flowerOpen);
  173. flowerHigh = EMA(Max(Temp, flowerClose),3);
  174. Temp = Min(Low,flowerOpen);
  175. flowerLow = EMA(Min(Temp, flowerClose),3);
  176.  
  177.  
  178.  
  179. m1=MACD(r1,r2);
  180. s1=Signal(r1,r2,r3);
  181. mycolor=IIf(m1<0 AND m1>s1, colorYellow,IIf(m1>0 AND
  182.  
  183. m1>s1,colorWhite,IIf(m1>0 AND m1<s1,colorDarkYellow,colorRed)));
  184. if(Show_color)
  185. {
  186. ColorHighliter = myColor;
  187. SetBarFillColor( ColorHighliter );
  188. }
  189.  
  190. barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorWhite));
  191.  
  192.  
  193. PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen,
  194.  
  195. flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose,
  196.  
  197. flowerOpen), "Close", barColor, styleNoTitle | styleCandle);
  198.  
  199.  
  200.  
  201. _SECTION_END();
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209. _SECTION_BEGIN("Bands");
  210.  
  211. SupResB =Param("Sup-Res Short",6,0,100,1);
  212. nn=SupResB;
  213.  
  214.  
  215.  
  216. Bandlinecol=ParamColor("SupResLineColor",ColorRGB(82,82,82));
  217. ParmCloud = ParamToggle("Cloud", "No|Yes", 0);
  218. BoxCloudColor=ParamColor("BoxCloudColor",ColorRGB(27,27,27));
  219.  
  220.  
  221. Line2=Param("ResLineLength",100,2,500,0.1);
  222. Daysback1 = Line2;
  223. FirstBar1 = BarCount - DaysBack1;
  224. Hh=HHV(flowerHigh,nn);
  225. LL=LLV(flowerLow,nn);
  226.  
  227. Res2=Hh;
  228. Sup2=LL;
  229.  
  230. BandRes=IIf(BarIndex() >= Firstbar1,EndValue(Res2),Null);
  231. BandSup=IIf(BarIndex() >= Firstbar1,EndValue(Sup2),Null);
  232. Plot(BandRes,"",Bandlinecol,ParamStyle("ShortSupBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));
  233. Plot(BandSup,"",Bandlinecol,ParamStyle("ShortResBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));
  234.  
  235.  
  236.  
  237.  
  238. CS=BandRes;
  239. CR=BandSup;
  240.  
  241.  
  242. if(parmCloud == 1)
  243.  
  244. PlotOHLC( CS, CS, CR,CR, "Band",BoxCloudColor, styleCloud | styleNoLabel|styleNoTitle);
  245.  
  246. _SECTION_END();
  247.  
  248. _SECTION_BEGIN("Breakout Setting");
  249. Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
  250. Sellperiods=Param("Exit Breakout",5,1,100,1,1);
  251.  
  252. HaClose =EMA((O+H+L+C)/4,3); // Woodie
  253. //HaClose =(O+H+L+C)/4;
  254. HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
  255. HaHigh = Max( H, Max( HaClose, HaOpen ) );
  256. HaLow = Min( L, Min( HaClose, HaOpen ) );
  257. Buy= C>Ref(HHV(High,Buyperiods),-1) ;
  258. Sell= C<Ref(LLV(Low,Sellperiods),-1);
  259.  
  260. /* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
  261. Buy = ExRem(Buy, Sell);
  262. Sell = ExRem(Sell, Buy);
  263.  
  264. PlotShapes( IIf( Buy, shapeSmallUpTriangle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -30);
  265. //PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -8);
  266.  
  267. PlotShapes( IIf( Sell, shapeSmallDownTriangle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -30);
  268. //PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -8);
  269.  
  270. _SECTION_END();
  271.  
  272. _SECTION_BEGIN("Graphics");
  273. GrpPrm=Param("Graphic Space",-5,-10,10);
  274. GraphXSpace=GrpPrm;
  275. _SECTION_END();
  276.  
  277.  
  278.  
  279. //#include <T3.AFL>;
  280.  
  281. _SECTION_BEGIN("PFE");
  282.  
  283. pds=10;
  284. x=sqrt((ROC(C,9)*ROC(C,9))+100);
  285. y=Sum(sqrt((ROC(C,1)* ROC(C,1))+1),pds);
  286. z=(x/y);
  287. pfe=EMA(IIf(C>Ref(C,-9),z,-z)*100,5);
  288.  
  289. rsidn=pfe <-10 AND pfe<Ref(pfe,-1);
  290. rsiup=pfe >10 AND pfe>Ref(pfe,-1);
  291.  
  292.  
  293.  
  294. rsiresult1 = WriteIf( rsiup,"cu", "");
  295. rsiresult2 = WriteIf( rsidn,"cd", "");
  296.  
  297.  
  298.  
  299.  
  300. RequestTimedRefresh( 0 );
  301. GfxSelectFont( "Tahoma", 12, 120 );
  302. GfxSetBkMode( 1 );
  303. GfxSetTextColor( colorWhite );
  304.  
  305. if ( rsiresult1 =="cu")
  306. {
  307. GfxSelectSolidBrush( ColorRGB(0,90,0) );
  308.  
  309. }
  310. else
  311.  
  312. if ( rsiresult2 =="cd")
  313.  
  314. {
  315. GfxSelectSolidBrush( ColorRGB(90,0,0));
  316.  
  317. }
  318.  
  319. else
  320.  
  321. if ( rsiresult2 =="")
  322.  
  323. {
  324. GfxSelectSolidBrush( colorDarkTeal );
  325.  
  326. }
  327.  
  328. GfxSelectFont( "Arial", 10, 100 );
  329. GfxSetBkMode( 1 );
  330. GfxSetTextColor( colorBlue );
  331.  
  332.  
  333. GfxCircle( 100,90,50 );
  334. _SECTION_END();
  335.  
  336.  
  337.  
  338.  
  339.  
  340. //GfxRoundRect( 15,305,135,215, 5, 5 );
  341. GfxCircle( 100,100,70 );
  342. _SECTION_END();
  343.  
  344.  
  345. _SECTION_BEGIN("STC");
  346.  
  347. _SECTION_BEGIN("Schaff Trend Cycle");
  348. /*
  349. Ported directly from original STC Tradestation code
  350. results differ from other Amibroker versions that are not based directly on original EasyLanguage code
  351. http://mediaserver.fxstreet.com/Reports/99afdb5f-d41d-4a2c-802c-f5d787df886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf
  352. */
  353. MA1=23;
  354. MA2=50;
  355. TCLen=10;
  356. MA1=Param("ShortMACDLen",23,5,36);
  357. MA2=Param("LOngMACDLen",50,10,100);
  358. TCLen=Param("TCLen(StochPeriod)",10,5,20);
  359. Factor=.5;
  360. //Calculate a MACD Line
  361. XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation
  362.  
  363. //1st Stochastic: Calculate Stochastic of a MACD
  364. Value1 = LLV(XMac, TCLen);
  365. Value2 = HHV(XMac, TCLen) - Value1;
  366.  
  367. //Frac1=1; // prime Frac1 to a default of 1
  368. //Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1));
  369. // have to "prime" first value so that reference to "i-1" does not result in subscript out of range
  370. // since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value
  371. frac1=0;
  372. for (i = 1; i < BarCount; i++) {
  373. if (Value2[i] > 0) {
  374. frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100;
  375. }
  376. else {
  377. frac1[i]= frac1[i-1];
  378. }
  379. }
  380.  
  381. //Smoothed calculation for %FastD of MACD
  382.  
  383. PF[0]=frac1[0];
  384. PF[1]=frac1[1];
  385. for (i = 2; i < BarCount; i++) {
  386. PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1]));
  387. }
  388.  
  389.  
  390. //2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above.
  391. Value3 = LLV(PF, TCLen);
  392. Value4 = HHV(PF, TCLen) - Value3;
  393.  
  394. //%FastK of PF
  395. /*
  396. Frac2=1;
  397. Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1));
  398. */
  399.  
  400. frac2[0]=0;
  401. for (i = 1; i < BarCount; i++) {
  402. if (Value4[i] > 0 ) {
  403. frac2[i]=((PF[i] - Value3[i])/Value4[i])*100;
  404. }
  405. else {
  406. frac2[i]=frac2[i-1];
  407. }
  408. }
  409.  
  410. //Smoothed calculation for %FastD of PF
  411. PFF[0]=frac2[0];
  412. PFF[1]=frac2[1];
  413. for (i = 2; i < BarCount; i++) {
  414. PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1]));
  415. }
  416.  
  417. //HT=ParamColor("HT", colorRed );
  418.  
  419. rsidn=pff <2;
  420. rsiup=pff >98;
  421.  
  422.  
  423. rsiresult1 = WriteIf( rsiup,"cu", "");
  424. rsiresult2 = WriteIf( rsidn,"cd", "");
  425.  
  426.  
  427.  
  428.  
  429. RequestTimedRefresh( 0 );
  430. GfxSelectFont( "Tahoma", 12, 120 );
  431. GfxSetBkMode( 1 );
  432. GfxSetTextColor( colorWhite );
  433.  
  434. if ( rsiresult1 =="cu")
  435. {
  436. GfxSelectSolidBrush( ColorRGB(0,120,0) );
  437.  
  438. }
  439. else
  440.  
  441. if ( rsiresult2 =="cd")
  442.  
  443. {
  444. GfxSelectSolidBrush( ColorRGB(120,0,0));
  445.  
  446. }
  447.  
  448. else
  449.  
  450. if ( rsiresult2 =="")
  451.  
  452. {
  453. GfxSelectSolidBrush( colorDarkTeal );
  454.  
  455. }
  456.  
  457. GfxSelectFont( "Arial", 10, 100 );
  458. GfxSetBkMode( 1 );
  459. GfxSetTextColor( colorBlue );
  460.  
  461.  
  462. GfxCircle( 100,100,60 );
  463. _SECTION_END();
  464.  
  465.  
  466. _SECTION_BEGIN("rsi");
  467.  
  468. //HT=ParamColor("HT", colorRed );
  469.  
  470. rsidn=RSI(7) <30;
  471. rsiup=RSI(7) >70;
  472.  
  473.  
  474. rsiresult1 = WriteIf( rsiup,"cu", "");
  475. rsiresult2 = WriteIf( rsidn,"cd", "");
  476.  
  477.  
  478.  
  479.  
  480. RequestTimedRefresh( 0 );
  481. GfxSelectFont( "Tahoma", 12, 120 );
  482. GfxSetBkMode( 1 );
  483. GfxSetTextColor( colorWhite );
  484.  
  485. if ( rsiresult1 =="cu")
  486. {
  487. GfxSelectSolidBrush( ColorRGB(0,150,0) );
  488.  
  489. }
  490. else
  491.  
  492. if ( rsiresult2 =="cd")
  493.  
  494. {
  495. GfxSelectSolidBrush( ColorRGB(150,0,0));
  496.  
  497. }
  498.  
  499. else
  500.  
  501. if ( rsiresult2 =="")
  502.  
  503. {
  504. GfxSelectSolidBrush( colorDarkTeal );
  505.  
  506. }
  507.  
  508. GfxSelectFont( "Arial", 10, 100 );
  509. GfxSetBkMode( 1 );
  510. GfxSetTextColor( colorBlue );
  511.  
  512.  
  513. GfxCircle( 100,100,50 );
  514. _SECTION_END();
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523. _SECTION_BEGIN("Rays");
  524.  
  525. //FT=ParamColor("FT", colorRed );
  526.  
  527. Pp1=3;
  528. Pp2=2;
  529.  
  530. CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4);
  531. CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5);
  532.  
  533. AtrupTrendCond1 = flowerClose> CS33 ;
  534. AtrdnTrendCond1 =CS33>flowerClose ;
  535.  
  536.  
  537. ATRup = WriteIf(AtrupTrendCond1,"atrup", "");
  538. ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", "");
  539.  
  540. if ( ATRup =="atrup")
  541. {
  542. GfxSelectSolidBrush( ColorRGB(0,180,0) );
  543.  
  544. }
  545. else
  546.  
  547. if (ATRdown =="atrdn")
  548.  
  549. {
  550. GfxSelectSolidBrush( ColorRGB(180,0,0));
  551.  
  552. }
  553.  
  554. else
  555.  
  556. if ( ATRdown =="")
  557.  
  558. {
  559. GfxSelectSolidBrush( colorDarkTeal );
  560.  
  561. }
  562.  
  563. GfxSelectFont( "Arial", 10, 100 );
  564. GfxSetBkMode( 1 );
  565. GfxSetTextColor( colorBlue );
  566.  
  567. GfxSelectPen( colorBlue, 1 ); // broader color
  568. GfxCircle( 100,100,40 );
  569.  
  570. _SECTION_END();
  571.  
  572.  
  573. _SECTION_BEGIN("Exit_Beast-3");
  574.  
  575. //GT=ParamColor("GT", colorRed );
  576.  
  577. EntrylookbackPeriod=10;
  578. EntryATRperiod=1.9;
  579. EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) );
  580. ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) );
  581.  
  582.  
  583. RequestTimedRefresh( 0 );
  584. GfxSelectFont( "Tahoma", 12, 100 );
  585. GfxSetBkMode( 1 );
  586. GfxSetTextColor( colorWhite );
  587.  
  588. EntryB = WriteIf( EntrySig,"eu", "");
  589. ExitB = WriteIf( ExitSig,"ed", "");
  590.  
  591. if ( EntryB =="eu")
  592. {
  593. GfxSelectSolidBrush( ColorRGB(0,210,0) ); //
  594.  
  595. }
  596. else
  597.  
  598. if ( ExitB =="ed")
  599.  
  600. {
  601. GfxSelectSolidBrush( ColorRGB(210,0,0)); //
  602.  
  603. }
  604.  
  605. else
  606.  
  607. if ( ExitB =="")
  608.  
  609. {
  610. GfxSelectSolidBrush( colorDarkTeal );
  611.  
  612. }
  613.  
  614. GfxSelectFont( "Arial", 10, 100 );
  615. GfxSetBkMode( 1 );
  616. GfxSetTextColor( colorBlue );
  617.  
  618. GfxSelectPen( colorBlue, 1 ); // broader color
  619. GfxCircle( 100,100,30 );// changing the value of x,y,rad x-70, y-90, rad-24
  620.  
  621. _SECTION_END();
  622.  
  623.  
  624.  
  625. _SECTION_BEGIN("CCI9-2");
  626.  
  627. //HT=ParamColor("HT", colorRed );
  628.  
  629. ccidn=CCI(8) < 0;
  630. cciup=CCI(9) > 0;
  631.  
  632.  
  633. ccresult1 = WriteIf( cciup,"cu", "");
  634. ccresult2 = WriteIf( ccidn,"cd", "");
  635.  
  636.  
  637.  
  638.  
  639. RequestTimedRefresh( 0 );
  640. GfxSelectFont( "Tahoma", 12, 100 );
  641. GfxSetBkMode( 1 );
  642. GfxSetTextColor( colorWhite );
  643.  
  644. if ( ccresult1 =="cu")
  645. {
  646. GfxSelectSolidBrush( ColorRGB(0,240,0) );
  647.  
  648. }
  649. else
  650.  
  651. if ( ccresult2 =="cd")
  652.  
  653. {
  654. GfxSelectSolidBrush( ColorRGB(240,0,0));
  655.  
  656. }
  657.  
  658. else
  659.  
  660. if ( ccresult2 =="")
  661.  
  662. {
  663. GfxSelectSolidBrush( colorDarkTeal );
  664.  
  665. }
  666.  
  667. GfxSelectFont( "Arial", 10, 100 );
  668. GfxSetBkMode( 1 );
  669. GfxSetTextColor( colorBlue );
  670.  
  671. GfxSelectPen( colorBlue, 1 ); // broader color
  672. GfxCircle( 100,100,20);
  673.  
  674.  
  675.  
  676.  
  677. _SECTION_END();
  678.  
  679.  
  680.  
  681.  
  682. _SECTION_BEGIN("%BB7-1");
  683.  
  684. //IT=ParamColor("IT", colorRed );
  685. p=7;
  686. x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100;
  687. bbdown= x < 40;
  688. bbup= x > 40;
  689.  
  690. bbresult1 = WriteIf( bbup,"bu", "");
  691. bbresult2 = WriteIf( bbdown,"bd", "");
  692. bbresult3 = WriteIf( C,"bearishrevers", "");
  693.  
  694.  
  695.  
  696. RequestTimedRefresh( 0 );
  697. GfxSelectFont( "Tahoma", 12, 100 );
  698. GfxSetBkMode( 1 );
  699. GfxSetTextColor( colorWhite );
  700.  
  701. if ( bbresult1 =="bu")
  702. {
  703. GfxSelectSolidBrush( ColorRGB(62,255,62) );
  704.  
  705. }
  706. else
  707.  
  708. if ( bbresult2 =="bd")
  709.  
  710. {
  711. GfxSelectSolidBrush( ColorRGB(255,62,62) );
  712.  
  713. }
  714.  
  715. else
  716.  
  717. if ( bbresult2 =="")
  718.  
  719. {
  720. GfxSelectSolidBrush( colorDarkTeal );
  721.  
  722. }
  723.  
  724. GfxSelectFont( "Arial", 10, 100 );
  725. GfxSetBkMode( 1 );
  726. GfxSetTextColor( colorBlue );
  727.  
  728. GfxSelectPen( colorBlue, 1 ); // broader color
  729. GfxCircle( 100,100,10 );
  730.  
  731.  
  732. _SECTION_END();
  733.  
  734.  
  735. _SECTION_BEGIN("MACDHIGHBULLISH");
  736. r1 = Param( "Fast avg", 12, 2, 200, 1 );
  737. r2 = Param( "Slow avg", 26, 2, 200, 1 );
  738. r3 = Param( "Signal avg", 9, 2, 200, 1 );
  739. r4 = Param( "Wk slow", 17, 2, 200, 1 );
  740. r5 = Param( "Wk fast", 8, 2, 200, 1 );
  741. m1=MACD(r1,r2);
  742. s1=Signal(r1,r2,r3);
  743.  
  744.  
  745.  
  746.  
  747.  
  748. rsidn=m1>0 AND m1>s1;
  749. rsiresult2 = WriteIf( rsidn,"cd", "");
  750. if ( rsiresult2 =="cd")
  751.  
  752. {
  753. GfxSelectSolidBrush( ColorRGB(0,147,0));
  754.  
  755. }
  756.  
  757. else
  758.  
  759. if ( rsiresult2 =="")
  760.  
  761. {
  762. GfxSelectSolidBrush( colorDarkTeal );
  763.  
  764. }
  765. RequestTimedRefresh( 0 );
  766. GfxSelectFont( "Arial", 10, 100 );
  767. GfxSetBkMode( 1 );
  768. GfxSetTextColor( colorBlue );
  769.  
  770. GfxSelectPen( colorBlue, 1 );
  771. // broader color
  772.  
  773. GfxRectangle(80,220,120,280);
  774. _SECTION_END();
  775.  
  776. _SECTION_BEGIN("MACDLOWHBULLISH");
  777. r1 = Param( "Fast avg", 12, 2, 200, 1 );
  778. r2 = Param( "Slow avg", 26, 2, 200, 1 );
  779. r3 = Param( "Signal avg", 9, 2, 200, 1 );
  780. r4 = Param( "Wk slow", 17, 2, 200, 1 );
  781. r5 = Param( "Wk fast", 8, 2, 200, 1 );
  782. m1=MACD(r1,r2);
  783. s1=Signal(r1,r2,r3);
  784.  
  785.  
  786.  
  787.  
  788.  
  789. rsidn=m1<0 AND m1>s1;
  790. rsiresult2 = WriteIf( rsidn,"cd", "");
  791. if ( rsiresult2 =="cd")
  792.  
  793. {
  794. GfxSelectSolidBrush( ColorRGB(0,147,0));
  795.  
  796. }
  797.  
  798. else
  799.  
  800. if ( rsiresult2 =="")
  801.  
  802. {
  803. GfxSelectSolidBrush( colorDarkTeal );
  804.  
  805. }
  806. RequestTimedRefresh( 0 );
  807. GfxSelectFont( "Arial", 10, 100 );
  808. GfxSetBkMode( 1 );
  809. GfxSetTextColor( colorBlue );
  810.  
  811. GfxSelectPen( colorBlue, 1 );
  812. // broader color
  813.  
  814. GfxRectangle(120,315,180,280);
  815. _SECTION_END();
  816.  
  817. _SECTION_BEGIN("MACDLOWHBEARISH");
  818. r1 = Param( "Fast avg", 12, 2, 200, 1 );
  819. r2 = Param( "Slow avg", 26, 2, 200, 1 );
  820. r3 = Param( "Signal avg", 9, 2, 200, 1 );
  821. r4 = Param( "Wk slow", 17, 2, 200, 1 );
  822. r5 = Param( "Wk fast", 8, 2, 200, 1 );
  823. m1=MACD(r1,r2);
  824. s1=Signal(r1,r2,r3);
  825.  
  826.  
  827.  
  828.  
  829.  
  830. rsidn=m1>0 AND m1<s1;
  831. rsiresult2 = WriteIf( rsidn,"cd", "");
  832. if ( rsiresult2 =="cd")
  833.  
  834. {
  835. GfxSelectSolidBrush( ColorRGB(225,0,0));
  836.  
  837. }
  838.  
  839. else
  840.  
  841. if ( rsiresult2 =="")
  842.  
  843. {
  844. GfxSelectSolidBrush( colorDarkTeal );
  845.  
  846. }
  847. RequestTimedRefresh( 0 );
  848. GfxSelectFont( "Arial", 10, 100 );
  849. GfxSetBkMode( 1 );
  850. GfxSetTextColor( colorBlue );
  851.  
  852. GfxSelectPen( colorBlue, 1 );
  853. // broader color
  854.  
  855. GfxRectangle(20,315,80,280);
  856. _SECTION_END();
  857.  
  858. _SECTION_BEGIN("MACDHIGHHBEARISH");
  859. r1 = Param( "Fast avg", 12, 2, 200, 1 );
  860. r2 = Param( "Slow avg", 26, 2, 200, 1 );
  861. r3 = Param( "Signal avg", 9, 2, 200, 1 );
  862. r4 = Param( "Wk slow", 17, 2, 200, 1 );
  863. r5 = Param( "Wk fast", 8, 2, 200, 1 );
  864. m1=MACD(r1,r2);
  865. s1=Signal(r1,r2,r3);
  866.  
  867.  
  868.  
  869.  
  870.  
  871. rsidn=m1<0 AND m1<s1;
  872. rsiresult2 = WriteIf( rsidn,"cd", "");
  873. if ( rsiresult2 =="cd")
  874.  
  875. {
  876. GfxSelectSolidBrush( ColorRGB(225,0,0));
  877.  
  878. }
  879.  
  880. else
  881.  
  882. if ( rsiresult2 =="")
  883.  
  884. {
  885. GfxSelectSolidBrush( colorDarkTeal );
  886.  
  887. }
  888. RequestTimedRefresh( 0 );
  889. GfxSelectFont( "Arial", 10, 100 );
  890. GfxSetBkMode( 1 );
  891. GfxSetTextColor( colorBlue );
  892.  
  893. GfxSelectPen( colorBlue, 1 );
  894. // broader color
  895.  
  896. GfxRectangle(80,375,120,315);
  897. _SECTION_END();
  898.  
  899. _SECTION_BEGIN("bearishline");
  900. GfxSelectFont( "Arial", 10, 100 );
  901. GfxSetBkMode( 1 );
  902. GfxSetTextColor( colorRed );
  903.  
  904. GfxSelectPen( colorRed, 1 );
  905.  
  906.  
  907. GfxMoveTo( 25,320 );
  908. GfxLineTo( 75, 370 );
  909. _SECTION_END();
  910. _SECTION_BEGIN("bullishline");
  911. GfxSelectFont( "Arial", 10, 100 );
  912. GfxSetBkMode( 1 );
  913. GfxSetTextColor( colorGreen );
  914.  
  915. GfxSelectPen( colorGreen, 1 );
  916.  
  917.  
  918.  
  919.  
  920. GfxMoveTo( 125,225 );
  921. GfxLineTo( 175, 275 );
  922. _SECTION_END();
  923.  
  924.  
  925. _SECTION_BEGIN("volume1");
  926.  
  927.  
  928.  
  929.  
  930.  
  931. GfxSelectSolidBrush( colorDarkTeal );
  932.  
  933. GfxRoundRect(240,30,260,200,20,20);
  934.  
  935. _SECTION_END();
  936. _SECTION_BEGIN("volume2");
  937.  
  938.  
  939.  
  940.  
  941.  
  942. GfxSelectSolidBrush( colorDarkTeal );
  943.  
  944. GfxCircle( 250,180,23 );
  945.  
  946. _SECTION_END();
  947.  
  948.  
  949. _SECTION_BEGIN("spiker");
  950. C1 = Ref(C, -1);
  951. uc = C > C1; dc = C <= C1;
  952. ud = C > O; dd = C <= O;
  953.  
  954.  
  955. green = 1; blue = 2; yellow = 3; red = 4; white = 5;
  956. VType = IIf(ud,
  957. IIf(uc, green, yellow),
  958. IIf(dd,
  959. IIf(dc, red, blue), white));
  960.  
  961. /* green volume: up-day and up-close*/
  962. gv = IIf(VType == green, V, 0);
  963. /* yellow volume: up-day but down-close */
  964. yv = IIf(VType == yellow, V, 0);
  965. /* red volume: down-day and down-close */
  966. rv = IIf(VType == red, V, 0);
  967. /* blue volume: down-day but up-close */
  968. bv = IIf(VType == blue, V, 0);
  969.  
  970.  
  971. uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
  972. dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */
  973.  
  974.  
  975. VolPer = Param("Adjust Vol. MA per.", 10, 1, 255, 1);
  976. ConvPer = Param("Adjust Conv. MA per.", 4, 1, 255, 1);
  977.  
  978.  
  979. MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
  980. MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
  981. MAtv = TEMA(V, VolPer );//total volume
  982.  
  983.  
  984.  
  985.  
  986. Converge = (TEMA(MAuv - MAdv, ConvPer));
  987. Converge1 = Ref(Converge, -1);
  988. ConvergeUp = Converge > Converge1;
  989. ConvergeOver = Converge > 0;
  990. rising = ConvergeUp AND ConvergeOver;
  991. falling = !ConvergeUp AND ConvergeOver;
  992.  
  993.  
  994. _SECTION_END();
  995. _SECTION_BEGIN("vol30");
  996. rsiup=rising;
  997. rsidn=falling;
  998. down=Converge > 0;
  999. rsiresult1 = WriteIf( rsiup,"ab", "");
  1000. rsiresult2 = WriteIf( rsidn,"cd", "");
  1001. rsiresult3 = WriteIf( down,"ef", "");
  1002. RequestTimedRefresh( 0 );
  1003. if ( rsiresult1 =="ab")
  1004. {
  1005. GfxSelectSolidBrush( ColorRGB(0,147,0) );
  1006. GfxSelectFont( "Arial", 10, 100 );
  1007. GfxSetBkMode( 1 );
  1008. GfxSetTextColor( colorGreen );
  1009. GfxSelectPen( colorGreen, 1 );
  1010. }
  1011. else
  1012.  
  1013. if ( rsiresult2 =="cd")
  1014. {
  1015. GfxSelectSolidBrush( ColorRGB(0,85,0) );
  1016. GfxSelectFont( "Arial", 10, 100 );
  1017. GfxSetBkMode( 1 );
  1018. GfxSetTextColor( colorDarkGreen );
  1019. GfxSelectPen( colorDarkGreen, 1 );
  1020.  
  1021. }
  1022.  
  1023. else
  1024.  
  1025.  
  1026.  
  1027. {
  1028. GfxSelectSolidBrush( ColorRGB(255,0,0) );
  1029. GfxSelectFont( "Arial", 10, 100 );
  1030. GfxSetBkMode( 1 );
  1031. GfxSetTextColor( colorRed );
  1032. GfxSelectPen( colorRed, 1 );
  1033.  
  1034. }
  1035. GfxRectangle(241,50,259,200);
  1036.  
  1037. _SECTION_END();
  1038. _SECTION_BEGIN("vol31");
  1039. rsiup=rising;
  1040. rsidn=falling;
  1041. down=Converge > 0;
  1042. rsiresult1 = WriteIf( rsiup,"ab", "");
  1043. rsiresult2 = WriteIf( rsidn,"cd", "");
  1044. rsiresult3 = WriteIf( down,"ef", "");
  1045. RequestTimedRefresh( 0 );
  1046. if ( rsiresult1 =="ab")
  1047. {
  1048. GfxSelectSolidBrush( ColorRGB(0,147,0) );
  1049. GfxSelectFont( "Arial", 10, 100 );
  1050. GfxSetBkMode( 1 );
  1051. GfxSetTextColor( colorGreen );
  1052. GfxSelectPen( colorGreen, 1 );
  1053. }
  1054. else
  1055.  
  1056. if ( rsiresult2 =="cd")
  1057. {
  1058. GfxSelectSolidBrush( ColorRGB(0,85,0) );
  1059. GfxSelectFont( "Arial", 10, 100 );
  1060. GfxSetBkMode( 1 );
  1061. GfxSetTextColor( colorDarkGreen );
  1062. GfxSelectPen( colorDarkGreen, 1 );
  1063.  
  1064. }
  1065.  
  1066. else
  1067.  
  1068.  
  1069.  
  1070. {
  1071. GfxSelectSolidBrush( ColorRGB(255,0,0) );
  1072. GfxSelectFont( "Arial", 10, 100 );
  1073. GfxSetBkMode( 1 );
  1074. GfxSetTextColor( colorRed );
  1075. GfxSelectPen( colorRed, 1 );
  1076.  
  1077. }
  1078. GfxCircle( 250,180,22 );
  1079.  
  1080. _SECTION_END();
  1081.  
  1082. _SECTION_BEGIN("Average 0");
  1083. //Average_switch = ParamToggle("Candle On/off", "Off|On");
  1084. P = HaClose;
  1085. Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
  1086. Regression-45,Exponential,Double Exponential,Tripple
  1087. Exponential,Wilders,Simple");
  1088. Periods = Param("Periods", 20, 2, 200 );
  1089. Displacement = Param("Displacement", 1, -50, 50 );
  1090. m = 0;
  1091.  
  1092. if( Type == "Weighted" ) m= WMA( P, Periods );
  1093. if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
  1094. if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
  1095. if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
  1096. if( Type == "Exponential" ) m = EMA( P, Periods );
  1097. if( Type == "Double Exponential" ) m = DEMA( P, Periods );
  1098. if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
  1099. if( Type == "Wilders" ) m = Wilders( P, Periods );
  1100. if( Type == "Simple" ) m = MA( P, Periods );
  1101.  
  1102. Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorLightGrey),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement );
  1103.  
  1104. _SECTION_END();
  1105.  
  1106.  
  1107. _SECTION_BEGIN("Average 1");
  1108. //Average_switch = ParamToggle("Candle On/off", "Off|On");
  1109. P = HaClose;
  1110. Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
  1111. Regression-45,Exponential,Double Exponential,Tripple
  1112. Exponential,Wilders,Simple");
  1113. Periods = Param("Periods", 60, 2, 200 );
  1114. Displacement = Param("Displacement", 1, -50, 50 );
  1115. m = 0;
  1116.  
  1117. if( Type == "Weighted" ) m= WMA( P, Periods );
  1118. if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
  1119. if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
  1120. if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
  1121. if( Type == "Exponential" ) m = EMA( P, Periods );
  1122. if( Type == "Double Exponential" ) m = DEMA( P, Periods );
  1123. if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
  1124. if( Type == "Wilders" ) m = Wilders( P, Periods );
  1125. if( Type == "Simple" ) m = MA( P, Periods );
  1126.  
  1127. Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorGrey50),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
  1128.  
  1129. _SECTION_END();
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135. _SECTION_BEGIN("Average 5");
  1136. P = HaClose;
  1137. Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
  1138. Regression-45,Exponential,Double Exponential,Tripple
  1139. Exponential,Wilders,Simple");
  1140. Periods = Param("Periods", 120 ,2, 200 );
  1141. Displacement = Param("Displacement", 1, -50, 50 );
  1142. m = 0;
  1143.  
  1144. if( Type == "Weighted" ) m= WMA( P, Periods );
  1145. if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
  1146. if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
  1147. if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
  1148. if( Type == "Exponential" ) m = EMA( P, Periods );
  1149. if( Type == "Double Exponential" ) m = DEMA( P, Periods );
  1150. if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
  1151. if( Type == "Wilders" ) m = Wilders( P, Periods );
  1152. if( Type == "Simple" ) m = MA( P, Periods );
  1153.  
  1154. Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorGrey40),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
  1155. _SECTION_END();
  1156.  
  1157.  
  1158. _SECTION_BEGIN("Sell Average 3");
  1159. P = HaClose;
  1160. Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
  1161. Regression-45,Exponential,Double Exponential,Tripple
  1162. Exponential,Wilders,Simple");
  1163. Periods = Param("Periods", 180, 2, 800 );
  1164. Displacement = Param("Displacement", 1, -50, 50 );
  1165. m = 0;
  1166.  
  1167. if( Type == "Weighted" ) m= WMA( P, Periods );
  1168. if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
  1169. if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
  1170. if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
  1171. if( Type == "Exponential" ) m = EMA( P, Periods );
  1172. if( Type == "Double Exponential" ) m = DEMA( P, Periods );
  1173. if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
  1174. if( Type == "Wilders" ) m = Wilders( P, Periods );
  1175. if( Type == "Simple" ) m = MA( P, Periods );
  1176.  
  1177. Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorRGB(40,40,40)),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
  1178. _SECTION_END();
  1179. _SECTION_BEGIN("trendline");
  1180.  
  1181. farback=Param("How Far back to go",100,50,5000,10);
  1182. nBars = Param("Number of bars", 12, 5, 40);
  1183. aHPivs = H - H;aLPivs = L - L;
  1184. aHPivHighs = H - H;aLPivLows = L - L;aHPivIdxs = H - H;aLPivIdxs = L - L;
  1185. nHPivs = 0;nLPivs = 0;lastHPIdx = 0;lastLPIdx = 0;lastHPH = 0;lastLPL = 0;
  1186. curPivBarIdx = 0;
  1187. aHHVBars = HHVBars(H, nBars);aLLVBars = LLVBars(L, nBars);
  1188. aHHV = HHV(H, nBars);aLLV = LLV(L, nBars);
  1189. aVisBars = Status("barvisible");nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
  1190. _TRACE("Last visible bar: " + nLastVisBar);
  1191. curBar = (BarCount-1);curTrend = "";if (aLLVBars[curBar] < aHHVBars[curBar]) {
  1192. curTrend = "D";}else {curTrend = "U";}
  1193. for (i=0; i<farback; i++) {curBar = (BarCount - 1) - i;
  1194. if (aLLVBars[curBar] < aHHVBars[curBar]) {
  1195. if (curTrend == "U") {curTrend = "D";
  1196. curPivBarIdx = curBar - aLLVBars[curBar];aLPivs[curPivBarIdx] = 1;aLPivLows[nLPivs] = L[curPivBarIdx];
  1197. aLPivIdxs[nLPivs] = curPivBarIdx;nLPivs++;}
  1198. } else {if (curTrend == "D") {curTrend = "U";curPivBarIdx = curBar - aHHVBars[curBar];
  1199. aHPivs[curPivBarIdx] = 1;aHPivHighs[nHPivs] = H[curPivBarIdx];
  1200. aHPivIdxs[nHPivs] = curPivBarIdx;nHPivs++;}} }
  1201. curBar = (BarCount-1);candIdx = 0;candPrc = 0;lastLPIdx = aLPivIdxs[0];lastLPL = aLPivLows[0];
  1202. lastHPIdx = aHPivIdxs[0];lastHPH = aHPivHighs[0];if (lastLPIdx > lastHPIdx) {
  1203. candIdx = curBar - aHHVBars[curBar];candPrc = aHHV[curBar];
  1204. if (lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) {
  1205. aHPivs[candIdx] = 1;
  1206. for (j=0; j<nHPivs; j++) {aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
  1207. aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];}aHPivHighs[0] = candPrc ;
  1208. aHPivIdxs[0] = candIdx;nHPivs++;}} else {
  1209. candIdx = curBar - aLLVBars[curBar];candPrc = aLLV[curBar];if (lastLPL > candPrc AND
  1210. candIdx > lastHPIdx AND candIdx < curBar) {
  1211. aLPivs[candIdx] = 1;
  1212. for (j=0; j<nLPivs; j++) {aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
  1213. aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];}aLPivLows[0] = candPrc;
  1214. aLPivIdxs[0] = candIdx;nLPivs++;}}
  1215. for (k=0; k<nHPivs; k++) {_TRACE("High pivot no. " + k
  1216. + " at barindex: " + aHPivIdxs[k] + ", "
  1217. + WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
  1218. DateTime(), 1), formatDateTime)+ ", " + aHPivHighs[k]);}
  1219. a1=ahpivs==1;a2=alpivs==1;
  1220. x = Cum(1);s1=L;s11=H;pS = a2 == 1;
  1221. endt= SelectedValue(ValueWhen( pS, x, 1 ));
  1222. startt=SelectedValue(ValueWhen( pS, x, 2 ));dtS =endt-startt;
  1223. endS = SelectedValue(ValueWhen( pS, s1, 1 ) );
  1224. startS = SelectedValue( ValueWhen( pS, s1, 2 ));aS = (endS-startS)/dtS;
  1225. bS = endS;trendlineS = aS * ( x -endt ) + bS;
  1226. g3= IIf(x>startt-10,trendlineS,-1e10);
  1227.  
  1228. pR = a1== 1;endt1= SelectedValue(ValueWhen( pR, x, 1 ));
  1229. startt1=SelectedValue(ValueWhen( pR, x, 2 ));
  1230. dtR =endt1-startt1;endR = SelectedValue(ValueWhen( pR, s11, 1 ) );
  1231. startR = SelectedValue( ValueWhen( pR, s11, 2 ));
  1232. aR = (endR-startR)/dtR;bR = endR;
  1233. trendlineR = aR * ( x -endt1 ) + bR;
  1234. g4= IIf(x>startT1-10,trendlineR,-1e10);
  1235. _SECTION_END();
  1236.  
  1237. _SECTION_BEGIN("trendlineA");
  1238. dn=g3>C;
  1239. up=g3<C;
  1240. bbresult1 = WriteIf( dn,"dn", "");
  1241. bbresult2 = WriteIf( up,"up", "");
  1242. RequestTimedRefresh( 0 );
  1243. if ( bbresult1 =="dn")
  1244. {
  1245. GfxSelectSolidBrush( ColorRGB(255,0,0) );
  1246.  
  1247. }
  1248. else
  1249.  
  1250. if ( bbresult2 =="up")
  1251.  
  1252. {
  1253. GfxSelectSolidBrush( ColorRGB(0,147,0) );
  1254.  
  1255. }
  1256.  
  1257. GfxSelectFont( "Arial", 10, 100 );
  1258. GfxSetBkMode( 1 );
  1259. GfxSetTextColor( colorWhite );
  1260. GfxSelectPen( colorWhite, 1 );
  1261.  
  1262. GfxCircle( 30,229,8 );
  1263. _SECTION_END();
  1264. _SECTION_BEGIN("trendlineA");
  1265. dn=g3>C;
  1266. up=g3<C;
  1267. bbresult1 = WriteIf( dn,"dn", "");
  1268. bbresult2 = WriteIf( up,"up", "");
  1269. RequestTimedRefresh( 0 );
  1270. if ( bbresult1 =="dn")
  1271. {
  1272. GfxSelectSolidBrush( ColorRGB(255,0,0) );
  1273.  
  1274. }
  1275. else
  1276.  
  1277. if ( bbresult2 =="up")
  1278.  
  1279. {
  1280. GfxSelectSolidBrush( ColorRGB(0,147,0) );
  1281.  
  1282. }
  1283.  
  1284. GfxSelectFont( "Arial", 10, 100 );
  1285. GfxSetBkMode( 1 );
  1286. GfxSetTextColor( colorWhite );
  1287. GfxSelectPen( colorWhite, 1 );
  1288.  
  1289. GfxCircle( 168,367,8 );
  1290. _SECTION_END();
  1291.  
  1292. _SECTION_BEGIN("TRENDLINEline");
  1293. GfxSelectFont( "Arial", 10, 100 );
  1294. GfxSetBkMode( 1 );
  1295. GfxSetTextColor( colorWhite );
  1296.  
  1297. GfxSelectPen( colorWhite, 1 );
  1298.  
  1299.  
  1300.  
  1301.  
  1302. GfxMoveTo( 35,234 );
  1303. GfxLineTo( 163, 362 );
  1304. _SECTION_END();
  1305.  
  1306. _SECTION_BEGIN("traing sl");
  1307.  
  1308. function vstop_func(trBull,trBear)
  1309. {
  1310. trailArray[ 0 ] = C[ 0 ]; // initialize
  1311. for( i = 1; i < BarCount; i++ )
  1312. {
  1313. prev = trailArray[ i - 1 ];
  1314.  
  1315. if (C[ i ] > prev AND C[ i - 1 ] > prev)
  1316. {
  1317. trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
  1318. }
  1319. else if (C[ i ] < prev AND C[ i - 1 ] < prev)
  1320. {
  1321. trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
  1322. }
  1323. else if (C[ i ] > prev)
  1324. {
  1325. trailArray[ i ] = C[ i ] - trBull[ i ];
  1326. }
  1327. else
  1328. {
  1329. trailArray[ i ] = C[ i ] + trBear[ i ];
  1330. }
  1331. }
  1332. return trailArray;
  1333. }
  1334.  
  1335. per = Param("per",20, 1, 150, 1);
  1336. multBull = Param("multBull",2, 1, 4, 0.05);
  1337. multBear = Param("multBear",2, 1, 4, 0.05);
  1338.  
  1339. trBull = multBull * ATR(per);
  1340. trBear = multBear * ATR(per);
  1341.  
  1342. trailArray = vstop_func(trBull,trBear);
  1343. s0=trailArray;
  1344.  
  1345. s1= s0 > C ;
  1346. s2= s0 <C ;
  1347. ccresult1 = WriteIf( s1,"cu", "");
  1348. ccresult2 = WriteIf( s2,"cd", "");
  1349.  
  1350. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorRed);
  1351. GfxSetTextColor( ParamColor("Color",colorRed) );
  1352. Hor=Param("Horizontal Position",30,10,1200,1);
  1353. Ver=Param("Vertical Position",185,100,50,50);
  1354.  
  1355. if ( ccresult1 =="cu")
  1356.  
  1357.  
  1358. {
  1359. GfxTextOut(""+s0,Hor , Ver );
  1360. }
  1361. else
  1362.  
  1363. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorGreen );
  1364. GfxSetTextColor( ParamColor("Color",colorGreen) );
  1365. Hor=Param("Horizontal Position",75,10,1200,1);
  1366. Ver=Param("Vertical Position",185,100,50,50);
  1367.  
  1368. if ( ccresult2 =="")
  1369.  
  1370. {
  1371. GfxTextOut(""+s0,Hor , Ver );
  1372. }
  1373. _SECTION_END();
  1374.  
  1375. _SECTION_BEGIN("traing s2");
  1376.  
  1377. s0=trailArray;
  1378.  
  1379. s1= s0 > C ;
  1380. s2= s0 <C ;
  1381. ccresult1 = WriteIf( s1,"cu", "");
  1382. ccresult2 = WriteIf( s2,"cd", "");
  1383.  
  1384. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorBrightGreen );
  1385. GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
  1386. Hor=Param("Horizontal Position",30,10,1200,1);
  1387. Ver=Param("Vertical Position",185,100,50,50);
  1388.  
  1389. if ( ccresult2 =="cd")
  1390.  
  1391.  
  1392. {
  1393. GfxTextOut(""+s0,Hor , Ver );
  1394. }
  1395. else
  1396.  
  1397. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
  1398. GfxSetTextColor( ParamColor("Color",colorWhite) );
  1399. Hor=Param("Horizontal Position",75,10,1200,1);
  1400. Ver=Param("Vertical Position",185,100,50,50);
  1401.  
  1402. if ( ccresult1 =="")
  1403.  
  1404. {
  1405. GfxTextOut(""+s0,Hor , Ver );
  1406. }
  1407.  
  1408. _SECTION_END();
  1409.  
  1410. _SECTION_BEGIN("CMP");
  1411. GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
  1412. GfxSetTextColor( ParamColor("Color",colorWhite) );
  1413. Hor=Param("Horizontal Position",120,10,1200,1);
  1414. Ver=Param("Vertical Position",185,100,50,50);
  1415. GfxTextOut(""+C,Hor , Ver );
  1416.  
  1417.  
  1418. _SECTION_END();
  1419. _SECTION_BEGIN("buycircle");
  1420. GfxSelectFont( "Arial", 10, 100 );
  1421. GfxSetBkMode( 1 );
  1422. GfxSetTextColor( colorBlue );
  1423. GfxSelectPen( colorBlue, 1 );
  1424. if ( ccresult2 =="cd")
  1425. {
  1426. GfxSelectSolidBrush( ColorRGB(0,255,0) );
  1427. }
  1428. else
  1429. {
  1430. GfxSelectSolidBrush( ColorRGB(0,0,94) );
  1431. }
  1432. GfxCircle( 20,40,7 );
  1433.  
  1434. _SECTION_END();
  1435. _SECTION_BEGIN("sellcircle");
  1436. GfxSelectFont( "Arial", 10, 100 );
  1437. GfxSetBkMode( 1 );
  1438. GfxSetTextColor( colorBlue );
  1439. GfxSelectPen( colorBlue, 1 );
  1440. if ( ccresult1 =="cu")
  1441. {
  1442. GfxSelectSolidBrush( ColorRGB(255,0,0) );
  1443. }
  1444. else
  1445. {
  1446. GfxSelectSolidBrush( ColorRGB(0,0,94) );
  1447. }
  1448.  
  1449. GfxCircle( 180,40,7 );
  1450. _SECTION_END();
  1451. _SECTION_BEGIN("Trend Direction and Force Index Ribbon");
  1452. MMA=EMA(C,15);
  1453. SMMA=EMA(MMA,15);
  1454. IMPETMMA=MMA - Ref(MMA,-1);
  1455. IMPETSMMA=SMMA - Ref(SMMA,-1);
  1456. DIVMA= abs(MMA - SMMA);
  1457. AVERIMPET= (IMPETMMA+IMPETSMMA)/2;
  1458. K1=DIVMA;
  1459. K2=AVERIMPET*AVERIMPET*AVERIMPET;
  1460. TDF= K1*K2;
  1461. NTDF1=EMA(TDF/HHV(abs(TDF),15*3),3)*100;
  1462. NTDF=EMA(NTDF1,3);
  1463. Bull_Trend=NTDF>4;
  1464. Bear_Trend=NTDF<=-4;
  1465. Ribbon_kol=IIf(Bull_Trend,colorGreen, IIf(Bear_Trend,colorBlue, colorOrange));
  1466. Plot(2, "", Ribbon_kol, styleOwnScale|styleArea|styleNoLabel, -0.50,100);
  1467.  
  1468. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement