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

Alert going to the chart

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

    Alert going to the chart

    Hi,

    Is there a way to make an alert show up on the chart, instead of in the "Alerts Window"?

    If so, can it be set to show for 30seconds, then to disappear?

    Thanks,

    #2
    Hello ScottieDog,

    Thanks for your post about on chart alerts.

    There is no method to redirect an alert to a chart.

    However you can do what you are suggesting through some custom programming of your indicator. The methods would involve using DrawText or DrawTextFixed, PlaySound and a time check. For the time check you could use a time span or just simply a bar count depending on the type chart.

    Here is an example using bar count as the means to remove the object.


    Code:
    [I]Variables section[/I]
    
    private int barCount = 0;
    private bool trigger = true ;
    
    .
    [I]OnBarUpDate section[/I]
    
    if (yourAlertCondition && trigger)   // trigger is bool previous set to true
    
    {
    
    DrawTextFixed("tag1", "Your Alert message", TextPosition.Center);  // Draw in center of screen for alert
    
    PlaySound(@"C:\mySound.wav");  // PlaySound is optional
    
    trigger = false ;   // change the trigger condition
    
    barCount = CurrentBar ;  // Save the current bar number for the time reference
    
    }
    
    if (Currentbar - barCount > 4 && !trigger)   // if the number of bars is greater than 4 since the alert and the trigger is false
    {
    
    RemoveDrawObject("tag1");    // Remove the drawtext object
    trigger= true;   // reEnable the trigger
    }

    Please let me know if I can be of further assistance
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Great stuff, thanks. I should be able to get it sorted from that info. Thanks.

      Comment


        #4
        Hello ScottieDog,

        Thanks for your reply.

        If you do want to try using a time system, here is an example:


        Code:
        [I]In the variables section:[/I]
        private Time myDateTime;  // Date time object to use
        private bool trigger = true ;
        
        [I]in OnBarUpdate section[/I]
        
        if (yourAlertCondition && trigger)   // trigger is bool previous set to true
        
        {
        
        DrawTextFixed("tag1", "Your Alert message", TextPosition.Center);  // Draw in center of screen for alert
        PlaySound(@"C:\mySound.wav");  // PlaySound is optional
        trigger = false ;   // change the trigger condition
        myDateTime = DateTime.Now;              // Event time
        myDateTime = myDateTime.AddSeconds(30);      // add the 30 seconds, or whatever interval duration for reset is desired.
        }
        
        if ((DateTime.Compare (DateTime.Now,myDateTime) >0) && !trigger)   // if 30 seconds have passed and the trigger is false
        {
        RemoveDrawObject("tag1");    // Remove the drawtext object
        trigger= true;   // reEnable the trigger
        }

        Please let me know if I can be of further assistance.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Today, 06:40 PM
        0 responses
        9 views
        0 likes
        Last Post algospoke  
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        7 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        7 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        168 views
        0 likes
        Last Post jeronymite  
        Started by cre8able, Today, 04:22 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X