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:
    Variables section
    
    private int barCount = 0;
    private bool trigger = true ;
    
    .
    OnBarUpDate section
    
    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:
        In the variables section:
        private Time myDateTime;  // Date time object to use
        private bool trigger = true ;
        
        in OnBarUpdate section
        
        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 309338, Today, 12:06 PM
        0 responses
        3 views
        0 likes
        Last Post 309338
        by 309338
         
        Started by AaronKoRn, Yesterday, 08:38 PM
        2 responses
        49 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by rocketstock, 08-05-2022, 09:36 PM
        2 responses
        73 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by ronyggg83, Yesterday, 03:48 PM
        4 responses
        49 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by preqc, 08-05-2022, 09:10 AM
        1 response
        34 views
        0 likes
        Last Post NinjaTrader_Jim  
        Working...
        X