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

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.

    Brandon H.NinjaTrader Customer Service

    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 rhyminkevin, Today, 04:58 PM
      3 responses
      47 views
      0 likes
      Last Post Anfedport  
      Started by iceman2018, Today, 05:07 PM
      0 responses
      5 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      7 views
      0 likes
      Last Post lightsun47  
      Started by 00nevest, Today, 02:27 PM
      1 response
      14 views
      0 likes
      Last Post 00nevest  
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      50 views
      0 likes
      Last Post futtrader  
      Working...
      X