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 yertle, Today, 08:38 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by love2code2trade, Yesterday, 01:45 PM
    3 responses
    22 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by trilliantrader, Today, 08:16 AM
    2 responses
    6 views
    0 likes
    Last Post trilliantrader  
    Started by samish18, Today, 08:31 AM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by Creamers, 09-08-2023, 10:26 AM
    6 responses
    157 views
    0 likes
    Last Post JonyGurt  
    Working...
    X