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 fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,404 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by Shai Samuel, 07-02-2022, 02:46 PM
            4 responses
            95 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by DJ888, Yesterday, 10:57 PM
            0 responses
            7 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            159 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Yesterday, 09:29 PM
            0 responses
            8 views
            0 likes
            Last Post Belfortbucks  
            Working...
            X