Help with Insidebarindikator

 
Hi everyone,
I am relative new to MQL4 so I need a little help programming a new Indicator. I already programmed it in NinjaTrader but I could not do it in MT4. So I hope someone can help me.

Description: I call the Indikator Insidebarindikator, this is a translation from german so it might not be right but anyway. The Indikator should look for bars that close in(side) the range of the previous bar. For example: I have a bar with a 40pip range from High to Low. The next bar closes in between this range that means this one would be an Insidebar and the first would be the Outsidebar. The Outsidebar will be active as long as the following bars close inside his 40pip range. If a bar opens outside but closes inside the range it will allso be an Insidebar, because only the close matters. For better identification it would be good to color the background from the High and Low of the Outsidebar forward to the last bar that closed within his range, in the form of a square.

I hope I made my self clear but I include a picture for better understanding. The greenish-blue square would be the beckgroung for the all Insidebars.

I found an Indicator that works almost like I want it but not completly, it just looks for bars that have the High and Low inbetween the range of the previous bar.
https://www.mql5.com/en/code/8242

I would appreciate your help with this problem.

Thanks


Reason: