Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

convert an indicator into a strategy

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

    convert an indicator into a strategy

    Hello,

    Could you pls give me a hint, I am trying to convert this indicator into a strategy to give me buy signals when the line turns green and sell signals when the line turns red and NO signals when is blue, thanks

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.SkyBlue), PlotStyle.Line, "Upper"));
    Add(new Plot(Color.FromKnownColor(KnownColor.SkyBlue), PlotStyle.Line, "Lower"));

    // Increase the default widths of the plots
    Plots[0].Pen.Width = 2;
    Plots[1].Pen.Width = 2;

    CalculateOnBarClose = true;
    Overlay = true;

    // Initialize the DataSeries.
    middle = new DataSeries(this);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Set the plots and the DataSeries.
    Lower.Set(SMA(Low, Period)[0]);
    Upper.Set(SMA(High, Period)[0]);
    middle.Set((SMA(Low, Period)[0] + SMA(High, Period)[0]) / 2);

    // If the average of the two plots is rising, change the plot colors.
    if (Rising(middle))
    {
    // The indexers for PlotColors are PlotColors[plot index][bars back], so the below code would set the first plot (Upper) to black and the second plot (Lower) to green.
    PlotColors[0][0] = Color.Black;
    PlotColors[1][0] = Color.LimeGreen;
    }
    // If the average is falling, change the plot colors.
    else if (Falling(middle))
    {
    PlotColors[0][0] = Color.Red;
    PlotColors[1][0] = Color.Black;
    }
    // If the average remains the same, set both plots to the same color.
    else
    {
    PlotColors[0][0] = Color.Blue;
    PlotColors[1][0] = Color.Blue;
    }
    }

    #2
    Hello,

    This should be fairly easy to create in the Strategy Wizard.

    Please see our Help Guide article on the Condition & Action screen for information on how to use this tool:



    You should be able to replicate the Rising and Filling based off the Middle plot of your indicator you're using.
    MatthewNinjaTrader Product Management

    Comment


      #3
      OK Matthew, I got it, but it's giving me too many signals, I want just 1 entry per signal, how can I change that?

      thanks

      Comment


        #4
        This is controlled by the Order Handling Properties you set when you start the strategy.

        You will want to see the EntriesPerDirection to 1 and the EntryHandling to "All Entries".

        Please see our Understanding strategy properties section for clarification on these options:

        MatthewNinjaTrader Product Management

        Comment


          #5
          Thats exactly how it is set:

          EntriesPerDirection to 1 and the EntryHandling to "All Entries"

          but still is giving me more than 1 entry, do you need to see my code?

          thanks

          Comment


            #6
            If you do not mind sharing your code, I'd be happy to have a look.
            MatthewNinjaTrader Product Management

            Comment


              #7
              Ok, Matthew your e-mail is support at ninjatrader dot com?

              Comment


                #8
                Yes, you can send it to our help desk using that address.

                Please reference this thread in your email.
                MatthewNinjaTrader Product Management

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                647 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                573 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X