Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

coloring the slope

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

    coloring the slope

    Hi!
    I would like to correct the list displayed here so that you repulse colors differently depending on if it goes down or up
    anyone can write this small change?
    thanks for everything

    ================================================== ===============

    #region Using declarations
    using System;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.ComponentModel;
    using System.Xml.Serialization;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    #endregion
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Repulse. The Repulse indicator is based on the formula by Eric Lefort.
    /// </summary>
    [Description("The Repulse indicator is based on the formula by Eric Lefort.")]
    public class Repulse : Indicator
    {
    #region Variables
    private int period1 = 3;
    private int period2 = 5;
    private int period3 = 15;
    private int p1 = 0;
    private int p2 = 0;
    private int p3 = 0;
    private int barsCount = 0;
    private MAX myHigh1;
    private MAX myHigh2;
    private MAX myHigh3;
    private MIN myLow1;
    private MIN myLow2;
    private MIN myLow3;
    private EMA mm1;
    private EMA mm2;
    private EMA mm3;
    private EMA mb1;
    private EMA mb2;
    private EMA mb3;
    private DataSeries bullishThrust1;
    private DataSeries bullishThrust2;
    private DataSeries bullishThrust3;
    private DataSeries bearishThrust1;
    private DataSeries bearishThrust2;
    private DataSeries bearishThrust3;


    #endregion
    /// <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(new Pen(Color.Lime,2), "Repulse 1"));
    Add(new Plot(new Pen(Color.Gold,2), "Repulse 2"));
    Add(new Plot(new Pen(Color.Red,2), "Repulse 3"));
    Add(new Line(Color.SlateGray, 0, "Zeroline"));

    Overlay = false;
    PriceTypeSupported = true;

    bullishThrust1 = new DataSeries(this);
    bullishThrust2 = new DataSeries(this);
    bullishThrust3 = new DataSeries(this);
    bearishThrust1 = new DataSeries(this);
    bearishThrust2 = new DataSeries(this);
    bearishThrust3 = new DataSeries(this);
    }
    protected override void OnStartUp()
    {
    p1 = 5 * period1;
    p2 = 5 * period2;
    p3 = 5 * period3;
    barsCount = Math.Max(period1, Math.Max(period2, period3));
    myHigh1 = MAX(High, period1);
    myHigh2 = MAX(High, period2);
    myHigh3 = MAX(High, period3);
    myLow1 = MIN(Low, period1);
    myLow2 = MIN(Low, period2);
    myLow3 = MIN(Low, period3);
    mm1 = EMA(bullishThrust1, p1);
    mm2 = EMA(bullishThrust2, p2);
    mm3 = EMA(bullishThrust3, p3);
    mb1 = EMA(bearishThrust1, p1);
    mb2 = EMA(bearishThrust2, p2);
    mb3 = EMA(bearishThrust3, p3);
    }

    /// Called on each bar update event (incoming tick) ///
    protected override void OnBarUpdate()
    {
    if (CurrentBar < barsCount)
    return;
    if(Math.Abs(Close[0]) > 0.00000001)
    {
    bullishThrust1.Set((3*Close[0]-2*myLow1[0]-Open[period1-1])/Close[0]*100);
    bullishThrust2.Set((3*Close[0]-2*myLow2[0]-Open[period2-1])/Close[0]*100);
    bullishThrust3.Set((3*Close[0]-2*myLow3[0]-Open[period3-1])/Close[0]*100);
    bearishThrust1.Set((Open[period1-1]+2*myHigh1[0]-3*Close[0])/Close[0]*100);
    bearishThrust2.Set((Open[period2-1]+2*myHigh2[0]-3*Close[0])/Close[0]*100);
    bearishThrust3.Set((Open[period3-1]+2*myHigh3[0]-3*Close[0])/Close[0]*100);
    Repulse1.Set(mm1[0]-mb1[0]);
    Repulse2.Set(mm2[0]-mb2[0]);
    Repulse3.Set(mm3[0]-mb3[0]);
    }
    else
    {
    bullishThrust1.Reset();
    bullishThrust2.Reset();
    bullishThrust3.Reset();
    bearishThrust1.Reset();
    bearishThrust2.Reset();
    bearishThrust3.Reset();
    Repulse1.Reset();
    Repulse2.Reset();
    Repulse3.Reset();
    }
    }

    #region Properties

    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Repulse1
    {
    get { return Values[0]; }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Repulse2
    {
    get { return Values[1]; }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Repulse3
    {
    get { return Values[2]; }
    }

    [Description("")]
    [GridCategory("Parameters")]
    [Gui.Design.DisplayName("Period 1")]
    public int Period1
    {
    get { return period1; }
    set { period1 = Math.Max(1, value); }
    }

    [Description("")]
    [GridCategory("Parameters")]
    [Gui.Design.DisplayName("Period 2")]
    public int Period2
    {
    get { return period2; }
    set { period2 = Math.Max(1, value); }
    }

    [Description("")]
    [GridCategory("Parameters")]
    [Gui.Design.DisplayName("Period 3")]
    public int Period3
    {
    get { return period3; }
    set { period3 = 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 Repulse[] cacheRepulse = null;
    private static Repulse checkRepulse = new Repulse();
    /// <summary>
    /// The Repulse indicator is based on the formula by Eric Lefort.
    /// </summary>
    /// <returns></returns>
    public Repulse Repulse(int period1, int period2, int period3)
    {
    return Repulse(Input, period1, period2, period3);
    }
    /// <summary>
    /// The Repulse indicator is based on the formula by Eric Lefort.
    /// </summary>
    /// <returns></returns>
    public Repulse Repulse(Data.IDataSeries input, int period1, int period2, int period3)
    {
    if (cacheRepulse != null)
    for (int idx = 0; idx < cacheRepulse.Length; idx++)
    if (cacheRepulse[idx].Period1 == period1 && cacheRepulse[idx].Period2 == period2 && cacheRepulse[idx].Period3 == period3 && cacheRepulse[idx].EqualsInput(input))
    return cacheRepulse[idx];
    lock (checkRepulse)
    {
    checkRepulse.Period1 = period1;
    period1 = checkRepulse.Period1;
    checkRepulse.Period2 = period2;
    period2 = checkRepulse.Period2;
    checkRepulse.Period3 = period3;
    period3 = checkRepulse.Period3;
    if (cacheRepulse != null)
    for (int idx = 0; idx < cacheRepulse.Length; idx++)
    if (cacheRepulse[idx].Period1 == period1 && cacheRepulse[idx].Period2 == period2 && cacheRepulse[idx].Period3 == period3 && cacheRepulse[idx].EqualsInput(input))
    return cacheRepulse[idx];
    Repulse indicator = new Repulse();
    indicator.BarsRequired = BarsRequired;
    indicator.CalculateOnBarClose = CalculateOnBarClose;
    #if NT7
    indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
    indicator.MaximumBarsLookBack = MaximumBarsLookBack;
    #endif
    indicator.Input = input;
    indicator.Period1 = period1;
    indicator.Period2 = period2;
    indicator.Period3 = period3;
    Indicators.Add(indicator);
    indicator.SetUp();
    Repulse[] tmp = new Repulse[cacheRepulse == null ? 1 : cacheRepulse.Length + 1];
    if (cacheRepulse != null)
    cacheRepulse.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheRepulse = tmp;
    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>
    /// The Repulse indicator is based on the formula by Eric Lefort.
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.Repulse Repulse(int period1, int period2, int period3)
    {
    return _indicator.Repulse(Input, period1, period2, period3);
    }
    /// <summary>
    /// The Repulse indicator is based on the formula by Eric Lefort.
    /// </summary>
    /// <returns></returns>
    public Indicator.Repulse Repulse(Data.IDataSeries input, int period1, int period2, int period3)
    {
    return _indicator.Repulse(input, period1, period2, period3);
    }
    }
    }
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// The Repulse indicator is based on the formula by Eric Lefort.
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.Repulse Repulse(int period1, int period2, int period3)
    {
    return _indicator.Repulse(Input, period1, period2, period3);
    }
    /// <summary>
    /// The Repulse indicator is based on the formula by Eric Lefort.
    /// </summary>
    /// <returns></returns>
    public Indicator.Repulse Repulse(Data.IDataSeries input, int period1, int period2, int period3)
    {
    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.Repulse(input, period1, period2, period3);
    }
    }
    }
    #endregion

Latest Posts

Collapse

Topics Statistics Last Post
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
0 responses
557 views
0 likes
Last Post Geovanny Suaza  
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
0 responses
324 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
545 views
1 like
Last Post Geovanny Suaza  
Started by RFrosty, 01-28-2026, 06:49 PM
0 responses
547 views
1 like
Last Post RFrosty
by RFrosty
 
Working...
X