Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Checking my stop order

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

    Checking my stop order

    While performing backtesting on a strategy, I am getting a 'Calculated stop order price for strategy.... was smaller/equal 0.' message in the log. No stop order placed.' It looks like it is only once per instrument.

    I am using the strategy wizard to set the stop loss to the value of one of the dynamic user defined variables; i.e., the Variable0 is set to a value on the bar proceeding the entry bar upon entering the Long/Short position. Something like:

    Code:
    Variable0 = Close[1];
    Then the stop loss is assigned to the value for Variable0.

    I don't see the SetStopLoss() method called anywhere in the code.

    My question is, is this working? iI the log reflecting perhaps the first stop loss set up? Or am I not getting any stop losses?

    I can unlock the code I suppose, but I am still changing alot of the strategy and it is much simpler to use the wizard.

    Thanks for any help.

    #2
    Day Trading Fool, you can view the code without unlocking it. If you don't mind, could you please copy + paste the code from the strategy here? It will assist us with helping you.

    So if SetStopLoss() isn't being called anywhere, is there any where else a stop could be set?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Ok - Here is part of it:

      Code:
              protected override void Initialize()
              {
                  Add(BobsIndicator(4));
                  Add(VOL());
      
                  SetStopLoss("", CalculationMode.Price, Variable0, false);
      
                  CalculateOnBarClose = true;
              }
      
              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
                  // Condition set 1
                  if (Position.MarketPosition == MarketPosition.Flat
                      && BobsIndicator(4).High[0] >= BobsIndicator(4).High[1])
                  {
                      EnterLong(DefaultQuantity, "Long");
                      Variable0 = BobsIndicator(4).Low[1];
                      Alert("MyAlert0", Priority.High, "Enter Long", @"C:\Program Files\NinjaTrader 6.5\sounds\Alert1.wav", 0, Color.White, Color.Green);
                      DrawDot("Stop Long Order" + CurrentBar, false, 0, Variable0, Color.Blue);
                  }

      Comment


        #4
        Day Trading Fool, a stop loss is being set in the code in the Initialize() section. Please make sure your Variable0 is never negative.
        AustinNinjaTrader Customer Service

        Comment


          #5
          It is never negative.

          I unlocked the code while i was waiting and added the SetStopLoss(Variable0) line after the assignment. I then printed Variable0 to the output window. Something is defintely not working right.

          Comment


            #6
            You likely see this at the beginning of the chart / trading history as your custom indicator is 'catching' up with the prices until calculated as expected.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Is it correct to say that the stop-loss was not being set before I added the SetStopLoss() code? After the SetStopLoss(), the strategy behaves very differently.

              I am using the Heiken - Ashi candlestick on the chart, making it somewhat difficult to see actual price behavior to check for a correct stop loss execution.

              Digressing a little - is there a way to make both the traditional candle and the Heiken-Ashi appear on the same chart? After the HA is applied, I cannot get traditional candlesticks (or any other price maker for that matter) to draw on the chart unless I change the properties of the chart, which seems to re-draw or re-apply everything.

              Comment


                #8
                Correct, the SetStopLoss call would add the StopLoss to the strategy - I think it would be best to debug this with your custom stop working on a regular candlestick chart for best visualization, you can then later let the final strategy run on the chart with the HA indicator applied (though even with this working you should still see all needed wicks in the candles).
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Ahh ok - finally figured out what the problem was. The stop loss was running to something over two decimal places. Rounding took care of the problem.

                  Thanks for the help!

                  Comment


                    #10
                    You're welcome - great you got it figured out!
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by arvidvanstaey, Today, 02:19 PM
                    4 responses
                    11 views
                    0 likes
                    Last Post arvidvanstaey  
                    Started by samish18, 04-17-2024, 08:57 AM
                    16 responses
                    60 views
                    0 likes
                    Last Post samish18  
                    Started by jordanq2, Today, 03:10 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post jordanq2  
                    Started by traderqz, Today, 12:06 AM
                    10 responses
                    18 views
                    0 likes
                    Last Post traderqz  
                    Started by algospoke, 04-17-2024, 06:40 PM
                    5 responses
                    47 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X