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 BeachTrader11807, Today, 01:14 PM
      3 responses
      20 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by futureszone, Today, 06:09 PM
      0 responses
      3 views
      0 likes
      Last Post futureszone  
      Started by futureszone, 02-07-2025, 02:48 AM
      2 responses
      21 views
      0 likes
      Last Post futureszone  
      Started by cutzpr, Today, 05:24 PM
      0 responses
      5 views
      0 likes
      Last Post cutzpr
      by cutzpr
       
      Started by Ezequiel40, Today, 05:23 PM
      0 responses
      7 views
      0 likes
      Last Post Ezequiel40  
      Working...
      X