Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace NinjaTrader.NinjaScript.Indicators
- {
- public class Diff : Indicator
- {
- private PriorDayOHLC PriorDayOHLC1;
- private PriorDayOHLC PriorDayOHLC2;
- protected override void OnStateChange()
- {
- if (State == State.SetDefaults)
- {
- Description = @"Enter the description for your new custom Indicator here.";
- Name = "Diff";
- Calculate = Calculate.OnBarClose;
- 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, "Diff");
- }
- else if (State == State.Configure)
- {
- }
- }
- protected override void OnBarUpdate()
- {
- if (CurrentBars[0] <= 55)
- return;
- if (BarsInProgress != 0)
- return;
- if (PriorDayOHLC1.PriorHigh[1] - PriorDayOHLC2.PriorOpen[1] == 0) // check for potential divide by zero
- {
- return; // don't plot the value
- }
- double PDHigh = PriorDayOHLC1.PriorHigh[1];
- double PDOpen = PriorDayOHLC2.PriorOpen[1];
- Value[0] = PDHigh - PDOpen;
- }
- #region Properties
- [Browsable(false)]
- [XmlIgnore]
- public Series<double> Diff
- {
- get { return Values[0]; }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement