Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLongLimit doesn´t accept integer

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

    EnterLongLimit doesn´t accept integer

    Dear Support Team,

    I´ve created a double to calculate the right amount of contracts for the entry order.

    double KontrakteLong = Math.Round(MaxRisk/RiskTicksLong*Tickwert);

    MaxRisk is the maximum Risk (in Euro, Dollar, ...)

    RiskTicksLong is the amount of ticks between entry and stop order.

    Tickwert is the tick value.

    The entry order: EnterLongLimit(KontrakteLong, Close[0], ""); requires an integer, instead of KontrakteLong, so compiling was not successful.

    So i`ve tried to convert the double to an integer:

    int PositionsgroesseLong = (int) (KontrakteLong);

    After this, compiling was successful, but in every backtest the strategy still trades 1 contract.

    Hope you can help me.

    Best Regards


    #2
    Hello Heikoman,

    Thanks for your post.

    EnterLongLimit() requires passing in an int value for the quantity parameter of the method.

    EnterLongLimit(int quantity, double limitPrice, string signalName)

    The error occurs because a double value is being passed into the method instead of an int value.

    Have you added debugging prints to the script to see exactly how it is processing logic and what PositionsgroesseLong and KontrakteLong evaluate to?

    One line above where you call EnterLongLimit() add prints to the strategy that print out the variable you are passing into the 'int quantity' parameter of the Enter method.

    Prints will appear in a New > NinjaScript Editor window.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.

    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hello BrandonH,

      I`ve seen, that the conversion (double to integer) was correctly.

      The problem was just another input value I use to calculate the amount of contracts.

      Depending on my maximum Risk, the strategy could not allow to trade more than 1 contract.

      After debugging it works, thank you very much for your help.

      Best Regards

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X