- ago
I set up a chart with an active strategy in a workspace. I've set the timeframe of the strategy to a relatively short term (~2 months) but I'm getting a huge number of emails (hit the Outlook limit of 500 per day) sent from the strategy notifying me of signals.

Is there something I can do in the code to limit the signals to the current day only?
0
472
Solved
4 Replies

Reply

Bookmark

Sort
Cone8
 ( 6.17% )
- ago
#1
Sure. Don't allow the SendEmail() statement to get hit 500 times.
You should be processing the signals in the BacktestComplete() method.
0
Cone8
 ( 6.17% )
- ago
#2
For an [nearly complete] good start, use this method.

CODE:
// make sure these are at the top using System.Collections.Generic; using System.Linq; using System.Text;       public override void BacktestComplete()       {          // process the signals          if (Backtester.Orders.Count > 0)          {             StringBuilder sb = new System.Text.StringBuilder();             sb.AppendLine("Signal Count = " + Backtester.Orders.Count.ToString()).AppendLine().AppendLine("Exits ------------- Type\tPrice\tWeight\t\tValue");             string fmt = "{0,-6}{1,-6}{2,-8}{3,-8}{4,-8:N2}{5,-8:N4}{6}";             List<Transaction> sells = Backtester.Orders.Where(x => x.IsExit).OrderBy(w => w.Weight).ToList();             if (sells != null)             for (int n = sells.Count - 1; n >= 0; n--)             {                Transaction t = sells[n];                double tradevalue = t.Bars.LastValue * t.Quantity;                string signal = String.Format(fmt, t.TransactionType, t.Quantity, t.Bars.Symbol, t.OrderType, t.OrderPrice, t.Weight, tradevalue.ToString("C2", System.Globalization.CultureInfo.CurrentCulture));                sb.AppendLine(signal);             }             sb.AppendLine().AppendLine("Entries ----------- Type\tPrice\tWeight\t\tValue");             List<Transaction> buys = Backtester.Orders.Where(x => x.IsEntry).OrderBy(w => w.Weight).ToList();             if (buys != null)                for (int n = buys.Count - 1; n >= 0; n--)                {                   Transaction t = buys[n];                   double tradevalue = t.Bars.LastValue * t.Quantity;                   string signal = String.Format(fmt, t.TransactionType, t.Quantity, t.Bars.Symbol, t.OrderType, t.OrderPrice, t.Weight, tradevalue.ToString("C2", System.Globalization.CultureInfo.CurrentCulture));                   sb.AppendLine(signal);                }             WriteToDebugLog(sb.ToString());                          //now do your send email stuff here             //SendEmail(... messageText: sb.ToString());          }       }
0
Best Answer
- ago
#3
Thanks, Cone. I'll give this a try over the weekend.

1
- ago
#4
I like the idea of building the details shown in the Quotes window (from the Transaction instances) into a string that can be emailed. And you even sort the Transactions. Nice touch.

The StringBuilder datatype does allow '\n' newline characters in a string, so you may be able to eliminate the empty AppendLine() calls for a '\n' character when you want a blank line.

CODE:
Backtester.Orders.Count.ToString()).AppendLine("\nExits ------------- Type\tPrice\tWeight\t\tValue"); //Backtester.Orders.Count.ToString()).AppendLine().AppendLine("Exits ------------- Type\tPrice\tWeight\t\tValue");
0

Reply

Bookmark

Sort