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

Counting strategy instances

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

    Counting strategy instances

    hello,

    is there a way to count an instance of a strategy run?

    i tried to create a dummy counter under all the below states but it didnt work

    Code:
    			if (State == State.SetDefaults)
    
    		protected override void OnStateChange()
    
    			else if (State == State.Configure)
    
    			else if (State == State.DataLoaded)

    i want to count every single a time a strategy is ran in live/the strategy analyzer/optimizer. basically anytime the strategy is used.. i want to add that instance to a counter..

    for example, if i run the strategy 5 times in the strategy analyzer, I want to get an output of 5.

    #2
    Hello staycool3_a,

    Thank you for your note.

    You could write to a file every time the strategy is run, saving the run time or a tally of the number of times it’s been ran, you would use streamwriter,



    You could save to the file every time the first bar on OnBarUpdate was ran, which I would expect to be unique per run. So if CurrentBar==1, save to file.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rocketman7, Today, 02:12 AM
    3 responses
    20 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    7 responses
    27 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by samish18, 04-17-2024, 08:57 AM
    17 responses
    64 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by briansaul, Today, 05:31 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by PaulMohn, Today, 03:49 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X