Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Little modification to Flash/Sound Bar Timer

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

    #16
    Hello Ludwik,

    While I cannot debug the script you provided I can provide a simplifed sample of how to execute code 30 seconds before the primary bar. I have attached a script that prints to the output window the times for the event. For example if you are using a 15 minute bar we may see a print like the following:

    Time of the primary last close bar is 11/7/2023 4:45:00 PM Time of the future primary bar is 11/7/2023 4:59:30 PM Time of the secondary series is 11/7/2023 4:59:30 PM


    The print happens when the time of the secondary series is greater or equal to the projected time. It resets for each new primary bar. You would need to use logic like this if you wanted to do something before the end of a primary bar. Please note that you will see varying times for the secondary series depending on how much volume the instrument in question has, if there is little volume it may wait some time which is why the secondary series timestamps may not be exactly at the projected time. It would be best to use 1 second or 1 tick granularity for the secondary series if you use a instrument that has times of low volume.
    Attached Files

    Comment


      #17
      All working now. You made my day. Thank you so much Jesse.

      Only thing I needed to do is adding an alert, which is very easy thing to do.

      Thanks again

      Comment


        #18
        I'm trying to add a modification to the SampleProjectTime which would let me to take the data from the current timeframe on chart and make calculations without phyically adding data so the data is updated upon changing timeframe on the chart. Then have an alert 30 seconds before current timeframe bar is closed.
        Issue which I'm getting triggers an alert 30 seconds after current bar opens instead of 30 seconds before it closes.

        Here are the types of code which I tried.

        Code:
         DateTime newTime = Times[0][0].AddMinutes(BarsPeriod.Value).AddSeconds(-30);
        Code:
         DateTime newTime = Times[0][0].AddMinutes(BarsPeriod.Value).AddSeconds(-(BarsPeriod.Value - 30);
        Code:
         DateTime newTime = Times[0][0].AddMinutes(BarsPeriod.Value).AddSeconds(-((BarsPeriod.Value * 60) - 30);
        None of the above is working as expected

        Could you plesae point me in the direction of how to approach it?

        Comment


          #19
          Hello Ludwik,

          Have you tried using a Print to see what values you are working with when you calculate the time? To add a number of minutes and then subtract a number of seconds would look exactly like the sample that I provided or

          Code:
           DateTime newTime = Times[0][0].AddMinutes(number of minutes to be added).AddSeconds(- number of seconds to be subtracted);
          which looks like:
          Code:
           DateTime newTime = Times[0][0].AddMinutes(15).AddSeconds(-30);
          Keep in mind the secondary series needs to be a small timeframe like 1 second, you have to add the secondary series to be able to use this type of logic.

          Comment

          Latest Posts

          Collapse

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