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

  • NinjaTrader_Jesse
    replied
    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.

    Leave a comment:


  • Mr Bread
    replied
    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

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    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.

    Leave a comment:


  • Mr Bread
    started a topic Prior to bar close alert

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by joseph_kuruvilla12, Today, 01:01 AM
0 responses
6 views
0 likes
Last Post joseph_kuruvilla12  
Started by joseph_kuruvilla12, Today, 12:40 AM
0 responses
4 views
0 likes
Last Post joseph_kuruvilla12  
Started by joseph_kuruvilla12, Today, 12:13 AM
0 responses
5 views
0 likes
Last Post joseph_kuruvilla12  
Started by stafe, 07-19-2024, 01:32 PM
3 responses
40 views
0 likes
Last Post stafe
by stafe
 
Started by joseph_kuruvilla12, Yesterday, 10:29 PM
0 responses
5 views
0 likes
Last Post joseph_kuruvilla12  
Working...
X