Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error message when trading manually with IB demo account

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

    Error message when trading manually with IB demo account

    Hello

    I'm testing a trading strategy before deploying to a customer, this is my first NT strategy and I'm getting errors I don't understand:

    Click image for larger version

Name:	Capture1.PNG
Views:	369
Size:	7.4 KB
ID:	1146692


    I have been able to reproduce the error fo manual trading when, from chart trader I click Buy Bid or Sell Ask, but never (so far) when I use Buy Market or Sell Market.

    When this error is triggered by the strategy, the strategy is disabled.

    Can you give me a hand with this?

    I'm using real time and historic data from this Demo IBKR account.

    Thanks in advanced.

    #2

    Please see this video also



    regards

    Comment


      #3
      Hello, thanks for writing in.

      Before submitting the order with the saved price you will need to round it to the nearest tick size. We have a method that will do this for you here:

      https://ninjatrader.com/support/help...toticksize.htm

      Please let me know if this does not resolve your inquiry.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Hi Chris

        I still got the issue.


        The problem, apparently, is when I'm submitting the stop loss and take profit orders:

        Here is the log for one case:

        DU3605895, The price does not conform to the minimum price variation for this contract. affected Order: Sell 350000 Limit @ 1.49003
        Order='62c301c664004523b1e4f46603ef7ec9/DU3605895' Name='Stop loss' New state='Rejected' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=1.37503 Quantity=350,000 Type='Stop Market' Time in force=GTC Oco='GBPUSD/000132b0.60512622.01.01' Filled=0 Fill price=0 Error='Order rejected' Native error='The price does not conform to the minimum price variation for this contract.'
        DU3605895, The price does not conform to the minimum price variation for this contract. affected Order: Sell 350000 StopMarket @ 1.37503
        Order='d3583389948f4c8e8bb5af7a09c422db/DU3605895' Name='Profit target' New state='Rejected' Instrument='GBPUSD' Action='Sell' Limit price=1.49003 Stop price=0 Quantity=350,000 Type='Limit' Time in force=GTC Oco='GBPUSD/000132b0.60512622.01.01' Filled=0 Fill price=0 Error='Order rejected' Native error='The price does not conform to the minimum price variation for this contract.'
        Order='d3583389948f4c8e8bb5af7a09c422db/DU3605895' Name='Profit target' New state='Submitted' Instrument='GBPUSD' Action='Sell' Limit price=1.49003 Stop price=0 Quantity=350,000 Type='Limit' Time in force=GTC Oco='GBPUSD/000132b0.60512622.01.01' Filled=0 Fill price=0 Error='No error' Native error=''
        Order='516846884/DU3605895' Name='STOCH_DIV_GBP_50_L_LONG_11' New state='Filled' Instrument='GBPUSD' Action='Buy' Limit price=0 Stop price=0 Quantity=350,000 Type='Market' Time in force=GTC Oco='' Filled=350000 Fill price=1.39003 Error='No error' Native error=''
        Order='62c301c664004523b1e4f46603ef7ec9/DU3605895' Name='Stop loss' New state='Submitted' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=1.37503 Quantity=350,000 Type='Stop Market' Time in force=GTC Oco='GBPUSD/000132b0.60512622.01.01' Filled=0 Fill price=0 Error='No error' Native error=''
        Execution='GBPUSD/000132b0.60512622.01.01' Instrument='GBPUSD' Account='DU3605895' Exchange=Default Price=1.39003 Quantity=350,000 Market position=Long Operation=Operation_Add Order='516846884' Time='3/17/2021 7:10 AM'
        Order='516846884/DU3605895' Name='STOCH_DIV_GBP_50_L_LONG_11' New state='Working' Instrument='GBPUSD' Action='Buy' Limit price=0 Stop price=0 Quantity=350,000 Type='Market' Time in force=GTC Oco='' Filled=350000 Fill price=1.39003 Error='No error' Native error=''
        DU3605895, The price does not conform to the minimum price variation for this contract. affected Order: Sell 350000 Limit @ 1.49003
        Order='62c301c664004523b1e4f46603ef7ec9/DU3605895' Name='Stop loss' New state='Rejected' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=1.37503 Quantity=350,000 Type='Stop Market' Time in force=GTC Oco='GBPUSD/000132b0.60512622.01.01' Filled=0 Fill price=0 Error='Order rejected' Native error='The price does not conform to the minimum price variation for this contract.'
        DU3605895, The price does not conform to the minimum price variation for this contract. affected Order: Sell 350000 StopMarket @ 1.37503
        Order='d3583389948f4c8e8bb5af7a09c422db/DU3605895' Name='Profit target' New state='Rejected' Instrument='GBPUSD' Action='Sell' Limit price=1.49003 Stop price=0 Quantity=350,000 Type='Limit' Time in force=GTC Oco='GBPUSD/000132b0.60512622.01.01' Filled=0 Fill price=0 Error='Order rejected' Native error='The price does not conform to the minimum price variation for this contract.'
        Order='d3583389948f4c8e8bb5af7a09c422db/DU3605895' Name='Profit target' New state='Submitted' Instrument='GBPUSD' Action='Sell' Limit price=1.49003 Stop price=0 Quantity=350,000 Type='Limit' Time in force=GTC Oco='GBPUSD/000132b0.60512622.01.01' Filled=0 Fill price=0 Error='No error' Native error=''
        Order='516846884/DU3605895' Name='STOCH_DIV_GBP_50_L_LONG_11' New state='Filled' Instrument='GBPUSD' Action='Buy' Limit price=0 Stop price=0 Quantity=350,000 Type='Market' Time in force=GTC Oco='' Filled=350000 Fill price=1.39003 Error='No error' Native error=''
        Order='62c301c664004523b1e4f46603ef7ec9/DU3605895' Name='Stop loss' New state='Submitted' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=1.37503 Quantity=350,000 Type='Stop Market' Time in force=GTC Oco='GBPUSD/000132b0.60512622.01.01' Filled=0 Fill price=0 Error='No error' Native error=''
        Execution='GBPUSD/000132b0.60512622.01.01' Instrument='GBPUSD' Account='DU3605895' Exchange=Default Price=1.39003 Quantity=350,000 Market position=Long Operation=Operation_Add Order='516846884' Time='3/17/2021 7:10 AM'
        Order='516846884/DU3605895' Name='STOCH_DIV_GBP_50_L_LONG_11' New state='Working' Instrument='GBPUSD' Action='Buy' Limit price=0 Stop price=0 Quantity=350,000 Type='Market' Time in force=GTC Oco='' Filled=350000 Fill price=1.39003 Error='No error' Native error=''


        The code I'm using to open the position is:

        if (signal == Signal.LONG && this.BuyTrade)
        { // opens a long order
        LastEntryOrder = EnterLong(this.PositionSize, _SignalId);
        }
        else if (signal == Signal.SHORT && this.SellTrade)
        { // opens a short order
        LastEntryOrder = EnterShort(this.PositionSize, _SignalId);
        }


        To set take profit:

        private void SetInitialTakeProfit(String SignalId, Signal SignalSide)
        {
        if (this.TpMode == TakeProfitMode.ON_DYNAMIC_TAKE_PROFIT)
        {
        double _tp = this.CalcTpAtMva(SignalSide);
        LogEvent("Setting initial take profit for " + this.TpMode + " take profit mode at price " + _tp);
        SetProfitTarget(CalculationMode.Price, Instrument.MasterInstrument.RoundToTickSize(_tp));
        }
        else if (this.TpMode == TakeProfitMode.ON_FIX_TAKE_PROFIT)
        {
        LogEvent("Setting initial take profit for " + this.TpMode + " take profit mode at " + this.TpFix + " pips away from opening price");
        SetProfitTarget(CalculationMode.Pips, this.TpFix);
        }
        else
        {
        LogEvent("Setting initial take profit for " + this.TpMode + " take profit mode at " + this.TpSafe + " pips away from opening price");
        SetProfitTarget(CalculationMode.Pips, this.TpSafe);
        }

        }


        Where :
        • TpFix and TpSafe are integers representing pips. Normal values are 20, 30, 40 to set the take profit distance in pips (20 pips, 30 pips, 40 pips repspectively.
        • _tp is a price calculated as a function of an MVA and an offset in pips.



        To set stop loss:

        The code is:

        SetStopLoss(_SignalId, CalculationMode.Pips, StopLossPips, false);

        Where:

        StopLossPips is an integer with values like 50, 100, 1000, representing the number of pips that the stop loss level needs to be away from opening price.


        Is there any setting I cpuld be missing that is generating the issue?


        The Setup:

        IQFeed for real-time and historic
        IBKR Demo account for trades.

        Could be the difference between IQFeed and IBKR data the issue?


        Thanks in advanced.

        Comment


          #5
          Adding more evidence

          Click image for larger version  Name:	Orders.PNG Views:	0 Size:	50.5 KB ID:	1146999

          I can see that the rejected orders the price sent didn't ended in 0 or 5

          The next image confirms that:

          Click image for larger version

Name:	Orders2.PNG
Views:	251
Size:	76.6 KB
ID:	1147001


          I think it is a rounding problem, but I'm applying the rounding method, what could be wrong?


          Regards
          Last edited by mchiuminatto; 03-17-2021, 08:35 AM.

          Comment


            #6
            Hello, thanks for your reply.

            Please Print out the value of the Instrument.MasterInstrument.RoundToTickSize(_tp) variable to confirm the price value is properly formatted. Also, you are using values like this.TpFix and this.TpSafe, please make sure these are in a supported format as well.

            Best regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi Chris

              For this order

              Click image for larger version

Name:	Order3.PNG
Views:	229
Size:	33.0 KB
ID:	1147126

              The print outs of the take profit (raw and rounded)

              3/17/2021 9:40:06 PM - Setting initial take profit for ON_DYNAMIC_TAKE_PROFIT take profit mode at price 0.725490000000001, rounded 0.72549

              The code that calculates and prints:

              double _tp = this.CalcTpAtMva(SignalSide);
              double _round_tp = Instrument.MasterInstrument.RoundToTickSize(_tp);
              LogEvent("Setting initial take profit for " + this.TpMode + " take profit mode at price " + _tp + ", rounded " + _round_tp);
              SetProfitTarget(CalculationMode.Price, _round_tp);

              Regards

              Comment


                #8
                Hello mchiuminatto, I found something you can do to fix this issue.
                • Shut down NinjaTrader
                • Make the adjustment below within Trader Workstation
                  • File > Global Configuration
                  • Display > Ticker Row
                  • Enable 'Allow Forex trading in 1/10 pips'
                  • OK
                • Restart TWS and NinjaTrader
                Please make this change and test the strategy again.

                Best regards.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  It worked Chris, thanks!!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ScottWalsh, Today, 04:29 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post ScottWalsh  
                  Started by rtwave, 04-12-2024, 09:30 AM
                  2 responses
                  21 views
                  0 likes
                  Last Post rtwave
                  by rtwave
                   
                  Started by tsantospinto, 04-12-2024, 07:04 PM
                  5 responses
                  69 views
                  0 likes
                  Last Post tsantospinto  
                  Started by cre8able, Today, 03:20 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post cre8able  
                  Started by Fran888, 02-16-2024, 10:48 AM
                  3 responses
                  49 views
                  0 likes
                  Last Post Sam2515
                  by Sam2515
                   
                  Working...
                  X