Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time in Trade Display on Chart and Creating a Condition to Exit

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

    Time in Trade Display on Chart and Creating a Condition to Exit

    Does anyone know if there is a way to create a variable to calculate how long we have been in the trade and have it count and show on the chart? I have also wanted to calculate the current trade duration and exit if it above the average buy in price and has been longer than 2 hours. I have other time constraints for selling at the end of the day and only limiting trading to certain hours but I do not know if it is similar for this type of idea

    #2
    Hello, thanks for writing in. If you are using the strategy builder, there is the "Bars Since Entry" property in the Misc folder that can be printed to the screen. To measure time difference and print it ontot the chart you would need to unlock the script and use the BarTimer example as a reference.

    Kind regards,

    -ChrisL

    Comment


      #3
      So if I am using a non-time-based bar like renko or range would the bar timer work for that still?

      Comment


        #4
        Hi, thanks for the follow up. No, the bar timer would not work on non time based bars. You would need to record the time of execution using a DateTime object, then measure the time difference between that DateTime object and DateTime.Now (System time) to determine how long the trade has been active.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        80 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        41 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