Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plot execution markers disappear when running custom strategy.

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

    plot execution markers disappear when running custom strategy.

    I am using a simple strategy that draws a 200 period SMA on my 50 tick chart. It works, but when I use it, the trade execution markers no longer appear. Any idea why this might be happening?

    here's the 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.Strategy;
    #endregion

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Display the SMA200 from the 1 min chart on the 50 tick chart (or another time period)")]
    [Gui.Design.DisplayName("DrawSMA200")]
    public class DrawSMA200 : Strategy
    {
    #region Variables
    // Wizard generated variables
    // User defined variables (add any user defined variables below)
    private int tagNumber = 0;
    private string tagName;
    private double sma200Value_0;
    private double sma200Value_1;
    #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 the 1 minute chart
    Add(Instrument.FullName, PeriodType.Minute, 1);
    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1) // 1 min
    {
    sma200Value_0 = SMA(200)[0];
    sma200Value_1 = SMA(200)[1];
    return;
    }

    if (BarsInProgress == 0) // 50 tick chart
    {
    tagNumber = tagNumber + 1;
    tagName = "tag" + tagNumber.ToString();
    // Draw the SMA 200 from the 1 minute chart on the 50 tick chart using draw tools
    DrawLine(tagName, 1, sma200Value_1, 0, sma200Value_0, Color.DarkOrchid, DashStyle.Solid, 4);
    return;
    }
    }

    #region Properties
    #endregion
    }
    }

    #2
    This is correct behaviour. When you run a strategy, only executions resulting from the running strategy will be displayed.

    Since your strategy code does not place orders, there will be no executions displayed.

    On another note, you can remove your code for processing the minute data and simply do something like:

    DrawLine(tagName, 1, SMA(BarsArray[1], 200)[0], 0, SMA(BarsArray[1], 200)[1], Color.DarkOrchid, DashStyle.Solid, 4);
    RayNinjaTrader Customer Service

    Comment


      #3
      ok, so maybe I should have rephrased my question.

      Is there a way to allow the trade markers to show along with the 200 SMA line?

      seems like that would be a very important capability.

      Comment


        #4
        If your strategy is *not* going to submit orders, then implement your visuals using an indicator instead of a strategy. Then you can have your account based executions plotted alongside your indicator.

        When a strategy is running, it will only show trades generated by that strategy. This is by design since trader will not want to pollute their chart with trades/executions that are not related to a running strategy.
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Waxavi, Today, 02:10 AM
        0 responses
        3 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        8 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Working...
        X