#region Variables
// Wizard generated variables
private double priceGapPercent = 5.000; // Default setting PriceGapPercent
// User defined variables (add any user defined variables below)
public double GapHigh; // should retain value
public double GapLow; //should retain value
#endregion
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), PlotStyle.Bar, "Plot0"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
GapHigh = double.NaN;
GapLow = double.NaN;
}
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
//Plot0.Set(Close[0]);
if ((High[0] >= GapLow*0.99) || (Low[0] <= GapHigh*1.01))
{
Plot0.Set(1);
if (High[0] >= GapLow)
{
GapLow = Double.NaN;
}
if (Low[0] <= GapHigh)
{
GapHigh = Double.NaN;
}
}
if (Low[0] >= (High[1] * (1 + priceGapPercent/100)))
{
GapHigh = Low[0];
}
if (High[0] <= (Low[1] - (High[1]*priceGapPercent/100)))
{
GapLow = High[0];
}
}
-----------------------------------------------------------------------
This logic works in Blocks scanning software and I was trying to make it work using NinjaTrader.
The original code in Blocks is as follows:
'# gapSizePercent = userinput.single = 5.00
'#Cumulative
Static GapHigh As Single
Static GapLow As Single
If isFirstBar Then
GapHigh = Single.NaN
GapLow = Single.NaN
End If
If Price.High >= GapLow*(0.99) Or Price.Low <= GapHigh*(1.01) Then
Pass
If Price.High >= GapLow Then GapLow = Single.NaN
If Price.Low <= GapHigh Then GapHigh = Single.NaN
'If Price.High >= GapHigh Then GapHigh = Single.NaN
'If Price.Low <= GapLow Then GapLow = Single.NaN
End If
If Price.Low >= Price.High(1)+(Price.High(1)*(gapSizePercent)/100) Then GapHigh = Price.Low
If Price.High <= Price.Low(1)-(Price.High(1)*(gapSizePercent)/100) Then GapLow = Price.High
------------------------------------------------------------------------
I am able to compile the code in Ninja Trader but when I apply it on a stock chart like TEG, it does not seem to work.
Few other symbols you can try:
NCMI, SNPS, PRGO
Can anyone help me as I am new to NinjaTrader. Am I doing anything wrong!!!
Comment