Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get Speed of Price Change

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

    Get Speed of Price Change

    Is their a builtin method that allows one to get the speed at which a price changed? Not really bid/ask change but when a price is changed as a result of taking liquidity. Say bid is 10 and ask is 11. I don't care about the speed at which they trade at 10 or 11 I care about the price when it changes to 9 or 12.

    Any ideas to point me in the right direction would be appreciated.

    My first thought is to use OnMarketData and inside create a timer that starts a timer at say 10 and stops it when price goes to 9 or 12. It feels hackish but I also don't know how this timer will act in market replay when running at full speed.

    Thanks,

    #2
    Hi bc24fl, thanks for your post.

    I would not recommend doing this with the Time[] array on historical data as that uses DateTime objects which only have a 15 millisecond resolution, so it would not be accurate. You would need to use a stop watch like so:

    Code:
    private Stopwatch stopWatch = new Stopwatch();
    
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
            {
                stopWatch.Stop();
    
                TimeSpan ts = stopWatch.Elapsed;
                Print(String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                ts.Hours, ts.Minutes, ts.Seconds,
                ts.Milliseconds / 10));
                stopWatch.Reset();
                stopWatch.Start();
            }
    If you wanted to try this on historical data, you would run this code on a 1 tick series:

    Code:
    private DateTime TimeNow;
    private DateTime PreviousTime;
    
    ...
    
    else if(State == State.DataLoaded)
    {
        TimeNow = Time.GetValueAt(0);
        PreviousTime = Time.GetValueAt(0);
    }
    
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
        if(CurrentBar < 1)
            return;
    
        TimeNow = Time[0];
        Print("Time since last OMD call:" + TimeNow.Subtract(PreviousTime).Milliseconds);
    
        PreviousTime = TimeNow;    
    }

    Comment


      #3
      Thank you. I guess i'll have to test this in realtime.

      Comment


        #4
        Are you using the Stopwatch efficiently in .NET?

        Comment


          #5
          Hello All, Hope you are well, I have a quick question! I am developing an indicator that can use Tick Replay to get the Delta values of bars. I have already developed the Bid/Ask Delta. I am having issues calculating the UpDownTick Delta. I have tried all the combinations I could think of, closest I came to the actual

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          602 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          347 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          559 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          559 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X