Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Newly Created Strategies Not Showing Up in List

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

    Newly Created Strategies Not Showing Up in List

    I have recently created a few strategies that are not in the list when I attempt to add them to the chart. They are visible and editable from Editor, and they are in the bin/custom/Strategies folder, but not in the list to be loaded. What could be the problem?

    Also, I moved some older strategies out of the bin/custom/Strategies folder in an attempt to archive them and clean up my strategies list, but the strategies I moved still show up in the list and I can still add them to the charts. What am I doing wrong?

    Thanks in advance!

    #2
    Well, I found out what the problem was. See below if you care to.

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {

    //SMA1 = SMA(Close, 14); //This, uncommented, prevented this strategy from showing up in the list to be added to a chart.
    //SMA2 = SMA(Close, 28); //This, uncommented, prevented this strategy from showing up in the list to be added to a chart.

    Comment


      #3
      Hello Trader146,

      Thanks for your notes.

      Indicator objects, such as "private SMA SMA1;" should be instantiated in OnStateChange() when the State == State.DataLoaded, not in State.SetDefaults.

      See the SampleMACrossOver reference sample that comes default with NinjaTrader for an example of this.

      To view the script open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleMACrossover file.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Thank you!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        43 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        21 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        30 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        50 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Working...
        X