Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Single Sound Alert

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

    Single Sound Alert

    Greetings,

    I have the following code in an indicator:

    Alert("Buy",NinjaTrader.Cbi.Priority.High,"Buy",lo ngWavefilename,
    1,Color.Black,Color.LimeGreen);

    DrawDot(CurrentBar.ToString(),1, Low[0]-1.5,Color.
    FromKnownColor(KnownColor.LimeGreen));


    When the alert is triggered I get several alert sounds for about a minute after the alert triggers but only ONE dot.

    How can I get the sound to trigger ONLY once?
    The continued sound seems to slow NT down and gets annoying after a few seconds.

    Thanks,

    #2
    Hello,

    You probably have CalculateOnBarClose = false? What is happenning is your alter is triggering every tick that comes in. Your dot is using the same string name so it just keeps moving your existing dot to the new location.

    I suggest either this: ClaculateOnBarClose = true
    Or create a bool flag that resets once a new bar is formed. Maybe something like this:
    //in initialize code block
    bool alertfinished = false;

    //in OnBarUpdate code block
    if(alertfinished == false)
    {
    //dot draw and alert go here
    ....
    alterfinished = true;
    }

    if(FirstTickOfBar)
    {
    alterfinished = false;
    }

    Note this is untested, but it should get you started.
    DenNinjaTrader Customer Service

    Comment


      #3
      Ben,

      Thanks for the reply. You were correct about the CalculateOnBarClose. That solved the problem.

      I've noticed an addition problem that I've discovered.

      When I use the indicator on ES charts, the display is perfect. On all types of charts Range, tick, Minute, etc.

      When I use it on any currency futures. 6E, 6J, etc the chart behaves funny when I turn the alerts on.

      The indicator places a Dot or Text above or below the price when a condition is met in the indcator in panel2. i.e. when the indicator crosses the zero line, put a dot or text in the price panel.


      When used on ES, it works fine. The 6E chart is shown below. When the Alerts are set to True (write them to the chart) the prices are rendered as a straight line with the dots at the top and bottom margin of the chart.

      Someone told me that NT will not write in two panels at the same time and this is the result. Is that true?

      Here is the code for placing the text:

      if (soundOn){
      if(CrossAbove(PO, 0, 1))
      {
      Alert("Buy",NinjaTrader.Cbi.Priority.High,"Buy",lo ngWavefilename,60,Color.Black,Color.LimeGreen);
      DrawText("Buy"+CurrentBar.ToString(), true, "‡", 2, Low[0] - 1.5 + TickSize, Color.LimeGreen, largeFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
      } }

      The DrawDot is the code in the previous post.

      Thanks,
      Attached Files

      Comment


        #4
        Hello,

        A quick look at your picture and your sample code lead me to believe that you need to change this:
        Low[0] - 1.5 + TickSize

        To:

        Low[0] - 1.5*Ticksize + TickSize

        Or something like that depening on your intentions. 1.5 is too large for the price scaling in the currency futures most likely.
        DenNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        28 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by bmartz, 03-12-2024, 06:12 AM
        2 responses
        21 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by funk10101, Today, 12:02 AM
        0 responses
        5 views
        0 likes
        Last Post funk10101  
        Started by gravdigaz6, Yesterday, 11:40 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by MarianApalaghiei, Yesterday, 10:49 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X