Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I show a buy/sell signal on the chart

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

    How can I show a buy/sell signal on the chart

    Hi,

    I am just begin to write some auto trading code. for buy/sell action, I want to add some buy and sell signals/signs on the chart.

    How can I add that?

    Thanks in advance
    Thomson

    #2
    Hello thomson,

    Thank you for your post and welcome to the NinjaTrader Support Forum.

    You can add a custom drawing object to a chart with a strategy by defining the condition and then programming the custom drawing object.

    For a reference on adding custom plots to a strategy please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=6651

    You can find information on adding custom shapes, lines, text and colors to your indicators and strategies at the following link: http://www.ninjatrader.com/support/h...ml?drawing.htm

    Please let me know if I may be further assistance.

    Comment


      #3
      Patrick,

      Thanks for your quick respond. I download the SampleStrategyPlot and load the strategy to my chart. It doesn't show any plot. Is there anything wrong?

      Anyway, Could you please help me add a plot to me code? Please see my sample strategy blow,

      #region Using declarations
      using System;
      using System.ComponentModel;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Indicator;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Strategy;
      #endregion

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// Simple MA Cross Strategy
      /// </summary>
      [Description("Simple MA Cross Strategy")]
      public class zyySMA : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int fast = 5; // Default setting for Fast
      private int slow = 20; // Default setting for Slow
      // 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(SMA(Fast));
      Add(SMA(Slow));

      CalculateOnBarClose = true;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (CrossAbove(SMA(Fast), SMA(Slow), 1))
      {
      EnterLong(DefaultQuantity, "1");
      }

      // Condition set 2
      if (CrossBelow(SMA(Fast), SMA(Slow), 1))
      {
      EnterShort(DefaultQuantity, "1");
      }
      }

      #region Properties
      [Description("Fast MA Period")]
      [GridCategory("Parameters")]
      public int Fast
      {
      get { return fast; }
      set { fast = Math.Max(1, value); }
      }

      [Description("Slow MA Period")]
      [GridCategory("Parameters")]
      public int Slow
      {
      get { return slow; }
      set { slow = Math.Max(1, value); }
      }
      #endregion
      }
      }

      Thanks in advance

      Thomson

      Comment


        #4
        Hello thomson,

        Thank you for your response.

        Strategies will have to be enabled on your chart by right clicking in your chart > select Strategies > left click on your strategy > change the 'Enabled' parameter to 'True'.
        For information on working with strategies please visit the following link: http://www.ninjatrader.com/support/h...ed_strateg.htm

        You can plot indicators on your chart through the strategy and you can draw an object such as a line to indicate the buy/sell signal. Which one would you like to see an example of?

        I look forward to assisting you further.

        Comment


          #5
          indicator signal triggering a strategy order

          Hi Patrick,

          Can you show an example of an indicator generating a buy/sell signal that would be sent to a very simple strategy attached to the same chart? The strategy would only execute the signals received from your indicator.

          Thanks

          Originally posted by NinjaTrader_PatrickH View Post
          Hello thomson,

          Thank you for your response.

          Strategies will have to be enabled on your chart by right clicking in your chart > select Strategies > left click on your strategy > change the 'Enabled' parameter to 'True'.
          For information on working with strategies please visit the following link: http://www.ninjatrader.com/support/h...ed_strateg.htm

          You can plot indicators on your chart through the strategy and you can draw an object such as a line to indicate the buy/sell signal. Which one would you like to see an example of?

          I look forward to assisting you further.

          Comment


            #6
            Hello,

            Thank you for the question.

            There is actually a strategy included with NinjaTrader that serves this purpose.

            Please go to: Tools -> Edit NinjaScript -> Strategy -> SampleMACrossOver

            This shows how to use the SMA in the Stratetgy to generate Signals.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by hazylizard, Today, 08:38 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by geddyisodin, Today, 05:20 AM
            2 responses
            16 views
            0 likes
            Last Post geddyisodin  
            Started by Max238, Today, 01:28 AM
            5 responses
            44 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by giulyko00, Yesterday, 12:03 PM
            3 responses
            13 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by habeebft, Today, 07:27 AM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Working...
            X