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 Haiasi, Today, 06:53 PM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by ScottWalsh, Today, 06:52 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by ScottW, Today, 06:09 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by ftsc2022, 10-25-2022, 12:03 PM
    5 responses
    256 views
    0 likes
    Last Post KeyonMatthews  
    Started by Board game geek, 10-29-2023, 12:00 PM
    14 responses
    244 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Working...
    X