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 pjsmith, 09-25-2022, 07:13 AM
        7 responses
        57 views
        0 likes
        Last Post pjsmith
        by pjsmith
         
        Started by elliot5, Today, 03:28 AM
        0 responses
        9 views
        0 likes
        Last Post elliot5
        by elliot5
         
        Started by knarfoe, 09-23-2021, 05:19 AM
        7 responses
        66 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by EstheYund, Today, 01:56 AM
        0 responses
        12 views
        0 likes
        Last Post EstheYund  
        Started by Daveman0, 09-25-2022, 11:14 PM
        4 responses
        46 views
        0 likes
        Last Post jeronymite  
        Working...
        X