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

Different behavior when enabling strategy through chart vs control center

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

    Different behavior when enabling strategy through chart vs control center

    I have a working strategy that I usually load through the chart panel. Once I have loaded and configure the strategy, I then have two choices to enable it:
    1) In the strategy's configuration window, select the Enable property and then click Apply in the configuration window
    2) Exit the strategy's configuration window without enabling the strategy. Then go to the Strategy tab in the Control Center and click the enable column for row that pertains to the strategy in question

    I have created a string that displays certain parameters and outputs then using Draw.TextFixed(). Since the logic only need to be executed one time, I have added the code to the (State == State.Configure) section.

    If I enable the strategy using option 1, the TextFixed gets displayed for a second but once the strategy is up and running the text gets removed. If I enable the strategy using option 2, the TextFixed gets displayed correctly and it never leaves the chart until I disable the strategy.

    Is there a different behavior for option1 and 2? From what I can tell with option 1, there seems to be two renderings; in the first one I can see the text, but before the strategy gets activated 100% there is a second rendering that deletes my text. Again, this behavior is only specific to option 1.

    #2
    Hello GARZONJ,

    Thanks for your post.

    Between items 1 and 2, there will be a difference in behavior as the script's lifecycle will transverse through State.SetDefaults and State.Configure again when the Strategies dialog is opened on the chart.

    The lifecycle can be observed more closely by printing the State in OnStateChange.

    I recommend using State.DataLoaded for tasks that should be performed once, just before the script starts if you would like these behaviors to be more consistent.

    LifeCycle - https://ninjatrader.com/support/help...fecycle_of.htm

    Please let me know if I can be of further assistance.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    17 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    5 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Started by poplagelu, Today, 05:00 AM
    0 responses
    3 views
    0 likes
    Last Post poplagelu  
    Working...
    X