usingcAlgo.API;usingcAlgo.API.Indicators;usingcAlgo.API.Internals;namespacecAlgo.Robots{// This sample cBot shows how to use the Linear Regression Slope indicator[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassLinearRegressionSlopeSample:Robot{privatedouble_volumeInUnits;privateLinearRegressionSlope_linearRegressionSlope;privateSimpleMovingAverage_simpleMovingAverage;privateExponentialMovingAverage_exponentialMovingAverage;[Parameter("Volume (Lots)", DefaultValue = 0.01)]publicdoubleVolumeInLots{get;set;}[Parameter("Stop Loss (Pips)", DefaultValue = 10)]publicdoubleStopLossInPips{get;set;}[Parameter("Take Profit (Pips)", DefaultValue = 10)]publicdoubleTakeProfitInPips{get;set;}[Parameter("Label", DefaultValue = "Sample")]publicstringLabel{get;set;}publicPosition[]BotPositions{get{returnPositions.FindAll(Label);}}protectedoverridevoidOnStart(){_volumeInUnits=Symbol.QuantityToVolumeInUnits(VolumeInLots);_linearRegressionSlope=Indicators.LinearRegressionSlope(Bars.ClosePrices,20);_simpleMovingAverage=Indicators.SimpleMovingAverage(_linearRegressionSlope.Result,10);_exponentialMovingAverage=Indicators.ExponentialMovingAverage(Bars.ClosePrices,20);}protectedoverridevoidOnBar(){if(Bars.ClosePrices.Last(1)>_exponentialMovingAverage.Result.Last(1)&&Bars.ClosePrices.Last(2)<=_exponentialMovingAverage.Result.Last(2)){ClosePositions(TradeType.Sell);if(_linearRegressionSlope.Result.Last(1)>_simpleMovingAverage.Result.Last(1)){ExecuteMarketOrder(TradeType.Buy,SymbolName,_volumeInUnits,Label,StopLossInPips,TakeProfitInPips);}}elseif(Bars.ClosePrices.Last(1)<_exponentialMovingAverage.Result.Last(1)&&Bars.ClosePrices.Last(2)>=_exponentialMovingAverage.Result.Last(2)){ClosePositions(TradeType.Buy);if(_linearRegressionSlope.Result.Last(1)>_simpleMovingAverage.Result.Last(1)){ExecuteMarketOrder(TradeType.Sell,SymbolName,_volumeInUnits,Label,StopLossInPips,TakeProfitInPips);}}}privatevoidClosePositions(TradeTypetradeType){foreach(varpositioninBotPositions){if(position.TradeType!=tradeType)continue;ClosePosition(position);}}}}