Indicators

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
How to install
RSI STARC indicator
  0
  0
  218
by mfejza
free  16 Dec 2022
The indicator represents a combination of RSI and STARC components (Stoller Average Range Channels), which is similar to indicator Bollinger Bands. Its bands get narrower on stable markets and wider on volatile markets. STARC component does not consider standard square deviation as BBands, its is calculated using average true range (ATR), and its components are derived from RSI, for providing more detailed information on market volatility.
free  15 Dec 2022
Alpilean is a weight reduction pill that assists you with consuming fat by focusing on your internal heat level. It works by expanding digestion and controlling your hunger. The fixings in the enhancement help to diminish fat cells and increment the development of brown fat tissue (BAT). BAT has been distinguished to be areas of strength for an in expanding thermogenesis in the body, which is the most common way of consuming calories. Alpilean is the principal weight reduction supplement made in the USA under FDA and GMP-managed offices. The fixings are unadulterated, regular, and tried for security. The cases are made with an exclusive mix of regular fixings that assist you with getting more fit and increment energy levels. Alpilean works by raising your internal heat level, which makes the fat-consuming cycle inside your body actuate. Alpilean is the main weight reduction supplement that utilizes this one of a kind and demonstrated logical guideline to assist you with diminishing your weight. It contains all-normal fixings that cooperate to raise your inward internal heat level and increment your digestion, along these lines supporting your weight reduction endeavors. The review uncovered that thin individuals have a generally higher internal heat level when contrasted with fat. Less fatty individuals have more body heat, which assists them with consuming fat quicker. This is on the grounds that the more intensity you have in your body, the quicker your digestion works and subsequently assists you with getting thinner. Alpilean utilizes this standard to assist you with shedding pounds quick. With its extraordinary normal fixings (counting Brilliant Green growth and Drumstick Leaf), Alpilean can raise your inward internal heat level. This, thusly, actuates the fat-consuming cycle in your body. Consequently you can lose more weight than expected. Alpilean is a powerful weight reduction supplement that works by initiating your digestion and working on your stomach related framework. It's made with 100 percent normal fixings and is non-GMO, so you can feel significantly better about utilizing it while you're attempting to lose weight.The item's site and the bundling both contain a total rundown of fixings. It's really smart to investigate the Reddit strings and remarks around Alpilean prior to putting resources into it. Many individuals post their outcomes from utilizing the enhancement, and this can assist you with deciding if it merits your cash. Certain individuals say that Alpilean assisted them with thinning down, while others say it didn't help them with their weight issues. Some even say it merited the cash, yet there are a lot of commentators who disagree with that opinion. It's likewise essential to take note of that despite the fact that Alpilean is irrefutably a top notch supplement, there are different choices out there that might be more qualified for your requirements. https://www.ndtv.com/health/alpilean-reviews-fake-promises-or-real-weight-loss-benefits-3544045
by mfejza
free  12 Dec 2022
The GaussianBands indicator works like BollingerBands and performs centerline and deviation band filtering based on input deviation parameters. This indicator identifies the price squeeze, and this means the beginning of the open trade position, and the direction of the trade is determined by the price position with the central line of the indicator (above/beelow). This indicator also identifies the state of momentum and trend based on extended internal and external bands Use the ZScore indicator for confirmation. (download ZScore from here)  
free  14 Dec 2022
Hi tank you from TraderExperto I edited this indicator to show the risk to reward and the amount of entering the position and.. at the same time.   PS = position size from balance R/R = Risk/Reward Note : The Lots / Units does not work, it only works based on percentage Risk edite
renko
  1
  0
  171
