Announcement

Collapse
No announcement yet.

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

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        36 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        23 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        96 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        152 views
        2 likes
        Last Post CaptainJack  
        Working...
        X