Advertisement
saisri

first 04112012

Nov 4th, 2012
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.53 KB | None | 0 0
  1. SetChartOptions(0,chartShowArrows|chartShowDates);
  2. SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack));
  3.  
  4. Title =
  5. EncodeColor(colorWhite)+ Title = Name () + " | "
  6. +EncodeColor(colorYellow) + Date() +" | " + Interval( 2 )+ " | "
  7. +EncodeColor(colorTurquoise)+ "Op : "+ EncodeColor(colorLightGrey)+ O + " | "
  8. +EncodeColor(colorTurquoise)+ "Hi : "+ EncodeColor(colorLightGrey)+ H + " | "
  9. +EncodeColor(colorTurquoise)+ "Lo : "+ EncodeColor(colorLightGrey)+ L + " | "
  10. +EncodeColor(colorTurquoise)+ "Cls : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
  11. +EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
  12. +EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
  13. +EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1);
  14.  
  15. _SECTION_END();
  16.  
  17. _SECTION_BEGIN( "STREND" );
  18.  
  19. ZAMAN = Param( "ZAMAN", 29, 1, 2000, 1 );
  20. mtOpen = LinearReg( Open, ZAMAN ); // calculate moving trend from open
  21. mtHigh = LinearReg( High, ZAMAN ); // calculate moving trend from open
  22. mtLow = LinearReg( Low, ZAMAN ); // calculate moving trend from open
  23. mtClose = LinearReg( Close, ZAMAN ); // calculate moving trend from open
  24. // plot surrogate chart
  25. _SECTION_END();
  26.  
  27. _SECTION_BEGIN("Heiken Ashi Smoothed");
  28. SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorBlack),ParamColor("Titleblock",colorBlack ));
  29. SetChartOptions(0,chartShowArrows|chartShowDates);
  30. GraphXSpace=5;
  31. p=Param("Period",8,2,30,1);
  32. Om=MA(O,p);
  33. hm=MA(H,p);
  34. lm=MA(L,p);
  35. Cm=MA(C,p);
  36. HACLOSE=(Om+Hm+Lm+Cm)/4;
  37. HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
  38. HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
  39. HaLow = Min( Lm, Min( HaClose, HaOpen ) );
  40. PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorWhite, styleCandle | styleNoLabel );
  41. _SECTION_END();
  42. a=LinearReg(HaClose, 5 ) ;
  43. b=LinearReg( HaClose, 5 ) ;
  44.  
  45. Plot( IIf(HaHigh>HaOpen,a,b), _DEFAULT_NAME(), colorRed, ParamStyle("Style") );
  46.  
  47. Plot( LinearReg( HaOpen, 5 ), _DEFAULT_NAME(), colorWhite, ParamStyle("Style") );
  48.  
  49. _SECTION_BEGIN("kgs 12 26 ma buy sell");
  50.  
  51.  
  52. a=MA(C,3) ;
  53. b=MA(C,15) ;
  54.  
  55. Buy = Cross( a,b );
  56. Sell = Cross( b,a );
  57. //Short = Sell;
  58. //Cover = Buy;
  59.  
  60. //AlertIf( Buy, "", "MA cross BUY", 1,1+2 );
  61.  
  62. //AlertIf( Sell, "", "MA cross SELL", 2 ,1+2)
  63. AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
  64. AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
  65.  
  66.  
  67. _SECTION_END();
  68. _SECTION_BEGIN("TSKPMoMo");
  69.  
  70.  
  71. blsLong = 0;
  72.  
  73.  
  74.  
  75. KPStopLine = E_TSKPSTOPLINE(High,Low,Close);
  76. // tskp_upsell, tskp_triggerline, tskp_triggerlinevma
  77. sw = E_TSKPUPSELL(Open,High,Low,Close,Volume);
  78. KPTriggerLine = tskp_triggerline;
  79. KPFast3Val = IIf((E_TSKPFAST3(Open,High,Low,Close,Volume)> 0),1, -1);
  80. //tskp_fast2val1, tskp_fast2val2
  81. dummy = E_TSKPFAST2(Open,High,Low,Close,Volume);
  82. KPFast2Val = IIf ((tskp_fast2val1 > 0),1,-1);
  83.  
  84.  
  85.  
  86. Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
  87. sctotal = 0;
  88. sctotal = sctotal + IIf(tskp_colortmplcnd0 > 0, 1, -1);
  89. sctotal = sctotal + IIf(tskp_colortmplcnd1 > 0, 1, -1);
  90. sctotal = sctotal + IIf(tskp_colortmplcnd2 > 0, 1, -1);
  91. sctotal = sctotal + IIf(tskp_colortmplcnd3 > 0, 1, -1);
  92. sctotal = sctotal + IIf(tskp_colortmplcnd4 > 0, 1, -1);
  93. sctotal = sctotal + IIf(tskp_colortmplcnd5 > 0, 1, -1);
  94. sctotal = sctotal + IIf(tskp_colortmplcnd6 > 0, 1, -1);
  95. sctotal = sctotal + IIf(tskp_colortmplcnd7 > 0, 1, -1);
  96. sctotal = sctotal + IIf(tskp_colortmplcnd8 > 0, 1, -1);
  97.  
  98. // tskp_mediumma,tskp_mediumup,tskp_mediumdown
  99. dummy = E_TSKPMEDIUM(Close);
  100. KPMediumUP = tskp_mediumup;
  101. KPMediumDwn = tskp_mediumdown;
  102. KPMediumMA = tskp_mediumma;
  103.  
  104. // -- Create 0-initialized arrays the size of barcount
  105. aHPivs = H - H;
  106. aLPivs = L - L;
  107. aHiVal = H - H;
  108. aLoVal = L - L;
  109.  
  110.  
  111. for (curBar=5; curBar < BarCount-1; curBar++)
  112. {
  113.  
  114.  
  115. if( (blsLong == -1) OR (blsLong == 0))
  116. {
  117. if ((sctotal[CurBar] >= 5) AND (KPMediumUP[CurBar] > KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar] == 1) AND
  118. (KPFast2Val[CurBar] == 1) AND (KPTriggerLine[CurBar] >= KPStopLine[CurBar] ))
  119. {
  120. blsLong = 1;
  121. aLPivs[CurBar] = 1;
  122. aLoVal[CurBar] = Low[CurBar];
  123. }
  124. }
  125.  
  126. if( (blsLong == 1) OR (blsLong == 0))
  127. {
  128. if ((sctotal[CurBar] <= -5) AND (KPMediumDwn[CurBar] < KPMediumMA[CurBar] ) AND (KPFast3Val[CurBar] == -1) AND
  129. (KPFast2Val[CurBar] == -1) AND (KPTriggerLine[CurBar] <= KPStopLine[CurBar] ))
  130. {
  131. blsLong = -1;
  132. aHPivs[Curbar] = 1;
  133. aHiVal[Curbar] = High[Curbar];
  134. }
  135. }
  136.  
  137. if ((blsLong == 1) AND ((sctotal[CurBar] < 5) OR (KPMediumUP[CurBar] < KPMediumMA[CurBar] ) OR
  138. (KPFast2Val[CurBar] < 1) OR (KPFast3Val[CurBar] < 1) OR (KPTriggerLine[CurBar] < KPStopLine[CurBar] )) )
  139. {
  140. blsLong= 0;
  141. }
  142.  
  143. if ((blsLong == -1) AND ((sctotal[CurBar] > -5) OR (KPMediumDwn[CurBar] > KPMediumMA[CurBar] ) OR
  144. (KPFast2Val[CurBar] > -1) OR (KPFast3Val[CurBar] > -1) OR
  145. (KPTriggerLine[CurBar] > KPStopLine[CurBar] )) )
  146. {
  147. blsLong = 0;
  148. }
  149. }
  150.  
  151.  
  152. PlotShapes (IIf(aHPivs == 1, shapeSmallCircle, shapeNone) ,colorRed, layer = 0, yposition = haHigh, offset = 17 );
  153. PlotShapes (IIf(aLPivs == 1, shapeSmallCircle, shapeNone) ,colorGreen, layer = 0, yposition = haLow, offset = -8 );
  154. AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
  155. AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 );
  156.  
  157. _SECTION_END();
  158. _SECTION_BEGIN( "DESTEK D?RENÇ " );
  159.  
  160.  
  161.  
  162. SetBarsRequired( sbrAll, sbrAll );
  163. xx = Cum( 1 );
  164. nbar = Param( "nbar", 5, 2, 50, 1 );
  165.  
  166. PHigh = mtHigh > Ref( HHV( mtHigh, nbar ), -1 ) AND Ref( HHV( mtHigh, nbar ), nbar ) <= mtHigh;
  167. PHighPrice = ValueWhen( PHigh, mtHigh );
  168. PLow = mtLow < Ref( LLV( mtLow, nbar ), -1 ) AND Ref( LLV( mtLow, nbar ), nbar ) >= mtLow;
  169. PLowPrice = ValueWhen( PLow, mtLow );
  170.  
  171. startval_L = ValueWhen( PLow, mtLow, 1 );
  172. endval_L = ValueWhen( PLow, mtLow, 0 );
  173. startbar_L = ValueWhen( PLow, xx, 1 );
  174. endbar_L = ValueWhen( PLow, xx, 0 );
  175. aa_L = ( endval_L - startval_L ) / ( endbar_L - startbar_L );
  176. bb_L = startval_L;
  177. trendline_L = aa_L * ( xx - startbar_L ) + bb_L;
  178. dtrendline_L = trendline_L - Ref( trendline_L, -1 );
  179.  
  180. startval_L_extend = ValueWhen( PLow, mtLow, 2 );
  181. endval_L_extend = ValueWhen( PLow, mtLow, 1 );
  182. startbar_L_extend = ValueWhen( PLow, xx, 2 );
  183. endbar_L_extend = ValueWhen( PLow, xx, 1 );
  184. aa_L_extend = ( endval_L_extend - startval_L_extend ) / ( endbar_L_extend - startbar_L_extend );
  185. bb_L_extend = startval_L;
  186. trendline_L_extend = aa_L_extend * ( xx - startbar_L ) + endval_L_extend;
  187.  
  188. dtrendline_L_extend = trendline_L_extend - Ref( trendline_L_extend, -1 );
  189. dtrendline_L_extend = IIf( PLow, Ref( dtrendline_L, -1 ), dtrendline_L_extend );
  190.  
  191. startval_L_extend2 = ValueWhen( PLow, mtLow, 3 );
  192. endval_L_extend2 = ValueWhen( PLow, mtLow, 2 );
  193. startbar_L_extend2 = ValueWhen( PLow, xx, 3 );
  194. endbar_L_extend2 = ValueWhen( PLow, xx, 2 );
  195. aa_L_extend2 = ( endval_L_extend2 - startval_L_extend2 ) / ( endbar_L_extend2 - startbar_L_extend2 );
  196. bb_L_extend2 = endval_L_extend2;
  197. trendline_L_extend2 = aa_L_extend2 * ( xx - endbar_L_extend2 ) + endval_L_extend2;
  198.  
  199. dtrendline_L_extend2 = trendline_L_extend2 - Ref( trendline_L_extend2, -1 );
  200. dtrendline_L_extend2 = IIf( PLow, Ref( dtrendline_L_extend, -1 ), dtrendline_L_extend2 );
  201.  
  202. startval_H = ValueWhen( PHigh, mtHigh, 1 );
  203. endval_H = ValueWhen( PHigh, mtHigh, 0 );
  204. startbar_H = ValueWhen( PHigh, xx, 1 );
  205. endbar_H = ValueWhen( PHigh, xx, 0 );
  206. aa_H = ( endval_H - startval_H ) / ( endbar_H - startbar_H );
  207. bb_H = startval_H;
  208. trendline_H = aa_H * ( xx - startbar_H ) + bb_H;
  209. dtrendline_H = trendline_H - Ref( trendline_H, -1 );
  210.  
  211. startval_H_extend = ValueWhen( PHigh, mtHigh, 2 );
  212. endval_H_extend = ValueWhen( PHigh, mtHigh, 1 );
  213. startbar_H_extend = ValueWhen( PHigh, xx, 2 );
  214. endbar_H_extend = ValueWhen( PHigh, xx, 1 );
  215. aa_H_extend = ( endval_H_extend - startval_H_extend ) / ( endbar_H_extend - startbar_H_extend );
  216. bb_H_extend = startval_H;
  217. trendline_H_extend = aa_H_extend * ( xx - startbar_H ) + endval_H_extend;
  218. dtrendline_H_extend = trendline_H_extend - Ref( trendline_H_extend, -1 );
  219. dtrendline_H_extend = IIf( PHigh, Ref( dtrendline_H, -1 ), dtrendline_H_extend );
  220.  
  221. startval_H_extend2 = ValueWhen( PHigh, mtHigh, 3 );
  222. endval_H_extend2 = ValueWhen( PHigh, mtHigh, 2 );
  223. startbar_H_extend2 = ValueWhen( PHigh, xx, 3 );
  224. endbar_H_extend2 = ValueWhen( PHigh, xx, 2 );
  225. aa_H_extend2 = ( endval_H_extend2 - startval_H_extend2 ) / ( endbar_H_extend2 - startbar_H_extend2 );
  226. bb_H_extend2 = endval_H_extend2;
  227. trendline_H_extend2 = aa_H_extend2 * ( xx - endbar_H_extend2 ) + endval_H_extend2;
  228.  
  229. dtrendline_H_extend2 = trendline_H_extend2 - Ref( trendline_H_extend2, -1 );
  230. dtrendline_H_extend2 = IIf( PHigh, Ref( dtrendline_H_extend, -1 ), dtrendline_H_extend2 );
  231.  
  232. tld = ParamToggle( "All trendlines", "Show|Hide", 1 );
  233.  
  234. if ( tld )
  235. {
  236.  
  237. trendline_L = IIf( dtrendline_L > 0, trendline_L, Null );
  238. trendline_L_extend = IIf( dtrendline_L_extend > 0, trendline_L_extend, Null );
  239. trendline_L_extend2 = IIf( dtrendline_L_extend2 > 0, trendline_L_extend2, Null );
  240. trendline_H = IIf( dtrendline_H < 0, trendline_H, Null );
  241. trendline_H_extend = IIf( dtrendline_H_extend < 0, trendline_H_extend, Null );
  242. trendline_H_extend2 = IIf( dtrendline_H_extend2 < 0, trendline_H_extend2, Null );
  243. }
  244.  
  245. trendline_L_extend2 = IIf( BarsSince( Plow ) <= nbar, trendline_L_extend2, Null );
  246.  
  247. trendline_H_extend2 = IIf( BarsSince( PHigh ) <= nbar, trendline_H_extend2, Null );
  248.  
  249. GraphXSpace = 5;
  250. SetChartOptions( 0, chartShowDates );
  251. chartflag = ParamToggle( "Heikin Ashi", "show|hide", 1 );
  252.  
  253. if ( chartFlag )
  254. {
  255. }
  256. else
  257. {
  258. HaClose = ( O + H + L + C ) / 4;
  259. HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
  260. HaHigh = Max( mtHigh, Max( HaClose, HaOpen ) );
  261. HaLow = Min( mtLow, Min( HaClose, HaOpen ) );
  262. PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "Modified " + Name(), colorWhite, styleBar );
  263. }
  264.  
  265. PlotShapes( shapeHollowStar*PLow, colorYellow, 0, mtLow, -10 );
  266.  
  267. PlotShapes( shapeHollowStar*PHigh, colorRed, 0, mtHigh , 10 );
  268.  
  269. Plot( trendline_L, "", colorBrightGreen, styleLine );
  270.  
  271. Plot( IIf( BarsSince( Plow ) <= nbar, trendline_L_extend, Null ), "", colorLightGrey, styleNoLine | styleDots | styleThick );
  272. Plot( IIf( BarsSince( Plow ) > nbar, trendline_L_extend, Null ), "", colorBrightGreen, styleNoLine | styleDots | styleThick );
  273.  
  274. Plot( IIf( BarsSince( Plow ) <= nbar, trendline_L_extend2, Null ), "", colorDarkGreen, styleNoLine | styleDots | styleThick );
  275.  
  276. Plot( trendline_H, "", colorRed, styleLine );
  277.  
  278. Plot( IIf( BarsSince( PHigh ) <= nbar, trendline_H_extend, Null ), "", colorLightGrey, styleNoLine | styleDots | styleThick );
  279. Plot( IIf( BarsSince( PHigh ) > nbar, trendline_H_extend, Null ), "", colorOrange, styleNoLine | styleDots | styleThick );
  280.  
  281.  
  282.  
  283. _SECTION_BEGIN("Isfandi Technical Viewer");
  284. //Plot(C,"",ParamColor( "Color", colorBlue ),ParamStyle("Style") );
  285. //---- pivot points
  286. GfxSetBkColor(colorBlack);
  287. GfxSetTextColor( colorGrey50 );
  288. GfxSelectFont("Edwardian Script ITC", 25, 500, True );
  289. DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
  290. DayL = TimeFrameGetPrice("L", inDaily, -1);//low
  291. DayC = TimeFrameGetPrice("C", inDaily, -1);//close
  292. DayO = TimeFrameGetPrice("O", inDaily);// current day open
  293. HiDay = TimeFrameGetPrice("H", inDaily);
  294. LoDay = TimeFrameGetPrice("L", inDaily);
  295. PP = (DayH + DayL + DayO + DayO) / 4 ;
  296. R1 = (2 * PP) - DayL;
  297. S1 = (2 * PP) - DayH;
  298. R2 = PP + R1 - S1;
  299. S2 = PP + S1 - R1;
  300. R3 = R2 + (R1 - PP);
  301. S3 = S2 - (PP - S1);
  302.  
  303. radius = 0.1 * Status("pxheight"); // get pixel height of the chart and use 45% for pie chart radius
  304. textoffset = 0.1 * radius;
  305.  
  306. //====================
  307. GfxSetOverlayMode(0);
  308.  
  309. //-Paint Background
  310.  
  311. GfxSelectSolidBrush( colorBlack);
  312. GfxSelectPen( colorPink);
  313. GfxRoundRect( 2, 14, 880, 33, 32, 32 );
  314. GfxSetBkMode( 1 );
  315.  
  316. GfxSelectFont("Arial", 8, 900);
  317.  
  318.  
  319. // OTHER INDICATOR
  320. MOMETUM =RSI(14);
  321. radius = 0.1 * Status("pxheight"); // get pixel height of the chart and use 45% for pie chart radius
  322. textoffset = 0.1 * radius;
  323. GfxSelectFont("Arial", 9, 500, True );
  324. GfxSelectFont("Arial", 9 );
  325. GfxSetTextColor( colorLime);
  326. GfxTextOut( "R1 =" + R1, textoffset + 310, 17 );
  327. GfxSetTextColor( colorLime );
  328. GfxTextOut( "R2 = " +R2, textoffset + 410, 17 );
  329. GfxSetTextColor( colorWhite );
  330. GfxTextOut( "PP = " +PP, textoffset + 210, 17 );
  331. GfxSetTextColor( colorOrange );
  332. GfxTextOut( "S1 = " +S1, textoffset + 10, 17 );
  333. GfxSetTextColor( colorRed );
  334. GfxTextOut( "S2 = " +S2, textoffset + 110, 17 );
  335. GfxSelectFont("Arial", 9 );
  336. _SECTION_END();
  337.  
  338. //-Paint Background
  339.  
  340. GfxSelectSolidBrush( colorBlack);
  341. GfxSelectPen( colorBlue);
  342. GfxRoundRect( 2, 50, 880, 31, 32, 32 );
  343. GfxSetBkMode( 1 );
  344.  
  345. GfxSelectFont("Arial", 8, 900);
  346. //////////////////////////////////////////////////////////////////////
  347. _SECTION_BEGIN("Elder Impulse");
  348. GfxSelectFont("Arial", 9, 500, True );
  349. ///////////////////////////////////////////////////
  350. SetChartOptions(0,chartShowArrows|chartShowDates);
  351. EnableTextOutput(False);
  352. // User-defined parameter for EMA periods
  353. EMA_Type = Param("EMA-1, TEMA-2, JMA-3", 2, 1, 3, 1);
  354. EMA_prds = Param("EMA_periods", 7, 1, 30, 1);
  355. Std_MACD = Param("Standard MACD? No-0, Yes-1", 1, 0, 1, 1);
  356. Plot_fashion = Param("Bar+Arrows-1, Impulse Bars-2", 2, 1, 2, 1);
  357. // Allow user to define Weekly and Monthly Ribbon Location and Height
  358. WR_P1 = Param("Weekly Ribbon Location", 5.2, -1000, 1000, 0.1);
  359. WR_P2 = Param("Weekly Ribbon Height", 199, -0.001, 500, 0.1);
  360. //MR_P1 = Param("Monthly Ribbon Location", 5.2, -1000, 1000, 0.1);
  361. //MR_P2 = Param("Monthly Ribbon Height", 199, -0.001, 500, 0.1);
  362. // Compute EMA and MACD Histogram
  363. if(EMA_Type == 1)
  364. {
  365. DayEMA = EMA(Close, EMA_prds);
  366. }
  367. if (EMA_Type == 2)
  368. {
  369. DayEMA = TEMA(Close, EMA_prds);
  370. }
  371. Histogram = MACD() - Signal();
  372. // Determine if we have an Impulse UP, DOWN or None
  373. Impulse_Up = DayEMA > Ref(DayEMA, -1) AND Histogram > Ref(Histogram, -1);
  374. Impulse_Down = DayEMA < Ref(DayEMA, -1) AND Histogram < Ref(Histogram, -1);
  375. Impulse_None = (NOT Impulse_UP) AND (NOT Impulse_Down);
  376. // Compute Weekly MACD and determine whether rising or falling
  377. TimeFrameSet(inWeekly);
  378. if (Std_MACD == 0)
  379. {
  380. MACD_val = MACD(5, Cool);
  381. Signal_val = Signal(5, 8, 5);
  382. }
  383. else
  384. {
  385. MACD_val = MACD(12, 26);
  386. Signal_val = Signal(12, 26, 9);
  387. }
  388. Hist_in_w = MACD_val - Signal_val;
  389. wh_rising = Hist_in_w > Ref(Hist_in_w, -1);
  390. wh_falling = Hist_in_w < Ref(Hist_in_w, -1);
  391. wh_none = (NOT wh_rising) AND (NOT wh_falling);
  392. TimeFrameRestore();
  393. // Now get Monthly MACD Histogram....
  394. TimeFrameSet(inMonthly);
  395. MACD_val = MACD(5, 8);
  396. Signal_val = Signal(5, 8, 5);
  397. Hist_in_m = MACD_val - Signal_val;
  398. mh_rising = Hist_in_m > Ref(Hist_in_m, -1);
  399. mh_falling = Hist_in_m < Ref(Hist_in_m, -1);
  400. TimeFrameRestore();
  401. wh_rising = TimeFrameExpand( wh_rising, inWeekly, expandLast );
  402. wh_falling = TimeFrameExpand( wh_falling, inWeekly, expandLast);
  403. wh_none = TimeFrameExpand( wh_none, inWeekly, expandLast);
  404. mh_rising = TimeFrameExpand(mh_rising, inMonthly, expandLast);
  405. mh_falling = TimeFrameExpand(mh_falling, inMonthly, expandLast);
  406. kol = IIf( wh_rising, colorBrightGreen, IIf(wh_falling, colorRed, IIf(wh_none, colorCustom11, colorLightGrey)));
  407. mkol = IIf( mh_rising, colorBlue, IIf(mh_falling, colorYellow, colorLightGrey));
  408. if (Plot_fashion == 1)
  409. {
  410. }
  411. else
  412. {
  413. bar_kol = IIf(impulse_UP, colorBrightGreen, IIf(impulse_Down, colorRed, colorCustom11));
  414. }
  415. Impulse_State = WriteIf(Impulse_Up, "Bulllish", WriteIf(Impulse_Down, "Bearish", "Neutral"));
  416. GfxSetTextColor( colorYellow );
  417. GfxTextOut( "IMPULSE STATE = " +Impulse_State, textoffset + 10, 33 );
  418. // Set the background color for Impulse Status Column
  419. Impulse_Col = IIf(Impulse_Up, colorGreen, IIf(Impulse_Down, colorRed, colorGrey40));
  420. // Determine Weekly Trend. Display as Text Column
  421. Weekly_Trend = WriteIf(wh_rising, "Rising", WriteIf(wh_falling, "Falling", "Flat!"));
  422. Weekly_Col = IIf(wh_rising, colorGreen, IIf(wh_falling, colorRed, colorLightGrey));
  423. GfxSetTextColor( colorPink );
  424. GfxTextOut( "WEEKLT TREND = " +Weekly_Trend, textoffset + 500, 17 );
  425. // Determine Monthly Trend. Display as Text Column
  426. Monthly_Trend = WriteIf(mh_rising, "Rising", WriteIf(mh_falling, "Falling", "Flat!"));
  427. Monthly_Col = IIf(mh_rising, colorGreen, IIf(mh_falling, colorRed, colorLightGrey));
  428. GfxSetTextColor( colorOrange );
  429. GfxTextOut( "MONTHLY TREND = " +Monthly_Trend, textoffset + 690, 17 );
  430. // Determine how many bars has the current state existed
  431. bars_in_bull = Min(BarsSince(impulse_none), BarsSince(impulse_down));
  432. bars_in_bear = Min(BarsSince(impulse_up), BarsSince(impulse_none));
  433. bars_in_neut = Min(BarsSince(impulse_down), BarsSince(impulse_up));
  434. // Set a single variable to show number of bars in current state depending upon
  435. // actual Impulse Status - Bullish, Bearish or Neutral
  436. bars_in_state = IIf(Impulse_Up, bars_in_bull, IIf(Impulse_down, bars_in_bear, bars_in_neut));
  437. //weekly pivot
  438. k1=-1;
  439. SetChartBkColor(16 ) ;
  440. k=IIf(ParamList("select type","daily|next day")=="daily",-1,0);
  441. k1=-1;
  442. TimeFrameSet(inDaily);
  443. day_h= LastValue(Ref(H,K));
  444. day_l= LastValue(Ref(L,K));
  445. day_c= LastValue(Ref(C,K));
  446. TimeFrameRestore();
  447. // day
  448. DH=Day_h;
  449. DL=Day_L;
  450. DC=Day_C;
  451. // DAY PIVOT Calculation
  452. pd = ( DH+ DL + DC )/3;
  453. sd1 = (2*pd)-DH;
  454. sd2 = pd -(DH - DL);
  455. sd3 = Sd1 - (DH-DL);
  456. rd1 = (2*pd)-DL;
  457. rd2 = pd +(DH -DL);
  458. rd3 = rd1 +(DH-DL);
  459. WriteVal( StochK(39) - StochK(12) );
  460. GfxSelectFont("Arial", 8 );
  461. _SECTION_END();
  462.  
  463. _SECTION_BEGIN("STOCHASTIC");
  464. GfxSelectFont("Arial", 9, 500, True );
  465. periods = Param( "Periods", 15, 1, 200, 1 );
  466. Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
  467. a = StochK( periods , Ksmooth);
  468. Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
  469. b = StochD( periods , Ksmooth, DSmooth );
  470. Buy = Cross( a, b );
  471. Sell = Cross( b, a );
  472. STOCH =WriteIf(a>b , "Up","Down");
  473. GfxSetTextColor( colorYellow );
  474. GfxTextOut( "Stochastic = " +STOCH, textoffset + 200, 33 );
  475. GfxSelectFont("Arial", 8 );
  476. _SECTION_BEGIN("Van K Tharp Efficient Stocks");
  477. // Mark Keitel 12-05
  478. // Van K Tharp Efficient Stocks
  479. GfxSelectFont("Arial", 9, 500, True );
  480. ATRD180 = ATR(180);
  481. ATRD90 = ATR(90);
  482. ATRD45 = ATR(45);
  483. ATRD20 = ATR(20);
  484. ATRD5 = ATR(5);
  485. DifferenceD180 = Close - Ref(Close,-180);
  486. DifferenceD90 = Close - Ref(Close,-90);
  487. DifferenceD45 = Close - Ref(Close,-45);
  488. DifferenceD20 = Close - Ref(Close,-20);
  489. DifferenceD5 = Close - Ref(Close,-5);
  490. EfficiencyD180 = IIf(ATRD180!=0,DifferenceD180/ATRD180,1);
  491. EfficiencyD90 = IIf(ATRD90!=0,DifferenceD90/ATRD90,1);
  492. EfficiencyD45 = IIf(ATRD45!=0,DifferenceD45/ATRD45,1);
  493. EfficiencyD20 = IIf(ATRD20!=0,DifferenceD20/ATRD20,1);
  494. EfficiencyD5 = IIf(ATRD5!=0,DifferenceD5/ATRD5,1);
  495. Averageeff = (EfficiencyD180 + EfficiencyD90 + EfficiencyD45 +
  496. EfficiencyD20 ) / 4;
  497. //Plot( averageeff, "AvgEff", colorLightBlue, styleLine );
  498. x = Param ( "Add Results to a Watchlist? Yes = 1, No = 2" , 2 , 1 , 2 , 1 ) ; // select whether to add results to watchlist or not
  499. y = Param("Set Watchlist Number", 25, 2, 60,1); // sets the watchlist number, but reserves the first 2 and last 4 watchlists
  500. // -------- Parameter Variables for Exploration --------------------------------
  501. TCH = Param("High close value ", 20, 5, 300, 0.5);
  502. TCL = Param("Low close value " , 5, 1, 10, 0.25);
  503. AVP = Param("Period for Avg Vol " , 21, 10, 240, 1);
  504. SV = Param("Stock minimum Avg Vol " , 125000, 50000, 1000000, 500000);
  505. // -------------- Organize the exploration results ------------------------------------
  506. P = Param("Period for Price Delta Comparisons", 1, 1, 120, 1);
  507. P1 = Param("Period for Other Delta Comparisons", 3, 1, 120, 1);
  508. PATR = Param("Period for ATR", 5,1,21,1);
  509. PADX = Param("Period for ADX", 14, 3, 34,1);
  510. PRSI = Param("Period for RSI", 13, 3, 34,1);
  511. ADX_TREND =WriteIf(PDI(PADX)>MDI(PADX),"_ TREND UP","_TREND DOWN");
  512. GfxSetTextColor( colorYellow );
  513. GfxTextOut( "RSI(14) = " + MOMETUM + ADX_TREND , textoffset + 650,33);
  514. ADX_14 = ADX(14);
  515. GfxSetTextColor( colorYellow );
  516. GfxTextOut( "ADX_TREND = " +ADX_14+ ADX_TREND, textoffset + 380, 33 );
  517. _SECTION_END();
  518.  
  519. _SECTION_BEGIN("Ribbon");
  520. uptrend=PDI()>MDI()AND Signal()<MACD();
  521. downtrend=MDI()>PDI()AND Signal()>MACD();
  522. Plot( 1, /*efines the height of the ribbon in percent of pane width */"ribbon",
  523. IIf( uptrend, colorGreen, IIf( downtrend, colorRed,IIf(Signal()<MACD(), colorWhite, colorWhite ))), /* choose color */
  524. styleOwnScale|styleArea|styleNoLabel, -60, 17 );
  525. _SECTION_END();
  526.  
  527.  
  528. // Supertrend - Translated from Kolier MQ4
  529. // see: http://kolier.li/indicator/kolier-supertrend-indi
  530. // translation in Amibroker AFL code by E.M.Pottasch, 2011
  531.  
  532. procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
  533. {
  534. global buffer_line_down;
  535. global buffer_line_up;
  536. buffer_line_down = Null;
  537. buffer_line_up = Null;
  538.  
  539. PHASE_NONE = 0;
  540. PHASE_BUY = 1;
  541. PHASE_SELL = -1;
  542.  
  543. phase=PHASE_NONE;
  544. band_upper = 0;
  545. band_lower = 0;
  546.  
  547. for(i = ATR_Period + 1; i < BarCount; i++)
  548. {
  549. band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
  550. band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];
  551.  
  552. if(phase==PHASE_NONE)
  553. {
  554. buffer_line_up[i] = CalcPrice[i];
  555. buffer_line_down[i] = CalcPrice[i];
  556. }
  557. if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
  558. {
  559. phase = PHASE_BUY;
  560. buffer_line_up[i] = band_lower;
  561. buffer_line_up[i-1] = buffer_line_down[i-1];
  562. }
  563. if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
  564. {
  565. phase = PHASE_SELL;
  566. buffer_line_down[i] = band_upper;
  567. buffer_line_down[i-1] = buffer_line_up[i-1];
  568. }
  569. if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
  570. {
  571. if(band_lower>buffer_line_up[i-1])
  572. {
  573. buffer_line_up[i] = band_lower;
  574. }
  575. else
  576. {
  577. buffer_line_up[i] = buffer_line_up[i-1];
  578. }
  579. }
  580. if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
  581. {
  582. if(band_upper<buffer_line_down[i-1])
  583. {
  584. buffer_line_down[i] = band_upper;
  585. }
  586. else
  587. {
  588. buffer_line_down[i] = buffer_line_down[i-1];
  589. }
  590. }
  591. }
  592. }
  593.  
  594. SetBarsRequired(sbrAll,sbrAll);
  595.  
  596. TrendMode = ParamToggle("TrendMode","Off|On",0);
  597. ATR_Multiplier = Param("ATR_Multiplier",3,0.1,10,0.1);
  598. ATR_Period = Param( "ATR_Period",5,1,20,1);
  599. tr = ATR(ATR_Period);
  600.  
  601. CalcPrice = (H+L)/2;
  602. calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);
  603.  
  604. SetChartOptions(0,chartShowDates);
  605.  
  606. Plot( 2,"",IIf(buffer_line_up,colorBrightGreen,colorRed),styleOwnScale|styleArea|styleNoLabel, -400, 80 );
  607. Plot( 4,"",IIf(buffer_line_down,colorRed,colorBrightGreen),styleOwnScale|styleArea|styleNoLabel, -390, 92 );
  608.  
  609. _SECTION_BEGIN("Price Line");
  610.  
  611. PriceLineColor=ParamColor("PriceLineColor",colorYellow);
  612. PriceLevel = ParamField("PriceField", field = 3 );
  613.  
  614. Daysback = Param("Bars Back",500,10,900,1);
  615. FirstBar = BarCount - DaysBack;
  616. YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);
  617.  
  618. Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll));
  619.  
  620. side = Param("side",1,1,1000,2);
  621.  
  622. dist = 0;
  623.  
  624. for( i = 0; i < BarCount; i++ )
  625. {
  626. if(i+side== BarCount) PlotText( "\n " + PriceLevel[ i ], i, YY[ i ]-dist[i], colorRed );
  627. }
  628.  
  629. _SECTION_END();
  630.  
  631. _SECTION_BEGIN("Magfied Market Price");
  632.  
  633. //Magfied Market Price
  634. FS=Param("Font Size",15,11,100,1);
  635. GfxSelectFont("Times New Roman", FS, 700, True );
  636. GfxSetBkMode( colorWhite );
  637. GfxSetTextColor( ParamColor("Color",colorBlue) );
  638. Hor=Param("Horizontal Position",500,1,1200,1);
  639. Ver=Param("Vertical Position",110,1,830,1);
  640. GfxTextOut(""+C, Hor , Ver );
  641. YC=TimeFrameGetPrice("C",inDaily,-1);
  642. DD=Prec(C-YC,2);
  643. xx=Prec((DD/YC)*100,2);
  644. GfxSelectFont("Times New Roman", 8, 600, True );
  645. GfxSetBkMode( colorBlack );
  646. GfxSetTextColor(ParamColor("Color",colorYellow) );
  647. GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+22 );
  648.  
  649.  
  650.  
  651. _SECTION_END();
  652. _SECTION_BEGIN("system Ticker");
  653. function GetSecondNum()
  654. {
  655. Time = Now( 4 );
  656. Seconds = int( Time % 100 );
  657. Minutes = int( Time / 100 % 100 );
  658. Hours = int( Time / 10000 % 100 );
  659. SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
  660. return SecondNum;
  661. }
  662. RequestTimedRefresh( 1 );
  663. //----------------------------------------------------------------------------
  664. //----------------------------------------------------------------------------
  665. TimeFrame = Interval();
  666. SecNumber = GetSecondNum();
  667. Newperiod = SecNumber % TimeFrame == 0;
  668. SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
  669. SecsToGo = TimeFrame - SecsLeft;
  670.  
  671. x=Param(" xposn",880,100,1000,1000);
  672. y=Param(" yposn",0,40,1000,1);
  673.  
  674. GfxSelectSolidBrush( colorPink );
  675. GfxSelectPen( colorBlack, 2 );
  676. if ( NewPeriod )
  677. {
  678. GfxSelectSolidBrush( colorBlack );
  679. GfxSelectPen( colorBlack, 2 );
  680. Say( "New candle" );
  681. }
  682. GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
  683. GfxSetBkMode(1);
  684. GfxSelectFont( "Arial", 9, 700, False );
  685. GfxSetTextColor( colorBlack );
  686. GfxTextOut( "" +SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
  687. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement