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

How to calculate a position percentage size in the Builder

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

    How to calculate a position percentage size in the Builder

    Hello,

    I would like to know how can I set the position quantity of a strategy in the builder as the account is growing up or going down, this in a percentage of the account. In the condition Builder I can't set a math calculation to calculate the contract size which can be:
    // Calculate position size
    positionsize=round(accountvalue(iex:100000)*percen tage(iex:1.5%)/(stopsize*tickvalue),0);
    Do I need to unlock the code or how can I calculate the quantity?

    Thank you so much

    #2
    Hello jeremy83846,

    This would be a situation where unlocking the code would be needed. The math you would need for this would not be able to be done using the arithmetic builder. The actual account value also is not something you can access in the builder, you could define a user input for that to manually define an account size to use in the script but the other math would still be an issue.

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

    Comment


      #3
      OK, so if I need to use the code and I set the Realized PnL it is not recognized as the account size of that math formula?

      Comment


        #4
        Hello jeremy83846,

        I am not certain I understand the question how it was written, could you clarify what you are asking to do?

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

        Comment


          #5
          For example if I set on the code:

          EnterShort(Convert.ToInt32(SystemPerformance.AllTr ades.TradesPerformance.Currency.CumProfit*percen tage(iex:1.5%)/(stopsize*tickvalue), @"Corto");

          That formula should be honored?

          Comment


            #6
            Hello jeremy83846,

            Do you mean will that value be used for the short entry? If so yes.

            If you calculate a value before submitting the entry that would work to set a quantity. You could do the calculation directly in the method like you have shown or do it a line above that and make a variable that is really up to your coding style.

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by JoMoon2024, Today, 06:56 AM
            0 responses
            6 views
            0 likes
            Last Post JoMoon2024  
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            17 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            5 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,786 views
            0 likes
            Last Post Leafcutter  
            Started by poplagelu, Today, 05:00 AM
            0 responses
            3 views
            0 likes
            Last Post poplagelu  
            Working...
            X