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

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.



        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 Perr0Grande, Today, 08:16 PM
              0 responses
              2 views
              0 likes
              Last Post Perr0Grande  
              Started by elderan, Today, 08:03 PM
              0 responses
              5 views
              0 likes
              Last Post elderan
              by elderan
               
              Started by algospoke, Today, 06:40 PM
              0 responses
              10 views
              0 likes
              Last Post algospoke  
              Started by maybeimnotrader, Today, 05:46 PM
              0 responses
              12 views
              0 likes
              Last Post maybeimnotrader  
              Started by quantismo, Today, 05:13 PM
              0 responses
              7 views
              0 likes
              Last Post quantismo  
              Working...
              X