inside bar + color candle

Created at 04 Feb 2022, 16:28
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CL

clinttraders

Joined 28.06.2019

inside bar + color candle
04 Feb 2022, 16:28


Does anyone have a code available for "inside bar + color candle"?


@clinttraders
Replies

amusleh
07 Feb 2022, 09:26

Hi,

Not sure what do you mean by color candle, but for inside bar calculation you can use this method:

        /// <summary>
        /// Returns True if the index bar is an inside bar
        /// </summary>
        /// <param name="bars"></param>
        /// <param name="index">The bar index number in a market series</param>
        /// <returns>bool</returns>
        private bool IsInsideBar(Bars bars, int index)
        {
            var currentBar = bars[index];
            var previousBar = bars[index - 1];

            var currentBarType = currentBar.Close > currentBar.Open ? 1 : 0;
            var previousBarType = previousBar.Close > previousBar.Open ? 1 : 0;

            return currentBar.High < previousBar.High && currentBar.Low > previousBar.Low && currentBarType != previousBarType;
        }

 


@amusleh