For those that want to tally the PnL for themselves, here is (really quick and dirty) C# program that computes it. All you have to enter is the entries like this. Say you sold 1300, then exited and went long at 1305, then exited and went flat at 1302. The entry on the command line is:
-1300, 1305, -1302
A good exercise for budding programmers is to modify the above program so as only to have the user enter the sign of the first trade, then the program figures out the rest. This is fine for the crossover system because that is always in the market and is always flipping. This is way less error prone since you only have to input prices like this:
-1300, 1305, 1302
and the program figures out whether it was a long or short trade after the first one. It is a good exercise and interesting to turn this program into F#.
-1300, 1305, -1302
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputeProfitConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string entries = Console.ReadLine();
string[] prices = entries.Split(',');
double entry = 0;
double exit = 0;
double PnL = 0;
int trade = 0;
foreach (string priceStr in prices)
{
double tradePrice = double.Parse(priceStr);
if (0 == trade)
{
entry = tradePrice;
entry *= -1;
trade++;
}
else
{
trade+= 2;
exit = tradePrice;
exit *= -1;
PnL += entry + exit;
entry = exit;
}
}
trade -= 1;
Console.WriteLine("PNL = {0} Number of trades = {1}", PnL, trade);
Console.ReadLine();
}
}
}
A good exercise for budding programmers is to modify the above program so as only to have the user enter the sign of the first trade, then the program figures out the rest. This is fine for the crossover system because that is always in the market and is always flipping. This is way less error prone since you only have to input prices like this:
-1300, 1305, 1302
and the program figures out whether it was a long or short trade after the first one. It is a good exercise and interesting to turn this program into F#.