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 NullPointStrategies, Today, 05:17 AM
      0 responses
      20 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      119 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      63 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      41 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      45 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X