Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Turn Strategy into Indicator

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

    Turn Strategy into Indicator

    Is there a way to take the below Strategy that was created in your wizard and turn it into an Indicator? It Draws arrows by the candlesticks and plays a ding or beep. I have several Strategies that I would like to make Indicators so I don't have to load them every time. Is this possible? Thanks You for any help.


    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class AMOMOMACSTO : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {

    CalculateOnBarClose = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Open[0] < Close[0]
    && MACD(12, 26, 9)[0] > MACD(12, 26, 9).Avg[0]
    && Stochastics(7, 14, 3).K[0] > Stochastics(7, 14, 3).D[0]
    && MACD(12, 26, 9).Avg[0] > MACD(12, 26, 9).Avg[1]
    && StochasticsFast(3, 14).K[0] > StochasticsFast(3, 14).K[1]
    && MACD(12, 26, 9).Diff[0] > MACD(12, 26, 9).Diff[1]
    && BuyVolume()[0] > SellVolume()[0])
    {
    DrawArrowUp("My up arrow" + CurrentBar, true, 0, Low[0] + -3 * TickSize, Color.Yellow);
    PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\Ding.wav");
    }

    // Condition set 2
    if (Open[0] > Close[0]
    && MACD(12, 26, 9)[0] < MACD(12, 26, 9).Avg[0]
    && Stochastics(7, 14, 3).K[0] < Stochastics(7, 14, 3).D[0]
    && MACD(12, 26, 9).Avg[0] < MACD(12, 26, 9).Avg[1]
    && StochasticsFast(3, 14).K[0] < StochasticsFast(3, 14).K[1]
    && MACD(12, 26, 9).Diff[0] < MACD(12, 26, 9).Diff[1]
    && SellVolume()[0] > BuyVolume()[0])
    {
    DrawArrowDown("My down arrow" + CurrentBar, true, 0, High[0] + 3 * TickSize, Color.Yellow);
    PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\beep.wav");
    }

    #2
    All the code after the OnBarUpdate() is the same as indicator code. You could pretty much generate an indicator and do a copy and paste.
    This:
    Low[0] + -3 * TickSize
    Could be shortened to this too:
    Low[0] -3 * TickSize
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      I tried that but I still have no sign of the arrows showing up. Does the Market have to be open because as an indicator it will only show up in real time? When I run it as a strategy there are arrows on the previous bars when the strategy is met but not as an indicator. The ES is not open right now.
      Thanks for your previous reply and any further help.

      Comment


        #4
        Never mind. I think the problem is that my Ninja subscription ran out and the basic one that my broker gives me doesn't have the option to edit indicators or strategies. Sorry for the waste of time. But I may still convert all my strategies into indicators so your advice may still of great use to me so thank you.

        Comment


          #5
          Hi, when you move strategy code to an indicator, please also make sure to add those checks to the start of your OnBarUpdate() - http://www.ninjatrader-support2.com/...ead.php?t=3170

          Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          574 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          333 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X