Advertisement
saisri

final 1

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