Difference between Bars.HighPrices and Bars.LowPrices calculation for each index
Remarks
This volatility indicator works by calculating the difference between the high and the low of each trendbar. The larger the difference between high and low, the more volatile the market during that period.
Signature
1
publicabstractinterfaceHighMinusLow
Namespace
cAlgo.API.Indicators
Examples
1 2 3 4 5 6 7 8 910111213141516171819
usingcAlgo.API;usingcAlgo.API.Indicators;namespacecAlgo.Indicators{[Indicator]publicclassExample:Indicator{privateHighMinusLow_highMinusLow;protectedoverridevoidInitialize(){_highMinusLow=Indicators.HighMinusLow();}publicoverridevoidCalculate(intindex){// same as Bars.HighPrices[index] - Bars.LowPrices[index];Print("High minus Low result = {0}",_highMinusLow.Result[index]);}}}
usingcAlgo.API;usingcAlgo.API.Indicators;namespacecAlgo.Robots{/// /// This sample cBot shows how to use the High Minus Low indicator/// [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassHighMinusLowSample:Robot{privatedouble_volumeInUnits;privateHighMinusLow_highMinusLow;[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);_highMinusLow=Indicators.HighMinusLow();}protectedoverridevoidOnBar(){if(_highMinusLow.Result.Last(1)<_highMinusLow.Result.Maximum(10))return;if(Bars.ClosePrices.Last(1)>Bars.OpenPrices.Last(1)){ClosePositions(TradeType.Sell);ExecuteMarketOrder(TradeType.Buy,SymbolName,_volumeInUnits,Label,StopLossInPips,TakeProfitInPips);}elseif(Bars.ClosePrices.Last(1)<Bars.OpenPrices.Last(1)){ClosePositions(TradeType.Buy);ExecuteMarketOrder(TradeType.Sell,SymbolName,_volumeInUnits,Label,StopLossInPips,TakeProfitInPips);}}privatevoidClosePositions(TradeTypetradeType){foreach(varpositioninBotPositions){if(position.TradeType!=tradeType)continue;ClosePosition(position);}}}}
123456789
importclrclr.AddReference("cAlgo.API")fromcAlgo.APIimport*classTest():definitialize(self):self.highMinusLow=api.Indicators.HighMinusLow()defcalculate(self,index):# same as api.Bars.HighPrices[index] - api.Bars.LowPrices[index]print(f"High minus Low result = {api.highMinusLow.Result[index]}")