Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. #region Using declarations
  2. using System;
  3. using System.ComponentModel;
  4. using System.Diagnostics;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Xml.Serialization;
  8. using NinjaTrader.Cbi;
  9. using NinjaTrader.Data;
  10. using NinjaTrader.Gui.Chart;
  11. #endregion
  12.  
  13. // This namespace holds all indicators and is required. Do not change it.
  14. namespace NinjaTrader.Indicator
  15. {
  16. /// <summary>
  17. /// lower low then privous and better finish
  18. /// </summary>
  19. [Description("lower low then privous and better finish")]
  20. public class bottomReversal : Indicator
  21. {
  22. #region Variables
  23. // Wizard generated variables
  24. private int myInput0 = 1; // Default setting for MyInput0
  25. // User defined variables (add any user defined variables below)
  26. #endregion
  27.  
  28. /// <summary>
  29. /// This method is used to configure the indicator and is called once before any bar data is loaded.
  30. /// </summary>
  31. protected override void Initialize()
  32. {
  33. Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.TriangleUp, "Plot0"));
  34. Overlay = true;
  35. }
  36.  
  37. /// <summary>
  38. /// Called on each bar update event (incoming tick)
  39. /// </summary>
  40. protected override void OnBarUpdate()
  41. {
  42. // Use this method for calculating your indicator values. Assign a value to each
  43. // plot below by replacing 'Close[0]' with your own formula.
  44. if (CurrentBar <2) return;
  45. Value.Set(Math.Sign(Low[0]-Low[1])>Math.Sign(Low[1]-Low[2])? Low[1]:0);
  46.  
  47. }
  48.  
  49. #region Properties
  50. [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
  51. [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
  52. public DataSeries Plot0
  53. {
  54. get { return Values[0]; }
  55. }
  56.  
  57. [Description("")]
  58. [GridCategory("Parameters")]
  59. public int MyInput0
  60. {
  61. get { return myInput0; }
  62. set { myInput0 = Math.Max(1, value); }
  63. }
  64. #endregion
  65. }
  66. }
  67.  
  68. #region NinjaScript generated code. Neither change nor remove.
  69. // This namespace holds all indicators and is required. Do not change it.
  70. namespace NinjaTrader.Indicator
  71. {
  72. public partial class Indicator : IndicatorBase
  73. {
  74. private bottomReversal[] cachebottomReversal = null;
  75.  
  76. private static bottomReversal checkbottomReversal = new bottomReversal();
  77.  
  78. /// <summary>
  79. /// lower low then privous and better finish
  80. /// </summary>
  81. /// <returns></returns>
  82. public bottomReversal bottomReversal(int myInput0)
  83. {
  84. return bottomReversal(Input, myInput0);
  85. }
  86.  
  87. /// <summary>
  88. /// lower low then privous and better finish
  89. /// </summary>
  90. /// <returns></returns>
  91. public bottomReversal bottomReversal(Data.IDataSeries input, int myInput0)
  92. {
  93. if (cachebottomReversal != null)
  94. for (int idx = 0; idx < cachebottomReversal.Length; idx++)
  95. if (cachebottomReversal[idx].MyInput0 == myInput0 && cachebottomReversal[idx].EqualsInput(input))
  96. return cachebottomReversal[idx];
  97.  
  98. lock (checkbottomReversal)
  99. {
  100. checkbottomReversal.MyInput0 = myInput0;
  101. myInput0 = checkbottomReversal.MyInput0;
  102.  
  103. if (cachebottomReversal != null)
  104. for (int idx = 0; idx < cachebottomReversal.Length; idx++)
  105. if (cachebottomReversal[idx].MyInput0 == myInput0 && cachebottomReversal[idx].EqualsInput(input))
  106. return cachebottomReversal[idx];
  107.  
  108. bottomReversal indicator = new bottomReversal();
  109. indicator.BarsRequired = BarsRequired;
  110. indicator.CalculateOnBarClose = CalculateOnBarClose;
  111. #if NT7
  112. indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
  113. indicator.MaximumBarsLookBack = MaximumBarsLookBack;
  114. #endif
  115. indicator.Input = input;
  116. indicator.MyInput0 = myInput0;
  117. Indicators.Add(indicator);
  118. indicator.SetUp();
  119.  
  120. bottomReversal[] tmp = new bottomReversal[cachebottomReversal == null ? 1 : cachebottomReversal.Length + 1];
  121. if (cachebottomReversal != null)
  122. cachebottomReversal.CopyTo(tmp, 0);
  123. tmp[tmp.Length - 1] = indicator;
  124. cachebottomReversal = tmp;
  125. return indicator;
  126. }
  127. }
  128. }
  129. }
  130.  
  131. // This namespace holds all market analyzer column definitions and is required. Do not change it.
  132. namespace NinjaTrader.MarketAnalyzer
  133. {
  134. public partial class Column : ColumnBase
  135. {
  136. /// <summary>
  137. /// lower low then privous and better finish
  138. /// </summary>
  139. /// <returns></returns>
  140. [Gui.Design.WizardCondition("Indicator")]
  141. public Indicator.bottomReversal bottomReversal(int myInput0)
  142. {
  143. return _indicator.bottomReversal(Input, myInput0);
  144. }
  145.  
  146. /// <summary>
  147. /// lower low then privous and better finish
  148. /// </summary>
  149. /// <returns></returns>
  150. public Indicator.bottomReversal bottomReversal(Data.IDataSeries input, int myInput0)
  151. {
  152. return _indicator.bottomReversal(input, myInput0);
  153. }
  154. }
  155. }
  156.  
  157. // This namespace holds all strategies and is required. Do not change it.
  158. namespace NinjaTrader.Strategy
  159. {
  160. public partial class Strategy : StrategyBase
  161. {
  162. /// <summary>
  163. /// lower low then privous and better finish
  164. /// </summary>
  165. /// <returns></returns>
  166. [Gui.Design.WizardCondition("Indicator")]
  167. public Indicator.bottomReversal bottomReversal(int myInput0)
  168. {
  169. return _indicator.bottomReversal(Input, myInput0);
  170. }
  171.  
  172. /// <summary>
  173. /// lower low then privous and better finish
  174. /// </summary>
  175. /// <returns></returns>
  176. public Indicator.bottomReversal bottomReversal(Data.IDataSeries input, int myInput0)
  177. {
  178. if (InInitialize && input == null)
  179. throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
  180.  
  181. return _indicator.bottomReversal(input, myInput0);
  182. }
  183. }
  184. }
  185. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement