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 Tim-c, Today, 02:10 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Taddypole, Today, 02:47 PM
              0 responses
              2 views
              0 likes
              Last Post Taddypole  
              Started by chbruno, 04-24-2024, 04:10 PM
              4 responses
              50 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              10 responses
              399 views
              1 like
              Last Post beobast
              by beobast
               
              Started by lorem, Yesterday, 09:18 AM
              5 responses
              23 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X