free  11 Dec 2022
using cAlgo.API;<font></font> using cAlgo.API.Indicators;<font></font> using cAlgo.API.Internals;<font></font> using cAlgo.Indicators;<font></font> using System;<font></font> using System.Collections.Generic;<font></font> using System.Linq;<font></font> using System.Windows.Forms;<font></font> using System.Runtime.InteropServices;<font></font> using System.Diagnostics;<font></font> using cT_MedianRenkoEngine;<font></font> <font></font> namespace cAlgo<font></font> {<font></font>     [Indicator("MedianRenko", IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]<font></font>     public class MedianRenko : Indicator<font></font>     {<font></font>         [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]<font></font>         public double BarSizePips { get; set; }<font></font> <font></font>         [Parameter("Retracement factor (0.01 - 1.00)", DefaultValue = 0.5, MinValue = 0.01, MaxValue = 1.0, Step = 0.01)]<font></font>         public double Retracement { get; set; }<font></font> <font></font>         [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]<font></font>         public int BricksToShow { get; set; }<font></font> <font></font>         [Parameter("Symmetrical Reversals", DefaultValue = true)]<font></font>         public bool SymmetricalReversals { get; set; }<font></font> <font></font>         [Parameter("Reset Open on new trading day", DefaultValue = false)]<font></font>         public bool ResetOpenOnNewTradingDay { get; set; }<font></font> <font></font>         [Parameter("Apply offset to first renko bar", DefaultValue = false)]<font></font>         public bool ApplyOffsetToFirstBar { get; set; }<font></font> <font></font>         [Parameter("Tick offset value", DefaultValue = 0, MinValue = 0)]<font></font>         public int OffsetValue { get; set; }<font></font> <font></font>         [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]<font></font>         public string ColorBull { get; set; }<font></font> <font></font>         [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]<font></font>         public string ColorBear { get; set; }<font></font> <font></font>         [Output("Open", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Open { get; set; }<font></font> <font></font>         [Output("High", Color = Colors.DimGray, Thickness = 1, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries High { get; set; }<font></font> <font></font>         [Output("Low", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Low { get; set; }<font></font> <font></font>         [Output("Close", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Close { get; set; }<font></font> <font></font>         private MedianRenkoCore core = null;<font></font>         private bool coreOK = true;<font></font> <font></font>         private DateTime lastTime;<font></font> <font></font>         private bool appliedOffset = false;<font></font> <font></font>         private T_OLHCV pOLHCV;<font></font>         private T_OLHCV OLHCV;<font></font>         private T_OLHCV mOLHCV;<font></font>         private T_OLHCV cOLHCV;<font></font>         private T_OLHCV memRates;<font></font>         private T_OLHCV lastBar;<font></font> <font></font>         private List<T_OLHCV> bars = new List<T_OLHCV>();<font></font>         private double barSize;<font></font>         private Colors colorBull, colorBear;<font></font> <font></font>         protected override void Initialize()<font></font>         {<font></font>             core = new MedianRenkoCore();<font></font>             coreOK = core.StatusCheck();<font></font> <font></font>             barSize = BarSizePips * Symbol.PipSize;<font></font> <font></font>             lastTime = new DateTime();<font></font>             lastTime = MarketSeries.OpenTime[MarketSeries.Close.Count - 1];<font></font> <font></font>             lastBar = new T_OLHCV();<font></font>             pOLHCV = new T_OLHCV();<font></font>             OLHCV = new T_OLHCV();<font></font>             mOLHCV = new T_OLHCV();<font></font>             cOLHCV = new T_OLHCV();<font></font>             memRates = new T_OLHCV();<font></font> <font></font>             if (!Enum.TryParse<Colors>(ColorBull, out colorBull))<font></font>             {<font></font>                 colorBull = Colors.SeaGreen;<font></font>             }<font></font>             if (!Enum.TryParse<Colors>(ColorBear, out colorBear))<font></font>             {<font></font>                 colorBear = Colors.Tomato;<font></font>             }<font></font> <font></font>             appliedOffset = false;<font></font>         }<font></font> <font></font>         private bool NewBar(int index)<font></font>         {<font></font>             if (lastTime != MarketSeries.OpenTime[index])<font></font>             {<font></font>                 lastTime = MarketSeries.OpenTime[index];<font></font>                 return true;<font></font>             }<font></font> <font></font>             return false;<font></font>         }<font></font> <font></font>         private static int cc = 0;<font></font>         private void pushBars(T_OLHCV bar, bool display)<font></font>         {<font></font>             int count = bars.Count();<font></font> <font></font>             var newBar = new T_OLHCV();<font></font>             newBar.Copy(bar);<font></font>             newBar.Index = cc++;<font></font> <font></font>             bars.Insert(0, newBar);<font></font>             count++;<font></font> <font></font>             if (display)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font> <font></font>             if (count > BricksToShow)<font></font>             {<font></font>                 if (display)<font></font>                 {<font></font>                     for (int i = BricksToShow - 1; i < count; i++)<font></font>                     {<font></font>                         ChartObjects.RemoveObject("mr_Wick_" + bars[i].Index);<font></font>                         ChartObjects.RemoveObject("mr_Bar_" + bars[i].Index);<font></font>                     }<font></font>                 }<font></font> <font></font>                 bars.RemoveRange(BricksToShow, count - BricksToShow);<font></font> <font></font>                 Open[count - BricksToShow] = double.NaN;<font></font>                 High[count - BricksToShow] = double.NaN;<font></font>                 Low[count - BricksToShow] = double.NaN;<font></font>                 Close[count - BricksToShow] = double.NaN;<font></font>             }<font></font> <font></font>         }<font></font> <font></font>         private void shiftBars(int shift)<font></font>         {<font></font>             int count = bars.Count;<font></font>             int ix = MarketSeries.Close.Count - 2;<font></font> <font></font>             for (int i = 0; i < count && i < BricksToShow; i++)<font></font>             {<font></font>                 var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;<font></font> <font></font>                 ChartObjects.DrawLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);<font></font>                 ChartObjects.DrawLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>                 Open[ix] = bars[i].Open;<font></font>                 High[ix] = bars[i].High;<font></font>                 Low[ix] = bars[i].Low;<font></font>                 Close[ix] = bars[i].Close;<font></font> <font></font>                 ix--;<font></font>             }<font></font>         }<font></font> <font></font>         private void UpdateLastBar(int ix)<font></font>         {<font></font>             var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;<font></font> <font></font>             ChartObjects.DrawLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);<font></font>             ChartObjects.DrawLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>             Open[ix] = memRates.Open;<font></font>             High[ix] = memRates.High;<font></font>             Low[ix] = memRates.Low;<font></font>             Close[ix] = memRates.Close;<font></font> <font></font>         }<font></font> <font></font>         public override void Calculate(int index)<font></font>         {<font></font>             if (ResetOpenOnNewTradingDay)<font></font>             {<font></font>                 if (IsNewSession(MarketSeries.OpenTime[(index > 0) ? (index - 1) : index], MarketSeries.OpenTime[index]))<font></font>                 {<font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font>                     pOLHCV.Clear();<font></font>                     memRates.Copy(mOLHCV);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsRealTime)<font></font>             {<font></font>                 if (!coreOK)<font></font>                 {<font></font>                     ChartObjects.DrawText("TrialOverMsg", "MedianRenko Indicator - Trial period ended. Please purchase a license file at www.az-invest.eu", StaticPosition.Center, Colors.White);<font></font>                     return;<font></font>                 }<font></font> <font></font>                 if (NewBar(index))<font></font>                 {<font></font>                     shiftBars(0);<font></font> <font></font>                     Open[index - BricksToShow - 1] = double.NaN;<font></font>                     High[index - BricksToShow - 1] = double.NaN;<font></font>                     Low[index - BricksToShow - 1] = double.NaN;<font></font>                     Close[index - BricksToShow - 1] = double.NaN;<font></font>                 }<font></font> <font></font>                 OLHCV.Open = MarketSeries.Close[index];<font></font>                 OLHCV.Low = MarketSeries.Close[index];<font></font>                 OLHCV.High = MarketSeries.Close[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = 1;<font></font> <font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font>                 UpdateLastBar(index);<font></font>             }<font></font>             else<font></font>             {<font></font>                 OLHCV.Open = MarketSeries.Open[index];<font></font>                 OLHCV.Low = MarketSeries.Low[index];<font></font>                 OLHCV.High = MarketSeries.High[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = MarketSeries.TickVolume[index];<font></font> <font></font>                 if (ApplyOffsetToFirstBar && !appliedOffset)<font></font>                 {<font></font>                     OLHCV.Open = OffsetValue * Symbol.TickSize + Math.Floor(OLHCV.Open / barSize) * barSize;<font></font>                     appliedOffset = true;<font></font>                 }<font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font> <font></font>                 if (IsLastBar)<font></font>                     UpdateLastBar(index);<font></font>             }<font></font>         }<font></font> <font></font>         private void ProcessMarketData(T_OLHCV ___OLHCV)<font></font>         {<font></font>             int rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);<font></font>             while (true)<font></font>             {<font></font>                 if ((rb_return >= 1) && (rb_return <= 4))<font></font>                 {<font></font>                     pushBars(cOLHCV, IsRealTime);<font></font>                     memRates.Copy(mOLHCV);<font></font>                     OLHCV.Copy(memRates);<font></font> <font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font> <font></font>                     rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);<font></font>                     continue;<font></font> <font></font>                 }<font></font>                 else if (rb_return == 10)<font></font>                 {<font></font>                     memRates.Copy(mOLHCV);<font></font>                     break;<font></font>                 }<font></font>                 else if (rb_return == -1)<font></font>                 {<font></font>                     return;<font></font>                 }<font></font>                 else<font></font>                 {<font></font>                     throw new Exception("Unhandled return value = " + rb_return);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsLastBar && !IsRealTime)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font>         }<font></font> <font></font>         private bool IsNewSession(DateTime prevTime, DateTime currTime)<font></font>         {<font></font>             if (prevTime.DayOfWeek != currTime.DayOfWeek)<font></font>                 return true;<font></font>             else<font></font>                 return false;<font></font>         }<font></font> <font></font> <font></font>     }<font></font> }<font></font> <font></font>
renko
  1
  0
  193
free  11 Dec 2022
using cAlgo.API;<font></font> using cAlgo.API.Indicators;<font></font> using cAlgo.API.Internals;<font></font> using cAlgo.Indicators;<font></font> using System;<font></font> using System.Collections.Generic;<font></font> using System.Linq;<font></font> using System.Windows.Forms;<font></font> using System.Runtime.InteropServices;<font></font> using System.Diagnostics;<font></font> using cT_MedianRenkoEngine;<font></font> <font></font> namespace cAlgo<font></font> {<font></font>     [Indicator("MedianRenko", IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]<font></font>     public class MedianRenko : Indicator<font></font>     {<font></font>         [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]<font></font>         public double BarSizePips { get; set; }<font></font> <font></font>         [Parameter("Retracement factor (0.01 - 1.00)", DefaultValue = 0.5, MinValue = 0.01, MaxValue = 1.0, Step = 0.01)]<font></font>         public double Retracement { get; set; }<font></font> <font></font>         [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]<font></font>         public int BricksToShow { get; set; }<font></font> <font></font>         [Parameter("Symmetrical Reversals", DefaultValue = true)]<font></font>         public bool SymmetricalReversals { get; set; }<font></font> <font></font>         [Parameter("Reset Open on new trading day", DefaultValue = false)]<font></font>         public bool ResetOpenOnNewTradingDay { get; set; }<font></font> <font></font>         [Parameter("Apply offset to first renko bar", DefaultValue = false)]<font></font>         public bool ApplyOffsetToFirstBar { get; set; }<font></font> <font></font>         [Parameter("Tick offset value", DefaultValue = 0, MinValue = 0)]<font></font>         public int OffsetValue { get; set; }<font></font> <font></font>         [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]<font></font>         public string ColorBull { get; set; }<font></font> <font></font>         [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]<font></font>         public string ColorBear { get; set; }<font></font> <font></font>         [Output("Open", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Open { get; set; }<font></font> <font></font>         [Output("High", Color = Colors.DimGray, Thickness = 1, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries High { get; set; }<font></font> <font></font>         [Output("Low", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Low { get; set; }<font></font> <font></font>         [Output("Close", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Close { get; set; }<font></font> <font></font>         private MedianRenkoCore core = null;<font></font>         private bool coreOK = true;<font></font> <font></font>         private DateTime lastTime;<font></font> <font></font>         private bool appliedOffset = false;<font></font> <font></font>         private T_OLHCV pOLHCV;<font></font>         private T_OLHCV OLHCV;<font></font>         private T_OLHCV mOLHCV;<font></font>         private T_OLHCV cOLHCV;<font></font>         private T_OLHCV memRates;<font></font>         private T_OLHCV lastBar;<font></font> <font></font>         private List<T_OLHCV> bars = new List<T_OLHCV>();<font></font>         private double barSize;<font></font>         private Colors colorBull, colorBear;<font></font> <font></font>         protected override void Initialize()<font></font>         {<font></font>             core = new MedianRenkoCore();<font></font>             coreOK = core.StatusCheck();<font></font> <font></font>             barSize = BarSizePips * Symbol.PipSize;<font></font> <font></font>             lastTime = new DateTime();<font></font>             lastTime = MarketSeries.OpenTime[MarketSeries.Close.Count - 1];<font></font> <font></font>             lastBar = new T_OLHCV();<font></font>             pOLHCV = new T_OLHCV();<font></font>             OLHCV = new T_OLHCV();<font></font>             mOLHCV = new T_OLHCV();<font></font>             cOLHCV = new T_OLHCV();<font></font>             memRates = new T_OLHCV();<font></font> <font></font>             if (!Enum.TryParse<Colors>(ColorBull, out colorBull))<font></font>             {<font></font>                 colorBull = Colors.SeaGreen;<font></font>             }<font></font>             if (!Enum.TryParse<Colors>(ColorBear, out colorBear))<font></font>             {<font></font>                 colorBear = Colors.Tomato;<font></font>             }<font></font> <font></font>             appliedOffset = false;<font></font>         }<font></font> <font></font>         private bool NewBar(int index)<font></font>         {<font></font>             if (lastTime != MarketSeries.OpenTime[index])<font></font>             {<font></font>                 lastTime = MarketSeries.OpenTime[index];<font></font>                 return true;<font></font>             }<font></font> <font></font>             return false;<font></font>         }<font></font> <font></font>         private static int cc = 0;<font></font>         private void pushBars(T_OLHCV bar, bool display)<font></font>         {<font></font>             int count = bars.Count();<font></font> <font></font>             var newBar = new T_OLHCV();<font></font>             newBar.Copy(bar);<font></font>             newBar.Index = cc++;<font></font> <font></font>             bars.Insert(0, newBar);<font></font>             count++;<font></font> <font></font>             if (display)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font> <font></font>             if (count > BricksToShow)<font></font>             {<font></font>                 if (display)<font></font>                 {<font></font>                     for (int i = BricksToShow - 1; i < count; i++)<font></font>                     {<font></font>                         ChartObjects.RemoveObject("mr_Wick_" + bars[i].Index);<font></font>                         ChartObjects.RemoveObject("mr_Bar_" + bars[i].Index);<font></font>                     }<font></font>                 }<font></font> <font></font>                 bars.RemoveRange(BricksToShow, count - BricksToShow);<font></font> <font></font>                 Open[count - BricksToShow] = double.NaN;<font></font>                 High[count - BricksToShow] = double.NaN;<font></font>                 Low[count - BricksToShow] = double.NaN;<font></font>                 Close[count - BricksToShow] = double.NaN;<font></font>             }<font></font> <font></font>         }<font></font> <font></font>         private void shiftBars(int shift)<font></font>         {<font></font>             int count = bars.Count;<font></font>             int ix = MarketSeries.Close.Count - 2;<font></font> <font></font>             for (int i = 0; i < count && i < BricksToShow; i++)<font></font>             {<font></font>                 var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;<font></font> <font></font>                 ChartObjects.DrawLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);<font></font>                 ChartObjects.DrawLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>                 Open[ix] = bars[i].Open;<font></font>                 High[ix] = bars[i].High;<font></font>                 Low[ix] = bars[i].Low;<font></font>                 Close[ix] = bars[i].Close;<font></font> <font></font>                 ix--;<font></font>             }<font></font>         }<font></font> <font></font>         private void UpdateLastBar(int ix)<font></font>         {<font></font>             var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;<font></font> <font></font>             ChartObjects.DrawLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);<font></font>             ChartObjects.DrawLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>             Open[ix] = memRates.Open;<font></font>             High[ix] = memRates.High;<font></font>             Low[ix] = memRates.Low;<font></font>             Close[ix] = memRates.Close;<font></font> <font></font>         }<font></font> <font></font>         public override void Calculate(int index)<font></font>         {<font></font>             if (ResetOpenOnNewTradingDay)<font></font>             {<font></font>                 if (IsNewSession(MarketSeries.OpenTime[(index > 0) ? (index - 1) : index], MarketSeries.OpenTime[index]))<font></font>                 {<font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font>                     pOLHCV.Clear();<font></font>                     memRates.Copy(mOLHCV);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsRealTime)<font></font>             {<font></font>                 if (!coreOK)<font></font>                 {<font></font>                     ChartObjects.DrawText("TrialOverMsg", "MedianRenko Indicator - Trial period ended. Please purchase a license file at www.az-invest.eu", StaticPosition.Center, Colors.White);<font></font>                     return;<font></font>                 }<font></font> <font></font>                 if (NewBar(index))<font></font>                 {<font></font>                     shiftBars(0);<font></font> <font></font>                     Open[index - BricksToShow - 1] = double.NaN;<font></font>                     High[index - BricksToShow - 1] = double.NaN;<font></font>                     Low[index - BricksToShow - 1] = double.NaN;<font></font>                     Close[index - BricksToShow - 1] = double.NaN;<font></font>                 }<font></font> <font></font>                 OLHCV.Open = MarketSeries.Close[index];<font></font>                 OLHCV.Low = MarketSeries.Close[index];<font></font>                 OLHCV.High = MarketSeries.Close[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = 1;<font></font> <font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font>                 UpdateLastBar(index);<font></font>             }<font></font>             else<font></font>             {<font></font>                 OLHCV.Open = MarketSeries.Open[index];<font></font>                 OLHCV.Low = MarketSeries.Low[index];<font></font>                 OLHCV.High = MarketSeries.High[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = MarketSeries.TickVolume[index];<font></font> <font></font>                 if (ApplyOffsetToFirstBar && !appliedOffset)<font></font>                 {<font></font>                     OLHCV.Open = OffsetValue * Symbol.TickSize + Math.Floor(OLHCV.Open / barSize) * barSize;<font></font>                     appliedOffset = true;<font></font>                 }<font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font> <font></font>                 if (IsLastBar)<font></font>                     UpdateLastBar(index);<font></font>             }<font></font>         }<font></font> <font></font>         private void ProcessMarketData(T_OLHCV ___OLHCV)<font></font>         {<font></font>             int rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);<font></font>             while (true)<font></font>             {<font></font>                 if ((rb_return >= 1) && (rb_return <= 4))<font></font>                 {<font></font>                     pushBars(cOLHCV, IsRealTime);<font></font>                     memRates.Copy(mOLHCV);<font></font>                     OLHCV.Copy(memRates);<font></font> <font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font> <font></font>                     rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);<font></font>                     continue;<font></font> <font></font>                 }<font></font>                 else if (rb_return == 10)<font></font>                 {<font></font>                     memRates.Copy(mOLHCV);<font></font>                     break;<font></font>                 }<font></font>                 else if (rb_return == -1)<font></font>                 {<font></font>                     return;<font></font>                 }<font></font>                 else<font></font>                 {<font></font>                     throw new Exception("Unhandled return value = " + rb_return);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsLastBar && !IsRealTime)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font>         }<font></font> <font></font>         private bool IsNewSession(DateTime prevTime, DateTime currTime)<font></font>         {<font></font>             if (prevTime.DayOfWeek != currTime.DayOfWeek)<font></font>                 return true;<font></font>             else<font></font>                 return false;<font></font>         }<font></font> <font></font> <font></font>     }<font></font> }<font></font> <font></font>
renko
  1
  0
  77
free  11 Dec 2022
using cAlgo.API;<font></font> using cAlgo.API.Indicators;<font></font> using cAlgo.API.Internals;<font></font> using cAlgo.Indicators;<font></font> using System;<font></font> using System.Collections.Generic;<font></font> using System.Linq;<font></font> using System.Windows.Forms;<font></font> using System.Runtime.InteropServices;<font></font> using System.Diagnostics;<font></font> using cT_MedianRenkoEngine;<font></font> <font></font> namespace cAlgo<font></font> {<font></font>     [Indicator("MedianRenko", IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]<font></font>     public class MedianRenko : Indicator<font></font>     {<font></font>         [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]<font></font>         public double BarSizePips { get; set; }<font></font> <font></font>         [Parameter("Retracement factor (0.01 - 1.00)", DefaultValue = 0.5, MinValue = 0.01, MaxValue = 1.0, Step = 0.01)]<font></font>         public double Retracement { get; set; }<font></font> <font></font>         [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]<font></font>         public int BricksToShow { get; set; }<font></font> <font></font>         [Parameter("Symmetrical Reversals", DefaultValue = true)]<font></font>         public bool SymmetricalReversals { get; set; }<font></font> <font></font>         [Parameter("Reset Open on new trading day", DefaultValue = false)]<font></font>         public bool ResetOpenOnNewTradingDay { get; set; }<font></font> <font></font>         [Parameter("Apply offset to first renko bar", DefaultValue = false)]<font></font>         public bool ApplyOffsetToFirstBar { get; set; }<font></font> <font></font>         [Parameter("Tick offset value", DefaultValue = 0, MinValue = 0)]<font></font>         public int OffsetValue { get; set; }<font></font> <font></font>         [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]<font></font>         public string ColorBull { get; set; }<font></font> <font></font>         [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]<font></font>         public string ColorBear { get; set; }<font></font> <font></font>         [Output("Open", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Open { get; set; }<font></font> <font></font>         [Output("High", Color = Colors.DimGray, Thickness = 1, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries High { get; set; }<font></font> <font></font>         [Output("Low", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Low { get; set; }<font></font> <font></font>         [Output("Close", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Close { get; set; }<font></font> <font></font>         private MedianRenkoCore core = null;<font></font>         private bool coreOK = true;<font></font> <font></font>         private DateTime lastTime;<font></font> <font></font>         private bool appliedOffset = false;<font></font> <font></font>         private T_OLHCV pOLHCV;<font></font>         private T_OLHCV OLHCV;<font></font>         private T_OLHCV mOLHCV;<font></font>         private T_OLHCV cOLHCV;<font></font>         private T_OLHCV memRates;<font></font>         private T_OLHCV lastBar;<font></font> <font></font>         private List<T_OLHCV> bars = new List<T_OLHCV>();<font></font>         private double barSize;<font></font>         private Colors colorBull, colorBear;<font></font> <font></font>         protected override void Initialize()<font></font>         {<font></font>             core = new MedianRenkoCore();<font></font>             coreOK = core.StatusCheck();<font></font> <font></font>             barSize = BarSizePips * Symbol.PipSize;<font></font> <font></font>             lastTime = new DateTime();<font></font>             lastTime = MarketSeries.OpenTime[MarketSeries.Close.Count - 1];<font></font> <font></font>             lastBar = new T_OLHCV();<font></font>             pOLHCV = new T_OLHCV();<font></font>             OLHCV = new T_OLHCV();<font></font>             mOLHCV = new T_OLHCV();<font></font>             cOLHCV = new T_OLHCV();<font></font>             memRates = new T_OLHCV();<font></font> <font></font>             if (!Enum.TryParse<Colors>(ColorBull, out colorBull))<font></font>             {<font></font>                 colorBull = Colors.SeaGreen;<font></font>             }<font></font>             if (!Enum.TryParse<Colors>(ColorBear, out colorBear))<font></font>             {<font></font>                 colorBear = Colors.Tomato;<font></font>             }<font></font> <font></font>             appliedOffset = false;<font></font>         }<font></font> <font></font>         private bool NewBar(int index)<font></font>         {<font></font>             if (lastTime != MarketSeries.OpenTime[index])<font></font>             {<font></font>                 lastTime = MarketSeries.OpenTime[index];<font></font>                 return true;<font></font>             }<font></font> <font></font>             return false;<font></font>         }<font></font> <font></font>         private static int cc = 0;<font></font>         private void pushBars(T_OLHCV bar, bool display)<font></font>         {<font></font>             int count = bars.Count();<font></font> <font></font>             var newBar = new T_OLHCV();<font></font>             newBar.Copy(bar);<font></font>             newBar.Index = cc++;<font></font> <font></font>             bars.Insert(0, newBar);<font></font>             count++;<font></font> <font></font>             if (display)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font> <font></font>             if (count > BricksToShow)<font></font>             {<font></font>                 if (display)<font></font>                 {<font></font>                     for (int i = BricksToShow - 1; i < count; i++)<font></font>                     {<font></font>                         ChartObjects.RemoveObject("mr_Wick_" + bars[i].Index);<font></font>                         ChartObjects.RemoveObject("mr_Bar_" + bars[i].Index);<font></font>                     }<font></font>                 }<font></font> <font></font>                 bars.RemoveRange(BricksToShow, count - BricksToShow);<font></font> <font></font>                 Open[count - BricksToShow] = double.NaN;<font></font>                 High[count - BricksToShow] = double.NaN;<font></font>                 Low[count - BricksToShow] = double.NaN;<font></font>                 Close[count - BricksToShow] = double.NaN;<font></font>             }<font></font> <font></font>         }<font></font> <font></font>         private void shiftBars(int shift)<font></font>         {<font></font>             int count = bars.Count;<font></font>             int ix = MarketSeries.Close.Count - 2;<font></font> <font></font>             for (int i = 0; i < count && i < BricksToShow; i++)<font></font>             {<font></font>                 var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;<font></font> <font></font>                 ChartObjects.DrawLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);<font></font>                 ChartObjects.DrawLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>                 Open[ix] = bars[i].Open;<font></font>                 High[ix] = bars[i].High;<font></font>                 Low[ix] = bars[i].Low;<font></font>                 Close[ix] = bars[i].Close;<font></font> <font></font>                 ix--;<font></font>             }<font></font>         }<font></font> <font></font>         private void UpdateLastBar(int ix)<font></font>         {<font></font>             var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;<font></font> <font></font>             ChartObjects.DrawLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);<font></font>             ChartObjects.DrawLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>             Open[ix] = memRates.Open;<font></font>             High[ix] = memRates.High;<font></font>             Low[ix] = memRates.Low;<font></font>             Close[ix] = memRates.Close;<font></font> <font></font>         }<font></font> <font></font>         public override void Calculate(int index)<font></font>         {<font></font>             if (ResetOpenOnNewTradingDay)<font></font>             {<font></font>                 if (IsNewSession(MarketSeries.OpenTime[(index > 0) ? (index - 1) : index], MarketSeries.OpenTime[index]))<font></font>                 {<font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font>                     pOLHCV.Clear();<font></font>                     memRates.Copy(mOLHCV);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsRealTime)<font></font>             {<font></font>                 if (!coreOK)<font></font>                 {<font></font>                     ChartObjects.DrawText("TrialOverMsg", "MedianRenko Indicator - Trial period ended. Please purchase a license file at www.az-invest.eu", StaticPosition.Center, Colors.White);<font></font>                     return;<font></font>                 }<font></font> <font></font>                 if (NewBar(index))<font></font>                 {<font></font>                     shiftBars(0);<font></font> <font></font>                     Open[index - BricksToShow - 1] = double.NaN;<font></font>                     High[index - BricksToShow - 1] = double.NaN;<font></font>                     Low[index - BricksToShow - 1] = double.NaN;<font></font>                     Close[index - BricksToShow - 1] = double.NaN;<font></font>                 }<font></font> <font></font>                 OLHCV.Open = MarketSeries.Close[index];<font></font>                 OLHCV.Low = MarketSeries.Close[index];<font></font>                 OLHCV.High = MarketSeries.Close[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = 1;<font></font> <font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font>                 UpdateLastBar(index);<font></font>             }<font></font>             else<font></font>             {<font></font>                 OLHCV.Open = MarketSeries.Open[index];<font></font>                 OLHCV.Low = MarketSeries.Low[index];<font></font>                 OLHCV.High = MarketSeries.High[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = MarketSeries.TickVolume[index];<font></font> <font></font>                 if (ApplyOffsetToFirstBar && !appliedOffset)<font></font>                 {<font></font>                     OLHCV.Open = OffsetValue * Symbol.TickSize + Math.Floor(OLHCV.Open / barSize) * barSize;<font></font>                     appliedOffset = true;<font></font>                 }<font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font> <font></font>                 if (IsLastBar)<font></font>                     UpdateLastBar(index);<font></font>             }<font></font>         }<font></font> <font></font>         private void ProcessMarketData(T_OLHCV ___OLHCV)<font></font>         {<font></font>             int rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);<font></font>             while (true)<font></font>             {<font></font>                 if ((rb_return >= 1) && (rb_return <= 4))<font></font>                 {<font></font>                     pushBars(cOLHCV, IsRealTime);<font></font>                     memRates.Copy(mOLHCV);<font></font>                     OLHCV.Copy(memRates);<font></font> <font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font> <font></font>                     rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);<font></font>                     continue;<font></font> <font></font>                 }<font></font>                 else if (rb_return == 10)<font></font>                 {<font></font>                     memRates.Copy(mOLHCV);<font></font>                     break;<font></font>                 }<font></font>                 else if (rb_return == -1)<font></font>                 {<font></font>                     return;<font></font>                 }<font></font>                 else<font></font>                 {<font></font>                     throw new Exception("Unhandled return value = " + rb_return);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsLastBar && !IsRealTime)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font>         }<font></font> <font></font>         private bool IsNewSession(DateTime prevTime, DateTime currTime)<font></font>         {<font></font>             if (prevTime.DayOfWeek != currTime.DayOfWeek)<font></font>                 return true;<font></font>             else<font></font>                 return false;<font></font>         }<font></font> <font></font> <font></font>     }<font></font> }<font></font> <font></font>
renko
  1
  0
  75
free  11 Dec 2022
using cAlgo.API;<font></font> using cAlgo.API.Indicators;<font></font> using cAlgo.API.Internals;<font></font> using cAlgo.Indicators;<font></font> using System;<font></font> using System.Collections.Generic;<font></font> using System.Linq;<font></font> using System.Windows.Forms;<font></font> using System.Runtime.InteropServices;<font></font> using System.Diagnostics;<font></font> using cT_MedianRenkoEngine;<font></font> <font></font> namespace cAlgo<font></font> {<font></font>     [Indicator("MedianRenko", IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]<font></font>     public class MedianRenko : Indicator<font></font>     {<font></font>         [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]<font></font>         public double BarSizePips { get; set; }<font></font> <font></font>         [Parameter("Retracement factor (0.01 - 1.00)", DefaultValue = 0.5, MinValue = 0.01, MaxValue = 1.0, Step = 0.01)]<font></font>         public double Retracement { get; set; }<font></font> <font></font>         [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]<font></font>         public int BricksToShow { get; set; }<font></font> <font></font>         [Parameter("Symmetrical Reversals", DefaultValue = true)]<font></font>         public bool SymmetricalReversals { get; set; }<font></font> <font></font>         [Parameter("Reset Open on new trading day", DefaultValue = false)]<font></font>         public bool ResetOpenOnNewTradingDay { get; set; }<font></font> <font></font>         [Parameter("Apply offset to first renko bar", DefaultValue = false)]<font></font>         public bool ApplyOffsetToFirstBar { get; set; }<font></font> <font></font>         [Parameter("Tick offset value", DefaultValue = 0, MinValue = 0)]<font></font>         public int OffsetValue { get; set; }<font></font> <font></font>         [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]<font></font>         public string ColorBull { get; set; }<font></font> <font></font>         [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]<font></font>         public string ColorBear { get; set; }<font></font> <font></font>         [Output("Open", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Open { get; set; }<font></font> <font></font>         [Output("High", Color = Colors.DimGray, Thickness = 1, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries High { get; set; }<font></font> <font></font>         [Output("Low", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Low { get; set; }<font></font> <font></font>         [Output("Close", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Close { get; set; }<font></font> <font></font>         private MedianRenkoCore core = null;<font></font>         private bool coreOK = true;<font></font> <font></font>         private DateTime lastTime;<font></font> <font></font>         private bool appliedOffset = false;<font></font> <font></font>         private T_OLHCV pOLHCV;<font></font>         private T_OLHCV OLHCV;<font></font>         private T_OLHCV mOLHCV;<font></font>         private T_OLHCV cOLHCV;<font></font>         private T_OLHCV memRates;<font></font>         private T_OLHCV lastBar;<font></font> <font></font>         private List<T_OLHCV> bars = new List<T_OLHCV>();<font></font>         private double barSize;<font></font>         private Colors colorBull, colorBear;<font></font> <font></font>         protected override void Initialize()<font></font>         {<font></font>             core = new MedianRenkoCore();<font></font>             coreOK = core.StatusCheck();<font></font> <font></font>             barSize = BarSizePips * Symbol.PipSize;<font></font> <font></font>             lastTime = new DateTime();<font></font>             lastTime = MarketSeries.OpenTime[MarketSeries.Close.Count - 1];<font></font> <font></font>             lastBar = new T_OLHCV();<font></font>             pOLHCV = new T_OLHCV();<font></font>             OLHCV = new T_OLHCV();<font></font>             mOLHCV = new T_OLHCV();<font></font>             cOLHCV = new T_OLHCV();<font></font>             memRates = new T_OLHCV();<font></font> <font></font>             if (!Enum.TryParse<Colors>(ColorBull, out colorBull))<font></font>             {<font></font>                 colorBull = Colors.SeaGreen;<font></font>             }<font></font>             if (!Enum.TryParse<Colors>(ColorBear, out colorBear))<font></font>             {<font></font>                 colorBear = Colors.Tomato;<font></font>             }<font></font> <font></font>             appliedOffset = false;<font></font>         }<font></font> <font></font>         private bool NewBar(int index)<font></font>         {<font></font>             if (lastTime != MarketSeries.OpenTime[index])<font></font>             {<font></font>                 lastTime = MarketSeries.OpenTime[index];<font></font>                 return true;<font></font>             }<font></font> <font></font>             return false;<font></font>         }<font></font> <font></font>         private static int cc = 0;<font></font>         private void pushBars(T_OLHCV bar, bool display)<font></font>         {<font></font>             int count = bars.Count();<font></font> <font></font>             var newBar = new T_OLHCV();<font></font>             newBar.Copy(bar);<font></font>             newBar.Index = cc++;<font></font> <font></font>             bars.Insert(0, newBar);<font></font>             count++;<font></font> <font></font>             if (display)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font> <font></font>             if (count > BricksToShow)<font></font>             {<font></font>                 if (display)<font></font>                 {<font></font>                     for (int i = BricksToShow - 1; i < count; i++)<font></font>                     {<font></font>                         ChartObjects.RemoveObject("mr_Wick_" + bars[i].Index);<font></font>                         ChartObjects.RemoveObject("mr_Bar_" + bars[i].Index);<font></font>                     }<font></font>                 }<font></font> <font></font>                 bars.RemoveRange(BricksToShow, count - BricksToShow);<font></font> <font></font>                 Open[count - BricksToShow] = double.NaN;<font></font>                 High[count - BricksToShow] = double.NaN;<font></font>                 Low[count - BricksToShow] = double.NaN;<font></font>                 Close[count - BricksToShow] = double.NaN;<font></font>             }<font></font> <font></font>         }<font></font> <font></font>         private void shiftBars(int shift)<font></font>         {<font></font>             int count = bars.Count;<font></font>             int ix = MarketSeries.Close.Count - 2;<font></font> <font></font>             for (int i = 0; i < count && i < BricksToShow; i++)<font></font>             {<font></font>                 var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;<font></font> <font></font>                 ChartObjects.DrawLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);<font></font>                 ChartObjects.DrawLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>                 Open[ix] = bars[i].Open;<font></font>                 High[ix] = bars[i].High;<font></font>                 Low[ix] = bars[i].Low;<font></font>                 Close[ix] = bars[i].Close;<font></font> <font></font>                 ix--;<font></font>             }<font></font>         }<font></font> <font></font>         private void UpdateLastBar(int ix)<font></font>         {<font></font>             var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;<font></font> <font></font>             ChartObjects.DrawLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);<font></font>             ChartObjects.DrawLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>             Open[ix] = memRates.Open;<font></font>             High[ix] = memRates.High;<font></font>             Low[ix] = memRates.Low;<font></font>             Close[ix] = memRates.Close;<font></font> <font></font>         }<font></font> <font></font>         public override void Calculate(int index)<font></font>         {<font></font>             if (ResetOpenOnNewTradingDay)<font></font>             {<font></font>                 if (IsNewSession(MarketSeries.OpenTime[(index > 0) ? (index - 1) : index], MarketSeries.OpenTime[index]))<font></font>                 {<font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font>                     pOLHCV.Clear();<font></font>                     memRates.Copy(mOLHCV);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsRealTime)<font></font>             {<font></font>                 if (!coreOK)<font></font>                 {<font></font>                     ChartObjects.DrawText("TrialOverMsg", "MedianRenko Indicator - Trial period ended. Please purchase a license file at www.az-invest.eu", StaticPosition.Center, Colors.White);<font></font>                     return;<font></font>                 }<font></font> <font></font>                 if (NewBar(index))<font></font>                 {<font></font>                     shiftBars(0);<font></font> <font></font>                     Open[index - BricksToShow - 1] = double.NaN;<font></font>                     High[index - BricksToShow - 1] = double.NaN;<font></font>                     Low[index - BricksToShow - 1] = double.NaN;<font></font>                     Close[index - BricksToShow - 1] = double.NaN;<font></font>                 }<font></font> <font></font>                 OLHCV.Open = MarketSeries.Close[index];<font></font>                 OLHCV.Low = MarketSeries.Close[index];<font></font>                 OLHCV.High = MarketSeries.Close[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = 1;<font></font> <font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font>                 UpdateLastBar(index);<font></font>             }<font></font>             else<font></font>             {<font></font>                 OLHCV.Open = MarketSeries.Open[index];<font></font>                 OLHCV.Low = MarketSeries.Low[index];<font></font>                 OLHCV.High = MarketSeries.High[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = MarketSeries.TickVolume[index];<font></font> <font></font>                 if (ApplyOffsetToFirstBar && !appliedOffset)<font></font>                 {<font></font>                     OLHCV.Open = OffsetValue * Symbol.TickSize + Math.Floor(OLHCV.Open / barSize) * barSize;<font></font>                     appliedOffset = true;<font></font>                 }<font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font> <font></font>                 if (IsLastBar)<font></font>                     UpdateLastBar(index);<font></font>             }<font></font>         }<font></font> <font></font>         private void ProcessMarketData(T_OLHCV ___OLHCV)<font></font>         {<font></font>             int rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);<font></font>             while (true)<font></font>             {<font></font>                 if ((rb_return >= 1) && (rb_return <= 4))<font></font>                 {<font></font>                     pushBars(cOLHCV, IsRealTime);<font></font>                     memRates.Copy(mOLHCV);<font></font>                     OLHCV.Copy(memRates);<font></font> <font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font> <font></font>                     rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);<font></font>                     continue;<font></font> <font></font>                 }<font></font>                 else if (rb_return == 10)<font></font>                 {<font></font>                     memRates.Copy(mOLHCV);<font></font>                     break;<font></font>                 }<font></font>                 else if (rb_return == -1)<font></font>                 {<font></font>                     return;<font></font>                 }<font></font>                 else<font></font>                 {<font></font>                     throw new Exception("Unhandled return value = " + rb_return);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsLastBar && !IsRealTime)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font>         }<font></font> <font></font>         private bool IsNewSession(DateTime prevTime, DateTime currTime)<font></font>         {<font></font>             if (prevTime.DayOfWeek != currTime.DayOfWeek)<font></font>                 return true;<font></font>             else<font></font>                 return false;<font></font>         }<font></font> <font></font> <font></font>     }<font></font> }<font></font> <font></font>
renko
  3
  0
  86
free  11 Dec 2022
using cAlgo.API;<font></font> using cAlgo.API.Indicators;<font></font> using cAlgo.API.Internals;<font></font> using cAlgo.Indicators;<font></font> using System;<font></font> using System.Collections.Generic;<font></font> using System.Linq;<font></font> using System.Windows.Forms;<font></font> using System.Runtime.InteropServices;<font></font> using System.Diagnostics;<font></font> using cT_MedianRenkoEngine;<font></font> <font></font> namespace cAlgo<font></font> {<font></font>     [Indicator("MedianRenko", IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]<font></font>     public class MedianRenko : Indicator<font></font>     {<font></font>         [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]<font></font>         public double BarSizePips { get; set; }<font></font> <font></font>         [Parameter("Retracement factor (0.01 - 1.00)", DefaultValue = 0.5, MinValue = 0.01, MaxValue = 1.0, Step = 0.01)]<font></font>         public double Retracement { get; set; }<font></font> <font></font>         [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]<font></font>         public int BricksToShow { get; set; }<font></font> <font></font>         [Parameter("Symmetrical Reversals", DefaultValue = true)]<font></font>         public bool SymmetricalReversals { get; set; }<font></font> <font></font>         [Parameter("Reset Open on new trading day", DefaultValue = false)]<font></font>         public bool ResetOpenOnNewTradingDay { get; set; }<font></font> <font></font>         [Parameter("Apply offset to first renko bar", DefaultValue = false)]<font></font>         public bool ApplyOffsetToFirstBar { get; set; }<font></font> <font></font>         [Parameter("Tick offset value", DefaultValue = 0, MinValue = 0)]<font></font>         public int OffsetValue { get; set; }<font></font> <font></font>         [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]<font></font>         public string ColorBull { get; set; }<font></font> <font></font>         [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]<font></font>         public string ColorBear { get; set; }<font></font> <font></font>         [Output("Open", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Open { get; set; }<font></font> <font></font>         [Output("High", Color = Colors.DimGray, Thickness = 1, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries High { get; set; }<font></font> <font></font>         [Output("Low", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Low { get; set; }<font></font> <font></font>         [Output("Close", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Close { get; set; }<font></font> <font></font>         private MedianRenkoCore core = null;<font></font>         private bool coreOK = true;<font></font> <font></font>         private DateTime lastTime;<font></font> <font></font>         private bool appliedOffset = false;<font></font> <font></font>         private T_OLHCV pOLHCV;<font></font>         private T_OLHCV OLHCV;<font></font>         private T_OLHCV mOLHCV;<font></font>         private T_OLHCV cOLHCV;<font></font>         private T_OLHCV memRates;<font></font>         private T_OLHCV lastBar;<font></font> <font></font>         private List<T_OLHCV> bars = new List<T_OLHCV>();<font></font>         private double barSize;<font></font>         private Colors colorBull, colorBear;<font></font> <font></font>         protected override void Initialize()<font></font>         {<font></font>             core = new MedianRenkoCore();<font></font>             coreOK = core.StatusCheck();<font></font> <font></font>             barSize = BarSizePips * Symbol.PipSize;<font></font> <font></font>             lastTime = new DateTime();<font></font>             lastTime = MarketSeries.OpenTime[MarketSeries.Close.Count - 1];<font></font> <font></font>             lastBar = new T_OLHCV();<font></font>             pOLHCV = new T_OLHCV();<font></font>             OLHCV = new T_OLHCV();<font></font>             mOLHCV = new T_OLHCV();<font></font>             cOLHCV = new T_OLHCV();<font></font>             memRates = new T_OLHCV();<font></font> <font></font>             if (!Enum.TryParse<Colors>(ColorBull, out colorBull))<font></font>             {<font></font>                 colorBull = Colors.SeaGreen;<font></font>             }<font></font>             if (!Enum.TryParse<Colors>(ColorBear, out colorBear))<font></font>             {<font></font>                 colorBear = Colors.Tomato;<font></font>             }<font></font> <font></font>             appliedOffset = false;<font></font>         }<font></font> <font></font>         private bool NewBar(int index)<font></font>         {<font></font>             if (lastTime != MarketSeries.OpenTime[index])<font></font>             {<font></font>                 lastTime = MarketSeries.OpenTime[index];<font></font>                 return true;<font></font>             }<font></font> <font></font>             return false;<font></font>         }<font></font> <font></font>         private static int cc = 0;<font></font>         private void pushBars(T_OLHCV bar, bool display)<font></font>         {<font></font>             int count = bars.Count();<font></font> <font></font>             var newBar = new T_OLHCV();<font></font>             newBar.Copy(bar);<font></font>             newBar.Index = cc++;<font></font> <font></font>             bars.Insert(0, newBar);<font></font>             count++;<font></font> <font></font>             if (display)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font> <font></font>             if (count > BricksToShow)<font></font>             {<font></font>                 if (display)<font></font>                 {<font></font>                     for (int i = BricksToShow - 1; i < count; i++)<font></font>                     {<font></font>                         ChartObjects.RemoveObject("mr_Wick_" + bars[i].Index);<font></font>                         ChartObjects.RemoveObject("mr_Bar_" + bars[i].Index);<font></font>                     }<font></font>                 }<font></font> <font></font>                 bars.RemoveRange(BricksToShow, count - BricksToShow);<font></font> <font></font>                 Open[count - BricksToShow] = double.NaN;<font></font>                 High[count - BricksToShow] = double.NaN;<font></font>                 Low[count - BricksToShow] = double.NaN;<font></font>                 Close[count - BricksToShow] = double.NaN;<font></font>             }<font></font> <font></font>         }<font></font> <font></font>         private void shiftBars(int shift)<font></font>         {<font></font>             int count = bars.Count;<font></font>             int ix = MarketSeries.Close.Count - 2;<font></font> <font></font>             for (int i = 0; i < count && i < BricksToShow; i++)<font></font>             {<font></font>                 var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;<font></font> <font></font>                 ChartObjects.DrawLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);<font></font>                 ChartObjects.DrawLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>                 Open[ix] = bars[i].Open;<font></font>                 High[ix] = bars[i].High;<font></font>                 Low[ix] = bars[i].Low;<font></font>                 Close[ix] = bars[i].Close;<font></font> <font></font>                 ix--;<font></font>             }<font></font>         }<font></font> <font></font>         private void UpdateLastBar(int ix)<font></font>         {<font></font>             var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;<font></font> <font></font>             ChartObjects.DrawLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);<font></font>             ChartObjects.DrawLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>             Open[ix] = memRates.Open;<font></font>             High[ix] = memRates.High;<font></font>             Low[ix] = memRates.Low;<font></font>             Close[ix] = memRates.Close;<font></font> <font></font>         }<font></font> <font></font>         public override void Calculate(int index)<font></font>         {<font></font>             if (ResetOpenOnNewTradingDay)<font></font>             {<font></font>                 if (IsNewSession(MarketSeries.OpenTime[(index > 0) ? (index - 1) : index], MarketSeries.OpenTime[index]))<font></font>                 {<font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font>                     pOLHCV.Clear();<font></font>                     memRates.Copy(mOLHCV);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsRealTime)<font></font>             {<font></font>                 if (!coreOK)<font></font>                 {<font></font>                     ChartObjects.DrawText("TrialOverMsg", "MedianRenko Indicator - Trial period ended. Please purchase a license file at www.az-invest.eu", StaticPosition.Center, Colors.White);<font></font>                     return;<font></font>                 }<font></font> <font></font>                 if (NewBar(index))<font></font>                 {<font></font>                     shiftBars(0);<font></font> <font></font>                     Open[index - BricksToShow - 1] = double.NaN;<font></font>                     High[index - BricksToShow - 1] = double.NaN;<font></font>                     Low[index - BricksToShow - 1] = double.NaN;<font></font>                     Close[index - BricksToShow - 1] = double.NaN;<font></font>                 }<font></font> <font></font>                 OLHCV.Open = MarketSeries.Close[index];<font></font>                 OLHCV.Low = MarketSeries.Close[index];<font></font>                 OLHCV.High = MarketSeries.Close[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = 1;<font></font> <font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font>                 UpdateLastBar(index);<font></font>             }<font></font>             else<font></font>             {<font></font>                 OLHCV.Open = MarketSeries.Open[index];<font></font>                 OLHCV.Low = MarketSeries.Low[index];<font></font>                 OLHCV.High = MarketSeries.High[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = MarketSeries.TickVolume[index];<font></font> <font></font>                 if (ApplyOffsetToFirstBar && !appliedOffset)<font></font>                 {<font></font>                     OLHCV.Open = OffsetValue * Symbol.TickSize + Math.Floor(OLHCV.Open / barSize) * barSize;<font></font>                     appliedOffset = true;<font></font>                 }<font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font> <font></font>                 if (IsLastBar)<font></font>                     UpdateLastBar(index);<font></font>             }<font></font>         }<font></font> <font></font>         private void ProcessMarketData(T_OLHCV ___OLHCV)<font></font>         {<font></font>             int rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);<font></font>             while (true)<font></font>             {<font></font>                 if ((rb_return >= 1) && (rb_return <= 4))<font></font>                 {<font></font>                     pushBars(cOLHCV, IsRealTime);<font></font>                     memRates.Copy(mOLHCV);<font></font>                     OLHCV.Copy(memRates);<font></font> <font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font> <font></font>                     rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);<font></font>                     continue;<font></font> <font></font>                 }<font></font>                 else if (rb_return == 10)<font></font>                 {<font></font>                     memRates.Copy(mOLHCV);<font></font>                     break;<font></font>                 }<font></font>                 else if (rb_return == -1)<font></font>                 {<font></font>                     return;<font></font>                 }<font></font>                 else<font></font>                 {<font></font>                     throw new Exception("Unhandled return value = " + rb_return);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsLastBar && !IsRealTime)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font>         }<font></font> <font></font>         private bool IsNewSession(DateTime prevTime, DateTime currTime)<font></font>         {<font></font>             if (prevTime.DayOfWeek != currTime.DayOfWeek)<font></font>                 return true;<font></font>             else<font></font>                 return false;<font></font>         }<font></font> <font></font> <font></font>     }<font></font> }<font></font> <font></font>
renko
  0
  0
  81
free  11 Dec 2022
using cAlgo.API;<font></font> using cAlgo.API.Indicators;<font></font> using cAlgo.API.Internals;<font></font> using cAlgo.Indicators;<font></font> using System;<font></font> using System.Collections.Generic;<font></font> using System.Linq;<font></font> using System.Windows.Forms;<font></font> using System.Runtime.InteropServices;<font></font> using System.Diagnostics;<font></font> using cT_MedianRenkoEngine;<font></font> <font></font> namespace cAlgo<font></font> {<font></font>     [Indicator("MedianRenko", IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]<font></font>     public class MedianRenko : Indicator<font></font>     {<font></font>         [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]<font></font>         public double BarSizePips { get; set; }<font></font> <font></font>         [Parameter("Retracement factor (0.01 - 1.00)", DefaultValue = 0.5, MinValue = 0.01, MaxValue = 1.0, Step = 0.01)]<font></font>         public double Retracement { get; set; }<font></font> <font></font>         [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]<font></font>         public int BricksToShow { get; set; }<font></font> <font></font>         [Parameter("Symmetrical Reversals", DefaultValue = true)]<font></font>         public bool SymmetricalReversals { get; set; }<font></font> <font></font>         [Parameter("Reset Open on new trading day", DefaultValue = false)]<font></font>         public bool ResetOpenOnNewTradingDay { get; set; }<font></font> <font></font>         [Parameter("Apply offset to first renko bar", DefaultValue = false)]<font></font>         public bool ApplyOffsetToFirstBar { get; set; }<font></font> <font></font>         [Parameter("Tick offset value", DefaultValue = 0, MinValue = 0)]<font></font>         public int OffsetValue { get; set; }<font></font> <font></font>         [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]<font></font>         public string ColorBull { get; set; }<font></font> <font></font>         [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]<font></font>         public string ColorBear { get; set; }<font></font> <font></font>         [Output("Open", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Open { get; set; }<font></font> <font></font>         [Output("High", Color = Colors.DimGray, Thickness = 1, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries High { get; set; }<font></font> <font></font>         [Output("Low", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Low { get; set; }<font></font> <font></font>         [Output("Close", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Close { get; set; }<font></font> <font></font>         private MedianRenkoCore core = null;<font></font>         private bool coreOK = true;<font></font> <font></font>         private DateTime lastTime;<font></font> <font></font>         private bool appliedOffset = false;<font></font> <font></font>         private T_OLHCV pOLHCV;<font></font>         private T_OLHCV OLHCV;<font></font>         private T_OLHCV mOLHCV;<font></font>         private T_OLHCV cOLHCV;<font></font>         private T_OLHCV memRates;<font></font>         private T_OLHCV lastBar;<font></font> <font></font>         private List<T_OLHCV> bars = new List<T_OLHCV>();<font></font>         private double barSize;<font></font>         private Colors colorBull, colorBear;<font></font> <font></font>         protected override void Initialize()<font></font>         {<font></font>             core = new MedianRenkoCore();<font></font>             coreOK = core.StatusCheck();<font></font> <font></font>             barSize = BarSizePips * Symbol.PipSize;<font></font> <font></font>             lastTime = new DateTime();<font></font>             lastTime = MarketSeries.OpenTime[MarketSeries.Close.Count - 1];<font></font> <font></font>             lastBar = new T_OLHCV();<font></font>             pOLHCV = new T_OLHCV();<font></font>             OLHCV = new T_OLHCV();<font></font>             mOLHCV = new T_OLHCV();<font></font>             cOLHCV = new T_OLHCV();<font></font>             memRates = new T_OLHCV();<font></font> <font></font>             if (!Enum.TryParse<Colors>(ColorBull, out colorBull))<font></font>             {<font></font>                 colorBull = Colors.SeaGreen;<font></font>             }<font></font>             if (!Enum.TryParse<Colors>(ColorBear, out colorBear))<font></font>             {<font></font>                 colorBear = Colors.Tomato;<font></font>             }<font></font> <font></font>             appliedOffset = false;<font></font>         }<font></font> <font></font>         private bool NewBar(int index)<font></font>         {<font></font>             if (lastTime != MarketSeries.OpenTime[index])<font></font>             {<font></font>                 lastTime = MarketSeries.OpenTime[index];<font></font>                 return true;<font></font>             }<font></font> <font></font>             return false;<font></font>         }<font></font> <font></font>         private static int cc = 0;<font></font>         private void pushBars(T_OLHCV bar, bool display)<font></font>         {<font></font>             int count = bars.Count();<font></font> <font></font>             var newBar = new T_OLHCV();<font></font>             newBar.Copy(bar);<font></font>             newBar.Index = cc++;<font></font> <font></font>             bars.Insert(0, newBar);<font></font>             count++;<font></font> <font></font>             if (display)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font> <font></font>             if (count > BricksToShow)<font></font>             {<font></font>                 if (display)<font></font>                 {<font></font>                     for (int i = BricksToShow - 1; i < count; i++)<font></font>                     {<font></font>                         ChartObjects.RemoveObject("mr_Wick_" + bars[i].Index);<font></font>                         ChartObjects.RemoveObject("mr_Bar_" + bars[i].Index);<font></font>                     }<font></font>                 }<font></font> <font></font>                 bars.RemoveRange(BricksToShow, count - BricksToShow);<font></font> <font></font>                 Open[count - BricksToShow] = double.NaN;<font></font>                 High[count - BricksToShow] = double.NaN;<font></font>                 Low[count - BricksToShow] = double.NaN;<font></font>                 Close[count - BricksToShow] = double.NaN;<font></font>             }<font></font> <font></font>         }<font></font> <font></font>         private void shiftBars(int shift)<font></font>         {<font></font>             int count = bars.Count;<font></font>             int ix = MarketSeries.Close.Count - 2;<font></font> <font></font>             for (int i = 0; i < count && i < BricksToShow; i++)<font></font>             {<font></font>                 var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;<font></font> <font></font>                 ChartObjects.DrawLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);<font></font>                 ChartObjects.DrawLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>                 Open[ix] = bars[i].Open;<font></font>                 High[ix] = bars[i].High;<font></font>                 Low[ix] = bars[i].Low;<font></font>                 Close[ix] = bars[i].Close;<font></font> <font></font>                 ix--;<font></font>             }<font></font>         }<font></font> <font></font>         private void UpdateLastBar(int ix)<font></font>         {<font></font>             var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;<font></font> <font></font>             ChartObjects.DrawLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);<font></font>             ChartObjects.DrawLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>             Open[ix] = memRates.Open;<font></font>             High[ix] = memRates.High;<font></font>             Low[ix] = memRates.Low;<font></font>             Close[ix] = memRates.Close;<font></font> <font></font>         }<font></font> <font></font>         public override void Calculate(int index)<font></font>         {<font></font>             if (ResetOpenOnNewTradingDay)<font></font>             {<font></font>                 if (IsNewSession(MarketSeries.OpenTime[(index > 0) ? (index - 1) : index], MarketSeries.OpenTime[index]))<font></font>                 {<font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font>                     pOLHCV.Clear();<font></font>                     memRates.Copy(mOLHCV);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsRealTime)<font></font>             {<font></font>                 if (!coreOK)<font></font>                 {<font></font>                     ChartObjects.DrawText("TrialOverMsg", "MedianRenko Indicator - Trial period ended. Please purchase a license file at www.az-invest.eu", StaticPosition.Center, Colors.White);<font></font>                     return;<font></font>                 }<font></font> <font></font>                 if (NewBar(index))<font></font>                 {<font></font>                     shiftBars(0);<font></font> <font></font>                     Open[index - BricksToShow - 1] = double.NaN;<font></font>                     High[index - BricksToShow - 1] = double.NaN;<font></font>                     Low[index - BricksToShow - 1] = double.NaN;<font></font>                     Close[index - BricksToShow - 1] = double.NaN;<font></font>                 }<font></font> <font></font>                 OLHCV.Open = MarketSeries.Close[index];<font></font>                 OLHCV.Low = MarketSeries.Close[index];<font></font>                 OLHCV.High = MarketSeries.Close[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = 1;<font></font> <font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font>                 UpdateLastBar(index);<font></font>             }<font></font>             else<font></font>             {<font></font>                 OLHCV.Open = MarketSeries.Open[index];<font></font>                 OLHCV.Low = MarketSeries.Low[index];<font></font>                 OLHCV.High = MarketSeries.High[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = MarketSeries.TickVolume[index];<font></font> <font></font>                 if (ApplyOffsetToFirstBar && !appliedOffset)<font></font>                 {<font></font>                     OLHCV.Open = OffsetValue * Symbol.TickSize + Math.Floor(OLHCV.Open / barSize) * barSize;<font></font>                     appliedOffset = true;<font></font>                 }<font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font> <font></font>                 if (IsLastBar)<font></font>                     UpdateLastBar(index);<font></font>             }<font></font>         }<font></font> <font></font>         private void ProcessMarketData(T_OLHCV ___OLHCV)<font></font>         {<font></font>             int rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);<font></font>             while (true)<font></font>             {<font></font>                 if ((rb_return >= 1) && (rb_return <= 4))<font></font>                 {<font></font>                     pushBars(cOLHCV, IsRealTime);<font></font>                     memRates.Copy(mOLHCV);<font></font>                     OLHCV.Copy(memRates);<font></font> <font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font> <font></font>                     rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);<font></font>                     continue;<font></font> <font></font>                 }<font></font>                 else if (rb_return == 10)<font></font>                 {<font></font>                     memRates.Copy(mOLHCV);<font></font>                     break;<font></font>                 }<font></font>                 else if (rb_return == -1)<font></font>                 {<font></font>                     return;<font></font>                 }<font></font>                 else<font></font>                 {<font></font>                     throw new Exception("Unhandled return value = " + rb_return);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsLastBar && !IsRealTime)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font>         }<font></font> <font></font>         private bool IsNewSession(DateTime prevTime, DateTime currTime)<font></font>         {<font></font>             if (prevTime.DayOfWeek != currTime.DayOfWeek)<font></font>                 return true;<font></font>             else<font></font>                 return false;<font></font>         }<font></font> <font></font> <font></font>     }<font></font> }<font></font> <font></font>
renko
  1
  0
  66
free  11 Dec 2022
using cAlgo.API;<font></font> using cAlgo.API.Indicators;<font></font> using cAlgo.API.Internals;<font></font> using cAlgo.Indicators;<font></font> using System;<font></font> using System.Collections.Generic;<font></font> using System.Linq;<font></font> using System.Windows.Forms;<font></font> using System.Runtime.InteropServices;<font></font> using System.Diagnostics;<font></font> using cT_MedianRenkoEngine;<font></font> <font></font> namespace cAlgo<font></font> {<font></font>     [Indicator("MedianRenko", IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]<font></font>     public class MedianRenko : Indicator<font></font>     {<font></font>         [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]<font></font>         public double BarSizePips { get; set; }<font></font> <font></font>         [Parameter("Retracement factor (0.01 - 1.00)", DefaultValue = 0.5, MinValue = 0.01, MaxValue = 1.0, Step = 0.01)]<font></font>         public double Retracement { get; set; }<font></font> <font></font>         [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]<font></font>         public int BricksToShow { get; set; }<font></font> <font></font>         [Parameter("Symmetrical Reversals", DefaultValue = true)]<font></font>         public bool SymmetricalReversals { get; set; }<font></font> <font></font>         [Parameter("Reset Open on new trading day", DefaultValue = false)]<font></font>         public bool ResetOpenOnNewTradingDay { get; set; }<font></font> <font></font>         [Parameter("Apply offset to first renko bar", DefaultValue = false)]<font></font>         public bool ApplyOffsetToFirstBar { get; set; }<font></font> <font></font>         [Parameter("Tick offset value", DefaultValue = 0, MinValue = 0)]<font></font>         public int OffsetValue { get; set; }<font></font> <font></font>         [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]<font></font>         public string ColorBull { get; set; }<font></font> <font></font>         [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]<font></font>         public string ColorBear { get; set; }<font></font> <font></font>         [Output("Open", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Open { get; set; }<font></font> <font></font>         [Output("High", Color = Colors.DimGray, Thickness = 1, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries High { get; set; }<font></font> <font></font>         [Output("Low", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Low { get; set; }<font></font> <font></font>         [Output("Close", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Close { get; set; }<font></font> <font></font>         private MedianRenkoCore core = null;<font></font>         private bool coreOK = true;<font></font> <font></font>         private DateTime lastTime;<font></font> <font></font>         private bool appliedOffset = false;<font></font> <font></font>         private T_OLHCV pOLHCV;<font></font>         private T_OLHCV OLHCV;<font></font>         private T_OLHCV mOLHCV;<font></font>         private T_OLHCV cOLHCV;<font></font>         private T_OLHCV memRates;<font></font>         private T_OLHCV lastBar;<font></font> <font></font>         private List<T_OLHCV> bars = new List<T_OLHCV>();<font></font>         private double barSize;<font></font>         private Colors colorBull, colorBear;<font></font> <font></font>         protected override void Initialize()<font></font>         {<font></font>             core = new MedianRenkoCore();<font></font>             coreOK = core.StatusCheck();<font></font> <font></font>             barSize = BarSizePips * Symbol.PipSize;<font></font> <font></font>             lastTime = new DateTime();<font></font>             lastTime = MarketSeries.OpenTime[MarketSeries.Close.Count - 1];<font></font> <font></font>             lastBar = new T_OLHCV();<font></font>             pOLHCV = new T_OLHCV();<font></font>             OLHCV = new T_OLHCV();<font></font>             mOLHCV = new T_OLHCV();<font></font>             cOLHCV = new T_OLHCV();<font></font>             memRates = new T_OLHCV();<font></font> <font></font>             if (!Enum.TryParse<Colors>(ColorBull, out colorBull))<font></font>             {<font></font>                 colorBull = Colors.SeaGreen;<font></font>             }<font></font>             if (!Enum.TryParse<Colors>(ColorBear, out colorBear))<font></font>             {<font></font>                 colorBear = Colors.Tomato;<font></font>             }<font></font> <font></font>             appliedOffset = false;<font></font>         }<font></font> <font></font>         private bool NewBar(int index)<font></font>         {<font></font>             if (lastTime != MarketSeries.OpenTime[index])<font></font>             {<font></font>                 lastTime = MarketSeries.OpenTime[index];<font></font>                 return true;<font></font>             }<font></font> <font></font>             return false;<font></font>         }<font></font> <font></font>         private static int cc = 0;<font></font>         private void pushBars(T_OLHCV bar, bool display)<font></font>         {<font></font>             int count = bars.Count();<font></font> <font></font>             var newBar = new T_OLHCV();<font></font>             newBar.Copy(bar);<font></font>             newBar.Index = cc++;<font></font> <font></font>             bars.Insert(0, newBar);<font></font>             count++;<font></font> <font></font>             if (display)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font> <font></font>             if (count > BricksToShow)<font></font>             {<font></font>                 if (display)<font></font>                 {<font></font>                     for (int i = BricksToShow - 1; i < count; i++)<font></font>                     {<font></font>                         ChartObjects.RemoveObject("mr_Wick_" + bars[i].Index);<font></font>                         ChartObjects.RemoveObject("mr_Bar_" + bars[i].Index);<font></font>                     }<font></font>                 }<font></font> <font></font>                 bars.RemoveRange(BricksToShow, count - BricksToShow);<font></font> <font></font>                 Open[count - BricksToShow] = double.NaN;<font></font>                 High[count - BricksToShow] = double.NaN;<font></font>                 Low[count - BricksToShow] = double.NaN;<font></font>                 Close[count - BricksToShow] = double.NaN;<font></font>             }<font></font> <font></font>         }<font></font> <font></font>         private void shiftBars(int shift)<font></font>         {<font></font>             int count = bars.Count;<font></font>             int ix = MarketSeries.Close.Count - 2;<font></font> <font></font>             for (int i = 0; i < count && i < BricksToShow; i++)<font></font>             {<font></font>                 var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;<font></font> <font></font>                 ChartObjects.DrawLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);<font></font>                 ChartObjects.DrawLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>                 Open[ix] = bars[i].Open;<font></font>                 High[ix] = bars[i].High;<font></font>                 Low[ix] = bars[i].Low;<font></font>                 Close[ix] = bars[i].Close;<font></font> <font></font>                 ix--;<font></font>             }<font></font>         }<font></font> <font></font>         private void UpdateLastBar(int ix)<font></font>         {<font></font>             var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;<font></font> <font></font>             ChartObjects.DrawLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);<font></font>             ChartObjects.DrawLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>             Open[ix] = memRates.Open;<font></font>             High[ix] = memRates.High;<font></font>             Low[ix] = memRates.Low;<font></font>             Close[ix] = memRates.Close;<font></font> <font></font>         }<font></font> <font></font>         public override void Calculate(int index)<font></font>         {<font></font>             if (ResetOpenOnNewTradingDay)<font></font>             {<font></font>                 if (IsNewSession(MarketSeries.OpenTime[(index > 0) ? (index - 1) : index], MarketSeries.OpenTime[index]))<font></font>                 {<font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font>                     pOLHCV.Clear();<font></font>                     memRates.Copy(mOLHCV);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsRealTime)<font></font>             {<font></font>                 if (!coreOK)<font></font>                 {<font></font>                     ChartObjects.DrawText("TrialOverMsg", "MedianRenko Indicator - Trial period ended. Please purchase a license file at www.az-invest.eu", StaticPosition.Center, Colors.White);<font></font>                     return;<font></font>                 }<font></font> <font></font>                 if (NewBar(index))<font></font>                 {<font></font>                     shiftBars(0);<font></font> <font></font>                     Open[index - BricksToShow - 1] = double.NaN;<font></font>                     High[index - BricksToShow - 1] = double.NaN;<font></font>                     Low[index - BricksToShow - 1] = double.NaN;<font></font>                     Close[index - BricksToShow - 1] = double.NaN;<font></font>                 }<font></font> <font></font>                 OLHCV.Open = MarketSeries.Close[index];<font></font>                 OLHCV.Low = MarketSeries.Close[index];<font></font>                 OLHCV.High = MarketSeries.Close[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = 1;<font></font> <font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font>                 UpdateLastBar(index);<font></font>             }<font></font>             else<font></font>             {<font></font>                 OLHCV.Open = MarketSeries.Open[index];<font></font>                 OLHCV.Low = MarketSeries.Low[index];<font></font>                 OLHCV.High = MarketSeries.High[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = MarketSeries.TickVolume[index];<font></font> <font></font>                 if (ApplyOffsetToFirstBar && !appliedOffset)<font></font>                 {<font></font>                     OLHCV.Open = OffsetValue * Symbol.TickSize + Math.Floor(OLHCV.Open / barSize) * barSize;<font></font>                     appliedOffset = true;<font></font>                 }<font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font> <font></font>                 if (IsLastBar)<font></font>                     UpdateLastBar(index);<font></font>             }<font></font>         }<font></font> <font></font>         private void ProcessMarketData(T_OLHCV ___OLHCV)<font></font>         {<font></font>             int rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);<font></font>             while (true)<font></font>             {<font></font>                 if ((rb_return >= 1) && (rb_return <= 4))<font></font>                 {<font></font>                     pushBars(cOLHCV, IsRealTime);<font></font>                     memRates.Copy(mOLHCV);<font></font>                     OLHCV.Copy(memRates);<font></font> <font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font> <font></font>                     rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);<font></font>                     continue;<font></font> <font></font>                 }<font></font>                 else if (rb_return == 10)<font></font>                 {<font></font>                     memRates.Copy(mOLHCV);<font></font>                     break;<font></font>                 }<font></font>                 else if (rb_return == -1)<font></font>                 {<font></font>                     return;<font></font>                 }<font></font>                 else<font></font>                 {<font></font>                     throw new Exception("Unhandled return value = " + rb_return);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsLastBar && !IsRealTime)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font>         }<font></font> <font></font>         private bool IsNewSession(DateTime prevTime, DateTime currTime)<font></font>         {<font></font>             if (prevTime.DayOfWeek != currTime.DayOfWeek)<font></font>                 return true;<font></font>             else<font></font>                 return false;<font></font>         }<font></font> <font></font> <font></font>     }<font></font> }<font></font> <font></font>
renko
  0
  0
  77
free  11 Dec 2022
using cAlgo.API;<font></font> using cAlgo.API.Indicators;<font></font> using cAlgo.API.Internals;<font></font> using cAlgo.Indicators;<font></font> using System;<font></font> using System.Collections.Generic;<font></font> using System.Linq;<font></font> using System.Windows.Forms;<font></font> using System.Runtime.InteropServices;<font></font> using System.Diagnostics;<font></font> using cT_MedianRenkoEngine;<font></font> <font></font> namespace cAlgo<font></font> {<font></font>     [Indicator("MedianRenko", IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]<font></font>     public class MedianRenko : Indicator<font></font>     {<font></font>         [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]<font></font>         public double BarSizePips { get; set; }<font></font> <font></font>         [Parameter("Retracement factor (0.01 - 1.00)", DefaultValue = 0.5, MinValue = 0.01, MaxValue = 1.0, Step = 0.01)]<font></font>         public double Retracement { get; set; }<font></font> <font></font>         [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]<font></font>         public int BricksToShow { get; set; }<font></font> <font></font>         [Parameter("Symmetrical Reversals", DefaultValue = true)]<font></font>         public bool SymmetricalReversals { get; set; }<font></font> <font></font>         [Parameter("Reset Open on new trading day", DefaultValue = false)]<font></font>         public bool ResetOpenOnNewTradingDay { get; set; }<font></font> <font></font>         [Parameter("Apply offset to first renko bar", DefaultValue = false)]<font></font>         public bool ApplyOffsetToFirstBar { get; set; }<font></font> <font></font>         [Parameter("Tick offset value", DefaultValue = 0, MinValue = 0)]<font></font>         public int OffsetValue { get; set; }<font></font> <font></font>         [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]<font></font>         public string ColorBull { get; set; }<font></font> <font></font>         [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]<font></font>         public string ColorBear { get; set; }<font></font> <font></font>         [Output("Open", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Open { get; set; }<font></font> <font></font>         [Output("High", Color = Colors.DimGray, Thickness = 1, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries High { get; set; }<font></font> <font></font>         [Output("Low", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Low { get; set; }<font></font> <font></font>         [Output("Close", Color = Colors.DimGray, Thickness = 0, PlotType = PlotType.Points)]<font></font>         public IndicatorDataSeries Close { get; set; }<font></font> <font></font>         private MedianRenkoCore core = null;<font></font>         private bool coreOK = true;<font></font> <font></font>         private DateTime lastTime;<font></font> <font></font>         private bool appliedOffset = false;<font></font> <font></font>         private T_OLHCV pOLHCV;<font></font>         private T_OLHCV OLHCV;<font></font>         private T_OLHCV mOLHCV;<font></font>         private T_OLHCV cOLHCV;<font></font>         private T_OLHCV memRates;<font></font>         private T_OLHCV lastBar;<font></font> <font></font>         private List<T_OLHCV> bars = new List<T_OLHCV>();<font></font>         private double barSize;<font></font>         private Colors colorBull, colorBear;<font></font> <font></font>         protected override void Initialize()<font></font>         {<font></font>             core = new MedianRenkoCore();<font></font>             coreOK = core.StatusCheck();<font></font> <font></font>             barSize = BarSizePips * Symbol.PipSize;<font></font> <font></font>             lastTime = new DateTime();<font></font>             lastTime = MarketSeries.OpenTime[MarketSeries.Close.Count - 1];<font></font> <font></font>             lastBar = new T_OLHCV();<font></font>             pOLHCV = new T_OLHCV();<font></font>             OLHCV = new T_OLHCV();<font></font>             mOLHCV = new T_OLHCV();<font></font>             cOLHCV = new T_OLHCV();<font></font>             memRates = new T_OLHCV();<font></font> <font></font>             if (!Enum.TryParse<Colors>(ColorBull, out colorBull))<font></font>             {<font></font>                 colorBull = Colors.SeaGreen;<font></font>             }<font></font>             if (!Enum.TryParse<Colors>(ColorBear, out colorBear))<font></font>             {<font></font>                 colorBear = Colors.Tomato;<font></font>             }<font></font> <font></font>             appliedOffset = false;<font></font>         }<font></font> <font></font>         private bool NewBar(int index)<font></font>         {<font></font>             if (lastTime != MarketSeries.OpenTime[index])<font></font>             {<font></font>                 lastTime = MarketSeries.OpenTime[index];<font></font>                 return true;<font></font>             }<font></font> <font></font>             return false;<font></font>         }<font></font> <font></font>         private static int cc = 0;<font></font>         private void pushBars(T_OLHCV bar, bool display)<font></font>         {<font></font>             int count = bars.Count();<font></font> <font></font>             var newBar = new T_OLHCV();<font></font>             newBar.Copy(bar);<font></font>             newBar.Index = cc++;<font></font> <font></font>             bars.Insert(0, newBar);<font></font>             count++;<font></font> <font></font>             if (display)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font> <font></font>             if (count > BricksToShow)<font></font>             {<font></font>                 if (display)<font></font>                 {<font></font>                     for (int i = BricksToShow - 1; i < count; i++)<font></font>                     {<font></font>                         ChartObjects.RemoveObject("mr_Wick_" + bars[i].Index);<font></font>                         ChartObjects.RemoveObject("mr_Bar_" + bars[i].Index);<font></font>                     }<font></font>                 }<font></font> <font></font>                 bars.RemoveRange(BricksToShow, count - BricksToShow);<font></font> <font></font>                 Open[count - BricksToShow] = double.NaN;<font></font>                 High[count - BricksToShow] = double.NaN;<font></font>                 Low[count - BricksToShow] = double.NaN;<font></font>                 Close[count - BricksToShow] = double.NaN;<font></font>             }<font></font> <font></font>         }<font></font> <font></font>         private void shiftBars(int shift)<font></font>         {<font></font>             int count = bars.Count;<font></font>             int ix = MarketSeries.Close.Count - 2;<font></font> <font></font>             for (int i = 0; i < count && i < BricksToShow; i++)<font></font>             {<font></font>                 var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;<font></font> <font></font>                 ChartObjects.DrawLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);<font></font>                 ChartObjects.DrawLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>                 Open[ix] = bars[i].Open;<font></font>                 High[ix] = bars[i].High;<font></font>                 Low[ix] = bars[i].Low;<font></font>                 Close[ix] = bars[i].Close;<font></font> <font></font>                 ix--;<font></font>             }<font></font>         }<font></font> <font></font>         private void UpdateLastBar(int ix)<font></font>         {<font></font>             var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;<font></font> <font></font>             ChartObjects.DrawLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);<font></font>             ChartObjects.DrawLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);<font></font> <font></font>             Open[ix] = memRates.Open;<font></font>             High[ix] = memRates.High;<font></font>             Low[ix] = memRates.Low;<font></font>             Close[ix] = memRates.Close;<font></font> <font></font>         }<font></font> <font></font>         public override void Calculate(int index)<font></font>         {<font></font>             if (ResetOpenOnNewTradingDay)<font></font>             {<font></font>                 if (IsNewSession(MarketSeries.OpenTime[(index > 0) ? (index - 1) : index], MarketSeries.OpenTime[index]))<font></font>                 {<font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font>                     pOLHCV.Clear();<font></font>                     memRates.Copy(mOLHCV);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsRealTime)<font></font>             {<font></font>                 if (!coreOK)<font></font>                 {<font></font>                     ChartObjects.DrawText("TrialOverMsg", "MedianRenko Indicator - Trial period ended. Please purchase a license file at www.az-invest.eu", StaticPosition.Center, Colors.White);<font></font>                     return;<font></font>                 }<font></font> <font></font>                 if (NewBar(index))<font></font>                 {<font></font>                     shiftBars(0);<font></font> <font></font>                     Open[index - BricksToShow - 1] = double.NaN;<font></font>                     High[index - BricksToShow - 1] = double.NaN;<font></font>                     Low[index - BricksToShow - 1] = double.NaN;<font></font>                     Close[index - BricksToShow - 1] = double.NaN;<font></font>                 }<font></font> <font></font>                 OLHCV.Open = MarketSeries.Close[index];<font></font>                 OLHCV.Low = MarketSeries.Close[index];<font></font>                 OLHCV.High = MarketSeries.Close[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = 1;<font></font> <font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font>                 UpdateLastBar(index);<font></font>             }<font></font>             else<font></font>             {<font></font>                 OLHCV.Open = MarketSeries.Open[index];<font></font>                 OLHCV.Low = MarketSeries.Low[index];<font></font>                 OLHCV.High = MarketSeries.High[index];<font></font>                 OLHCV.Close = MarketSeries.Close[index];<font></font>                 OLHCV.OpenTime = MarketSeries.OpenTime[index];<font></font>                 OLHCV.TickVolume = MarketSeries.TickVolume[index];<font></font> <font></font>                 if (ApplyOffsetToFirstBar && !appliedOffset)<font></font>                 {<font></font>                     OLHCV.Open = OffsetValue * Symbol.TickSize + Math.Floor(OLHCV.Open / barSize) * barSize;<font></font>                     appliedOffset = true;<font></font>                 }<font></font> <font></font>                 ProcessMarketData(OLHCV);<font></font> <font></font>                 if (IsLastBar)<font></font>                     UpdateLastBar(index);<font></font>             }<font></font>         }<font></font> <font></font>         private void ProcessMarketData(T_OLHCV ___OLHCV)<font></font>         {<font></font>             int rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);<font></font>             while (true)<font></font>             {<font></font>                 if ((rb_return >= 1) && (rb_return <= 4))<font></font>                 {<font></font>                     pushBars(cOLHCV, IsRealTime);<font></font>                     memRates.Copy(mOLHCV);<font></font>                     OLHCV.Copy(memRates);<font></font> <font></font>                     cOLHCV.Clear();<font></font>                     mOLHCV.Clear();<font></font> <font></font>                     rb_return = core.ProcessMedianRenko(barSize, Retracement, SymmetricalReversals, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);<font></font>                     continue;<font></font> <font></font>                 }<font></font>                 else if (rb_return == 10)<font></font>                 {<font></font>                     memRates.Copy(mOLHCV);<font></font>                     break;<font></font>                 }<font></font>                 else if (rb_return == -1)<font></font>                 {<font></font>                     return;<font></font>                 }<font></font>                 else<font></font>                 {<font></font>                     throw new Exception("Unhandled return value = " + rb_return);<font></font>                 }<font></font>             }<font></font> <font></font>             if (IsLastBar && !IsRealTime)<font></font>             {<font></font>                 shiftBars(0);<font></font>             }<font></font>         }<font></font> <font></font>         private bool IsNewSession(DateTime prevTime, DateTime currTime)<font></font>         {<font></font>             if (prevTime.DayOfWeek != currTime.DayOfWeek)<font></font>                 return true;<font></font>             else<font></font>                 return false;<font></font>         }<font></font> <font></font> <font></font>     }<font></font> }<font></font> <font></font>