Advertisement
Guest User

Untitled

a guest
Jul 20th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.29 KB | None | 0 0
  1. #region Using declarations
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.ComponentModel.DataAnnotations;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Xml.Serialization;
  13. using NinjaTrader.Cbi;
  14. using NinjaTrader.Gui;
  15. using NinjaTrader.Gui.Chart;
  16. using NinjaTrader.Gui.SuperDom;
  17. using NinjaTrader.Gui.Tools;
  18. using NinjaTrader.Data;
  19. using NinjaTrader.NinjaScript;
  20. using NinjaTrader.Core.FloatingPoint;
  21. using NinjaTrader.NinjaScript.DrawingTools;
  22. #endregion
  23.  
  24. //This namespace holds Indicators in this folder and is required. Do not change it.
  25. namespace NinjaTrader.NinjaScript.Indicators
  26. {
  27.     public class HighMinusOpen1 : Indicator
  28.     {
  29.         private PriorDayOHLC PriorDayOHLC1;
  30.        
  31.         protected override void OnStateChange()
  32.         {
  33.             if (State == State.SetDefaults)
  34.             {
  35.                 Description                                 = @"Enter the description for your new custom Indicator here.";
  36.                 Name                                        = "HighMinusOpen1";
  37.                 Calculate                                   = Calculate.OnBarClose;
  38.                 IsOverlay                                   = false;
  39.                 DisplayInDataBox                            = true;
  40.                 DrawOnPricePanel                            = true;
  41.                 DrawHorizontalGridLines                     = true;
  42.                 DrawVerticalGridLines                       = true;
  43.                 PaintPriceMarkers                           = true;
  44.                 ScaleJustification                          = NinjaTrader.Gui.Chart.ScaleJustification.Right;
  45.                 //Disable this property if your indicator requires custom values that cumulate with each new market data event.
  46.                 //See Help Guide for additional information.
  47.                 IsSuspendedWhileInactive                    = true;
  48.                 AddPlot(Brushes.White, "PriorOpen");
  49.                 AddPlot(Brushes.Lime, "PriorHigh");
  50.                 AddPlot(Brushes.Red, "PriorLow");
  51.                 AddPlot(Brushes.Pink, "PriorClose");
  52.                 AddPlot(Brushes.Cyan, "OpenMinusClose");
  53.             }
  54.             else if (State == State.Configure)
  55.             {
  56.             }
  57.             else if (State == State.DataLoaded)
  58.             {              
  59.                 PriorDayOHLC1 = PriorDayOHLC(Close);
  60.             }
  61.         }
  62.  
  63.         protected override void OnBarUpdate()
  64.         {
  65.             if (BarsInProgress != 0)
  66.                 return;
  67.  
  68.             if (CurrentBars[0] < 1)
  69.                 return;
  70.  
  71.              // Set 1
  72.             Print(Time[0] +
  73.                   " " + "Open Value: " + Convert.ToString(PriorDayOHLC1.PriorOpen[0]) +
  74.                   " " + "High Value: " +  Convert.ToString(PriorDayOHLC1.PriorHigh[0]) +
  75.                   " " + "Low Value: " +  Convert.ToString(PriorDayOHLC1.PriorLow[0])  +
  76.                   " " + "Close Value: " +  Convert.ToString(PriorDayOHLC1.PriorClose[0]));
  77.             {
  78.             }
  79.            
  80.  
  81.             if (Times[0][0].DayOfWeek != DayOfWeek.Monday)
  82.             {
  83.                 Values[0][0] = PriorDayOHLC1.PriorOpen[0];
  84.                 Values[1][0] = PriorDayOHLC1.PriorHigh[0];
  85.                 Values[2][0] = PriorDayOHLC1.PriorLow[0];
  86.                 Values[3][0] = PriorDayOHLC1.PriorClose[0];
  87.                
  88.                 //Values[4][0] = PriorDayOHLC1.PriorOpen[0] - (PriorDayOHLC1.PriorClose[0]);
  89.                 Values[4][0] = Values[0][0] - (Values[3][0]);
  90.             }
  91.             else
  92.             {
  93.                 Values[0][0] = PriorDayOHLC1.PriorOpen[1];
  94.                 Values[1][0] = PriorDayOHLC1.PriorHigh[1];
  95.                 Values[2][0] = PriorDayOHLC1.PriorLow[1];
  96.                 Values[3][0] = PriorDayOHLC1.PriorClose[1];
  97.                
  98.                 //Values[4][0] = PriorDayOHLC1.PriorOpen[0] - (PriorDayOHLC1.PriorClose[0]);
  99.                 Values[4][0] = Values[0][0] - (Values[3][0]);
  100.             }
  101.            
  102.         }
  103.         #region Properties
  104.         [Browsable(false)]
  105.         [XmlIgnore]
  106.         public Series<double> PriorOpen
  107.         {
  108.         get { return Values[0]; }
  109.         }
  110.        
  111.         [Browsable(false)]
  112.         [XmlIgnore]
  113.         public Series<double> PriorHigh
  114.         {
  115.         get { return Values[1]; }
  116.         }
  117.        
  118.         [Browsable(false)]
  119.         [XmlIgnore]
  120.         public Series<double> PriorLow
  121.         {
  122.         get { return Values[2]; }
  123.         }
  124.        
  125.         [Browsable(false)]
  126.         [XmlIgnore]
  127.         public Series<double> PriorClose
  128.         {
  129.         get { return Values[3]; }
  130.         }
  131.        
  132.         [Browsable(false)]
  133.         [XmlIgnore]
  134.         public Series<double> OpenMinusClose
  135.         {
  136.         get { return Values[4]; }
  137.         }
  138.         #endregion
  139.     }
  140. }
  141.  
  142. #region NinjaScript generated code. Neither change nor remove.
  143.  
  144. namespace NinjaTrader.NinjaScript.Indicators
  145. {
  146.     public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
  147.     {
  148.         private HighMinusOpen1[] cacheHighMinusOpen1;
  149.         public HighMinusOpen1 HighMinusOpen1()
  150.         {
  151.             return HighMinusOpen1(Input);
  152.         }
  153.  
  154.         public HighMinusOpen1 HighMinusOpen1(ISeries<double> input)
  155.         {
  156.             if (cacheHighMinusOpen1 != null)
  157.                 for (int idx = 0; idx < cacheHighMinusOpen1.Length; idx++)
  158.                     if (cacheHighMinusOpen1[idx] != null &&  cacheHighMinusOpen1[idx].EqualsInput(input))
  159.                         return cacheHighMinusOpen1[idx];
  160.             return CacheIndicator<HighMinusOpen1>(new HighMinusOpen1(), input, ref cacheHighMinusOpen1);
  161.         }
  162.     }
  163. }
  164.  
  165. namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
  166. {
  167.     public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
  168.     {
  169.         public Indicators.HighMinusOpen1 HighMinusOpen1()
  170.         {
  171.             return indicator.HighMinusOpen1(Input);
  172.         }
  173.  
  174.         public Indicators.HighMinusOpen1 HighMinusOpen1(ISeries<double> input )
  175.         {
  176.             return indicator.HighMinusOpen1(input);
  177.         }
  178.     }
  179. }
  180.  
  181. namespace NinjaTrader.NinjaScript.Strategies
  182. {
  183.     public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
  184.     {
  185.         public Indicators.HighMinusOpen1 HighMinusOpen1()
  186.         {
  187.             return indicator.HighMinusOpen1(Input);
  188.         }
  189.  
  190.         public Indicators.HighMinusOpen1 HighMinusOpen1(ISeries<double> input )
  191.         {
  192.             return indicator.HighMinusOpen1(input);
  193.         }
  194.     }
  195. }
  196.  
  197. #endregion
  198.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement