Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to define a variable within the strategy wizard?

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

    How to define a variable within the strategy wizard?

    How can i define a variable for my own use when creating the strategy with the Strategy Wizard?

    #2
    Hello,

    The variables in the wizard are known by User Variable. To set these, in a Set click Add to add a "Do the following".

    Select Misc -> set user defined variable.

    Select a variable from the drop down list, and for the value you can type in a number, or use the (...) button on the right to select a data value.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Ok, I have succeeded in generating the following code:
      if (Close[1] >= Open[1]
      && Close[2] >= Open[2]
      && Variable0 == true)
      However i cannot figure out how to make Variable0 boolian.
      PLEASE ADVISE & THANKS

      Comment


        #4
        joemiller,

        Variable0 through Variable9 are all special variables created by NinjaTrader mostly for use with the Strategy Wizard.

        It is not possible in C# to change a Variables type after it has been declared.

        These variables are created by the core of NinjaTrader and are created as doubles. They cannot be changed to bool.

        But you can use them like a bool. If you set the value to 0 that can mean false and if you set the value to 1 that can mean true.

        Code:
        if (Variable0 == 1)
        {
        // the value is 1 so use this as true
        }
        else if (Variable0 == 0)
        {
        // the value is 0 so use this as false
        }
        This won't compare with another variable that is bool, but would give you a trigger if thats what you are looking for.

        Instead, if you need a bool, I would recommend you just create bool. If you are using the Strategy Wizard you can make a public bool input on the User Defined Inputs page.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Since this seems to be a newbie thread, I have a similar request. I am trying to link certain variables to only one variable so that it will optimize only on one variable such as a SMA. For example, I would like to link a RSI to the SMA. So, whatever value is entered for the SMA, the RSI would be some fraction of that. Rather than using a hard number for RSI, I want it to be SMA*.25. It seems so simple, but I am not able to get it to work without errors in the code. With this approach, when I change the SMA, the RSI will remain proportional to the SMA. Please advise.

          Comment


            #6
            Originally posted by birdjaguar View Post
            Since this seems to be a newbie thread, I have a similar request. I am trying to link certain variables to only one variable so that it will optimize only on one variable such as a SMA. For example, I would like to link a RSI to the SMA. So, whatever value is entered for the SMA, the RSI would be some fraction of that. Rather than using a hard number for RSI, I want it to be SMA*.25. It seems so simple, but I am not able to get it to work without errors in the code. With this approach, when I change the SMA, the RSI will remain proportional to the SMA. Please advise.
            birdjaguar,
            sorry, not knowledgeable enough to help you.
            However, in case you have upgraded to NT8, i did just learn that
            ''Variable0 does not exist in NinjaTrader 8. (You can create your own private variables now)''
            joemiller

            Comment


              #7
              Hello birdjaguar,

              Are you currently using the wizard or manually coding? If you are manually coding can you provide the syntax you are using?

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                I use the wizard to see how things are coded and then do it manually. This is not an option, however, for what I am trying to accomplish. Therefore, I have no code for it. To illustrate, let me just show you how I do this in EasyLanguage.

                inputs: Price( Close ), SMAlength( 100 ) ;

                variables:
                MySMA (0), MyRSI( 0 );

                MySMA = Average( Price, SMAlength);
                MyRSI = RSI( Price, SMAlength*.25 );

                So, do I need to set my RSI in the initialize section and also in the properties? Will this enable me to set it to the SMA period *.25?

                Comment


                  #9
                  birdjaguar,

                  Please see my response in your thread: http://ninjatrader.com/support/forum...31&postcount=4

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by andrewtrades, Today, 04:57 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by chbruno, Today, 04:10 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post chbruno
                  by chbruno
                   
                  Started by josh18955, 03-25-2023, 11:16 AM
                  6 responses
                  436 views
                  0 likes
                  Last Post Delerium  
                  Started by FAQtrader, Today, 03:35 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post FAQtrader  
                  Started by rocketman7, Today, 09:41 AM
                  5 responses
                  19 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X