Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

execution issues

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    execution issues

    Hi Ninjatrader

    I have very simple strategy with profit_target and stop_loss inputed as a %. It does pretty much follow your tutorial on youtube, so it's not complex at all. there are 2 sets of conditions. one for long, another for short. I want to go long when 3 different MA lines are above the 4th and a price (close) hits one of the MAs from above(crossbelow). Short is the opposite: 3 lines are below the 4th and price hits one of the MAs from below(crossabove). So 2 actions are taken and they are EnterLong for Long positions and EnterShort when short conditions are met, nothing else in the order management section, just like in your tutorial on youtube.

    1. the biggest question to me is that all the trades get linked with each other (one trade begins where another ends) so visually they look like a curve in the strategy analizer
    2. profit target or stop loss don't work, % targets are not exceeded but they are far from input.

    3. I also don't understand why would I need to input % targets in decimals?? I was advised to do so. Say I want profit target to be 10%, so I input 0.1, then NT rounds it and displays "1". So in the backtest window I see "1" for profit and "1" for stop loss, I enter "0.06" for stop loss and it gets rounded to the nearest integer instantly. It just looks confusing and don't make sense. If I say in the wizard that target and stop will be percentages and link them to my input as per your tutorial on youtube, why won't they work as integers and be visually much less confusing then decimals looking like integers?

    Regards

    Jonas
    Last edited by ionaz; 11-16-2012, 05:53 PM.

    #2
    Jonas,

    Likely we would need to see your code here. Can you post it?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi AdamP

      Here's the code:

      Code:
              #region Variables
              // Wizard generated variables
              private double profit_Target = 0.15; // Default setting for Profit_Target
              private double stop_Loss = 0.06; // Default setting for Stop_Loss
              // 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()
              {
                  SetProfitTarget("", CalculationMode.Percent, Profit_Target);
                  SetStopLoss("", CalculationMode.Percent, Stop_Loss, false);
      
                  CalculateOnBarClose = true;
              }
      
              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
                  // Condition set 1
                  if (ema21(21)[0] > sma89(89).Plot0[0]
                      && ema5H(5)[0] > sma89(89).Plot0[0]
                      && ema5L(5)[0] > sma89(89).Plot0[0]
                      && CrossBelow(Close, ema5L(5), 1))
                  {
                      EnterLong(DefaultQuantity, "");
                  }
      
                  // Condition set 2
                  if (ema21(21)[0] < sma89(89).Plot0[0]
                      && ema5H(5)[0] < sma89(89).Plot0[0]
                      && ema5L(5)[0] < sma89(89).Plot0[0]
                      && CrossAbove(Close, ema5H(5), 1))
                  {
                      EnterShort(DefaultQuantity, "");
                  }
              }
      
              #region Properties
              [Description("")]
              [GridCategory("Parameters")]
              public double Profit_Target
              {
                  get { return profit_Target; }
                  set { profit_Target = Math.Max(1, value); }
              }
      
              [Description("")]
              [GridCategory("Parameters")]
              public double Stop_Loss
              {
                  get { return stop_Loss; }
                  set { stop_Loss = Math.Max(1, value); }
              }
              #endregion
          }
      }

      Comment


        #4
        Hello,

        The issue is here :

        Code:
        #region Properties
                [Description("")]
                [GridCategory("Parameters")]
                public double Profit_Target
                {
                    get { return profit_Target; }
                    set { profit_Target = Math.Max(1, value); }
                }
        
                [Description("")]
                [GridCategory("Parameters")]
                public double Stop_Loss
                {
                    get { return stop_Loss; }
                    set { stop_Loss = Math.Max(1, value); }
                }
                #endregion
        This would reset your stop loss and profit target variables to 1 if they were set to be less than 1.
        Adam P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        573 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        575 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X