usingcAlgo.API;usingcAlgo.API.Indicators;namespacecAlgo.Robots{// This sample cBot shows how to use the Weighted Close indicator[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassWeightedCloseSample:Robot{privatedouble_volumeInUnits;privateWeightedClose_weightedClose;privateSimpleMovingAverage_simpleMovingAverage;[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);_weightedClose=Indicators.WeightedClose();_simpleMovingAverage=Indicators.SimpleMovingAverage(_weightedClose.Result,14);}protectedoverridevoidOnBar(){if(_weightedClose.Result.HasCrossedAbove(_simpleMovingAverage.Result,0)){ClosePositions(TradeType.Sell);ExecuteMarketOrder(TradeType.Buy,SymbolName,_volumeInUnits,Label,StopLossInPips,TakeProfitInPips);}elseif(_weightedClose.Result.HasCrossedBelow(_simpleMovingAverage.Result,0)){ClosePositions(TradeType.Buy);ExecuteMarketOrder(TradeType.Sell,SymbolName,_volumeInUnits,Label,StopLossInPips,TakeProfitInPips);}}privatevoidClosePositions(TradeTypetradeType){foreach(varpositioninBotPositions){if(position.TradeType!=tradeType)continue;ClosePosition(position);}}}}