Advertisement
Guest User

Untitled

a guest
May 7th, 2021
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 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.Indicators;
  22. using NinjaTrader.NinjaScript.DrawingTools;
  23. #endregion
  24.  
  25. //This namespace holds Strategies in this folder and is required. Do not change it.
  26. namespace NinjaTrader.NinjaScript.Strategies
  27. {
  28. public class closelineUnlocked : Strategy
  29. {
  30. protected override void OnStateChange()
  31. {
  32. if (State == State.SetDefaults)
  33. {
  34. Description = @"Enter the description for your new custom Strategy here.";
  35. Name = "closelineUnlocked";
  36. Calculate = Calculate.OnBarClose;
  37. EntriesPerDirection = 1;
  38. EntryHandling = EntryHandling.AllEntries;
  39. IsExitOnSessionCloseStrategy = true;
  40. ExitOnSessionCloseSeconds = 30;
  41. IsFillLimitOnTouch = false;
  42. MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
  43. OrderFillResolution = OrderFillResolution.Standard;
  44. Slippage = 0;
  45. StartBehavior = StartBehavior.WaitUntilFlat;
  46. TimeInForce = TimeInForce.Gtc;
  47. TraceOrders = false;
  48. RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
  49. StopTargetHandling = StopTargetHandling.PerEntryExecution;
  50. BarsRequiredToTrade = 20;
  51. // Disable this property for performance gains in Strategy Analyzer optimizations
  52. // See the Help Guide for additional information
  53. IsInstantiatedOnEachOptimizationIteration = true;
  54. }
  55. else if (State == State.Configure)
  56. {
  57. }
  58. else if (State == State.DataLoaded)
  59. {
  60. Close.Plots[0].Brush = Brush.Red;
  61. AddChartIndicator(Close);
  62. }
  63. }
  64.  
  65. protected override void OnBarUpdate()
  66. {
  67. if (BarsInProgress != 0)
  68. return;
  69.  
  70. if (CurrentBars[0] < 1)
  71. return;
  72.  
  73. // Set 1
  74. if (Close[0] > Close[1])
  75. {
  76. PlaySound(@"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert1.wav");
  77. }
  78.  
  79. // Set 2
  80. if (Close[0] < Close[1])
  81. {
  82. PlaySound(@"C:\Program Files (x86)\NinjaTrader 8\sounds\Alert2.wav");
  83. }
  84.  
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement