DEFPARAM CumulateOrders=False
// initialize the array on the very first bar
ONCE Elements = 10
IF BarIndex = 0 THEN
FOR i = 1 TO Elements
$WinningTrade[i] = 0
NEXT
ENDIF
/*
UPDATE the array everytime a trade is a winner
Shift Elements-1 elemnts to the left, to drop the leftmost (oldest) trade and
make room for the current trade to be stored in element 1 (the rightmost element)
*/
IF StrategyProfit <> StrategyProfit[1] THEN
FOR i = Elements DOWNTO 2
$WinningTrade[i] = $WinningTrade[i - 1]
NEXT
$WinningTrade[1] = (StrategyProfit > StrategyProfit[1]) //assign 1 for a winning
// trade, 0 otherwise
// Initialize variables
wins = 0
// Loop through the last 10 trades
for i = 1 to Elements
wins = wins + $WinningTrade[i]
next
// Calculate the win percentage
value2 = ((wins / Elements) * 100)
ENDIF
// Buy
indicator1 = close
indicator2 = SuperTrend[7,67]
c1 = (indicator1 >= indicator2)
IF c1 THEN
BUY 1 SHARES AT MARKET
ENDIF
// Sell
indicator3 = close
indicator4 = SuperTrend[7,67]
c2 = (indicator3 <= indicator4)
IF c2 THEN
SELLSHORT AT MARKET
ENDIF
// Output the win percentage
GRAPH value2 as "Win %"