' custom Trade by Trade report with adverse excursion Sub MyCustomTBT() Dim row As Integer Dim i As Integer Dim NumTrades As Integer Dim NumOpenTrades As Integer Dim Info As Array Dim EDate As String Dim XDate As String Dim BuySell As String Dim RunningPL As Double If BarNumber <> LastBar Then Exit Sub ' print header row = GValue1 + 1 SetCell(row, 1, 1, 8, "Buy/Sell") SetCell(row, 2, 1, 20, "Entry Name") SetCell(row, 3, 1, 12, "Market") SetCell(row, 4, 1, 12, "Entry Date") SetCell(row, 5, 1, 4, "Size") SetCell(row, 6, 1, 10, "Entry Price") SetCell(row, 7, 1, 12, "Exit Date") SetCell(row, 8, 1, 10, "Exit Name") SetCell(row, 9, 1, 4, "Size") SetCell(row, 10, 1, 10, "Exit Price") SetCell(row, 11, 1, 10, "Trade P/L") SetCell(row, 12, 1, 10, "Running P/L") SetCell(row, 13, 1, 10, "Max Pos Profit") SetCell(row, 14, 1, 10, "Max Pos Loss") row = row + 1 ' print trades NumTrades = LiveTradeCount For i = 0 To NumTrades - 1 GetInfoAboutTrades(Info, i + 1) EDate = FormatDateTime(Info[4], vbShortDate) If Info[5] <> 0 Then EDate = EDate & " " & FormatDateTime(Info[5] / 43200, vbShortTime) XDate = FormatDateTime(Info[10], vbShortDate) If Info[11] <> 0 Then XDate = XDate & " " & FormatDateTime(Info[11] / 43200, vbShortTime) If Info[1] = 1 Then BuySell = "Buy" Else BuySell = "Sell" RunningPL = RunningPL + Info[13] SetCell(row, 1, 1, 8, BuySell) ' Buy/Sell SetCell(row, 2, 1, 10, Info[3]) ' Entry name SetCell(row, 3, 1, 12, Info[0]) ' Market SetCell(row, 4, 1, 12, EDate) ' Entry Date SetCell(row, 5, 3, 4, Info[2]) ' Entry size SetCell(row, 6, 2, 10, Info[6]) ' Entry price SetCell(row, 7, 1, 12, XDate) ' Exit Date SetCell(row, 8, 1, 10, Info[9]) ' Exit Name SetCell(row, 9, 3, 4, Info[8]) ' Exit size SetCell(row, 10, 2, 10, Info[12])' Exit price SetCell(row, 11, 2, 10, Info[13]) 'Trade P/L SetCell(row, 12, 2, 10, RunningPL) SetCell(row, 13, 2, 10, Info[16]) 'Max Pos Profit SetCell(row, 14, 2, 10, Info[17]) ' Max Pos Loss row = row + 1 Next ' open trades NumOpenTrades = OpenTradeCount For i = 0 To NumOpenTrades - 1 GetInfoAboutOpenTrade(Info, i) EDate = FormatDateTime(Info[4], vbShortDate) If Info[5] <> 0 Then EDate = EDate & " " & FormatDateTime(Info[5] / 43200, vbShortTime) XDate = FormatDateTime(Info[10], vbShortDate) If Info[11] <> 0 Then XDate = XDate & " " & FormatDateTime(Info[11] / 43200, vbShortTime) If Info[1] = 1 Then BuySell = "Buy" Else BuySell = "Sell" RunningPL = RunningPL + Info[13] SetCell(row, 1, 1, 8, BuySell) ' Buy/Sell SetCell(row, 2, 1, 10, Info[3]) ' Entry name SetCell(row, 3, 1, 12, Info[0]) ' Market SetCell(row, 4, 1, 12, EDate) ' Entry Date SetCell(row, 5, 3, 4, Info[2]) ' Entry size SetCell(row, 6, 2, 10, Info[6]) ' Entry price SetCell(row, 7, 1, 12, XDate) ' Exit Date SetCell(row, 8, 1, 10, Info[9]) ' Exit Name 'SetCell(row, 9, 3, 4, Info[8]) ' Exit size SetCell(row, 10, 2, 10, Info[12])' Exit price SetCell(row, 11, 2, 10, Info[13]) 'Trade P/L SetCell(row, 12, 2, 10, RunningPL) SetCell(row, 13, 2, 10, Info[16]) 'Max Pos Profit SetCell(row, 14, 2, 10, Info[17]) ' Max Pos Loss row = row + 1 Next GValue1 = row End Sub