Add(PeriodType.Tick, 1); Add(PeriodType.Minute, 240); SetStopLoss("", CalculationMode.Ticks, Mi_SL, false); SetProfitTarget(misenal, CalculationMode.Ticks, Mi_TP);
The complete code:
#region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Indicator; using NinjaTrader.Gui.Chart; using NinjaTrader.Strategy; #endregion // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { /// <summary> /// Enter the description of your strategy here /// </summary> [Description("Enter the description of your strategy here")] public class AVANTEtp : Strategy { #region Variables // Wizard generated variables private int mi_TP = 20; // Default setting for Mi_TP private int mi_SL = 286; // Default setting for Mi_SL private int mi_QT = 10; // Default setting for Mi_QT private int myBar; private bool Conditions = false; private string misenal; // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { Add(PeriodType.Tick, 1); Add(PeriodType.Minute, 240); SetStopLoss("", CalculationMode.Ticks, Mi_SL, false); SetProfitTarget(misenal, CalculationMode.Ticks, Mi_TP); CalculateOnBarClose = true; //ExitOnClose = true; //ExitOnCloseSeconds = 30; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (Close[2] < Open[0] && Low[2] > Open[0]) { EnterLong(Mi_QT,"misenal"); myBar = CurrentBar; } // Condition set 2 if(myBar == CurrentBar - 1) { myBar = 0; //The next bar has occurred. ExitLong("", ""); } } #region Properties [Description("mi valor de Take Profit")] [GridCategory("Parameters")] public int Mi_TP { get { return mi_TP; } set { mi_TP = Math.Max(1, value); } } [Description("mi valor de Stop Loss")] [GridCategory("Parameters")] public int Mi_SL { get { return mi_SL; } set { mi_SL = Math.Max(1, value); } } [Description("mi valor para cantidad")] [GridCategory("Parameters")] public int Mi_QT { get { return mi_QT; } set { mi_QT = Math.Max(1, value); } } #endregion } }
Comment