Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy - Strange result on SIM accout w/ live market data

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

    Strategy - Strange result on SIM accout w/ live market data

    I have a pretty complicated strategy that places an order using AtmStrategyCreate.
    The creation line is here:


    AtmStrategyCreate(OrderAction.Buy, OrderType.StopLimit,
    ((Convert.ToInt32(High[1]/TickSize)+entryPad)*TickSize),
    ((Convert.ToInt32(High[1]/TickSize)+entryPad)*TickSize),
    TimeInForce.Day,longOrderId, "X-STANDARD",longATMStrategyId);
    SetShortTradeStopForLongReversal();
    longTrend = true;


    The order is placed and IMMEDIATELY and I check GetAtmStrategyEntryOrderStatus(longOrderId); and get the status[2] as "Filled"
    Immediately in the next few lines I check GetAtmStrategyMarketPosition(longATMStrategyId) == MarketPosition.Flat and it returns a TRUE.

    This only seems to happen in SIM mode. And the order is Still FILLED and STILL on my DOM and Chart Trader Screens!

    In MARKET REPLAY I get FALSE when I check this value as GetAtmStrategyMarketPosition(longATMStrategyId) == MarketPosition.Long equal TRUE here when in market replay and that is correct!

    In SIM mode it happens about 60% of the time that GetAtmStrategyMarketPosition(longATMStrategyId) equals MarketPosition.Flat even though I can still see the order.

    This does not appear to be logical as in MARKET REPLAY I do not have this happen and wanted to know it it is possible there could be an issue with GetAtmStrategyMarketPosition() when in SIM


    The Code Being executed:


    string[] statusLong = GetAtmStrategyEntryOrderStatus(longOrderId);
    if (statusLong.GetLength(0) > 0)
    {
    if (debug1==true)
    if (lastlongstatus != statusLong[2] )
    {
    Print("################################## ");
    Print("# statusLong = "+statusLong[2]);
    Print("################################## ");
    lastlongstatus = statusLong[2];
    }
    if (statusLong[2] == "Filled" )
    {
    Print ("--> Long "+(GetAtmStrategyMarketPosition(longATMStrateg yId) == MarketPosition.Long));
    Print ("--> Flat "+(GetAtmStrategyMarketPosition(longATMStrateg yId) == MarketPosition.Flat));
    Print("GetAtmStrategyMarketPosition(longATMStrateg yId) : " + GetAtmStrategyMarketPosition(longATMStrategyId));
    if (GetAtmStrategyMarketPosition(longATMStrategyId) == MarketPosition.Long)
    {. . .




    the output window from this code...

    CreateNewLongEntry();
    Called Procedure CreateNewLongEntry() checking value: (longOrderId.Length == 0) True
    ***************************************
    Long Entry High. :82.07
    Long Entry. 82.08
    ***************************************
    longATMStrategyId = GetAtmStrategyUniqueId()
    **NT** Submitting order with strategy 'TradeDiv2/d6bf00b7b5574b5b83c867924e2c2bd2'
    ##################################
    # statusLong = PendingSubmit
    ##################################
    ##################################
    # statusLong = Accepted
    ##################################
    ##################################
    # statusLong = Working
    ##################################
    ##################################
    # statusLong = Filled
    ##################################
    --> Long False
    --> Flat True
    GetAtmStrategyMarketPosition(longATMStrategyId) : Flat

    #2
    mjc4118, this outcome could indeed be expected as the MarketPosition would only guaranteed to be updated as you receive the next OnBarUpdate() event.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      so what you are saying is that I should not use

      GetAtmStrategyMarketPosition(longATMStrateg yId) == MarketPosition.Long


      to determine if my position is long or short and that I am in a trade. I would think that defeats the purpose of having the ability to check that property.

      What should I check instead of this value ..am I correct in assuming that as long as:

      (statusLong[2] != "Filled") || || statusLong[2] == "PartFilled")

      Then I am in a trade correct? ..And I do not have to even check:

      GetAtmStrategyMarketPosition(longATMStrateg yId) == MarketPosition.Long

      Comment


        #4
        Correct, if you need the info intrabar you should not use MarketPosition check as this would be updated only if the next OnBarUpdate() call is done.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thank You.

          Much Appreciated.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by maybeimnotrader, Today, 12:58 PM
          0 responses
          3 views
          0 likes
          Last Post maybeimnotrader  
          Started by ETFVoyageur, Today, 10:27 AM
          1 response
          9 views
          0 likes
          Last Post bltdavid  
          Started by sofortune, Today, 11:48 AM
          1 response
          6 views
          0 likes
          Last Post Danila
          by Danila
           
          Started by schlabsm3129, 02-06-2024, 06:28 PM
          2 responses
          32 views
          0 likes
          Last Post karenmkrohn  
          Started by Mr Bread, Today, 12:01 PM
          0 responses
          8 views
          0 likes
          Last Post Mr Bread  
          Working...
          X