Advertisement
Guest User

Untitled

a guest
Jul 16th, 2021
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. namespace NinjaTrader.NinjaScript.Strategies
  2. {
  3.     public class HighMinusOpen : Strategy
  4.     {
  5.         private PriorDayOHLC PriorDayOHLC1;
  6.         private PriorDayOHLC PriorDayOHLC2;
  7.  
  8.         protected override void OnStateChange()
  9.         {
  10.             if (State == State.SetDefaults)
  11.             {
  12.                 Description                                 = @"Enter the description for your new custom Strategy here.";
  13.                 Name                                        = "HighMinusOpen";
  14.                 Calculate                                   = Calculate.OnBarClose;
  15.                 EntriesPerDirection                         = 1;
  16.                 EntryHandling                               = EntryHandling.AllEntries;
  17.                 IsExitOnSessionCloseStrategy                = true;
  18.                 ExitOnSessionCloseSeconds                   = 30;
  19.                 IsFillLimitOnTouch                          = false;
  20.                 MaximumBarsLookBack                         = MaximumBarsLookBack.TwoHundredFiftySix;
  21.                 OrderFillResolution                         = OrderFillResolution.Standard;
  22.                 Slippage                                    = 0;
  23.                 StartBehavior                               = StartBehavior.WaitUntilFlat;
  24.                 TimeInForce                                 = TimeInForce.Gtc;
  25.                 TraceOrders                                 = false;
  26.                 RealtimeErrorHandling                       = RealtimeErrorHandling.StopCancelClose;
  27.                 StopTargetHandling                          = StopTargetHandling.PerEntryExecution;
  28.                 BarsRequiredToTrade                         = 20;
  29.                 // Disable this property for performance gains in Strategy Analyzer optimizations
  30.                 // See the Help Guide for additional information
  31.                 IsInstantiatedOnEachOptimizationIteration   = true;
  32.             }
  33.             else if (State == State.Configure)
  34.             {
  35.             }
  36.             else if (State == State.DataLoaded)
  37.             {              
  38.                 PriorDayOHLC1               = PriorDayOHLC(High);
  39.                 PriorDayOHLC2               = PriorDayOHLC(Open);
  40.                 PriorDayOHLC1.Plots[0].Brush = Brushes.SteelBlue;
  41.                 PriorDayOHLC1.Plots[1].Brush = Brushes.DarkCyan;
  42.                 PriorDayOHLC1.Plots[2].Brush = Brushes.Crimson;
  43.                 PriorDayOHLC1.Plots[3].Brush = Brushes.SlateBlue;
  44.                 PriorDayOHLC2.Plots[0].Brush = Brushes.SteelBlue;
  45.                 PriorDayOHLC2.Plots[1].Brush = Brushes.DarkCyan;
  46.                 PriorDayOHLC2.Plots[2].Brush = Brushes.Crimson;
  47.                 PriorDayOHLC2.Plots[3].Brush = Brushes.SlateBlue;
  48.                 AddChartIndicator(PriorDayOHLC1);
  49.                 AddChartIndicator(PriorDayOHLC2);
  50.             }
  51.         }
  52.  
  53.         protected override void OnBarUpdate()
  54.         {
  55.             if (BarsInProgress != 0)
  56.                 return;
  57.  
  58.             if (CurrentBars[0] < 1)
  59.                 return;
  60.  
  61.              // Set 1
  62.             if (PriorDayOHLC1.PriorOpen[1] < PriorDayOHLC2.PriorOpen[1])
  63.             {
  64.             }
  65.            
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement