Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Timing changes in currency pair values

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

    Timing changes in currency pair values

    Hi,
    I am a newbie and have the following question:

    As part of a strategy I would like to develop in order to tes it, I want to time how long it takes between the current last value a currency pair traded at and the previous last value a currency pair traded at.

    If the time taken for the price to change by a certain amount (eg 1/100th of a USD in EURUSD pair - tick value) is below some threshold time (0.2 sec for example) I wish to then execute some other statements.


    How would I get the time between previous currency pair value changes in Ninjascript?

    Regards,
    Shane

    #2
    MrScrillz,

    This would basically require programming.

    Something like Time[0]-PreviousTime would work if calculate on bar close is set to false, or you can use the OnMarketData() method to calculate it.

    Are you looking to program this yourself or to use the strategy wizard?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      I would ultimately program it because the logic will end up with some degree of complexity for what I intend to do (eg - add machine learning potentially).

      But as a first building block I can just use the strategy wizard to test that I can get time between successive last trades.
      Regards,
      Shane

      Comment


        #4
        MrScrillz,

        Nice. I did some machine learning in college for face recognition projects.

        Well, the strategy wizard won't allow you to check between two times like that. It doesn't allow calculations unless they are within an indicator, so unless you create an indicator that provides you with some value you can compare to, it will have to be coded manually into the strategy rather than using the strategy wizard.

        If you declare variables :

        int previoustime = 0;
        int timedifference = 0;

        Then use OnMarketData() as follows :
        Code:
        protected override void OnMarketData(MarketDataEventArgs e)
        {
              if (e.MarketDataType == MarketDataType.Last) 
              {
                     timedifference = ToTime(e.Time) - previoustime;
                     previoustime = ToTime(e.Time);
              }
        }
        You can compare times between ticks, however I believe the resolution on this is in seconds. As such you may need to use something like :

        e.Time.Millisecond

        To access the milliseconds of its time stamp.

        For more information on OnMarketData() please see the following link.



        For more information on DateTime objects, please see the following link.

        Represents an instant in time, typically expressed as a date and time of day.


        Please let me know if I may assist further.
        Last edited by NinjaTrader_AdamP; 11-30-2011, 11:05 AM.
        Adam P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, Yesterday, 10:06 AM
        0 responses
        20 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        18 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        14 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        9 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        38 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X