• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

user definable value

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

    user definable value

    Part of something I am developing contains

    var margin = ((max - min) * 0.7);

    The "0.7" is something I would like to be able to change so as to more easily find out whether 0.4 or 0.5 or whatever is best rather than continuing to have to go into the code and change it there.

    How can I make that user definable in the indicator menu?

    I already added:
    #region Variables
    private double moderate = 0.1;
    #endregion
    and
    [Description("Percentage of upper and lower margin.")]
    [Category(" Moderate")]
    public double Moderate
    {
    get { return moderate; }
    set { moderate = Math.Max(0, value); }
    }

    But how do I have to change this line:

    var margin = ((max - min) * 0.7);

    This:
    var margin = ((max - min) * "moderate");
    does not work.

    sandman

    #2
    Hello Sandman, and thank you for your question. I have attached an example indicator which compiles and which uses a variable called Moderate the way you described. Please let us know if there are any other ways we can help.
    Attached Files
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hello JessicaP. can you help me?

      I need to increse or decrease the quantity of contract in base to last trade, for exemple i i win i need to add 1 contract and if i lost i have to decrease 1 contract.

      This is 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 DMcc : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int stoploss = 50; // Default setting for Stoploss
      // User defined variables (add any user defined variables below)
      #endregion

      private bool once = false;
      private IOrder entryOrder;

      /// <summary>
      /// This method is used to configure the strategy and is called once before any strategy method is called.
      /// </summary>
      protected override void Initialize()


      {
      SetStopLoss("", CalculationMode.Ticks, Stoploss, false);

      CalculateOnBarClose = true;
      }

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


      {


      // Condition set 1
      if (CrossAbove(DM(14).DiPlus, DM(14).DiMinus, 1)
      && ChaikinVolatility(14)[0] > 0)
      {
      EnterLong(DefaultQuantity, "");
      }

      // Condition set 2
      if (CrossAbove(DM(14).DiMinus, DM(14).DiPlus, 1)
      && ChaikinVolatility(14)[0] > 0)
      {
      EnterShort(DefaultQuantity, "");
      }
      }


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

      Comment


        #4
        Hello mylanel,

        I have already assisted you in this thread.

        http://ninjatrader.com/support/forum...991#post462991

        I would like to reserve this thread for helping sandman. Thank you for using Ninja.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Jessica. Thank you. I tried that but no go because, I think, my min/max are already defined differently.
          (Also I deal with decimals).
          Would you mind if I email you the full code for you to see the fuller picture?

          sandman

          Comment


            #6
            Of course, and thank you. I will be happy to look over your code. Please send it to platformsupport[at]ninjatrader[dot]com , referencing this unique ID number in the body of your e-mail : 1526769 .
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              I have done that just now.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Audiofail, Today, 05:40 AM
              6 responses
              18 views
              0 likes
              Last Post willwin
              by willwin
               
              Started by jerblaster23, Today, 03:42 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by brian meade, Today, 01:39 PM
              2 responses
              10 views
              0 likes
              Last Post brian meade  
              Started by Johnny Santiago, Today, 12:20 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by NinjaTrader_Brandon, Today, 10:24 AM
              0 responses
              69 views
              0 likes
              Last Post NinjaTrader_Brandon  
              Working...
              X