I'm attempting to add the chart volume indicator to panel 2 as per the help guides https://ninjatrader.com/support/help.../nt8/?tips.htm but nothing is being added to the chart window. Secondly I believe I have correctly defined a regression channel with a 1 standard deviation upper and lower bound however when opening the output window it's blank. The strategy does not have a symbol defined within the code so would that be part of the reason that there are no outputs when output window is opened from the ninjascript editor?
The strategy is currently running on 2 charts but neither is showing volume or the regression channel outputs
#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.Indicators;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class StratAttempt1 : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"First strat attempt";
Name = "StratAttempt1";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = true;
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0.25;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.ByStrategyPosition;
BarsRequiredToTrade = 6000;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
AddDataSeries("ES 09-21", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
}
else if (State == State.DataLoaded)
{
AddChartIndicator(VOL());
VOL().Panel = 2;
double price = Close[0];
int period = 6900;
int stdev = 1;
double RegChannelUpper = RegressionChannel(period, stdev).Upper[0];
double RegChannelLower = RegressionChannel(period, stdev).Lower[0];
Print("Regression channel value - upper -" + RegChannelUpper + " - lower - " + RegChannelLower);
Print("Price" + price.ToString());
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
}
}
}
Comment