/*[[ Name := Three Line Break Author := Equipe Forex Link := http://www.equipeforex.com Separate Window := No First Color := Blue First Draw Type := Histogram First Symbol := 159 Use Second Data := Yes Second Color := Red Second Draw Type := Histogram Second Symbol := 159 ]]*/ Inputs: BreakPeriod (5); Vars: CurrentBar (0), CurrentTrend (0), TotalBars (0), Value1 (0), Value2 (0); Vars: LowestBox (1000), HighestBox (-1000), i (0), CalculateLowHigh (True); Arrays: BoxLow[21] (1000), BoxHigh[21] (-1000); SetLoopCount(0); TotalBars = Bars; CurrentBar = TotalBars-1; If (Close[CurrentBar] < Open[CurrentBar]) Then { CurrentTrend = -1; BoxHigh[BreakPeriod + 1] = Open[CurrentBar]; BoxLow[BreakPeriod + 1] = Close[CurrentBar]; Value1 = Low[CurrentBar]; Value2 = High[CurrentBar]; } Else { CurrentTrend = 1; BoxHigh[BreakPeriod + 1] = Close[CurrentBar]; BoxLow[BreakPeriod + 1] = Open[CurrentBar]; Value1 = High[CurrentBar]; Value2 = Low[CurrentBar]; }; SetIndexValue(CurrentBar, Value1); SetIndexValue2(CurrentBar, Value2); For CurrentBar = TotalBars-2 Downto 0 Begin Value1 = 0; Value2 = 0; If (CalculateLowHigh) Then { LowestBox = 1000; HighestBox = -1000; For i = BreakPeriod + 1 Downto 0 Begin LowestBox = Min(LowestBox, BoxLow[i]); HighestBox = Max(HighestBox, BoxHigh[i]); End; CalculateLowHigh = False; }; If (((CurrentTrend > 0) And (Close[CurrentBar] < LowestBox)) Or (CurrentTrend < 0) And (Close[CurrentBar] < BoxLow[BreakPeriod + 1])) Then { Value1 = Low[CurrentBar]; Value2 = High[CurrentBar]; For i = 0 To BreakPeriod Begin BoxLow[i] = BoxLow[i + 1]; BoxHigh[i] = BoxHigh[i + 1]; End; BoxHigh[BreakPeriod + 1] = BoxLow[BreakPeriod + 1]; BoxLow[BreakPeriod + 1] = Close[CurrentBar]; CurrentTrend = -1; CalculateLowHigh = True; } Else If (((CurrentTrend < 0) And (Close[CurrentBar] > HighestBox)) Or (CurrentTrend > 0) And (Close[CurrentBar] > BoxHigh[BreakPeriod + 1])) Then { Value1 = High[CurrentBar]; Value2 = Low[CurrentBar]; For i = 0 To BreakPeriod Begin BoxLow[i] = BoxLow[i + 1]; BoxHigh[i] = BoxHigh[i + 1]; End; BoxLow[BreakPeriod + 1] = BoxHigh[BreakPeriod + 1]; BoxHigh[BreakPeriod + 1] = Close[CurrentBar]; CurrentTrend = 1; CalculateLowHigh = True; }; SetIndexValue(CurrentBar, Value1); SetIndexValue2(CurrentBar, Value2); End;