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

Prior to bar close alert

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

    Prior to bar close alert

    Hi all,

    Is there any indicator or way of having a alert prior to a bar close eg 5m chart and 20secs before close you get a alert.

    I've seen a script for on bar close but it would be useful to have prior.

    Thanks

    Bread

    #2
    Hello Mr Bread,

    Yes that is possible but would require using a secondary series if you also wanted this to work historically. In realtime you can use incoming market data and the timestamps from that data to complete actions when a specified time is met. Historically you would need to add a bar series that has 20 second timestamps or less so you could check if the time is past that time or not.

    I am not aware of a specific pre built script for this purpose but is something you could make. To compare times you would need to project a future bar close time based on the previous bar close. For example if the time of the last closed bar is 12:00 you would get the next bars time by adding 4:40 minutes to that time. In C# DateTime objects have an AddMinutes and AddSeconds methods

    Code:
    DateTime futureBarClose = Time[0].AddMinutes(4).AddSeconds(40);
    Returns a new DateTime that adds the specified number of minutes to the value of this instance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse

      I have this as a existing script for the bar close.....

      region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Gui.Tools;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.DrawingTools;
      #endregion

      //This namespace holds Indicators in this folder and is required. Do not change it.
      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class BarCloseAlert : Indicator
      {
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "BarCloseAlert";
      Calculate = Calculate.OnBarClose;
      IsOverlay = true;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      }
      else if (State == State.Configure)
      {
      }
      }

      protected override void OnBarUpdate()
      {
      Alert("myAlert", Priority.High, "Bar Closed", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Aler t1.wav", 1, Brushes.Black, Brushes.Yellow);
      }
      }
      }

      region NinjaScript generated code. Neither change nor remove.

      namespace NinjaTrader.NinjaScript.Indicators
      {
      public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
      {
      private BarCloseAlert[] cacheBarCloseAlert;
      public BarCloseAlert BarCloseAlert()
      {
      return BarCloseAlert(Input);
      }

      public BarCloseAlert BarCloseAlert(ISeries<double> input)
      {
      if (cacheBarCloseAlert != null)
      for (int idx = 0; idx < cacheBarCloseAlert.Length; idx++)
      if (cacheBarCloseAlert[idx] != null && cacheBarCloseAlert[idx].EqualsInput(input))
      return cacheBarCloseAlert[idx];
      return CacheIndicator<BarCloseAlert>(new BarCloseAlert(), input, ref cacheBarCloseAlert);
      }
      }
      }

      namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
      {
      public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
      {
      public Indicators.BarCloseAlert BarCloseAlert()
      {
      return indicator.BarCloseAlert(Input);
      }

      public Indicators.BarCloseAlert BarCloseAlert(ISeries<double> input )
      {
      return indicator.BarCloseAlert(input);
      }
      }
      }

      namespace NinjaTrader.NinjaScript.Strategies
      {
      public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
      {
      public Indicators.BarCloseAlert BarCloseAlert()
      {
      return indicator.BarCloseAlert(Input);
      }

      public Indicators.BarCloseAlert BarCloseAlert(ISeries<double> input )
      {
      return indicator.BarCloseAlert(input);
      }
      }
      }

      #endregion


      Would it be possible to move this to the indicator section to see if any one help me add the correct line and or see if anyone can build it?

      Thanks

      Bread

      Comment


        #4
        Hello Mr Bread,

        Yes I will move the post, if you are looking for someone to create items for you there are third party developers who you could hire. If you would like more information about the ecosystem developers I can have someone follow up with more information on that topic.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by crewtrades, 06-13-2024, 10:50 AM
        4 responses
        30 views
        0 likes
        Last Post crewtrades  
        Started by kingsteven, Today, 08:34 PM
        1 response
        3 views
        0 likes
        Last Post bltdavid  
        Started by biegea, Today, 08:54 PM
        0 responses
        3 views
        0 likes
        Last Post biegea
        by biegea
         
        Started by rene69851, Today, 08:36 PM
        0 responses
        2 views
        0 likes
        Last Post rene69851  
        Started by chartish, 04-11-2019, 12:40 PM
        15 responses
        3,832 views
        0 likes
        Last Post joselube001  
        Working...
        X