I'm in the Christmas spirit, so I thought I'd post some of my favorite helper methods I use in all of my trading strategies, both for backtesting and live trading. Also, some of these perhaps could be improved upon and if you have ways to improve them I'd love to hear them.
I'm wondering what other common code others use over and over again that others use. Maybe post some here too, spread the cheer.
Some of these have really made things easier for me over the years. Maybe it can help you too.
// whether or not the order is an exit order, not an entry
bool IsExit(IOrder order) { return order.OrderAction == OrderAction.Sell || order.OrderAction == OrderAction.BuyToCover; }
// adjust the "End Date" of the chart data series in case it stops updating, which sometimes happens
void AdjustChartEndDate()
{
if (!Historical && RunningInAChart && ChartControl.BarsArray[0].BarsData.To.Date