Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Account Verification Script

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

    Account Verification Script

    I am testing a strategy and want to make sure that it is running on the correct simulated account. When the strategy is running on my chart an enabled I want to make sure it is running on a particular simulated account, for example "Sim101". I know you can manually set it in the strategy parameters but I want a backup. I would like the script to verify it is running on that account only. Any help would be appreciated. I looked at this link but couldn't get the script at the bottom to run on the strategy.



    #2
    Hello EminiMES,

    Thank you for your post.

    I recently saw another forum thread that seemed to be attempting the same thing in their script:
    Hello, I am developing a strategy that I need to run on several instruments and several different time frames, but I don't want to add Data Series into a single strategy, I want to run each one on a different Chart. But with the same account, then I must always Select the same account for all strategies. I am running a Filter


    What they are doing is saving an account, based on its name in the Account.All collection, to the myAccount variable. Then, they compare myAccount.Name to Account.Name which would be the name of the account the strategy is running on. If these two names do not match each other, you can call CloseStrategy() to disable the strategy. You could try the following to save a specific account name to myAccount in State.SetDefaults, then you could make the comparison between myAccount.Name and Account.Name where you would like in your strategy, such as State.DataLoaded or at the beginning of OnBarUpdate():
    Code:
    private Account myAccount;
    
    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            // Find our Sim101 account
            lock (Account.All)
                  // save the account named Sim101 to myAccount (feel free to change this name to any account name you'd like)
                  myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");
        }
    }
    
    protected override void OnBarUpdate()
    {​
            if (myAccount != null)
            {
                 if (myAcccount.Name != Account.Name)
                 {
                      CloseStrategy("strategyName");
                 }
            }
     }​
    ​
    Please let us know if we may be of further assistance.

    Comment


      #3
      That works..... thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      56 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
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X