Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy sync when live

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

    Strategy sync when live

    Hi I have a question regarding losing my strategy loosing sync when live.

    first is there a way to always assume account position as correct and syncronise?

    Second the only reason I worry about this would be if the strategy is prevented from going long, because it thinks it is short when in fact the account is flat.

    i am getting this issue because i am front running the bid and offer and so the strategy will try to cancel an order just before the broker confirms it as filled.

    If it isn't affecting the strategy entries or exits then I don't care, it appears to work correctly but hasn't taken any long trades, this is probably just due to the current market, it seems to be doing as designed but it is first day live so i am working though thesr kinds of issues.

    If this will effect my system, is there a way to delay cancelation for say 100ms? my broker also has a max amount of cancellations per second rule and due to front running bids and offers i was getting a few messages until i stepped up my front run spread by an extra tick, I tried IOC orders but says rithmic account did not support this.
    (my system does not use stops or take profits only limits on bid and offer so it was not related to stop or tp issues)

    If I don't have to worry about changing anything then all the better, I am recording the screen at the moment to analyse later but I am asking in advance.


    Any advice would be appreciated. Thanks in advance.
    Last edited by BurnOutTrader; 04-24-2022, 08:32 PM.

    #2
    Hello BurnOutTrader,

    You can synchronize a strategy to match an account position with IsAdoptAccountPositionAware and StartBehavior.AdoptAccountPosition.




    Your custom logic could wait until the next bar update before calling CancelOrder().
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello BurnOutTrader,

      You can synchronize a strategy to match an account position with IsAdoptAccountPositionAware and StartBehavior.AdoptAccountPosition.
      https://ninjatrader.com/support/help...itionaware.htm
      https://ninjatrader.com/support/help...rtbehavior.htm
      https://ninjatrader.com/support/help...ccountPosition

      Your custom logic could wait until the next bar update before calling CancelOrder().
      Hi ChelseaB thanks for your help

      For 'adopt account positions'; this only seems to work when first starting the strategy, as soon as a trade is entered the accounts lose sync as I don't get the confirmation until a moment later when the strategy tries to cancel an order which has just been filled, I will try adding a 1 second data series and use a 1 second bar to create a delay on my bid ask data and hopefully my order cancelations.

      I am curious if 'adopt account positions' is supposed to keep syncing positions once the strategy has started or if it is only running once at startup?

      Also will sync even matter if i am managing trades by strategy position, technically a long should still trigger if I am short correct?

      AND 1 more question, If i was using ninjtrader brokerage would i have these issues? would i have a limited number of allowed cancellations? and would i lose sync with my account from order confirmations taking 2 seconds? I have a brokerage account but at the moment i have a funded account with a firm who uses rithmic.



      Here is how I implemented adopt account positions, pretty sure this is right. please let me know If i needed to call it elsewhere in my strategy for any reaason.

      Code:
      namespace NinjaTrader.NinjaScript.Strategies
      {
      public class ChannelsV7cLive : Strategy
      {
      
      private Indicators
      private Indicators
      private
      
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"B=Front Run Bid and offer / C= adapted to syncronise with account ";
      Name = "ChannelsV7cLive";
      Calculate = Calculate.OnEachTick;
      EntriesPerDirection = 4;
      EntryHandling = EntryHandling.AllEntries;
      IsExitOnSessionCloseStrategy = true;
      ExitOnSessionCloseSeconds = 900;
      IsFillLimitOnTouch = false;
      MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
      OrderFillResolution = OrderFillResolution.Standard;
      Slippage = 0;
      StartBehavior = StartBehavior.AdoptAccountPosition;
      TimeInForce = TimeInForce.Day;
      TraceOrders = false;
      RealtimeErrorHandling = RealtimeErrorHandling.StopCancelCloseIgnoreRejects ;
      StopTargetHandling = StopTargetHandling.ByStrategyPosition;
      BarsRequiredToTrade = 20;
      // Disable this property for performance gains in Strategy Analyzer optimizations
      // See the Help Guide for additional information
      IsInstantiatedOnEachOptimizationIteration = true;
      IsAdoptAccountPositionAware = true;
      DailyStop = -10000;
      Size = 1;
      HalfSize = 2;
      MaxSize = 4;
      }
      else if (State == State.Configure)
      {
      AddDataSeries
      AddDataSeries
      AddDataSeries
      }
      else if (State == State.DataLoaded)
      {
      Indicators XXX
      }
      }
      }
      Last edited by BurnOutTrader; 04-25-2022, 02:31 AM.

      Comment


        #4
        Hello BurnOutTrader,

        Start behavior synchronization only occurs when the strategy starts.

        No, this will not continue synchronizing after the strategy is running.

        If you are short and a buy order for the same quantity is submitted, the account would be flat.

        Below is a link to a forum post about sending multiple trades to the same account and instrument.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello BurnOutTrader,

          Start behavior synchronization only occurs when the strategy starts.

          No, this will not continue synchronizing after the strategy is running.

          If you are short and a buy order for the same quantity is submitted, the account would be flat.

          Below is a link to a forum post about sending multiple trades to the same account and instrument.
          https://ninjatrader.com/support/foru...660#post792660
          Hi Chelsea,

          Can you please help me with an example of using IOC orders in code?

          'EDIT CODE DELETED'

          I have this link already NinjaTrader 8 but I am trying to figure out how to use the syntax for IOC and I have limited experience.

          Thanks mate.
          Last edited by BurnOutTrader; 04-28-2022, 04:29 PM.

          Comment


            #6
            Hello BurnOutTrader,

            Unfortunately, NinjaTrader does not support IOC (Immediate-or-Cancel) orders, FOK (Fill-or-Kill) orders, or BOC (Book-or-Cancel) orders.

            Interest for this is being tracked with ID# SFT-1489. I will add your vote to this.


            NinjaTrader supports Limit, Market, MIT, StopMarket, and StopLimit orders.

            See the help guide under orderType.

            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            66 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            141 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            76 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            47 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            51 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X