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

Getting Error

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

    Getting Error

    Hello

    I am trying to develop a Strategy using Multi timeframe Ergo Oscillator. But I am getting error when i compile the below 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>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class ErgoStrategy : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int fast = 3; // Default setting for Fast 3
    private int slow = 14; // Default setting for Slow 14
    private int signalLen = 5; // Default setting for SignalLen 5


    private DataSeries signalLine;
    private DataSeries signal;
    private DataSeries myEMA;
    // 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(ErgodicNew(3, 5, 14, true));

    CalculateOnBarClose = true;
    Add(PeriodType.Minute, 2);
    Add(PeriodType.Minute, 30);


    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    double ergo = TSI(Close,fast,slow)[0] ;
    double prev_ergo = TSI(Close,fast,slow)[1] ;
    double signal = EMA(TSI(Close,fast,slow),signalLen)[0];
    double prev_signal = EMA(TSI(Close,fast,slow),signalLen)[1];



    if (BarsInProgress == 2)
    {
    if (Rising(signalLine) && signal(BarsArray[1])[0] > signal(BarsArray[1])[1])
    {
    EnterLongLimit(100, Low[1] + 3 * TickSize, "");
    }
    }

    if(BarsInProgress == 1)
    {
    if (Falling(signalLine))
    {
    ExitLong("Exit Long from 5min", "Enter Long from 15min");
    }

    }

    }
    #region Properties
    #endregion

    }
    }

    #2
    Hello,

    So we can isolate the issue, what is the error you are getting here when you compile?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Orders not getting executed

      Hi Adam,

      After some 4-5 hours of struggle, i was able to Compile, but however orders not executed

      see below 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.Gui.Chart;
      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("Enter the description of your strategy here")]
      public class ErgoStrategy : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int fast = 3; // Default setting for Fast 3
      private int slow = 14; // Default setting for Slow 14
      private int signalLen = 5; // Default setting for SignalLen 5


      private DataSeries signalLine;
      //private DataSeries signal;

      // 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(ErgodicNew(3, 5, 14, true));

      CalculateOnBarClose = true;
      signalLine = new DataSeries(this);
      Add(PeriodType.Minute, 30);





      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {

      double ergo = TSI(Close,fast,slow)[0] ;
      double prev_ergo = TSI(Close,fast,slow)[1] ;
      double signal = EMA(TSI(Close,fast,slow),signalLen)[0];
      double prev_signal = EMA(TSI(Close,fast,slow),signalLen)[1];

      if (BarsInProgress == 1)
      {
      if (Rising(signalLine) && ErgodicNew(BarsArray[1],3, 5, 14, true)[0] > ErgodicNew(BarsArray[1],3, 5, 14, true)[1])
      {
      EnterLong(100, "Enter Long from 2min");
      }
      }

      if(BarsInProgress == 0)
      {
      if (Falling(signalLine))
      {
      ExitLong("Exit Long from 2min", "Enter Long from 30min");
      }

      }

      if(BarsInProgress == 1)

      {
      if (Falling(signalLine) && ErgodicNew(BarsArray[1],3, 5, 14, true)[0] < ErgodicNew(BarsArray[1],3, 5, 14, true)[1])
      {
      EnterShort(100, "Enter Short from 2min");
      }

      }

      if(BarsInProgress == 0)

      {
      if (Rising(signalLine))
      {
      ExitShort("Exit Short from 2min", "Enter Short from 30min");
      }

      }
      }
      #region Properties
      #endregion

      }
      }

      Comment


        #4
        So if you apply the strategy, any errors being returned to you via NT's log tab, the rightmost tab in the Control Center?

        Further : to be sure that your conditions trigger as coded in, please add print statements or drawings to doublecheck -



        Another thought - would the news indicator be back-testable, so it would return values based on historical data as well?
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CyberNate, 11-17-2020, 08:15 PM
        2 responses
        424 views
        0 likes
        Last Post nurpalgo  
        Started by sdauteuil, 09-23-2021, 10:16 AM
        7 responses
        1,247 views
        0 likes
        Last Post marcus2300  
        Started by sofortune, 05-18-2024, 11:48 AM
        2 responses
        32 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by Zach55, 02-19-2024, 07:22 PM
        2 responses
        66 views
        0 likes
        Last Post lbadisa1  
        Started by JGriff5646, Yesterday, 05:47 PM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X