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 Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            30 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            943 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            7 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Working...
            X