Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

setting stop loss and target from account balance

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

    setting stop loss and target from account balance

    //double currentAccountBalance = Account.Get(Account.Name).Get(AccountItem.CashValu e, Currency.UsDollar);


    im getting a error with this code

    im trying to set stoploss and target based off % of balance of account, could i get some help with the correct code to do that.

    Thanks in Advance , Anton



    #2
    Hello Anton,

    Thanks for your post.

    In the code you shared you are using Account.Get().Get(); which is invalid syntax.

    Further, you would need to define the account in a class-level variable, such as private Account myAccount, and then use myAccount.Get(AccountItem.CashValue, Currency.UsDollar); in the script.

    For example:

    //class level variable
    private Account myAccount;

    //OnStateChange() State.SetDefaults
    lock (Account.All)
    myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");

    //OnBarUpdate()
    ​double currentAccountBalance = myAccount.Get(AccountItem.CashValue, Currency.UsDollar);


    See the help guide documentation below for more information and sample code:

    Account: https://ninjatrader.com/support/help...ount_class.htm
    <Account>.Get(): https://ninjatrader.com/support/helpGuides/nt8/get.htm
    AccountItem: https://ninjatrader.com/support/help...ccountitem.htm
    <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
      thanks for the info

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      59 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      133 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X