• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 JulieG, Today, 12:40 AM
            0 responses
            2 views
            0 likes
            Last Post JulieG
            by JulieG
             
            Started by jimjoe123, Yesterday, 09:28 PM
            2 responses
            9 views
            0 likes
            Last Post NinjaTrader_ChrisSch  
            Started by 12VMan, 08-20-2019, 09:29 AM
            2 responses
            21 views
            0 likes
            Last Post Lancer
            by Lancer
             
            Started by tgn55, Yesterday, 09:50 PM
            0 responses
            5 views
            0 likes
            Last Post tgn55
            by tgn55
             
            Started by tgn55, Yesterday, 08:57 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_ChrisSch  
            Working...
            X