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

Drawing an Arrow

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

    Drawing an Arrow

    In the strategy Action window...under "parameters"...in the "Y" line...I need to insert the phrase ..... Low(0) + 1 * TickSize

    Can someone help me out? Thank you

    #2
    In the Y line select the ... button and then select Price. Select Low then in the Offset field type in 1.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Drawing Arrows

      Thank you Josh. it works very well. Can you tell me ....when I start my strategy with the ema's the line's automatically come up. I'd like to be seeing only the arrows without the lines. Currently what I'm doing is changing the colors of the lines to white ( negating the appearance since my background is white ). However every time I change time frames thec hart resorts to the lins appearing.

      Is there a way to save the changes so that when I start my strategy the lines do not appear?
      Happy trades ! Ark 1

      Comment


        #4
        How about trying to set the color to "Transparent" instead of white?
        RayNinjaTrader Customer Service

        Comment


          #5
          Hi Ray,
          Again...I can't thank you enough for your support.
          I've used either 'white'...or...transparent...it doesn't matter. They both do the job. My problem is the following. I'll go through my steps so that you can point out my mistakes.

          1) after I've connected and my charts are up and running I must then right click on the chart and go through the process of starting up my strategy ( if there's a way around this please tell me...in other words...if I can open my charts> connect> and have my strategy start by default ...) that would be good.

          2) when my strategy starts my charts, by default, display the arrows ( indicating the EMA crosses ) but in addition they also display the 'lines' ( orange colored by default ) for the EMA's.

          3) I must then go to the indicators window and go through the process of making all of the 'ema lines' transparent so that the only thing that is visible on the chart are the arrows.

          The big problem is that every time I change timeframes or instruments...or...open up the strategy...the ema lines appear again and I must go through the same steps to make them transparent.

          Is there a method for accessing the 'orange ema lines' so that I can permanently make them transparent for my strategy? As I was going through the steps to creating my strategy I had the option of choosing the color for my arrows...but..the ema's give me no such option.
          Billy

          Comment


            #6
            Got it.

            1) This is the current approach, we will improve this with NT7 next year

            You can do what you wish however, it can only be done programatically, not using the wizard. Here is a tip that shows you how this can be done.

            RayNinjaTrader Customer Service

            Comment


              #7
              Hi Ray,
              I'm almost there.
              Josh states: To customize plot colors:
              Code:

              EMA(13).Plots[0].Pen.Color = Color.Blue; // Plots the EMA as a blue line

              Ok...here's my strategy....can you please tell me where I am to insert this code?

              #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>
              /// EMA crosses create an arrow
              /// </summary>
              [Description("EMA crosses create an arrow")]
              public class MTF : Strategy
              {
              #region Variables
              // Wizard generated variables
              private int fast = 15; // Default setting for Fast
              private int slow = 38; // Default setting for Slow
              private int rapid = 2; // Default setting for Rapid
              private int tardy = 15; // Default setting for Tardy
              // 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(Fast));
              Add(EMA(Slow));
              Add(EMA(Fast));
              Add(EMA(Slow));
              Add(EMA(Rapid));
              Add(EMA(Tardy));
              Add(EMA(Rapid));
              Add(EMA(Tardy));

              CalculateOnBarClose = true;
              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
              // Condition set 1
              if (CrossAbove(EMA(Fast), EMA(Slow), 1))
              {
              DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + 1 * TickSize, Color.Black);
              }

              // Condition set 2
              if (CrossBelow(EMA(Fast), EMA(Slow), 1))
              {
              DrawArrowDown("My down arrow" + CurrentBar, false, 0, Low[0] + 1 * TickSize, Color.Black);
              }

              // Condition set 3
              if (CrossAbove(EMA(Rapid), EMA(Tardy), 1))
              {
              DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + 1 * TickSize, Color.Blue);
              }

              // Condition set 4
              if (CrossBelow(EMA(Rapid), EMA(Tardy), 1))
              {
              DrawArrowDown("My down arrow" + CurrentBar, false, 0, Low[0] + 1 * TickSize, Color.Crimson);
              }
              }

              Comment


                #8
                Here is an example:

                Add(EMA(Fast));
                Add(EMA(Slow));
                EMA(Fast).Plots[0].Pen.Color = Color.Blue;
                EMA(Slow).Plots[0].Pen.Color = Color.Red;
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Drawing an Arrow

                  Hi Ray,
                  Here's what I have...but does not work as of yet.



                  #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>
                  /// Ema crosses and an arrow appears
                  /// </summary>
                  [Description("Ema crosses and an arrow appears")]
                  public class MiniTrendFinder : Strategy
                  {
                  #region Variables
                  // Wizard generated variables
                  private int fast = 15; // Default setting for Fast
                  private int slow = 38; // Default setting for Slow
                  private int rapid = 2; // Default setting for Rapid
                  private int tardy = 1; // Default setting for Tardy
                  // 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(Fast));
                  Add(EMA(Slow));
                  EMA(Fast).Plots(0).Pen.Color = Color.Transparent;
                  EMA(Slow).Plots(0).Pen.Color = Color.Transparent;
                  Add(EMA(Fast));
                  Add(EMA(Slow));
                  EMA(Fast).Plots(0).Pen.Color = Color.Transparent;
                  EMA(Slow).Plots(0).Pen.Color = Color.Transparent;
                  Add(EMA(Rapid));
                  Add(EMA(Tardy));
                  EMA(Rapid).Plots(0).Pen.Color = Color.Transparent;
                  EMA(Tardy).Plots(0).Pen.Color - Color.Transparent;
                  Add(EMA(Rapid));
                  Add(EMA(Tardy));
                  EMA(Rapid).Plots(0).Pen.Color = Color.Transparent;
                  EMA(Tardy).Plots(0).Pen.Color = Color.Transparent;

                  CalculateOnBarClose = true;
                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  // Condition set 1
                  if (CrossAbove(EMA(Fast), EMA(Slow), 1))
                  {
                  DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + 1 * TickSize, Color.Black);
                  }

                  // Condition set 2
                  if (CrossBelow(EMA(Fast), EMA(Slow), 1))
                  {
                  DrawArrowDown("My down arrow" + CurrentBar, false, 0, Low[0] + 1 * TickSize, Color.Black);
                  }

                  // Condition set 3
                  if (CrossAbove(EMA(Rapid), EMA(Tardy), 1))
                  {
                  DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + 1 * TickSize, Color.Blue);
                  }

                  // Condition set 4
                  if (CrossBelow(EMA(Rapid), EMA(Tardy), 1))
                  {
                  DrawArrowDown("My down arrow" + CurrentBar, false, 0, Low[0] + 1 * TickSize, Color.Red);
                  }
                  }

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

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

                  [Description("Rapid Period")]
                  [Category("Parameters")]
                  public int Rapid
                  {
                  get { return rapid; }
                  set { rapid = Math.Max(1, value); }
                  }

                  [Description("Tardy Period")]
                  [Category("Parameters")]
                  public int Tardy
                  {
                  get { return tardy; }
                  set { tardy = Math.Max(1, value); }
                  }
                  #endregion
                  }




                  Now...looking at Josh's post he's also included ...

                  // Plots the EMA as a blue line

                  This line doesn't appear anywhere in my strategy.

                  Billy

                  Comment


                    #10
                    Just to be clear, you never want to plot these indicators in your chart? If yes, just don't Add() them. Add() only adds them for plotting on the chart, nothing else.
                    RayNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by futtrader, 04-21-2024, 01:50 AM
                    4 responses
                    41 views
                    0 likes
                    Last Post futtrader  
                    Started by Option Whisperer, Today, 09:55 AM
                    1 response
                    12 views
                    0 likes
                    Last Post bltdavid  
                    Started by port119, Today, 02:43 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post port119
                    by port119
                     
                    Started by Philippe56140, Today, 02:35 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post Philippe56140  
                    Started by 00nevest, Today, 02:27 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post 00nevest  
                    Working...
                    X