• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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,

    https://ninjatrader.com/support/foru...ead.php?t=3475

    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 bosajin, Yesterday, 06:27 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by stefanrvc, Today, 04:59 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by 7robert, Yesterday, 08:30 PM
    2 responses
    16 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by pjsmith, Today, 01:13 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by yukashg, Yesterday, 09:56 PM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Working...
    X