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

Use of variables, comparing prices

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

    Use of variables, comparing prices

    I have done a lot of research on the use of variables but can't understanfd them! I don't have a programming background, I am quite confident with the wizard but when it comes to user variables, especialy after I downloaded SampleUserVariables.zip I am completely lost!
    what does variable0=1 then variable0==1 and then variable0=0 mean?
    The help is not so sufficient either. Need more examples on everyday stuff.
    For example I want to compare 2 prices, say yesterdays close and todays open with a percentage change (say market 2% up today). Then assign this to a variable and use it to compare other conditions.
    For example if price up by 2% (definable input) then buy at open or if down today by -1% sell.

    Pls give me exact steps so I can understand what goes under variables appart from =1, =0 etc (I see there are many choices of set user variables, like indicators, price data, startegy etc.)


    #2
    Please send a note to support [at] ninjatrader [dot] com and we will follow up with you there for this one.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Alexis,

      As discussed earlier today, please send to support.
      Vince B.NinjaTrader Customer Service

      Comment


        #4
        Mr Vince Bolte director of Customer service has asked me not to ask anymore questions about stratgey development. I have explained that there is no other way to learn since help files are limited (even the online seminar was down the other day - although I stayed up past midnight to watch it - about development) but he insists and screens my emails. I don't want to cause a problem to your community, I just want to learn and promote NT in my part of the world, Greece!

        If someone could be so kind and help me with my questions below I would appreciate it a lot.

        Comment


          #5
          alex.

          A variable is basically an area of computer memory given some meaningful name. You can think of it as a locker in a locker room at at gym. The contents of the locker only change when you go and change it. (this is a very crude, basic example).

          There are many types of variables. If you're using whole numbers, you use int. If you want to use a decimal number, you can use double. If you're using true / false, you can use bool.

          Lets say you want to compute the distance between the high and low of a bar of some instrument. You can define the following at the top of your code.

          Code:
          private double dHigh;
          private double dLow;
          If you want to set the dHigh to the high of the current bar, you do this
          Code:
          dHigh = High[0];
          If you want to compare the set value to the high of some other bar, you can do this.

          Code:
          if(dHigh == High[0])
          {
          // some code in here
          }
          There is a wealth of information about programming in C# on the web. I suggest using google and search for C# online course, or C# basics, starting with C#, etc.

          I hope this brief description is helpful.
          mrlogik
          NinjaTrader Ecosystem Vendor - Purelogik Trading

          Comment


            #6
            I appreciate your help but I have no idea about code. I have been using the wizard and only this. Is it possible to give me 2-3 examples using the user variables (cant change to int,double). The expression variable0=1 and variable1=1 mean that they are set to the above condition? Thye 1 means true or if I put 0 means false? What if I put 2,3 or so...? Then it has a choice of inserting startegy, price, indicators etc. That is where it is complicated. How can a conditions action be an indicator or a price?
            Say we want to compare 2 prices and their result to be a user variable. Say yesterdays close>todays open by 2% (offset 0,02) by entering below user variable0=1 this has assigned to variable0 this above comparison statement? examples are very few in wizard mode. Pls give us 2-3 with price, indicator, startegy or misc, or even another variable (is this possible?)

            Thanx


            Originally posted by mrlogik View Post
            alex.

            A variable is basically an area of computer memory given some meaningful name. You can think of it as a locker in a locker room at at gym. The contents of the locker only change when you go and change it. (this is a very crude, basic example).

            There are many types of variables. If you're using whole numbers, you use int. If you want to use a decimal number, you can use double. If you're using true / false, you can use bool.

            Lets say you want to compute the distance between the high and low of a bar of some instrument. You can define the following at the top of your code.

            Code:
            private double dHigh;
            private double dLow;
            If you want to set the dHigh to the high of the current bar, you do this
            Code:
            dHigh = High[0];
            If you want to compare the set value to the high of some other bar, you can do this.

            Code:
            if(dHigh == High[0])
            {
            // some code in here
            }
            There is a wealth of information about programming in C# on the web. I suggest using google and search for C# online course, or C# basics, starting with C#, etc.

            I hope this brief description is helpful.

            Comment


              #7
              I think I might be able to help you here as I'm teaching my son algebra at the moment.. He's 5 1/2 years old OK here goes with simple explanation.

              For example in Algebra you have:

              a = 2 (the value of 2 is assigned to a) or
              b = 4 (the value of 4 is assigned to b) or
              c = 7 (the value of 7 is assigned to c)and so on.

              also you can have:

              a + b = d and since we know that a = 2 and b = 4 then
              d = 6

              This is identical to saying:
              Variable0 = 2 (the value of 2 is assigned to Variable0) or
              Variable1 = 4 (the value of 4 is assigned to Variable1) or
              Variable2 = 7 (the value of 7 is assigned to Variable2)and so on.

              also you can have:

              Variable0 + Variable1 = Variable4 and since we know that Variable0 = 2 and Variable1 = 4 then
              Variable4 = 6

              These are equivalent to the "Do The Following" area of the strategy builder which essentially is the area you assign values to Variables and making actions do things.

              Therefore now understanding these basics I can tell you that where you see in the "When the following conditions are true" area :

              Variable0 == 2 (just an example) this actually means "If Variable0 is equal to 2 then do what it says to do in the "Do the following" area.


              What I found useful when trying to use the Wizard for the first time was to write in you own language exactly what you want to do and then start to put it into this sort of conversational context:
              eg.
              If this indicator crosses that indicator then enter a long position (trade).

              I hope this help to further your understanding.
              Cheers

              Chris



              Originally posted by alexnj View Post
              I appreciate your help but I have no idea about code. I have been using the wizard and only this. Is it possible to give me 2-3 examples using the user variables (cant change to int,double). The expression variable0=1 and variable1=1 mean that they are set to the above condition? Thye 1 means true or if I put 0 means false? What if I put 2,3 or so...? Then it has a choice of inserting startegy, price, indicators etc. That is where it is complicated. How can a conditions action be an indicator or a price?
              Say we want to compare 2 prices and their result to be a user variable. Say yesterdays close>todays open by 2% (offset 0,02) by entering below user variable0=1 this has assigned to variable0 this above comparison statement? examples are very few in wizard mode. Pls give us 2-3 with price, indicator, startegy or misc, or even another variable (is this possible?)

              Thanx

              Comment


                #8
                thanx but still...

                Chris you are great! Thanx but still I don't get it...
                I need 2-3 examples to use as a value for a user variable (as indicator, price data, stratgey, user inputs, user variables) these are the choices under Vaule for Variable0, 1,2 etc.
                So is it important to set first Variable0 = to something and then its value = something else? I just don't get it....
                get confused with all these choices.....


                Originally posted by alcamie View Post
                I think I might be able to help you here as I'm teaching my son algebra at the moment.. He's 5 1/2 years old OK here goes with simple explanation.

                For example in Algebra you have:

                a = 2 (the value of 2 is assigned to a) or
                b = 4 (the value of 4 is assigned to b) or
                c = 7 (the value of 7 is assigned to c)and so on.

                also you can have:

                a + b = d and since we know that a = 2 and b = 4 then
                d = 6

                This is identical to saying:
                Variable0 = 2 (the value of 2 is assigned to Variable0) or
                Variable1 = 4 (the value of 4 is assigned to Variable1) or
                Variable2 = 7 (the value of 7 is assigned to Variable2)and so on.

                also you can have:

                Variable0 + Variable1 = Variable4 and since we know that Variable0 = 2 and Variable1 = 4 then
                Variable4 = 6

                These are equivalent to the "Do The Following" area of the strategy builder which essentially is the area you assign values to Variables and making actions do things.

                Therefore now understanding these basics I can tell you that where you see in the "When the following conditions are true" area :

                Variable0 == 2 (just an example) this actually means "If Variable0 is equal to 2 then do what it says to do in the "Do the following" area.


                What I found useful when trying to use the Wizard for the first time was to write in you own language exactly what you want to do and then start to put it into this sort of conversational context:
                eg.
                If this indicator crosses that indicator then enter a long position (trade).

                I hope this help to further your understanding.
                Cheers

                Chris

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jackiegils, Today, 11:05 PM
                0 responses
                5 views
                0 likes
                Last Post jackiegils  
                Started by cre8able, Yesterday, 09:15 PM
                2 responses
                16 views
                0 likes
                Last Post cre8able  
                Started by Trader146, Today, 09:17 PM
                0 responses
                9 views
                0 likes
                Last Post Trader146  
                Started by ttrader23, 05-08-2024, 09:04 AM
                9 responses
                43 views
                0 likes
                Last Post ttrader23  
                Started by ZeroKuhl, Yesterday, 04:31 PM
                8 responses
                46 views
                0 likes
                Last Post ZeroKuhl  
                Working...
                X