Right now it prints the same time over and over and it is a Saturday of all things
isPlayBack=True CurrentTick Time=4/17/2022 3:05:00 PM
#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 PlaybackVsLive : Indicator
{
private DateTime ThisBarTime;
private DateTime PlaybackBarTime;
private string BarTime;
private string PlaybackTime;
private bool isPlayBack=false;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "PlaybackVsLive";
Calculate = Calculate.OnPriceChange;
IsOverlay = false;
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;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
if (Connection.PlaybackConnection==null)
{
Print("--------------------------------------------------------------------------------------------------NOT Playback---------------------------------->");
isPlayBack=false;
}
else
{
Print("--------------------------------------------------------------------------------------------------YES Playback==================================>");
isPlayBack=true;
}
}
}
protected override void OnBarUpdate()
{
//Add your custom indicator logic here.
if (isPlayBack)
{
BarTime = Bars.GetTime(0).ToString();
}
else
{
BarTime = DateTime.Now.ToString();
}
Print("isPlayBack="+isPlayBack+" CurrentTick Time="+BarTime);
}
}
}
#region NinjaScript generated code. Neither change nor remove.
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
private PlaybackVsLive[] cachePlaybackVsLive;
public PlaybackVsLive PlaybackVsLive()
{
return PlaybackVsLive(Input);
}
public PlaybackVsLive PlaybackVsLive(ISeries<double> input)
{
if (cachePlaybackVsLive != null)
for (int idx = 0; idx < cachePlaybackVsLive.Length; idx++)
if (cachePlaybackVsLive[idx] != null && cachePlaybackVsLive[idx].EqualsInput(input))
return cachePlaybackVsLive[idx];
return CacheIndicator<PlaybackVsLive>(new PlaybackVsLive(), input, ref cachePlaybackVsLive);
}
}
}
namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public Indicators.PlaybackVsLive PlaybackVsLive()
{
return indicator.PlaybackVsLive(Input);
}
public Indicators.PlaybackVsLive PlaybackVsLive(ISeries<double> input )
{
return indicator.PlaybackVsLive(input);
}
}
}
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{
public Indicators.PlaybackVsLive PlaybackVsLive()
{
return indicator.PlaybackVsLive(Input);
}
public Indicators.PlaybackVsLive PlaybackVsLive(ISeries<double> input )
{
return indicator.PlaybackVsLive(input);
}
}
}
#endregion

Comment