Public Function MAR_BuyEntStop(Cond As Boolean, EntryPrice As Double) Dim TomorDate As Date, CurHigh As Double, CurLow As Double, _ CurOpen As Double, CurRow As Integer, CurCol As Integer, _ BuyHeadCell As Variant, TmpEntry As Double, OrderFilled As Boolean, _ OrderString As String OrderFilled = False CurRow = Range(Application.Caller.Address).Row CurCol = Range(Application.Caller.Address).Column BuyHeadCell = Worksheets("MarketData").Range("BuyEntry").Cells(2, 1).Address CurHigh = Worksheets("MarketData").Range("High").Cells(CurRow - 1, 1).Value CurLow = Worksheets("MarketData").Range("Low").Cells(CurRow - 1, 1).Value CurOpen = Worksheets("MarketData").Range("Open").Cells(CurRow - 1, 1).Value TomorDate = Worksheets("MarketData").Range("Date").Cells(CurRow, 1).Value If CurCol = Range(BuyHeadCell).Column Then If IsBackTest = 1 Then If BuyEnt.Cond = True And Application.Caller.Address <> BuyHeadCell Then If CurHigh > BuyEnt.entprice Then MAR_BuyEntStop = Application.Max(BuyEnt.entprice, CurOpen) OrderFilled = True End If End If Else If Cond = True Then MAR_BuyEntStop = TomorDate & "," & "Buy Stop" & "," & EntryPrice Else MAR_BuyEntStop = False End If End If End If BuyEnt.Cond = Cond BuyEnt.ordtype = "Stop" BuyEnt.entprice = EntryPrice If OrderFilled = False And IsBackTest = 1 Then MAR_BuyEntStop = False End Function