Sub DonchianChanBrkoutFiltBuy(indLength, tradeLength, MALength) Dim donchianHigh As BarArray Dim donchianLow As BarArray Dim MA As BarArray Dim dH Dim dL Dim Value1 Dim EntryName Dim MinMove Dim CellRow As Integer 'Exit if there are not anough bars for the indicators If BarNumber < indLength Then Exit Sub If BarNumber=FirstBar Then dH = 0 dL = 0 Value1 = 0 End If 'Get min Move to enter the trade at a tradeable place MinMove=GetActiveMinMove() Value1 = DonchianChannel(indLength, dH, dL) donchianHigh = dH donchianLow = dL If BarsSinceEntry-1=tradeLength And MarketPosition=1 Then ExitLong("ExitLong",EntryName,1,0,CloseExit,Day) EntryName = "DonchianBreakoutBuy" + "|" + indLength + "|" + tradeLength + "|" + avgtruerange(indLength) 'Only enter a new trade if the filter condition is true (price > MA and MA rising) MA = ScriptAve(Close, MALength,0) If MA > MA[1] And Close > MA Then Buy(EntryName,1,donchianHigh+MinMove ,Stop,Day) MyCustomTBT() End Sub