
//
// Copyright (C) 2019, Order Flow Analytics Inc <www.orderflowanalytics.com>.
// OFA reserves the right to modify or overwrite this NinjaScript component with each release.
//
// By installing, using in whole or in part any sample code from Order Flow Analytics you agree to fully indemnify and hold harmless OrderFlowAnalytics, Inc 
// and its affiliates from and against any claims, losses, liabilities and expenses that may be incurred 
// as a result having downloaded and/or used any or all of the available code.
// Do thoroughly test any code & modifications for indicators and strategies in Replay Test mode

#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 OFASampleIndActiveProfileDataAccess : Indicator
	{
		// Key reference needed to declare to access the Active Profile Data on the OFA Chart
		
		private OFAIndSTProfileAccess OFAIndSTPRACCESS1;
		
		protected override void OnStateChange()
		{
			if (State == State.SetDefaults)
			{
				Description									= @"Enter the description for your new custom Indicator here.";
				Name										= "OFASampleIndActiveProfileDataAccess";
				Calculate									= Calculate.OnBarClose;
				IsOverlay									= false;
				DisplayInDataBox							= true;
				DrawOnPricePanel							= true;
				DrawHorizontalGridLines						= false;
				DrawVerticalGridLines						= false;
				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					= false;
				
			}
			else if (State == State.Configure)
			{
				;
				
			}
			
			else if (State == State.DataLoaded)
			{				
				
				OFAIndSTPRACCESS1				= OFAIndSTProfileAccess(Close);
			}
		}

		protected override void OnBarUpdate()
		{
			//Add your custom indicator logic here
			// For any indicator loaded into Bloodhound - can only be BarsInProgress == 0 ie the Primary Data Series
			
			if (BarsInProgress != 0) 
				return;

			if (CurrentBars[0] < 1)
				return;		
			
			// Before accessing Active Profile on the chart must always
			// Check an Active Profile is added and enabled before trying to access the data
			//
			
			if (OFAIndSTPRACCESS1.OFAIsActiveProfileEnabled)
			{
				
				Print("AP CWAP="); Print(OFAIndSTPRACCESS1.OFAActiveProfileCwap);   
				Print("AP VWAP="); Print(OFAIndSTPRACCESS1.OFAActiveProfileVwap);
				
				Print("AP VPOC="); Print(OFAIndSTPRACCESS1.OFAActiveProfileVPOCPrice);
				Print("AP CAH="); Print(OFAIndSTPRACCESS1.OFAActiveProfileCAHPrice);
				Print("AP CAL="); Print(OFAIndSTPRACCESS1.OFAActiveProfileCALPrice);
				Print("AP VAH="); Print(OFAIndSTPRACCESS1.OFAActiveProfileVAHPrice);
				Print("AP VAL="); Print(OFAIndSTPRACCESS1.OFAActiveProfileVALPrice);
				
				Print("AP Lower SD 1="); Print(OFAIndSTPRACCESS1.OFAActiveProfileLowerSD1Price);
				Print("AP Upper SD 1="); Print(OFAIndSTPRACCESS1.OFAActiveProfileUpperSD1Price);
				Print("AP Lower SD 2="); Print(OFAIndSTPRACCESS1.OFAActiveProfileLowerSD2Price);
				Print("AP Upper SD 2="); Print(OFAIndSTPRACCESS1.OFAActiveProfileUpperSD2Price);
				Print("AP Lower SD 3="); Print(OFAIndSTPRACCESS1.OFAActiveProfileLowerSD3Price);
				Print("AP Upper SD 3="); Print(OFAIndSTPRACCESS1.OFAActiveProfileUpperSD3Price);
				
				Print("AP CWAPVWAP Risk="); Print(OFAIndSTPRACCESS1.OFAActiveProfileCWAPVWAPRisk);
				
				
				// Advanced Profile Users will see values for the following
				
				Print("AP DWAP="); Print(OFAIndSTPRACCESS1.OFAActiveProfileDwap);
				Print("AP 50 Line="); Print(OFAIndSTPRACCESS1.OFAActiveProfile50LinePrice);
				Print("AP TWAP Close="); Print(OFAIndSTPRACCESS1.OFAActiveProfileTWAPCLOSEPrice);
				Print("AP TWAP POC="); Print(OFAIndSTPRACCESS1.OFAActiveProfileTWAPPOCPrice);
				Print("AP VWAPDWAP Risk="); Print(OFAIndSTPRACCESS1.OFAActiveProfileVWAPDWAPRisk);
				Print("AP CWAP VWAP Diff Price="); Print(OFAIndSTPRACCESS1.OFAActiveProfileCWAPVWAPDIFFPrice);
				Print("AP VA Median Price="); Print(OFAIndSTPRACCESS1.OFAActiveProfileVAMedianPrice);
				Print("AP VWAP to CWAP VWAP Diff Risk="); Print(OFAIndSTPRACCESS1.OFAActiveProfileVWAPCwapVwapDiffRisk);
				

			}
			
		
		}

		#region Properties

		
		#endregion
		

	}
}

#region NinjaScript generated code. Neither change nor remove.

namespace NinjaTrader.NinjaScript.Indicators
{
	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
	{
		private OFASampleIndActiveProfileDataAccess[] cacheOFASampleIndActiveProfileDataAccess;
		public OFASampleIndActiveProfileDataAccess OFASampleIndActiveProfileDataAccess()
		{
			return OFASampleIndActiveProfileDataAccess(Input);
		}

		public OFASampleIndActiveProfileDataAccess OFASampleIndActiveProfileDataAccess(ISeries<double> input)
		{
			if (cacheOFASampleIndActiveProfileDataAccess != null)
				for (int idx = 0; idx < cacheOFASampleIndActiveProfileDataAccess.Length; idx++)
					if (cacheOFASampleIndActiveProfileDataAccess[idx] != null &&  cacheOFASampleIndActiveProfileDataAccess[idx].EqualsInput(input))
						return cacheOFASampleIndActiveProfileDataAccess[idx];
			return CacheIndicator<OFASampleIndActiveProfileDataAccess>(new OFASampleIndActiveProfileDataAccess(), input, ref cacheOFASampleIndActiveProfileDataAccess);
		}
	}
}

namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
	{
		public Indicators.OFASampleIndActiveProfileDataAccess OFASampleIndActiveProfileDataAccess()
		{
			return indicator.OFASampleIndActiveProfileDataAccess(Input);
		}

		public Indicators.OFASampleIndActiveProfileDataAccess OFASampleIndActiveProfileDataAccess(ISeries<double> input )
		{
			return indicator.OFASampleIndActiveProfileDataAccess(input);
		}
	}
}

namespace NinjaTrader.NinjaScript.Strategies
{
	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
	{
		public Indicators.OFASampleIndActiveProfileDataAccess OFASampleIndActiveProfileDataAccess()
		{
			return indicator.OFASampleIndActiveProfileDataAccess(Input);
		}

		public Indicators.OFASampleIndActiveProfileDataAccess OFASampleIndActiveProfileDataAccess(ISeries<double> input )
		{
			return indicator.OFASampleIndActiveProfileDataAccess(input);
		}
	}
}

#endregion
