Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddChartIndicator(EMA1);
- #region Using declarations
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Xml.Serialization;
- using NinjaTrader.Cbi;
- using NinjaTrader.Gui;
- using NinjaTrader.Gui.Chart;
- using NinjaTrader.Gui.SuperDom;
- using NinjaTrader.Gui.Tools;
- using NinjaTrader.Data;
- using NinjaTrader.NinjaScript;
- using NinjaTrader.Core.FloatingPoint;
- using NinjaTrader.NinjaScript.Indicators;
- using NinjaTrader.NinjaScript.DrawingTools;
- #endregion
- //This namespace holds Strategies in this folder and is required. Do not change it.
- namespace NinjaTrader.NinjaScript.Strategies
- {
- public class FVGema : Strategy
- {
- private EMA EMA1;
- private PriceLine PriceLine1;
- protected override void OnStateChange()
- {
- if (State == State.SetDefaults)
- {
- Description = @"This is intended to be initiated on an FVG out of the cloud";
- Name = "FVGema";
- Calculate = Calculate.OnPriceChange;
- EntriesPerDirection = 2;
- EntryHandling = EntryHandling.UniqueEntries;
- IsExitOnSessionCloseStrategy = true;
- ExitOnSessionCloseSeconds = 30;
- IsFillLimitOnTouch = false;
- MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
- OrderFillResolution = OrderFillResolution.Standard;
- Slippage = 0;
- StartBehavior = StartBehavior.WaitUntilFlat;
- TimeInForce = TimeInForce.Gtc;
- TraceOrders = true;
- RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
- StopTargetHandling = StopTargetHandling.PerEntryExecution;
- BarsRequiredToTrade = 5;
- // Disable this property for performance gains in Strategy Analyzer optimizations
- // See the Help Guide for additional information
- IsInstantiatedOnEachOptimizationIteration = true;
- }
- else if (State == State.Configure)
- {
- AddDataSeries("MES 09-23", Data.BarsPeriodType.Minute, 5, Data.MarketDataType.Last);
- }
- else if (State == State.DataLoaded)
- {
- EMA1 = EMA(Close, 5);
- PriceLine1 = PriceLine(Close, false, false, true, 100, 100, 100);
- EMA1.Plots[0].Brush = Brushes.YellowGreen;
- AddChartIndicator(EMA1);
- AddChartIndicator(PriceLine1);
- }
- }
- protected override void OnBarUpdate()
- {
- if (BarsInProgress != 0)
- return;
- if (CurrentBars[0] < 1)
- return;
- // Set 1
- if (EMA1[0] >= PriceLine1[0])
- {
- EnterLong(Convert.ToInt32(DefaultQuantity), @"EMAlong");
- Print(@"5ema Ask price");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement