Can you fix this code I have 2 errors on it 
MyCustomStrategy.cs	'InstitutionalMesPullbackV1.OnExecutionUpdate(Execution string double int MarketPosition string DateTime ErrorCode string)': no suitable method found to override	CS0115	87	33
MyCustomStrategy.cs	'SystemPerformance' does not contain a definition for 'RealtimePerformance' and no accessible extension method 'RealtimePerformance' accepting a first argument of type 'SystemPerformance' could be found (are you missing a using directive or an assembly reference?)	CS1061	111	46



#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

// Ensure Namespace is NinjaTrader.NinjaScript.Strategies
namespace NinjaTrader.NinjaScript.Strategies
{
	// Ensure Class name matches the filename (InstitutionalMesPullbackV1.cs)
	public class InstitutionalMesPullbackV1 : Strategy
	{
		#region Variables & Parameters (Unchanged from v1.9)
		// --- INDICATORS ---
		private EMA ema20; private EMA ema50; private Stochastics stochastics; private ATR atr; private ADX adx;
		// --- STATE ---
		private double entryAtrValue; private bool isPT1Hit; private bool isAtBreakeven; private int tradesToday;
		private string entrySignalName = "LE"; private bool pauseTradingPostProfit; private int barNumberOfLastEntry = -1; private int barNumberOfLastExit = -1;
		// --- PARAMETERS (Defaults below, check values) ---
		[NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="EMA Fast Period", GroupName="Parameters", Order=1)] public int EmaFastPeriod { get; set; }
		[NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="EMA Slow Period", GroupName="Parameters", Order=2)] public int EmaSlowPeriod { get; set; }
		[NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="Stochastic K Period", GroupName="Parameters", Order=3)] public int StochKPeriod { get; set; }
		[NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="Stochastic D Period", GroupName="Parameters", Order=4)] public int StochDPeriod { get; set; }
		[NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="Stochastic Smooth", GroupName="Parameters", Order=5)] public int StochSmoothPeriod { get; set; }
		[NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="ATR Period", GroupName="Parameters", Order=6)] public int AtrPeriod { get; set; }
		[NinjaScriptProperty] [Range(0.1, double.MaxValue)] [Display(Name="ATR SL Multiplier", GroupName="Parameters", Order=7)] public double AtrSLMultiplier { get; set; }
		[NinjaScriptProperty] [Range(0.1, double.MaxValue)] [Display(Name="ATR PT1 Multiplier", GroupName="Parameters", Order=8)] public double AtrPT1Multiplier { get; set; }
		[NinjaScriptProperty] [Range(0.1, double.MaxValue)] [Display(Name="ATR PT2 Multiplier", GroupName="Parameters", Order=9)] public double AtrPT2Multiplier { get; set; }
		[NinjaScriptProperty] [Range(0.1, double.MaxValue)] [Display(Name="ATR PT3 Multiplier", GroupName="Parameters", Order=10)] public double AtrPT3Multiplier { get; set; }
		[NinjaScriptProperty] [Range(0.1, double.MaxValue)] [Display(Name="ATR Trail Multiplier", GroupName="Parameters", Order=11)] public double AtrTrailMultiplier { get; set; }
		[NinjaScriptProperty] [Range(1, 100)] [Display(Name="Contracts To Trade", GroupName="Parameters", Order=12)] public int ContractsToTrade { get; set; }
		[NinjaScriptProperty] [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")] [Display(Name = "Trade Start Time", GroupName = "Parameters", Order = 13)] public DateTime StartTime { get; set; }
		[NinjaScriptProperty] [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")] [Display(Name = "Trade End Time", GroupName = "Parameters", Order = 14)] public DateTime EndTime { get; set; }
		[NinjaScriptProperty] [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")] [Display(Name = "Stop Trading End Time", GroupName = "Parameters", Order = 15)] public DateTime FlattenTime { get; set; }
		[NinjaScriptProperty] [Range(0, int.MaxValue)] [Display(Name="Max Daily Trades", GroupName="Safety Filters", Order=16)] public int MaxDailyTrades { get; set; }
		[NinjaScriptProperty] [Range(0, double.MaxValue)] [Display(Name="Max Daily Loss (Abs)", GroupName="Safety Filters", Order=17)] public double MaxDailyLoss { get; set; }
		[NinjaScriptProperty] [Display(Name="Enable Chop Filter", GroupName="Safety Filters", Order=18)] public bool EnableChopFilter { get; set; }
		[NinjaScriptProperty] [Range(1, 100)] [Display(Name="ADX Period (Chop)", GroupName="Safety Filters", Order=19)] public int ChopAdxPeriod { get; set; }
		[NinjaScriptProperty] [Range(0, 100)] [Display(Name="ADX Threshold (Chop)", GroupName="Safety Filters", Order=20)] public double ChopAdxThreshold { get; set; }
		[NinjaScriptProperty] [Range(0.0, 10.0)] [Display(Name="EMA Separation (Chop)", GroupName="Safety Filters", Order=21)] public double ChopEmaSeparationAtrRatio { get; set; }
		[NinjaScriptProperty] [Display(Name="Pause After PT Hit", GroupName="Safety Filters", Order=22)] public bool PauseAfterProfit { get; set; }
		[NinjaScriptProperty] [Range(0, 60)] [Display(Name="Pause Bars After PT", GroupName="Safety Filters", Order=23)] public int PauseBars { get; set; }
		#endregion

		protected override void OnStateChange() { // v1.10
			if (State == State.SetDefaults) { /* Defaults Section */ Description = @"MES Trend Pullback strategy v1.10"; Name="InstitutionalMesPullbackV1"; Calculate=Calculate.OnBarClose; EntriesPerDirection=1; EntryHandling=EntryHandling.AllEntries; IsExitOnSessionCloseStrategy=true; ExitOnSessionCloseSeconds=30; IsFillLimitOnTouch=false; MaximumBarsLookBack=MaximumBarsLookBack.TwoHundredFiftySix; OrderFillResolution=OrderFillResolution.Standard; Slippage=2; StartBehavior=StartBehavior.WaitUntilFlat; TimeInForce=TimeInForce.Gtc; TraceOrders=false; RealtimeErrorHandling=RealtimeErrorHandling.StopCancelClose; StopTargetHandling=StopTargetHandling.PerEntryExecution; BarsRequiredToTrade=50; EmaFastPeriod=20; EmaSlowPeriod=50; StochKPeriod=14; StochDPeriod=3; StochSmoothPeriod=3; AtrPeriod=14; AtrSLMultiplier=1.5; AtrPT1Multiplier=1.5; AtrPT2Multiplier=3.0; AtrPT3Multiplier=4.5; AtrTrailMultiplier=1.5; ContractsToTrade=1; StartTime=DateTime.Parse("08:35",System.Globalization.CultureInfo.InvariantCulture); EndTime=DateTime.Parse("14:45",System.Globalization.CultureInfo.InvariantCulture); FlattenTime=DateTime.Parse("14:58",System.Globalization.CultureInfo.InvariantCulture); MaxDailyTrades=10; MaxDailyLoss=500; EnableChopFilter=true; ChopAdxPeriod=14; ChopAdxThreshold=20; ChopEmaSeparationAtrRatio=0.1; PauseAfterProfit=true; PauseBars=3; }
			else if (State == State.Configure) { /* Config */ }
			else if (State == State.DataLoaded) { /* Init Indicators */ ema20=EMA(EmaFastPeriod); ema50=EMA(EmaSlowPeriod); stochastics=Stochastics(StochDPeriod, StochKPeriod, StochSmoothPeriod); atr=ATR(AtrPeriod); if(EnableChopFilter)adx=ADX(ChopAdxPeriod); AddChartIndicator(ema20);AddChartIndicator(ema50);AddChartIndicator(stochastics);AddChartIndicator(atr);if(EnableChopFilter&&adx!=null)AddChartIndicator(adx); tradesToday=0;}
		}

		// Main logic loop
		protected override void OnBarUpdate() {
			if(CurrentBar<BarsRequiredToTrade || BarsInProgress!=0)return; if(IsFirstTickOfBar && Bars.IsFirstBarOfSession)ResetDailyCounters();
			if(IsMaxLossHitToday()){if(Position.MarketPosition!=MarketPosition.Flat)FlattenPosition("Max Loss"); return;} if(IsMaxTradesHitToday())return; // Safety checks
			DateTime exchTime = Time[0]; if(IsFlattenTime(exchTime)) return; // EOD Check
			if(Position.MarketPosition==MarketPosition.Long) ManageLongPosition(); // Manage open longs
			if(ShouldCheckForEntry(exchTime)) CheckLongEntrySignal(); // Look for new longs if flat
		}

		// MUST be defined inside the class
		#region Entry & Management Logic (Definitions Restored v1.9)
		private void CheckLongEntrySignal() { /* Full code as in v1.9 */ if(atr==null||ema20==null||ema50==null||stochastics==null||(EnableChopFilter&&adx==null)) return; double e20=ema20[0], e50=ema50[0], atrV=atr[0]; double sK=stochastics.K[0], sD=stochastics.D[0]; if (EnableChopFilter && IsChoppy(atrV)) return; bool isUptrend = e20 > e50 && Close[0] > e50; if (!isUptrend) return; bool pullbackOccurred = Low[1] <= ema20[1] || Low[0] <= e20; if (!pullbackOccurred) return; bool stochBuySignal = (CrossAbove(stochastics.K, stochastics.D,1)&&stochastics.K[1]<35) || (sK>sD && sK<60 && sK>stochastics.K[1]); if (!stochBuySignal) return; bool closedAboveEMA20 = Close[0] > e20; if(closedAboveEMA20){entryAtrValue=atrV;if(entryAtrValue<TickSize){Log("ATR Low.",LogLevel.Warning);entryAtrValue=TickSize*4;} double entryP=Close[0]; double stopP=Instrument.MasterInstrument.RoundToTickSize(entryP-(AtrSLMultiplier*entryAtrValue)); double targetP=Instrument.MasterInstrument.RoundToTickSize(entryP+(AtrPT1Multiplier*entryAtrValue)); LogEntrySignal(entryP,stopP,targetP); EnterLong(ContractsToTrade,entrySignalName); ResetTradeFlags();}}
		private void ManageLongPosition() { /* Full code as in v1.9 */ if (Position.MarketPosition!=MarketPosition.Long||Position.Quantity==0)return; EnsureEntryAtrSet(); double pt1P=CalculateTargetPrice(AtrPT1Multiplier); if(!isPT1Hit && High[0]>=pt1P) isPT1Hit=true; }
		#endregion

		#region Event Handlers

		// STANDARD OnExecutionUpdate SIGNATURE - Try this definitive version again (v1.10)
        protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time, ErrorCode error, string nativeError)
		{
			// Entry Fill Check
			if (execution.Order != null && execution.Order.Name == entrySignalName && execution.Order.OrderState == OrderState.Filled && marketPosition == MarketPosition.Long) {
				HandleEntryFill(execution, price);
			}
			// Exit Fill Check
			if (execution != null && execution.IsExit && execution.Order != null && execution.Order.OrderState == OrderState.Filled) {
				HandleExitFill(execution, marketPosition);
			}
		}

		// OnOrderUpdate (Unchanged)
		protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError) { if(TraceOrders){LogOrderUpdate(order, orderState, averageFillPrice);} CheckUnexpectedStopCancel(order, orderState); }
		#endregion


		// Ensure ALL Helpers are inside the class braces {}
		#region Helper Methods

		private void ResetDailyCounters() { tradesToday=0; pauseTradingPostProfit=false; barNumberOfLastExit=-1; Log("Counters Reset.", LogLevel.Information); }

		// **CORRECTED** BACK to SystemPerformance based on persistent error CS0103 (v1.10)
		private bool IsMaxLossHitToday() {
			if (MaxDailyLoss > 0 && SystemPerformance.RealtimePerformance.CurrentSession.ProfitCurrency <= -Math.Abs(MaxDailyLoss)) {
				return true;
			}
			return false;
		}

		private bool IsMaxTradesHitToday() { if(MaxDailyTrades > 0 && tradesToday >= MaxDailyTrades && Position.MarketPosition == MarketPosition.Flat){ return true; } return false; }
		private bool IsFlattenTime(DateTime cTime) { if(cTime.TimeOfDay >= FlattenTime.TimeOfDay){ if(Position.MarketPosition != MarketPosition.Flat) FlattenPosition("EOD"); return true; } return false; }
		private void FlattenPosition(string reason) { Log(reason + " - Flatten.", LogLevel.Information); if (Position.MarketPosition == MarketPosition.Long) ExitLong(reason, entrySignalName); }
		private bool ShouldCheckForEntry(DateTime cTime) { if (Position.MarketPosition!=MarketPosition.Flat || IsMaxLossHitToday() || IsMaxTradesHitToday() || cTime.TimeOfDay<StartTime.TimeOfDay || cTime.TimeOfDay>=EndTime.TimeOfDay) return false; if(PauseAfterProfit && pauseTradingPostProfit) { if(CurrentBar<barNumberOfLastExit+PauseBars) return false; else {pauseTradingPostProfit=false; Log("Pause Over.", LogLevel.Information);}} return true; }
		private bool IsChoppy(double atrV) { if (atrV<=TickSize || adx==null) return true; if (adx[0]<ChopAdxThreshold || ((ema20[0]-ema50[0])/atrV)<ChopEmaSeparationAtrRatio) return true; return false; }
		private void EnsureEntryAtrSet() { if (entryAtrValue.ApproxCompare(0.0) <= 0) { Log("Atr Err Mgmt.", LogLevel.Warning); entryAtrValue=atr[0]; if(entryAtrValue<TickSize) entryAtrValue=TickSize*4;} }
		private double CalculateTargetPrice(double mult) { return Instrument.MasterInstrument.RoundToTickSize(Position.AveragePrice + (mult * entryAtrValue)); }
		private double CalculateStopLossPrice(double mult) { return Instrument.MasterInstrument.RoundToTickSize(Position.AveragePrice - (mult * entryAtrValue)); }
		private void ResetTradeFlags() { isPT1Hit=false; isAtBreakeven=false; }
		private void LogEntrySignal(double entryP, double stopP, double targetP) { Log($"Entry Sig B{CurrentBar}. P={entryP:F2}, SL={stopP:F2}, PT1={targetP:F2}", LogLevel.Information); }
		private void LogOrderUpdate(Order order, OrderState oState, double avgFillPrice) { Log($"Order Udt: {order.Name}, St={oState}, F={order.Filled}/{order.Quantity} @ {avgFillPrice:F2}", LogLevel.Information); }
		private void CheckUnexpectedStopCancel(Order order, OrderState oState) { if ((order.Name.Contains("Stop")||order.Name.Contains("SL")) && (oState==OrderState.Rejected || oState==OrderState.Cancelled) && Position.MarketPosition != MarketPosition.Flat) { Log($"WARN: Stop {order.Name} {oState}!", LogLevel.Warning); } }
		private void HandleEntryFill(Execution exec, double fillP) { EnsureEntryAtrSet(); double slP=CalculateStopLossPrice(AtrSLMultiplier); double pt1P=CalculateTargetPrice(AtrPT1Multiplier); Log($"Entry Fill Q{exec.Quantity} @ {fillP:F2}. SL={slP:F2}, PT1={pt1P:F2}", LogLevel.Information); ExitLongStopMarket(0,true,exec.Quantity,slP,"SL Init",entrySignalName); ExitLongLimit(0,true,exec.Quantity,pt1P,"PT1",entrySignalName); ResetTradeFlags(); barNumberOfLastEntry=CurrentBar; tradesToday++; Log($"Trade#: {tradesToday}", LogLevel.Information); }
		private void HandleExitFill(Execution exec, MarketPosition resultPos) { Log($"Exit Fill: {exec.Order.Name} Q{exec.Quantity} @ {exec.Price:F2}. NewPos: {resultPos}", LogLevel.Information); if(exec.Order.Name=="PT1"){isPT1Hit=true;Log("PT1 Fill.", LogLevel.Information);if(resultPos==MarketPosition.Long && !isAtBreakeven){Position pos=Positions[0]; if(pos!=null&&pos.Quantity>0) MoveStopToBreakEvenAndTrail(pos); else{Log("Flat@PT1.",LogLevel.Information);isAtBreakeven=false;}} else if(resultPos==MarketPosition.Flat)isAtBreakeven=false;} HandlePostProfitPause(exec, resultPos); }
		private void MoveStopToBreakEvenAndTrail(Position pos) { double beP = Instrument.MasterInstrument.RoundToTickSize(pos.AveragePrice + TickSize); Log($"Pos Q{pos.Quantity}. BE@{beP:F2}", LogLevel.Information); ExitLongStopMarket(0,true,pos.Quantity,beP,"BE Stop",entrySignalName); isAtBreakeven=true; EnsureEntryAtrSet(); double trailAmt=AtrTrailMultiplier*entryAtrValue; if(trailAmt>0) {Log($"Trail:{trailAmt:F2}",LogLevel.Information);SetTrailStop(entrySignalName, CalculationMode.Price, trailAmt, false);} else Log("Trail Amt Err.",LogLevel.Warning);}
		// Keep using SystemPerformance for AllTrades (list of past trades)
		private void HandlePostProfitPause(Execution exec, MarketPosition resultPos) { if(PauseAfterProfit && resultPos==MarketPosition.Flat) { if(SystemPerformance.AllTrades.Count > 0) {Trade lastTrade = SystemPerformance.AllTrades.Last(); if(lastTrade.Entry.Name == entrySignalName && lastTrade.Exit.ExecutionId == exec.ExecutionId) { if(lastTrade.ProfitCurrency > 0) {pauseTradingPostProfit=true; barNumberOfLastExit=CurrentBar; Log($"Profit({lastTrade.ProfitCurrency:C}). Pause {PauseBars} bars.",LogLevel.Information);} else {pauseTradingPostProfit=false; barNumberOfLastExit=CurrentBar;}}} } else if (resultPos==MarketPosition.Flat) {pauseTradingPostProfit=false; barNumberOfLastExit=CurrentBar;} }

		#endregion

	} // END CLASS InstitutionalMesPullbackV1
} // END NAMESPACE NinjaTrader.NinjaScript.Strategies