NinjaTrader 8 code

Job ID: 37226049

Budget: $10 – $50 USD

I am looking for a skilled NinjaTrader 8 developer to modify an existing code. I am having issues with rendering drawing objects. And calling marketanalyzer, so the code will not compile.


using System;
using NinjaTrader.Cbi;
using NinjaTrader.Gui.Tools;
using NinjaTrader.NinjaScript;
using NinjaTrader.Data;
using NinjaTrader.Gui.Tools;
using NinjaTrader.NinjaScript.Strategies;
using NinjaTrader.Data.MarketAnalyzer;
using System.Windows.Media;

namespace NinjaTrader.NinjaScript.Strategies
{
public class GSO9Indicator : Indicator
{
private DateTime lastCalibrationDate = DateTime.MinValue;
private double centerPrice;
private double[] gannAngles = { 45, 90, 135, 180, 225, 270, 315, 360 };
private double[] supportResistanceLevels = new double[8];
private double imbalanceThreshold = 1.0; // Adjust this threshold
private double buyingLevel;
private double sellingLevel;
private double openingRangeHigh = double.MinValue;
private double openingRangeLow = double.MaxValue;
private double vwap;
private double vwap1StdDev;
private double vwap2StdDev;

protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "GSO9 Indicator with Volume Imbalances, Opening Range, Naked VPOC, and VWAP";
Name = "GSO9 v1.0"; // Version revision number
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = true;
}
}

protected override void OnBarUpdate()
{
if (BarsInProgress == 0 && CurrentBars[0] == 1)
{
openingRangeHigh = Highs[0][0];
openingRangeLow = Lows[0][0];
}
else if (BarsInProgress == 0 && Time[0].TimeOfDay.TotalMinutes >= 5)
{
openingRangeHigh = double.MinValue;
openingRangeLow = double.MaxValue;
}

if (Time[0].Date != lastCalibrationDate)
{
lastCalibrationDate = Time[0].Date;
centerPrice = Close[0];

for (int i = 0; i < gannAngles.Length; i++)
{
double radians = gannAngles[i] * Math.PI / 180;
double level = centerPrice + (Math.Cos(radians) * 10);

supportResistanceLevels[i] = level;
}
}

for (int i = 0; i < supportResistanceLevels.Length; i++)
{
// Plot the Gann angle lines directly on the price chart
Draw.Line(this, "SRLevel" + i, i, supportResistanceLevels[i], 0, supportResistanceLevels[i], i % 2 == 0 ? Brushes.Green : Brushes.Red, DashStyleHelper.Solid, 2);
}

double aboveVolume = 0;
double belowVolume = 0;

for (int i = 0; i < CurrentBars[0]; i++)
{
if (Close[i] > centerPrice)
aboveVolume += Volume[i];
else if (Close[i] < centerPrice)
belowVolume += Volume[i];
}

double imbalance = (aboveVolume - belowVolume) / (aboveVolume + belowVolume);

if (imbalance > imbalanceThreshold)
{
buyingLevel = centerPrice + (imbalanceThreshold * 10); // Adjust factor if needed
Draw.Line(this, "BuyingLevel", 0, buyingLevel, CurrentBars[0], buyingLevel, Brushes.Blue, DashStyleHelper.Dash, 2);
}
else if (imbalance < -imbalanceThreshold)
{
sellingLevel = centerPrice - (imbalanceThreshold * 10); // Adjust factor if needed
Draw.Line(this, "SellingLevel", 0, sellingLevel, CurrentBars[0], sellingLevel, Brushes.Orange, DashStyleHelper.Dash, 2);
}

if (BarsInProgress == 0 && Time[0].TimeOfDay.TotalMinutes == 5)
{
// Plot the opening range lines directly on the price chart
Draw.Line(this, "OpeningRangeHigh", 0, openingRangeHigh, CurrentBars[0], openingRangeHigh, Brushes.Yellow, DashStyleHelper.Solid, 2);
Draw.Line(this, "OpeningRangeLow", 0, openingRangeLow, CurrentBars[0], openingRangeLow, Brushes.Yellow, DashStyleHelper.Solid, 2);
}

// Plot the naked VPOC directly on the price chart
double nakedVPOC = (Highs[0][0] + Lows[0][0]) / 2.0;
Draw.Line(this, "NakedVPOC", 0, nakedVPOC, CurrentBars[0], nakedVPOC, Brushes.Magenta, DashStyleHelper.Solid, 2);

// Calculate VWAP
vwap = SUM(Close * Volume, 5) / SUM(Volume, 5);

// Calculate VWAP standard deviations
double vwapSum = 0;
for (int i = 0; i < 5; i++)
{
vwapSum += Math.Pow((Close[i] * Volume[i]) - vwap, 2);
}
double vwapVariance = vwapSum / 5;
double vwapStdDev = Math.Sqrt(vwapVariance);

// Plot 1 standard deviation VWAP directly on the price chart
vwap1StdDev = vwap + vwapStdDev;
Draw.Line(this, "VWAP1StdDev", 0, vwap1StdDev, CurrentBars[0], vwap1StdDev, Brushes.Cyan, DashStyleHelper.Solid, 2);

// Plot 2 standard deviation VWAP directly on the price chart
vwap2StdDev = vwap + (2 * vwapStdDev);
Draw.Line(this, "VWAP2StdDev", 0, vwap2StdDev, CurrentBars[0], vwap2StdDev, Brushes.Pink, DashStyleHelper.Solid, 2);
}
}
}