Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

HFT ATM Strategy Generating Unwanted Positions

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

    HFT ATM Strategy Generating Unwanted Positions

    I've created a strategy that monitors level 2 data to generate trades. It is using an ATM Strategy Template to manage the trade exits. For the most part, it is working as expected. However, in fast markets it is generating multiple positions. Are there any recommended methods of handling this?
    Attached Files

    #2
    Hello SystemTrading, thanks for your post.

    First, you would need to use Print methods throughout the code to see if anything is getting hit twice where it is not supposed to. To prevent duplicates and multiple positions, it will boil down to the code being used and how it's designed. It could be a simple bool variable that prevents blocks of code running for more than one bar e.g.

    Code:
    bool trade = true;
    
    if(Conditions To Trade && trade) 
    {
        EnterLong();
        trade = false;
    }
    
    if(Conditinos to Exit && !trade)
    {
        ExitLong();
        trade = true;
    }
    You are also using a try/catch in OnMarketData which could be suppressing an unknown error or order handling problem, try printing the Exception or remove the try catch and see if any errors come up.

    Please let me know if I can assist any further.

    Comment


      #3
      Originally posted by SystemTrading View Post
      I've created a strategy that monitors level 2 data to generate trades. It is using an ATM Strategy Template to manage the trade exits. For the most part, it is working as expected. However, in fast markets it is generating multiple positions. Are there any recommended methods of handling this?
      Hi SystemTrading,

      Nice work.


      From just a quick read of the code...

      If "HFT" in the name means you are trading from fast charts then I would not be surprised to see these of these if() statements sometimes fail.

      Code:
      if (atmLong.Position==MarketPosition.Flat)
      if (_buySignal && !buySignal)
      
      
      if (atmShort.Position==MarketPosition.Flat)
      if (_sellSignal && !sellSignal)

      When might if (atmLong.Position==MarketPosition.Flat) fail?
      When executing orders at speed on fast charts I would not be surprised to find that the (order risk approval > order execution > (broker <> NT8 sync process) is not always fast enough to ensure being sync with your actual market position prior to the next event update and "if (ATMStrategyId.Length==0)" will produce an inaccurate result.



      When might buySignal fail?
      I saw the bools Chris was referring to (buySignal, sellSignal) and at first glance it looks like they would protect you from double entries. However, if the total for _buySignal is 1.3 during event updates following a _buySignal > 1.5 signal that might potentially reset the entry protection bool buySignal too early ( buySignal = _buySignal; ).


      Best of Luck!
      HedgePlay
      Last edited by hedgeplay; 02-25-2021, 10:53 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X