Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

can't place limit order

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

    can't place limit order

    Hi, while backtesting I'd like to open a short position with a certain take profit and then if the price goes up just sell again (kind of a martingala but just one time)
    In the code of the simpleMA i just changed adding thes 2 rows, but when i do th backtest i can't see the limit order placed, why is that?

    if (CrossAbove(smaFast, smaSlow, 1))
    {
    var result = EnterShortLimit(GetCurrentBid() * 1.008);
    SetProfitTarget(CalculationMode.Price, GetCurrentBid() / 1.001);
    EnterShort();
    }
    thank you

    #2
    Hi Alessio, thanks for writing in.

    The Sell limit order needs to be at or above the Ask price, it could be getting ignored or rejected. Check the log tab of the Control Center for any errors, and also turn on TraceOrders = true in State.SetDefaults and monitor the NinjaScript Output window when running the backtest to look for ignored orders. Also, make sure to set EntriesPerDirection to at least 2 for both entries to happen.

    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Yes all of these are checked but still it doesn't send the order. Also in real time it works perfectly, i don't get why in backtest it doesnt.

      Comment


        #4
        Hi Alessio, thanks for your reply.

        Sorry, I should have seen this earlier, but the reason is likely because the order is not being re-submitted on every bar so it's getting canceled on the next bar. You can use this overload and set isLiveUntilCancelled to true to keep the order alive:

        EnterShortLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName)

        Best regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thanks you are right, unfortunately the problem persist, i set to true the trace order and i used OnOrderUpdate to print the state of the order and it goes with no error and is : submitted then accepted and then in working, but if i look at the graph in the playback using historical data i can't manage to see the limit order in the graph:
          orderId='bb5716c8b8ad4c86b738e4990593b382' account='Playback101' name='griglia1' orderState=Submitted instrument='FDAX 12-21' orderAction=SellShort orderType='Limit' limitPrice=15272 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=3813 time='2021-10-11 08:44:10' gtd='2099-12-01' statementDate='2021-10-11'

          orderId='bb5716c8b8ad4c86b738e4990593b382' account='Playback101' name='griglia1' orderState=Accepted instrument='FDAX 12-21' orderAction=SellShort orderType='Limit' limitPrice=15272 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=3813 time='2021-10-11 08:44:10' gtd='2099-12-01' statementDate='2021-10-11'

          orderId='bb5716c8b8ad4c86b738e4990593b382' account='Playback101' name='griglia1' orderState=Working instrument='FDAX 12-21' orderAction=SellShort orderType='Limit' limitPrice=15272 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=3813 time='2021-10-11 08:44:10' gtd='2099-12-01' statementDate='2021-10-11'

          The limit price is over the current price so if i place a sell order it shouldn't be a problem. Now I'm just trying to put a limit order in the backtest with no other intention, just to see if i can use them. Thanks

          Entries per direction = 150 so i don't have any problem there


          Comment


            #6
            Hi Alessio,

            Do you have ChartTrader enabled in the chart? That needs to be enabled to see the resting orders on the account.

            Best regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thanks that was it, i didn't enabled the charttrader....

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by trilliantrader, 04-18-2024, 08:16 AM
              4 responses
              18 views
              0 likes
              Last Post trilliantrader  
              Started by mgco4you, Today, 09:46 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by wzgy0920, Today, 09:53 PM
              0 responses
              9 views
              0 likes
              Last Post wzgy0920  
              Started by Rapine Heihei, Today, 08:19 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by Rapine Heihei, Today, 08:25 PM
              0 responses
              10 views
              0 likes
              Last Post Rapine Heihei  
              Working...
              X