Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to display signals on the historical charts?

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

    How to display signals on the historical charts?

    I have formulated a new Ninja Script strategy of EMA crossing the SMA. I can't get the historical graphs to plot the signal "dots" as the EMA4 crosses the SMA21. I have cut and paste the script as follows.....

    Also, how do I color the price bar instead of using dots?

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// TTM
    /// </summary>
    [Description("TTM")]
    public class MyTTMNinjaStrategy : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion
    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    Add(EMA(Median, 4));
    Add(SMA(Median, 21));
    CalculateOnBarClose = true;
    }
    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(EMA(Median, 4), SMA(Median, 21), 1))
    {
    DrawDot("My dot" + CurrentBar, true, 0, 0, Color.DodgerBlue);
    }
    DrawDot("My dot" + CurrentBar, true, 0, 0, Color.Red);
    }
    #region Properties
    [Description("")]
    [Category("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }
    #region Wizard settings, neither change nor remove
    /*@
    <?xml version="1.0" encoding="utf-16"?>
    <NinjaTrader>
    <Name>MyTTMNinjaStrategy</Name>
    <CalculateOnBarClose>True</CalculateOnBarClose>
    <Description>TTM</Description>
    <Parameters>
    <Parameter>
    <Default1>
    </Default1>
    <Default2>1</Default2>
    <Default3>
    </Default3>
    <Description>
    </Description>
    <Minimum>1</Minimum>
    <Name>MyInput0</Name>
    <Type>int</Type>
    </Parameter>
    </Parameters>
    <State>
    <CurrentState>

    Hazizi Hassan

    #2
    // Condition set 1
    if (CrossAbove(EMA(Median, 4), SMA(Median, 21), 1))
    {
    DrawDot("My dot" + CurrentBar, true, 0, 0, Color.DodgerBlue);
    }
    DrawDot("My dot" + CurrentBar, true, 0, 0, Color.Red);

    You are constantly overwriting your dots for the cross above with your red dots. You need to use different names for the dots.

    If you want to color the bar use BarColor = Color.Red.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply.
      I've tried using arrow as signal, but still unable to get it plotted on my tick chart. I'm using a demo account. Do I need to delete the historical files then repair DB before getting the arrow signals?

      The script are as follows ....

      [Description("TTM")]
      public class MyTTMNinjaStrategy : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      #endregion
      /// <summary>
      /// This method is used to configure the strategy and is called once before any strategy method is called.
      /// </summary>
      protected override void Initialize()
      {
      Add(EMA(Median, 4));
      Add(SMA(Median, 21));
      CalculateOnBarClose = true;
      }
      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (CrossAbove(EMA(Median, 4), SMA(Median, 21), 1))
      {
      DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime);
      }

      Comment


        #4
        Check your Control Center logs for errors.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          There is no error msg in my log.

          Comment


            #6
            How are you determining you are not drawing? You are placing your dots at 0. This may be completely outside the range of your chart.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            640 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            572 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X