1. My code
// Condition set 1
if (HMAColourChange(14).FallingPlot[0] < HMAColourChange(14).RisingPlot[1])
{
DrawArrowDown("My down arrow" + CurrentBar, false, 0, Close[0] + 20 * TickSize, Color.Red);
}
// Condition set 2
if (HMAColourChange(14).RisingPlot[0] > HMAColourChange(14).FallingPlot[1])
{
DrawArrowUp("My up arrow" + CurrentBar, false, 0, Close[0] + -20 * TickSize, Color.Lime);
}
2. HMA Code
//
// Copyright (C) 2009, GreatTradingSystems <www.greattradingsystems.com>.
//
//
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// This is a sample indicator plotting a HMA in three colors.
/// </summary>
[Description("Sample HMA plotted with three colors.")]
[Gui.Design.DisplayName("HMAColourChange")]
public class HMAColourChange : Indicator
{
#region Variables
private int period = 14;
#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 one plot for every color you wish to use.
Add(new Plot(Color.LimeGreen, PlotStyle.Line, "Rising"));
Add(new Plot(Color.Red, PlotStyle.Line, "Falling"));
Add(new Plot(Color.Yellow, PlotStyle.Line, "Neutral"));
CalculateOnBarClose = true;
Overlay = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Checks to make sure we have at least 1 bar before continuing
if (CurrentBar < 1)
return;
// Plot green if the HMA is rising
// Rising() returns true when the current value is greater than the value of the previous bar.
if (Rising(HMA(Period)))
{
// Connects the rising plot segment with the other plots
RisingPlot.Set(1, HMA(Period)[1]);
// Adds the new rising plot line segment to the line
RisingPlot.Set(HMA(Period)[0]);
}
// Plot red if the HMA is falling
// Falling() returns true when the current value is less than the value of the previous bar.
else if (Falling(HMA(Period)))
{
// Connects the new falling plot segment with the rest of the line
FallingPlot.Set(1, HMA(Period)[1]);
// Adds the new falling plot line segment to the line
FallingPlot.Set(HMA(Period)[0]);
}
// Plot yellow if the HMA is neutral
else
{
// Connects the neutral plot segment with the rest of the line
NeutralPlot.Set(1, HMA(Period)[1]);
// Adds the new neutral plot line segment to the line
NeutralPlot.Set(HMA(Period)[0]);
Comment