Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fastest way to place a long limit order?

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

    Fastest way to place a long limit order?

    I'm developing a strategy that places long limit orders at the PSAR[0] indicator value if the ask price of my equity is greater than it. I would like to place this order as soon as it is possible (i.e. as soon as the ask price is greater than or equal to the PSAR value of the previous closed bar). Initially, I was using the condition GetCurrentAsk() > PSAR[0] to place my long limit order at the PSAR[0] value, with the calculation mode to OnBarUpdate, but then I realized GetCurrentAsk() is only called once at the close of every bar, so now I'm wondering if I could have placed the order earlier. Originally I was using the following with range bars (with the CurrentBar logic to prevent multiple orders per bar):

    Code:
    Calculate = calculate.OnBarClose
    protected override void OnBarUpdate()
            {
                if (GetCurrentAsk() > PSAR[0] && tradeEntryBar != CurrentBar)
                {
                    EnterLongLimit(0,true,TradeQuantity,PSAR, "myLongEntry");
                    tradeEntryBar = CurrentBar;
                }
                
            }​
    But using OnEachTick, I am calculating the GetCurrentAsk() for each tick, then I'm using PSAR[1], which I believe the [1] would now represent the close of the previous bar (since I'm using OnEachTick).
    Code:
    Calculate = calculate.OnEachTick
    protected override void OnBarUpdate()
            {
                if (GetCurrentAsk() > PSAR[1] && tradeEntryBar != CurrentBar)
                {
                    EnterLongLimit(0,true,TradeQuantity, AuSuperTrendU111.StopDot[1], "myLongEntry");
                    tradeEntryBar = CurrentBar;
                }
                
            }​


    Or.... should I be using OnMarketData, so I would have something like this:
    Code:
    Calculate = calculate.OnBarClose
            protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    ​        {
               if (marketDataUpdate.MarketDataType == MarketDataType.Ask && marketDataUpdate.Price > PSAR[0] && tradeEntryBar != CurrentBar)
                {
                    EnterLongLimit(0,true,TradeQuantity, PSAR[0], "myLongEntry");
                    tradeEntryBar = CurrentBar;
                }​
                
            }​




    So my question is which of these 3 options (or is there another) is the fastest way of placing my limit order at the PSAR level as soon as it is possible (i.e. on the right side of the market).

    Thank you!
    Last edited by joehanus; 03-06-2025, 02:03 AM.

    #2
    Hello joehanus,

    Thank you for your post.

    If you want to do something intra-bar (as opposed to waiting until the bar closes), use Calculate.OnEachTick or Calculate.OnPriceChange.



    When using Calculate.OnEachTick or OnPriceChange, [0] is the currently building bar and [1] is the just closed bar. So PSAR[0] would be the current value of the indicator while PSAR[1] is the value of the indicator 1 bar ago.

    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