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

market replay issues

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

    market replay issues

    hi,

    "Playback101, Limit price can't be smaller than current bid. affeced order: sellshort 72000 Limit @.693"

    I'm getting the above error.

    The strategy is a multi instrument strategy. I have no issues during market analyzer testing.

    data:

    Code:
    			else if (State == State.Configure)
    			{
    				AddDataSeries("NZDUSD",Data.BarsPeriodType.Minute, 1);//1
    				AddDataSeries("AUDUSD",Data.BarsPeriodType.Minute, 1);//2
    				AddDataSeries("AUDNZD",Data.BarsPeriodType.Minute, 1);//3
    				AddDataSeries("EURUSD",Data.BarsPeriodType.Minute, 1);//4		
    				AddDataSeries("USDCAD",Data.BarsPeriodType.Minute, 1);//5				
    				AddDataSeries("NZDUSD", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);//6
    				AddDataSeries("AUDUSD", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);//7
    				AddDataSeries("AUDNZD", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);//8
    				AddDataSeries("EURUSD", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);//9
    				AddDataSeries("USDCAD", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);//10
    			}
    I'm sending limit orders to the underlying dataseries:

    Code:
    				EnterLongLimit(2,false,Convert.ToInt32(aud_Q), GetCurrentBid(0), @"audlogic1");
    or

    Code:
    				EnterLongLimit(4,false,Convert.ToInt32(eur_Q), GetCurrentBid(0), @"eurlogic1");
    etc..

    for some strange reason during replay, my orders are being sent on the primary data series, even if the order is for a different currency. and as you can see above, i'm sending the limit order to the underlying secondary/third/fourth etc dataseries.

    why is nt sending all my orders to the primary data series? this is why my orders are being rejected ..

    and yes, i have downloaded marketreplay data for each currency.
    Last edited by staycool3_a; 12-17-2017, 08:06 PM.

    #2
    Yikes - definitely nothing I tested.

    Is BarsInProgress = 1/2/3/4 when sending?

    Comment


      #3
      Originally posted by sledge View Post
      Yikes - definitely nothing I tested.

      Is BarsInProgress = 1/2/3/4 when sending?


      Code:
      			#region CurrBars
      			if (CurrentBars[0] < 1
      			|| CurrentBars[1] < 1
      			|| CurrentBars[2] < 1
      			|| CurrentBars[3] < 1
      			|| CurrentBars[4] < 1
      			|| CurrentBars[5] < 1
      			|| CurrentBars[6] < 1
      			|| CurrentBars[7] < 1
      			|| CurrentBars[8] < 1
      			|| CurrentBars[9] < 1
      			|| CurrentBars[10] < 1)
      			return;
      			#endregion

      Code:
      			if (Positions[6].MarketPosition == MarketPosition.Flat &&nzd==true &&buy==true
      			 && ...)
      			{
      				EnterLongLimit(1,false,Convert.ToInt32(nzd_Q), GetCurrentBid(0), @"nzdlogic1");
      			}
      			
      			 // logic2
      			if (Positions[6].MarketPosition == MarketPosition.Flat &&nzd==true &&sell==true
      			 && ...)
      			{
      				EnterShortLimit(1,false,Convert.ToInt32(nzd_Q), GetCurrentAsk(0), @"nzdlogic2");
      			}
      			#endregion
      Etc for 1/2/3/4/5/6/7

      I have the above instead, I think that would ensure that there are enough bars. Bars required to trade is 20.

      Also another question:

      Another question regarding limit orders.

      Suppose when my condition comes true the below is true:

      Last price:100
      Ask price:101
      Bid price:99

      When my condition comes true, I send a LIMIT order to buy at the bid price of 99. After some time passes, the price goes down, and then the ask price is 99. And then my limit order is filled. Only when the prevailing ask price equals my limit order. Is this how NT actually fills limit orders?

      Because it seems from reviewing backtested trade execution, my limit orders are being filled at last price the moment my condition to enter the market comes true,, even though in reality I couldn't possibly have had executed my order at the last price because the asking price was higher than my limit order... The whole point of sending limit orders is to get filled only when the limit price can actually be executed...

      Another example

      Suppose when my condition comes true the below is true:

      Last price:100
      Ask price:101
      Bid price:99

      When my condition comes true, I send a LIMIT order to buy at the last price of 100. Does NT have enough common sense that it will only give me a fill if the ask price decreases to a 100? Or will I have to manually add more data-series for the ask prices and check to see if ask=limit price and if ask=limit price, then fill my order at 100. I'd imagine this is basic order execution stuff already build into nt?

      Can you pls give me a example of how limit orders are actually filled and at what price. And if it follows the most basic rule of order execution (that buys occur only when asking price equals your limit price or sell occurs only when your limit sell price equals bid price).
      Last edited by staycool3_a; 12-17-2017, 11:13 PM.

      Comment


        #4
        Hello calhawk01,

        I'll create a simple script and give this a test, and I will let you know what I find.

        I appreciate your patience.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello calhawk01,

          As I was testing I was not able to reproduce and then I noticed that you are using the bid of the primary series only.

          GetCurrentBid(int barsSeriesIndex)

          Using GetCurrentBid(0) would return the bid of the primary series, not the additional series.

          Are you trying to place an order to added series using the bid price of the primary series instead of using the bid price of the added series that the order is being placed to?

          If so, you need to make sure that the bid price of the primary is equal to or less than the price of the series the order is being placed to.

          if (GetCurrentBid(0) <= GetCurrentBid(2))
          {
          EnterLongLimit(2, true, 1, GetCurrentBid(0), "entryName");
          }

          Below is a publicly available link to the help guide on GetCurrentBid().


          If you make sure that primary bid is less than the bid of the series the order is being placed to, are you still getting the error?


          As a heads up, this would not cause an issue historically, because GetCurrentBid() only returns the close price when in historical data.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          6 responses
          32 views
          0 likes
          Last Post ScottWalsh  
          Started by frankthearm, Today, 09:08 AM
          10 responses
          36 views
          0 likes
          Last Post frankthearm  
          Started by mmenigma, Today, 02:22 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by NRITV, Today, 01:15 PM
          2 responses
          10 views
          0 likes
          Last Post NRITV
          by NRITV
           
          Working...
          X