Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I am lost

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

    I am lost

    here is a piece of code which does not what I want it to do
    for some reason, it keeps selling ...although should do nothing ...

    can someone help ?

    is there soemthing i did not read properly ?

    thanks very much


    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 SlowStochasticSignal1 : Strategy
        {
            #region Variables
            // Wizard generated variables
            private int slowK = 13;
    		private int slowD = 9;
    		private int smoothD = 6;
    		
            // 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()
            {
        		//Stochastics(smoothD, slowK, slowD).Plot[0].Pen.Color = Color.Beige;
    			Add(Stochastics(6,13,9));
    			Add(SMA(13));
    			CalculateOnBarClose = true;
    			SetProfitTarget(CalculationMode.Ticks,30);
    		}
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
    			if (1 == 2) ;
    			{
    				EnterShort(1,"short");
    			}
    	    }
    
            #region Properties
    		public int Slowk
    		{
    			get { return slowK; }
    			set { slowK = Math.Max(1, value); }
    		}
    
    		public int SlowD
    		{
    			get { return slowD; }
    			set { slowD = Math.Max(1, value); }
    		}
    		public int SmoothD
    		{
    			get { return smoothD; }
    			set { smoothD = Math.Max(1, value); }
    		}
            #endregion
        }
    }

    #2
    Hello guilhem,

    Thank you for your post.

    You will need to remove ';' from the end of the if statement:
    Code:
    if (1 == 2) ;
    Change to the following:
    Code:
    			if (1 == 2)
    			{
    				EnterShort(1,"short");
    			}
    if statements would not have a ';' at the end.

    Please let me know if you have any questions.

    Comment


      #3
      I am so sorry about this ... I knew the problem was between the keyboard and the chair ...

      Comment


        #4
        Hello guilhem,

        We are always happy to help!

        You will find the community here on the NinjaTrader Support Forum to be extremely helpful.

        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by benmarkal, Yesterday, 12:52 PM
        3 responses
        22 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by helpwanted, Today, 03:06 AM
        1 response
        16 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        11 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        6 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        244 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Working...
        X