Advertisement
Guest User

Untitled

a guest
Sep 9th, 2019
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1.  
  2.  
  3. //This namespace holds Strategies in this folder and is required. Do not change it.
  4. namespace NinjaTrader.NinjaScript.Strategies
  5. {
  6. public class MyCustomStrategy : Strategy
  7. {
  8. private NinjaTrader.NinjaScript.Indicators.LizardIndicators.amaCurrentDayVWAP amaCurrentDayVWAP1;
  9. private NinjaTrader.NinjaScript.Indicators.LizardIndicators.amaCurrentDayVWAP amaCurrentDayVWAP2;
  10.  
  11. protected override void OnStateChange()
  12. {
  13. if (State == State.SetDefaults)
  14. {
  15. Description = @"Enter the description for your new custom Strategy here.";
  16. Name = "MyCustomStrategy";
  17. Calculate = Calculate.OnEachTick;
  18. EntriesPerDirection = 3;
  19. EntryHandling = EntryHandling.AllEntries;
  20. IsExitOnSessionCloseStrategy = false;
  21. ExitOnSessionCloseSeconds = 300;
  22. IsFillLimitOnTouch = true;
  23. MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
  24. OrderFillResolution = OrderFillResolution.Standard;
  25. Slippage = 0;
  26. StartBehavior = StartBehavior.WaitUntilFlat;
  27. TimeInForce = TimeInForce.Day;
  28. TraceOrders = true;
  29. RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
  30. StopTargetHandling = StopTargetHandling.ByStrategyPosition;
  31. BarsRequiredToTrade = 0;
  32. // Disable this property for performance gains in Strategy Analyzer optimizations
  33. // See the Help Guide for additional information
  34. IsInstantiatedOnEachOptimizationIteration = true;
  35. }
  36. else if (State == State.Configure)
  37. {
  38. AddDataSeries("FDAX 09-19", Data.BarsPeriodType.Minute, 5, Data.MarketDataType.Last);
  39. }
  40. else if (State == State.DataLoaded)
  41. {
  42. amaCurrentDayVWAP1 = amaCurrentDayVWAP(Close, amaSessionTypeVWAPD.Full_Session, amaBandTypeVWAPD.Standard_Deviation, amaTimeZonesVWAPD.Chart_Time, @"08:30", @"15:15", 1, 2, 3, 1, 2, 3);
  43. amaCurrentDayVWAP2 = amaCurrentDayVWAP(Close, amaSessionTypeVWAPD.Full_Session, amaBandTypeVWAPD.Standard_Deviation, amaTimeZonesVWAPD.Exchange_Time, @"08:30", @"15:15", 1, 2, 3, 1, 2, 3);
  44. amaCurrentDayVWAP1.Plots[0].Brush = Brushes.Gray;
  45. amaCurrentDayVWAP1.Plots[1].Brush = Brushes.Gray;
  46. amaCurrentDayVWAP1.Plots[2].Brush = Brushes.Gray;
  47. amaCurrentDayVWAP1.Plots[3].Brush = Brushes.Gray;
  48. amaCurrentDayVWAP1.Plots[4].Brush = Brushes.Gray;
  49. amaCurrentDayVWAP1.Plots[5].Brush = Brushes.Gray;
  50. amaCurrentDayVWAP1.Plots[6].Brush = Brushes.Gray;
  51. AddChartIndicator(amaCurrentDayVWAP1);
  52. SetStopLoss(CalculationMode.Ticks, 100);
  53. }
  54. }
  55.  
  56. protected override void OnBarUpdate()
  57. {
  58. if (BarsInProgress != 0)
  59. return;
  60.  
  61. if (CurrentBars[0] < 20)
  62. return;
  63.  
  64. // Set 1
  65. if ((Close[0] <= amaCurrentDayVWAP1.LowerBand3[20])
  66. && (Times[0][0].TimeOfDay >= new TimeSpan(10, 0, 0))
  67. && (Times[0][0].TimeOfDay <= new TimeSpan(17, 30, 0)))
  68. {
  69. EnterLong(Convert.ToInt32(DefaultQuantity), "");
  70. }
  71.  
  72. // Set 2
  73. if (High[0] >= amaCurrentDayVWAP2.SessionVWAP[0])
  74. {
  75. ExitLong(Convert.ToInt32(DefaultQuantity), "", @"");
  76. }
  77.  
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement