please can you help in how to get this indicator compiling which should be signalling when there is a wide body candle next to a small body candle.
Thank you.
#region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
public class abaBodiesModified : Indicator
{
private EMA EMA1;
private ROC ROC1;
private ABS ABS1;
private ABS ABS2;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "abaBodiesModified";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
IsAutoScale = 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;
First_body_size_Min = -0.01;
First_body_size_Max = 0.01;
Second_Bar_Multiplier = 8.0;
AddPlot(Brushes.DodgerBlue, "Pinch");
}
else if (State == State.Configure)
{
EMA1 = EMA(Close, 8);
ROC1 = ROC(Close, 1);
abs1 = abs(Close[0] - Open[0]);
abs2 = abs(Close[1] - Open[1]);
EMA1.Plots[0].Brush = Brushes.Goldenrod;
}
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 4)
return;
{
Value[0] = +0;
}
// Set 1
if (
// conditions for SMALL BODY bar for LONGs
// using ROC indicator in order to set percentage value of the body of 1st candle. for ex +- 0.01%
(
(ROC1[1] < First_body_size_Max)
&& (ROC1[1] > First_body_size_Min))
// conditions for WIDE BODY bar for LONGs
// using absolute value because 1st bar can be either upbar or down bar,
// ie value of 1st bar body can be either positive or negative
&& (Close[0] > Open[0])
&& abs1 > (abs2*Second_Bar_Multiplier)
)
{
BackBrush = Brushes.ForestGreen;
}
// Set 2
if (
// conditions for SMALL BODY bar for SHORTs
(
(ROC1[1] < First_body_size_Max)
&& (ROC1[1] > First_body_size_Min))
// conditions for WIDE BODY bar for SHORTs
&& (Close[0] < Open[0])
&& abs1 > (abs2*Second_Bar_Multiplier)
)
{
BackBrush = Brushes.OrangeRed;
}
}
public override void OnCalculateMinMax()
{
MinValue = - 1;
MaxValue = + 1;
}
#region Properties
[NinjaScriptProperty]
[Range(-99, double.MaxValue)]
[Display(Name="First_body_size_Min", Order=1, GroupName="Parameters")]
public double First_body_size_Min
{ get; set; }
[NinjaScriptProperty]
[Range(-99, double.MaxValue)]
[Display(Name="First_body_size_Max", Order=2, GroupName="Parameters")]
public double First_body_size_Max
{ get; set; }
[NinjaScriptProperty]
[Range(-99, double.MaxValue)]
[Display(Name="Second_Bar_Multiplier", Order=6, GroupName="Parameters")]
public double Second_Bar_Multiplier
{ get; set; }
#endregion
}
}
Comment