Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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 myDailyBarsPriorOHLC : Indicator
- {
- //private PriorDayOHLC PriorDayOHLC1;
- protected override void OnStateChange()
- {
- if (State == State.SetDefaults)
- {
- Description = @"Enter the description for your new custom Indicator here.";
- Name = "myDailyBarsPriorOHLC";
- Calculate = Calculate.OnEachTick;
- 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;
- AddPlot(Brushes.White, "PriorOpen");
- AddPlot(Brushes.Lime, "PriorHigh");
- AddPlot(Brushes.Red, "PriorLow");
- AddPlot(Brushes.Pink, "PriorClose");
- AddPlot(Brushes.Cyan, "OpenMinusClose");
- }
- else if (State == State.Configure)
- {
- }
- else if (State == State.DataLoaded)
- {
- //PriorDayOHLC1 = PriorDayOHLC(Close);
- }
- }
- protected override void OnBarUpdate()
- {
- if (BarsInProgress != 0)
- return;
- if (CurrentBars[0] < 1)
- return;
- // Set 1
- // Print(Time[0] +
- // " " + "Open Value: " + Convert.ToString(Open[1]) +
- // " " + "High Value: " + Convert.ToString(High[1]) +
- // " " + "Low Value: " + Convert.ToString(Low[1]) +
- // " " + "Close Value: " + Convert.ToString(Close[1]));
- {
- }
- if (IsFirstTickOfBar && Times[0][0].DayOfWeek != DayOfWeek.Monday)
- {
- Values[0][0] = Open[1];
- Values[1][0] = High[1];
- Values[2][0] = Low[1];
- Values[3][0] = Close[1];
- //Values[4][0] = Open[1] - (Close[1]);
- Values[4][0] = Values[0][0] - (Values[3][0]);
- }
- else
- {
- Values[0][0] = Open[1];
- Values[1][0] = High[1];
- Values[2][0] = Low[1];
- Values[3][0] = Close[1];
- //Values[4][0] = Open[0] - (Close[0]);
- Values[4][0] = Values[0][0] - (Values[3][0]);
- }
- Print(String.Format("CurrentBar index: {0} Time[0]: {1} Open[0]: {2}, High[0]: {3} Low[0]: {4}, Close[0]: {5} State: {6} Calculate: {7}",
- CurrentBar, Time[0], Open[0], High[0], Low[0], Close[0], State, Calculate));
- }
- #region Properties
- [Browsable(false)]
- [XmlIgnore]
- public Series<double> PriorOpen
- {
- get { return Values[0]; }
- }
- [Browsable(false)]
- [XmlIgnore]
- public Series<double> PriorHigh
- {
- get { return Values[1]; }
- }
- [Browsable(false)]
- [XmlIgnore]
- public Series<double> PriorLow
- {
- get { return Values[2]; }
- }
- [Browsable(false)]
- [XmlIgnore]
- public Series<double> PriorClose
- {
- get { return Values[3]; }
- }
- [Browsable(false)]
- [XmlIgnore]
- public Series<double> OpenMinusClose
- {
- get { return Values[4]; }
- }
- #endregion
- }
- }
- #region NinjaScript generated code. Neither change nor remove.
- namespace NinjaTrader.NinjaScript.Indicators
- {
- public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
- {
- private myDailyBarsPriorOHLC[] cachemyDailyBarsPriorOHLC;
- public myDailyBarsPriorOHLC myDailyBarsPriorOHLC()
- {
- return myDailyBarsPriorOHLC(Input);
- }
- public myDailyBarsPriorOHLC myDailyBarsPriorOHLC(ISeries<double> input)
- {
- if (cachemyDailyBarsPriorOHLC != null)
- for (int idx = 0; idx < cachemyDailyBarsPriorOHLC.Length; idx++)
- if (cachemyDailyBarsPriorOHLC[idx] != null && cachemyDailyBarsPriorOHLC[idx].EqualsInput(input))
- return cachemyDailyBarsPriorOHLC[idx];
- return CacheIndicator<myDailyBarsPriorOHLC>(new myDailyBarsPriorOHLC(), input, ref cachemyDailyBarsPriorOHLC);
- }
- }
- }
- namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
- {
- public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
- {
- public Indicators.myDailyBarsPriorOHLC myDailyBarsPriorOHLC()
- {
- return indicator.myDailyBarsPriorOHLC(Input);
- }
- public Indicators.myDailyBarsPriorOHLC myDailyBarsPriorOHLC(ISeries<double> input )
- {
- return indicator.myDailyBarsPriorOHLC(input);
- }
- }
- }
- namespace NinjaTrader.NinjaScript.Strategies
- {
- public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
- {
- public Indicators.myDailyBarsPriorOHLC myDailyBarsPriorOHLC()
- {
- return indicator.myDailyBarsPriorOHLC(Input);
- }
- public Indicators.myDailyBarsPriorOHLC myDailyBarsPriorOHLC(ISeries<double> input )
- {
- return indicator.myDailyBarsPriorOHLC(input);
- }
- }
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement