Dim i Dim high, low, close, open Dim body_high, body_low dim High_Outsidebar, Low_OutsideBar '' Serve the Data getdaten "High",high getdaten "Low",low getdaten "close",close getdaten "open", open '' Calculate the Bar/Candlebody if scriptberechneformel("max(open,close)", body_high) and scriptberechneformel("min(open,close)", body_low) then High_Outsidebar=0 Low_OutsideBar=0 '' all Results = 0 for i=1 to allperiods result(i)=0 next For i=2 to alleperioden if High_Outsidebar=0 then '' no outside bar yet if body_high(i)low(i-1) then '' the actual bar is the first insidebar High_Outsidebar=high(i-1) '' remember previous high Low_OutsideBar=low(i-1) '' remember previous low result(i)=1 '' insidebar is there end if else '' there has been previously identificated an outsidebar if body_high(i)Low_OutsideBar then result(i)=1 '' the next close is inside the outsidebar else High_Outsidebar = 0 '' reset the counter/init for the Outsidebar Low_OutsideBar = 0 end if end if next end if ''script