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

Variable EnterLong Position Quantity

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

    Variable EnterLong Position Quantity

    Hi

    I'd like to EnterLong a

    double amount = $10000/Close[0];

    so it will differs every time by the Close[0] price.

    Problem is that ninjatrader format:

    EnterLong[int quantity, string signalname]

    doesn´t allow a "double" value on quantity

    Any idea ?

    Thanks in advance.

    #2
    So I can give you a proper response.

    Is $10000/Close[0] worth a dollar amount you want to buy, or an amount of shares/lots
    LanceNinjaTrader Customer Service

    Comment


      #3
      amount shares please

      Comment


        #4
        In this case you'll want to convert your double value to an int

        Convert.ToInt32(yourDouble)



        Depending on how you want to handle the conversion you may want to also first round the double.
        Example: Math.Round http://msdn.microsoft.com/en-us/libr...ath.round.aspx
        LanceNinjaTrader Customer Service

        Comment


          #5
          Adjusting postion size

          if(DailyATR(5)[0] <150);
          {voldivide = 1;}

          if(DailyATR(5)[0] >=150);
          {voldivide = 2;}


          this code works but doesnt give me the option to make small changes to position size. I would like to use voldivide values or 1,4 1,3 etc... Is there any way to adjust the number of lots traded not using int values?




          Regards and thx

          Comment


            #6
            everington_f, what instrument do you trade? A quantity of 1 would be the smallest you could trade. Even if trading Forex for example, then just enter the full unit amount - i.e. 10000 for a minilot, or 0.01M
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I have solved the problem with a couple of Doubles and a double-int conversion. Thanks for the response though Bertrand.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by PhillT, Today, 02:16 PM
              1 response
              1 view
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Kaledus, Today, 01:29 PM
              3 responses
              9 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by frankthearm, Yesterday, 09:08 AM
              14 responses
              47 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by gentlebenthebear, Today, 01:30 AM
              2 responses
              13 views
              0 likes
              Last Post gentlebenthebear  
              Started by PaulMohn, Today, 12:36 PM
              2 responses
              17 views
              0 likes
              Last Post PaulMohn  
              Working...
              X