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

What is wrong with this code?

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

    What is wrong with this code?

    Hi There,

    I cant see whats wrong with this code but I keep getting errors on compilation,

    #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>
    /// Strategy to calcutale best moving averages.
    /// </summary>
    [Description("Strategy to calcutale best moving averages.")]
    public class EMACROSSBASIC : Strategy
    {
    private int emaf = 10;
    private int emas = 50;
    #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()
    {
    CalculateOnBarClose = true;
    ExitOnClose = false;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;

    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    EMA emavf = EMA (EMAf);
    EMA emavs = EMA (EMAs);


    //ManageOrders();

    if (EMA (EMAf) [0] < EMA (EMAs) [0]) GoShort();
    if (EMA (EMAf) [0] > EMA (EMAs) [0]) GoLong();


    }

    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int EMAf
    {
    get { return emaf; }
    set { emaf = Math.Max(1, value); }
    }
    [Description("")]
    [GridCategory("Parameters")]
    public int EMAs
    {
    get { return emas; }
    set { emas = Math.Max(1, value); }
    }
    #endregion
    }
    }




    Thanks for any help.

    #2
    Hello GKonheiser,
    NinjaTrder does not have any method/functions namely GoShort or GoLong. If they are custom methods then please make sure you have included the same.

    Code:
    if (EMA (EMAf) [0] < EMA (EMAs) [0]) [COLOR="red"]GoShort()[/COLOR];
    if (EMA (EMAf) [0] > EMA (EMAs) [0]) [COLOR="Red"]GoLong()[/COLOR];
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Yes sorry I just saw that. thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ghoul, Today, 06:02 PM
      3 responses
      13 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      180 views
      0 likes
      Last Post jeronymite  
      Started by DanielSanMartin, Yesterday, 02:37 PM
      2 responses
      13 views
      0 likes
      Last Post DanielSanMartin  
      Working...
      X