Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can someone tell me why this Strategy code is not working?

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

    Can someone tell me why this Strategy code is not working?

    I have a variable:

    double limitprice



    After OnBarUpdate I have:

    limitprice=Bollinger(0.50, 28).Lower[0] - 3* TickSize;

    after my if statement:

    {AtmStrategyCreate(OrderAction.Sell, OrderType.Limit, limitprice, 0,
    TimeInForce.Day, GetAtmStrategyUniqueId(), "Trade1",
    GetAtmStrategyUniqueId());}

    I get no error messages but the order does not fire...

    If I change the OrderType to Market and the limitprice to 0 the code works. But I don't want a market order...I want a limit order 3 ticks below the Lower Bollinger Band.

    What am I missing? The only coded example in Ninja Help was for a market order...so, please don't refer me there. Thanks in advance.

    #2
    Hello Sarasotavince,

    Thank you for your post.

    Can you please provide the code that you are using to submit these orders, so I can investigate this further?

    Are there no errors in the Log Tab of the Control Center after trying to run it?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Actually, the error log says:
      ATM Strategies can't be created on historical data

      Here's what I have figured out...please confirm if I am right or wrong.

      I saw these lines in the code and I turned them off:

      // Make sure this strategy does not execute against historical data
      if (Historical)
      return;

      like this:
      //if (Historical)
      //return;

      That used to be called REMing them out. REM = Remarks, not sure what it is called now.

      When I un-REM them ... the code worked.

      Since I was testing on historical data (market replay) I turned off the lines...

      Seems a little backwards..but it works for Market Replay. Next test is LIVE data on SIM.

      I appreciate your efforts to help me.

      Comment


        #4
        Hello Sarasotavince,

        ATM strategies from automated scripts only work in real time.

        Market replay is technically considered real time as it replays the market, and why you saw the error message when commenting or REMing them out, since the script then included historical data.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Got it. Much Thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          58 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          39 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          19 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          21 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          51 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X