Announcement

Collapse
No announcement yet.

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

    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

        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

            Comment


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

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              56 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              132 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              49 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X