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 samish18, Yesterday, 12:20 PM
    1 response
    12 views
    0 likes
    Last Post WaleeTheRobot  
    Started by Lancer, 01-29-2020, 10:15 PM
    6 responses
    460 views
    1 like
    Last Post neveral0n3  
    Started by Rogers101, Today, 11:30 AM
    1 response
    13 views
    0 likes
    Last Post WaleeTheRobot  
    Started by AndreiBig, Yesterday, 12:30 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Eduardo  
    Started by nicthe, Today, 07:38 AM
    2 responses
    15 views
    0 likes
    Last Post WaleeTheRobot  
    Working...
    X