Advertisement
Guest User

Untitled

a guest
Sep 8th, 2023
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. AddChartIndicator(EMA1);
  2.  
  3. #region Using declarations
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.ComponentModel.DataAnnotations;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Xml.Serialization;
  15. using NinjaTrader.Cbi;
  16. using NinjaTrader.Gui;
  17. using NinjaTrader.Gui.Chart;
  18. using NinjaTrader.Gui.SuperDom;
  19. using NinjaTrader.Gui.Tools;
  20. using NinjaTrader.Data;
  21. using NinjaTrader.NinjaScript;
  22. using NinjaTrader.Core.FloatingPoint;
  23. using NinjaTrader.NinjaScript.Indicators;
  24. using NinjaTrader.NinjaScript.DrawingTools;
  25. #endregion
  26.  
  27. //This namespace holds Strategies in this folder and is required. Do not change it.
  28. namespace NinjaTrader.NinjaScript.Strategies
  29. {
  30. public class FVGema : Strategy
  31. {
  32. private EMA EMA1;
  33. private PriceLine PriceLine1;
  34.  
  35. protected override void OnStateChange()
  36. {
  37. if (State == State.SetDefaults)
  38. {
  39. Description = @"This is intended to be initiated on an FVG out of the cloud";
  40. Name = "FVGema";
  41. Calculate = Calculate.OnPriceChange;
  42. EntriesPerDirection = 2;
  43. EntryHandling = EntryHandling.UniqueEntries;
  44. IsExitOnSessionCloseStrategy = true;
  45. ExitOnSessionCloseSeconds = 30;
  46. IsFillLimitOnTouch = false;
  47. MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
  48. OrderFillResolution = OrderFillResolution.Standard;
  49. Slippage = 0;
  50. StartBehavior = StartBehavior.WaitUntilFlat;
  51. TimeInForce = TimeInForce.Gtc;
  52. TraceOrders = true;
  53. RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
  54. StopTargetHandling = StopTargetHandling.PerEntryExecution;
  55. BarsRequiredToTrade = 5;
  56. // Disable this property for performance gains in Strategy Analyzer optimizations
  57. // See the Help Guide for additional information
  58. IsInstantiatedOnEachOptimizationIteration = true;
  59. }
  60. else if (State == State.Configure)
  61. {
  62. AddDataSeries("MES 09-23", Data.BarsPeriodType.Minute, 5, Data.MarketDataType.Last);
  63. }
  64. else if (State == State.DataLoaded)
  65. {
  66. EMA1 = EMA(Close, 5);
  67. PriceLine1 = PriceLine(Close, false, false, true, 100, 100, 100);
  68. EMA1.Plots[0].Brush = Brushes.YellowGreen;
  69. AddChartIndicator(EMA1);
  70. AddChartIndicator(PriceLine1);
  71. }
  72. }
  73.  
  74. protected override void OnBarUpdate()
  75. {
  76. if (BarsInProgress != 0)
  77. return;
  78.  
  79. if (CurrentBars[0] < 1)
  80. return;
  81.  
  82. // Set 1
  83. if (EMA1[0] >= PriceLine1[0])
  84. {
  85. EnterLong(Convert.ToInt32(DefaultQuantity), @"EMAlong");
  86. Print(@"5ema Ask price");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement