Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Paintbars based on 4 indicators all agreeing

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

    #16
    Originally posted by NinjaTrader_Austin View Post
    simpletrades, a double value is simply a number with a decimal. It doesn't have anything to do with multiplying a value by two. It is necessary for certain indicators because they return decimal values. A few other data types include:
    • Int - an integer value (1, 2, 3, -1, -7)
    • Long - an integer value with a wider range of values than Int
    • Float, double, decimal (from least possible precision to most possible precision, NOT accuracy) - make it possible to include decimal values (100.23, .94, 103838.3983932, etc).
    If you'd like to review the variable types in C#, this page is a good place to get started.
    Thanks, but i think they are included because all equations for all 4 indicators were copied and pasted intact from the ninja original scripts except for maybe renaming as required by the editor, that clue you gave yesterday on the Mom condition and things like that.

    Comment


      #17
      Pleae help me redo the 4 indicator paintbar again.
      I had to uninstall from control panel and reinstall and lost all my custom indicators.
      I had this saved as a .cs file and thought I was OK but when I tried to load the script in a new script window, I got the error message
      that the name RSImine does not exist in current context for condition set 1 and set 2

      I really need this back. It worked for almost 3 weeks.
      I dont where the line about RSI got currupted "
      && RSImine(
      21).Plot0[0] > 50 ' or how to fix it.
      I did have a new script saved caled RSImine.cs and if that is part of the problem how do I get this to reference the ninja default RSI script using 21 length? if that will resolve it.

      Also unsure if the MACD line for the 2 conditions is Ok, but since there was no error message, it hopefully is.

      thanks

      HTML Code:
      #region Using declarations
      using System;
      using System.ComponentModel;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Indicator;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Strategy;
      #endregion
      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      /// <summary>
      /// MFI RSI MACD MOM paintbar
      /// </summary>
      [Description("MFI RSI MACD MOM paintbar")]
      public class FourIndicatorPaintbar : Indicator
      {
      #region Variables
      // Wizard generated variables
      private int myMFI = 14; // Default setting for MyMFI
      private int myRSI = 21; // Default setting for MyRSI
      private int myMOM = 9; // Default setting for MyMOM
      private int fMACD = 8; // Default setting for FMACD
      private int sMACD = 18; // Default setting for SMACD
      private int avgMACD = 9; // Default setting for AvgMACD
      // 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 (MFI(14)[0]> 50
      && RSImine(21).Plot0[0] > 50 
      && Momentum(14)[0] > 0
      && MACD(8, 18, 9)[0] > MACD(8, 18, 9).Avg[0] )
      BarColor=Color.MediumBlue;
       
      // Condition set 2 
      if (MFI(14)[0]< 50
      && RSImine(21).Plot0[0] < 50
      && Momentum(14)[0] < 0
      && MACD(8, 18, 9)[0] < MACD(8, 18, 9).Avg[0] )
      BarColor=Color.Fuchsia;
       
       
       
       
      {
      }
      }
      #region Properties
      [Description("MFI length")]
      [Category("Parameters")]
      public int MyMFI
      {
      get { return myMFI; }
      set { myMFI = Math.Max(1, value); }
      }
      [Description("RSI Length")]
      [Category("Parameters")]
      public int MyRSI
      {
      get { return myRSI; }
      set { myRSI = Math.Max(1, value); }
      }
      [Description("MOM length")]
      [Category("Parameters")]
      public int MyMOM
      {
      get { return myMOM; }
      set { myMOM = Math.Max(1, value); }
      }
      [Description("MACD fast")]
      [Category("Parameters")]
      public int FMACD
      {
      get { return fMACD; }
      set { fMACD = Math.Max(1, value); }
      }
      [Description("MACD Slow")]
      [Category("Parameters")]
      public int SMACD
      {
      get { return sMACD; }
      set { sMACD = Math.Max(1, value); }
      }
      [Description("MACD Avg")]
      [Category("Parameters")]
      public int AvgMACD
      {
      get { return avgMACD; }
      set { avgMACD = Math.Max(1, value); }
      }
      #endregion
      }
      }
      #region NinjaScript generated code. Neither change nor remove.
      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      public partial class Indicator : IndicatorBase
      {
      private FourIndicatorPaintbar[] cacheFourIndicatorPaintbar = null;
      private static FourIndicatorPaintbar checkFourIndicatorPaintbar = new FourIndicatorPaintbar();
      /// <summary>
      /// MFI RSI MACD MOM paintbar
      /// </summary>
      /// <returns></returns>
      public FourIndicatorPaintbar FourIndicatorPaintbar(int avgMACD, int fMACD, int myMFI, int myMOM, int myRSI, int sMACD)
      {
      return FourIndicatorPaintbar(Input, avgMACD, fMACD, myMFI, myMOM, myRSI, sMACD);
      }
      /// <summary>
      /// MFI RSI MACD MOM paintbar
      /// </summary>
      /// <returns></returns>
      public FourIndicatorPaintbar FourIndicatorPaintbar(Data.IDataSeries input, int avgMACD, int fMACD, int myMFI, int myMOM, int myRSI, int sMACD)
      {
      checkFourIndicatorPaintbar.AvgMACD = avgMACD;
      avgMACD = checkFourIndicatorPaintbar.AvgMACD;
      checkFourIndicatorPaintbar.FMACD = fMACD;
      fMACD = checkFourIndicatorPaintbar.FMACD;
      checkFourIndicatorPaintbar.MyMFI = myMFI;
      myMFI = checkFourIndicatorPaintbar.MyMFI;
      checkFourIndicatorPaintbar.MyMOM = myMOM;
      myMOM = checkFourIndicatorPaintbar.MyMOM;
      checkFourIndicatorPaintbar.MyRSI = myRSI;
      myRSI = checkFourIndicatorPaintbar.MyRSI;
      checkFourIndicatorPaintbar.SMACD = sMACD;
      sMACD = checkFourIndicatorPaintbar.SMACD;
      if (cacheFourIndicatorPaintbar != null)
      for (int idx = 0; idx < cacheFourIndicatorPaintbar.Length; idx++)
      if (cacheFourIndicatorPaintbar[idx].AvgMACD == avgMACD && cacheFourIndicatorPaintbar[idx].FMACD == fMACD && cacheFourIndicatorPaintbar[idx].MyMFI == myMFI && cacheFourIndicatorPaintbar[idx].MyMOM == myMOM && cacheFourIndicatorPaintbar[idx].MyRSI == myRSI && cacheFourIndicatorPaintbar[idx].SMACD == sMACD && cacheFourIndicatorPaintbar[idx].EqualsInput(input))
      return cacheFourIndicatorPaintbar[idx];
      FourIndicatorPaintbar indicator = new FourIndicatorPaintbar();
      indicator.BarsRequired = BarsRequired;
      indicator.CalculateOnBarClose = CalculateOnBarClose;
      indicator.Input = input;
      indicator.AvgMACD = avgMACD;
      indicator.FMACD = fMACD;
      indicator.MyMFI = myMFI;
      indicator.MyMOM = myMOM;
      indicator.MyRSI = myRSI;
      indicator.SMACD = sMACD;
      indicator.SetUp();
      FourIndicatorPaintbar[] tmp = new FourIndicatorPaintbar[cacheFourIndicatorPaintbar == null ? 1 : cacheFourIndicatorPaintbar.Length + 1];
      if (cacheFourIndicatorPaintbar != null)
      cacheFourIndicatorPaintbar.CopyTo(tmp, 0);
      tmp[tmp.Length - 1] = indicator;
      cacheFourIndicatorPaintbar = tmp;
      Indicators.Add(indicator);
      return indicator;
      }
      }
      }
      // This namespace holds all market analyzer column definitions and is required. Do not change it.
      namespace NinjaTrader.MarketAnalyzer
      {
      public partial class Column : ColumnBase
      {
      /// <summary>
      /// MFI RSI MACD MOM paintbar
      /// </summary>
      /// <returns></returns>
      [Gui.Design.WizardCondition("Indicator")]
      public Indicator.FourIndicatorPaintbar FourIndicatorPaintbar(int avgMACD, int fMACD, int myMFI, int myMOM, int myRSI, int sMACD)
      {
      return _indicator.FourIndicatorPaintbar(Input, avgMACD, fMACD, myMFI, myMOM, myRSI, sMACD);
      }
      /// <summary>
      /// MFI RSI MACD MOM paintbar
      /// </summary>
      /// <returns></returns>
      public Indicator.FourIndicatorPaintbar FourIndicatorPaintbar(Data.IDataSeries input, int avgMACD, int fMACD, int myMFI, int myMOM, int myRSI, int sMACD)
      {
      return _indicator.FourIndicatorPaintbar(input, avgMACD, fMACD, myMFI, myMOM, myRSI, sMACD);
      }
      }
      }
      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      public partial class Strategy : StrategyBase
      {
      /// <summary>
      /// MFI RSI MACD MOM paintbar
      /// </summary>
      /// <returns></returns>
      [Gui.Design.WizardCondition("Indicator")]
      public Indicator.FourIndicatorPaintbar FourIndicatorPaintbar(int avgMACD, int fMACD, int myMFI, int myMOM, int myRSI, int sMACD)
      {
      return _indicator.FourIndicatorPaintbar(Input, avgMACD, fMACD, myMFI, myMOM, myRSI, sMACD);
      }
      /// <summary>
      /// MFI RSI MACD MOM paintbar
      /// </summary>
      /// <returns></returns>
      public Indicator.FourIndicatorPaintbar FourIndicatorPaintbar(Data.IDataSeries input, int avgMACD, int fMACD, int myMFI, int myMOM, int myRSI, int sMACD)
      {
      if (InInitialize && input == null)
      throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
      return _indicator.FourIndicatorPaintbar(input, avgMACD, fMACD, myMFI, myMOM, myRSI, sMACD);
      }
      }
      }
      #endregion
      Last edited by simpletrades; 08-22-2009, 05:03 PM.

      Comment


        #18
        You can ignore my last request at post 17 asking for help redoing my 4 indicator paintbar.
        I thought about it and tried loading my saved RSImine.cs file into a new script window, compiled it then tried to compile the 4 indicator script and this time it worked. I didnt realize the scripts pull code from other saved scripts and just wasnt able to find my custom RSI since I hadnt reloaded it.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        344 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        557 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X