The hope would be that as soon as it is possible that the candle will be a hammer it changes color and then changes back if it ends up not being a hammer.
Any help would be greatly appreciated.
This is how it work so far.
namespace NinjaTrader.NinjaScript.Indicators
{
public class HammerColor : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "HammerColor";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
WickPercMax = 89;
WickPercMin = 67;
BarColorUp = Brushes.Blue;
BarColorDown = Brushes.Yellow;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
// Print("O="+Open[0]+"H="+High[0]+"L="+Low[0]+"O-L/(H-L)*100="+(Open[0]-Low[0])/(High[Math.Min(CurrentBar, 1)]-Low[Math.Min(CurrentBar, 1)])*100+"H-O/(H-L)*100="+(High[0]-Open[0])/(High[Math.Min(CurrentBar, 1)]-Low[Math.Min(CurrentBar, 1)])*100);
if (Close[0]>Open[0] && (Open[0]-Low[0])/(High[Math.Min(CurrentBar, 1)]-Low[Math.Min(CurrentBar, 1)])*100>=WickPercMin && (Open[0]-Low[0])/(High[Math.Min(CurrentBar, 1)]-Low[Math.Min(CurrentBar, 1)])*100<=WickPercMax)
// { //hammer
BarBrush = BarColorUp;
// Draw.Text(this, "test"+CurrentBar, "O="+Open[0]+"L="+Low[0]+"O-L/(H-L)="+(Open[0]-Low[0])/(High[Math.Min(CurrentBar, 1)]-Low[Math.Min(CurrentBar, 1)]), 0, Low[0]);
// }
else if (Close[0]<Open[0] && (High[0]-Open[0])/(High[Math.Min(CurrentBar, 1)]-Low[Math.Min(CurrentBar, 1)])*100>=WickPercMin && (High[0]-Open[0])/(High[Math.Min(CurrentBar, 1)]-Low[Math.Min(CurrentBar, 1)])*100<=WickPercMax)
// {//inverted hammer
BarBrush = BarColorDown;
// Draw.Text(this, "test"+CurrentBar, "H="+High[0]+"O="+Open[0]+"H-O/H-L="+(High[0]-Open[0])/(High[Math.Min(CurrentBar, 1)]-Low[Math.Min(CurrentBar, 1)]), 0, High[0]);
// }
}
#region Properties
[NinjaScriptProperty]
[Range(80, int.MaxValue)]
[Display(Name="WickPercMax", Order=1, GroupName="Parameters")]
public int WickPercMax
{ get; set; }
[NinjaScriptProperty]
[Range(60, int.MaxValue)]
[Display(Name="WickPercMin", Order=2, GroupName="Parameters")]
public int WickPercMin
{ get; set; }
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name="BarColorUp", Order=3, GroupName="Parameters")]
public Brush BarColorUp
{ get; set; }
[Browsable(false)]
public string BarColorUpSerializable
{
get { return Serialize.BrushToString(BarColorUp); }
set { BarColorUp = Serialize.StringToBrush(value); }
}
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name="BarColorDown", Order=4, GroupName="Parameters")]
public Brush BarColorDown
{ get; set; }
[Browsable(false)]
public string BarColorDownSerializable
{
get { return Serialize.BrushToString(BarColorDown); }
set { BarColorDown = Serialize.StringToBrush(value); }
}
#endregion
}
}


Comment