Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inside bar announcement

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

    Inside bar announcement

    I've been working on a indicator that announces (voice) various candlestick patterns. Here is the code snippet for inside bar announcement. I hear multiple
    announcements (like "Inside bar on 30" few times) when the workspace with charts for various timeframes for the same instrument is loaded. Any ideas to avoid
    it? Once settled down, it seems to work perfectly. TY

    protected override void OnBarUpdate()
    {
    if (CurrentBar == 0)
    {
    speaker.Rate = 1; // controls how fast the voice goes
    speaker.SelectVoice("Microsoft Zira Desktop"); // You can change this if you have other voices, such as Microsoft David Desktop
    timeframe = ((int)BarsPeriod.Value).ToString();
    }

    if (CurrentBar < 2)
    return;

    if (!IsFirstTickOfBar)
    return;

    bool isInsideBar = High[1]<=High[2] && Low[1]>=Low[2];

    if (isInsideBar)
    {
    BarBrushes[1] = BorderBrush;

    if (Bars.IsLastBarOfSession)
    {
    Say("Inside bar on " + timeframe);
    }
    }
    }



    #2
    Originally posted by cay7man View Post
    I've been working on a indicator that announces (voice) various candlestick patterns. Here is the code snippet for inside bar announcement. I hear multiple
    announcements (like "Inside bar on 30" few times) when the workspace with charts for various timeframes for the same instrument is loaded. Any ideas to avoid
    it? Once settled down, it seems to work perfectly. TY

    protected override void OnBarUpdate()
    {
    if (CurrentBar == 0)
    {
    speaker.Rate = 1; // controls how fast the voice goes
    speaker.SelectVoice("Microsoft Zira Desktop"); // You can change this if you have other voices, such as Microsoft David Desktop
    timeframe = ((int)BarsPeriod.Value).ToString();
    }

    if (CurrentBar < 2)
    return;

    if (!IsFirstTickOfBar)
    return;

    bool isInsideBar = High[1]<=High[2] && Low[1]>=Low[2];

    if (isInsideBar)
    {
    BarBrushes[1] = BorderBrush;

    if (Bars.IsLastBarOfSession)
    {
    Say("Inside bar on " + timeframe);
    }
    }
    }

    Hi cay7man,

    So, please, how and where are the followings defined;

    1. speaker.Rate

    2. speaker.SelectVoice

    3. timeframe

    omololu

    NB: Oooooops ... just got some tips from an indicator. So, I now know how to resolve 1, and 2 ... and probably 3.
    Last edited by omololu; 03-01-2022, 04:02 AM.

    Comment


      #3
      omololu, ok, what is the fix?

      Comment


        #4
        Hello cay7man,

        Thanks for your post.

        It looks like there is a "SpeakCompleted" that you could use.

        This is not a NinjaScript item so documentation on SpeechSynthesizers and example's may be found externally. The Microsoft documentation is linked below (publicly available resource.)



        omololu may be able to share their solution as well.

        Comment


          #5
          You may have misunderstood the issue. I resolved the issue by adding

          announce = false;
          ...

          if (state.realtime)
          announce = true;

          Now, it announces for new bars only not the historical.

          Comment


            #6
            Originally posted by cay7man View Post
            You may have misunderstood the issue. I resolved the issue by adding

            announce = false;
            ...

            if (state.realtime)
            announce = true;

            Now, it announces for new bars only not the historical.
            Hi cay7man,

            I really did not have a fix ... just trying to understand the indicator, and in the course of that, I ran into this indicator here, and which gave me the insights to the requirements for the indicator to even run.

            Great that you resolve the issue ... I'll add these new codes and see the results. Meanwhile, it will be great and appreciated if you can share the full code with me.

            Thanks.

            omololu

            Comment


              #7
              Sure, PM me your email addr so I can share the complete indicator. I will post it as a free indicator after some more testing.

              Comment

              Latest Posts

              Collapse

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