Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order rejected

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

    Order rejected

    Hello Ninja Team!

    My strategy was on today for ES and M6E, and i got few errors, it might not be an issue(or I might need to change my code) but I wanted to confirm. Please see attachment.

    Thanks in advance!
    Attached Files

    #2
    Hello Bobisam,

    Thanks for your post.

    Can you clarify if you are using a ATM strategy or a Ninjascript/strategy builder strategy?

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi, Paul!

      I am using NinjaScript itself. So, once entry conditions are met, strategy executing a long position M6E at 1.1263

      My stop loss:

      Code:
      if (Position.MarketPosition == MarketPosition.Long)
      {
      SetStopLoss(CalculationMode.Price, execution.Order.AverageFillPrice - (2*ATR(100)[0]));
      }
      Looking at logs, it seems that the strategy set stop loss above long position's average price. Can you tell me what is wrong here please?

      Comment


        #4
        Hello Bobisam,

        Thanks for your post.

        I would recommend that you add code to ensure that the current price is greater than execution.Order.AverageFillPrice - (2*ATR(100)[0] before actually placing the stop order.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks Paul,

          Just wanted to make sure I implemented correctly to avoid order rejection issue(stop loss)

          Code:
          if (Position.MarketPosition == MarketPosition.Long && Close[0]>execution.Order.AverageFillPrice - (2*ATR(100)[0]))
                              {
                              SetStopLoss(CalculationMode.Price, execution.Order.AverageFillPrice - (2*ATR(100)[0]));
                              }
          
                          if (Position.MarketPosition == MarketPosition.Short && Close[0]<execution.Order.AverageFillPrice + (2*ATR(100)[0]))
                              {
                              SetStopLoss(CalculationMode.Price, execution.Order.AverageFillPrice + (2*ATR(100)[0]));
                              }

          I have another question, what should I do if I want to backtest stocks using strategy analyzer, my ninja only comes with cme data, but stocks were separate subscription, do I need to subscribe for stocks data to backtest or is it free for backtesting?

          Comment


            #6
            Hello Bobisam,

            Thanks for your reply.

            Please make sure you always confirm with a test using the Sim101 account.

            Backtesting would require access to historical data. If your data provider offers stock data you would need to check with them regarding their historical data.

            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            4 responses
            23 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Brevo, Today, 01:45 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by rjbtrade1, 11-30-2023, 04:38 PM
            2 responses
            74 views
            0 likes
            Last Post DavidHP
            by DavidHP
             
            Started by suroot, 04-10-2017, 02:18 AM
            5 responses
            3,021 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by Stanfillirenfro, Today, 07:23 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X