Advertisement
saisri

SWING N R

Jul 18th, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. _SECTION_BEGIN("SwingN R");
  2. //Franck LAMOTTE - 01/2010
  3.  
  4. SetChartBkColor(ParamColor("Outer panel color ",colorLightGrey)); // color of outer border
  5. SetChartOptions(0,chartShowArrows|chartShowDates);
  6. _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
  7. Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +"{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
  8.  
  9. n1 = Param("n1",3,2,4,1);
  10. n2 = Param("n2",4,3,7,1);
  11.  
  12. //SWING FORMULA//
  13. function HiLo_HL(no) {
  14. res=HHV(H,no);
  15. sup=LLV(L,no);
  16. avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
  17. avn=ValueWhen(avd!=0,avd,1);
  18. tsl=IIf(avn==1,sup,res);
  19. return tsl;
  20. }
  21. Plot(HiLo_HL(n1),"HiLo_HL",colorYellow,styleStaircase);
  22. Buy1=Cross(C,HiLo_HL(n1)) & H>Ref(H,-1) & L>Ref(L,-1);
  23. Sell1=Cross(HiLo_HL(n1),C);
  24. shape=Buy1*shapeUpArrow + Sell1*shapeDownArrow;
  25. if(ParamToggle("Shape System 1 : ", "No|Yes", 0)){PlotShapes(shape,IIf(Buy1,colorBrightGreen,colorRed),0,IIf(Buy1,Low,High));}
  26.  
  27.  
  28. _SECTION_BEGIN("xtl");
  29.  
  30. SetChartBkColor(ParamColor("Outer panel color ",colorLightGrey));
  31. tgt = 35;
  32. a = CCI(20) < -tgt;
  33. b = CCI(20) > tgt;
  34. state = IIf(a>b,-1,IIf(a==b,0,1));
  35. Color = IIf(state == 0, colorBlack, IIf(state == 1, colorBlue, IIf(state == -1, colorRed, 0)));
  36.  
  37. //Plot(state, "", color, styleHistogram);
  38.  
  39. SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
  40. _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
  41. Plot( C, "Close", color, styleNoTitle |styleCandle );
  42.  
  43. _SECTION_END();
  44.  
  45.  
  46. _SECTION_BEGIN("end 6&4");
  47. Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted");
  48. Periods = Param("Periods", 6, 2, 300 );
  49. Displacement = Param("Displacement", 4, -50, 50 );
  50. m1 = 0;
  51. m2 = 0;
  52.  
  53. if( Type == "Simple" ) {
  54. m1 = MA( H, Periods );
  55. m2 = MA( L, Periods);
  56. }
  57. if( Type == "Exponential" ) {
  58. m1 = EMA( H, Periods );
  59. m2 = EMA( L, Periods);
  60. }
  61.  
  62. if( Type == "Double Exponential" ) {
  63. m1 = DEMA( H, Periods );
  64. m2 = DEMA( L, Periods);
  65. }
  66.  
  67. if( Type == "Tripple Exponential" ) {
  68. m1 = TEMA( H, Periods );
  69. m2 = TEMA( L, Periods);
  70. }
  71.  
  72. if( Type == "Wilders" ) {
  73. m1 = Wilders( H, Periods );
  74. m2 = Wilders( L, Periods);
  75. }
  76.  
  77. if( Type == "Weighted" ) {
  78. m1 = WMA( H, Periods );
  79. m2 = WMA( L, Periods);
  80. }
  81.  
  82.  
  83. Plot( m1, _DEFAULT_NAME(), ParamColor("ColorTop", colorGreen), ParamStyle("Style"), 0, 0, Displacement );
  84. Plot( m2, _DEFAULT_NAME(), ParamColor("ColorBottom", colorRed), ParamStyle("Style"), 0, 0, Displacement );
  85.  
  86. PlotOHLC(m1,m1,m2,m2,"DMACloud",ParamColor("ColorChannel", colorLightGrey),styleCloud,Null,Null,Displacement);
  87. // Uncomment line below to plot price if Indicator is not overlaid a Price chart
  88. //Plot(C,"Close",colorBlack,styleCandle);
  89.  
  90.  
  91. ppl = ParamToggle("Plot Pivot Levels","Off|On",1);
  92. numbars = LastValue(Cum(Status("barvisible")));
  93. fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
  94. hts = -33.5;
  95.  
  96.  
  97. /* This code calculates the previous days high, low and close */
  98. Hi1 = IIf(Day()!=Ref(Day(),-1),Ref(HighestSince(Day()!=Ref(Day(),-1),H,1),-1),0);
  99. Hi = ValueWhen(Day()!=Ref(Day(),-1),Hi1,1);
  100. Lo1 = IIf(Day()!=Ref(Day(),-1),Ref(LowestSince(Day()!=Ref(Day(),-1),L,1),-1),0);
  101. Lo = ValueWhen(Day()!=Ref(Day(),-1),Lo1,1);
  102. Cl1 = IIf(Day()!=Ref(Day(),-1),Ref(C,-1),0);
  103. C1 = ValueWhen(Day()!=Ref(Day(),-1),Cl1,1);
  104.  
  105. //----------------------------------------------------------------------------------
  106.  
  107. /* This code calculates Daily Piovts */
  108.  
  109. rg = (Hi - Lo);
  110. bp = (Hi + Lo + C1)/3; bpI = LastValue (bp,1);
  111. r1 = (bp*2)-Lo; r1I = LastValue (r1,1);
  112. s1 = (bp*2)-Hi; s1I = LastValue (s1,1);
  113. r2 = bp + r1 - s1; r2I = LastValue (r2,1);
  114. s2 = bp - r1 + s1; s2I = LastValue (s2,1);
  115. r3 = bp + r2 - s1; r3I = LastValue (r3,1);
  116. s3 = bp - r2 + s1; s3I = LastValue (s3,1);
  117. r4 = bp + r2 - s2; r4I = LastValue (r4,1);
  118. s4 = bp - r2 + s2; s4I = LastValue (s4,1);
  119.  
  120. if(ppl==1) {
  121. Plot(bp,"",colorBlue,styleLine|styleLine|styleNoRescale);
  122. //Plot(s1,"",colorRed,styleLine|styleNoRescale);
  123. //Plot(s2,"",colorRed,styleLine|styleNoRescale);
  124. //Plot(s3,"",colorRed,styleLine|styleNoRescale);
  125. //Plot(s4,"",colorRed,styleLine|styleNoRescale);
  126. //Plot(r1,"",colorGreen,styleLine|styleNoRescale);
  127. //Plot(r2,"",colorGreen,styleLine|styleNoRescale);
  128. //Plot(r3,"",colorGreen,styleLine|styleNoRescale);
  129. //Plot(r4,"",colorGreen,styleLine|styleNoRescale);
  130. PlotText(" Pivot = " + WriteVal(bp,fraction), LastValue(BarIndex())-(numbars/Hts), bpI +0.05, colorBlue);
  131. PlotText(" r1 = " + WriteVal(r1,fraction), LastValue(BarIndex())-(numbars/Hts), r1I +0.05, colorGreen);
  132. PlotText(" s1 = " + WriteVal(s1,fraction), LastValue(BarIndex())-(numbars/Hts), s1I +0.05, colorRed);
  133. //PlotText(" r2 = " + WriteVal(r2,fraction), LastValue(BarIndex())-(numbars/Hts), r2I +0.05, colorGreen);
  134. //PlotText(" s2 = " + WriteVal(s2,fraction), LastValue(BarIndex())-(numbars/Hts), s2I +0.05, colorRed);
  135. //PlotText(" r3 = " + WriteVal(r3,fraction), LastValue(BarIndex())-(numbars/Hts), r3I +0.05, colorGreen);
  136. //PlotText(" s3 = " + WriteVal(s3,fraction), LastValue(BarIndex())-(numbars/Hts), s3I +0.05, colorRed);
  137. ////PlotText(" r4 = " + WriteVal(r4,fraction), LastValue(BarIndex())-(numbars/Hts), r4I +0.05, colorGreen);
  138. //PlotText(" s4 = " + WriteVal(s4,fraction), LastValue(BarIndex())-(numbars/Hts), s4I +0.05, colorRed);
  139. }
  140.  
  141. _SECTION_END();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement