Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Setting up Strategy outgoing Email
Collapse
X
-
For those you are looking for the coded script
SendMail(@"[email protected]", @"Subject Meassage here", Convert.ToString(Position.MarketPosition) + " Instrument " + Convert.ToString(Cbi.Instrument.GetInstrument(Inst rument.FullName, true)) + " Position Quantity " + Convert.ToString(Position.Quantity) + " Average Price " + Convert.ToString(Position.AveragePrice) + " Machine ID " + Convert.ToString(Cbi.License.MachineId));
and this is the condition set I used to send the email once per trade
Create a bool in variables " SendEmailONCE = false " , then where your strategy sends an Order to create a position in the "do the following area EnterLong() place the rule as addition action
SendEmailONCE == false;
these condition sets will then send the email for Long or Short positions created
// Set 125
if ((Position.MarketPosition == MarketPosition.Long)
&& (BarsSinceEntryExecution(0, "", 0) > -1)
&& (BarsSinceEntryExecution(0, "", 0) < 1)
&& (SendEmailONCE == false)
// Condition group 1
&& (((Close[0] + (1 * TickSize)) > Position.AveragePrice)
|| ((Close[0] + (-1 * TickSize)) < Position.AveragePrice)))
{
SendMail(@"[email protected]", @"Subject Message here", Convert.ToString(Position.MarketPosition) + " Instrument " + Convert.ToString(Cbi.Instrument.GetInstrument(Inst rument.FullName, true)) + " Position Quantity " + Convert.ToString(Position.Quantity) + " Average Price " + Convert.ToString(Position.AveragePrice) + " Machine ID " + Convert.ToString(Cbi.License.MachineId));
SendEmailONCE = true;
}
// Set 126
if ((Position.MarketPosition == MarketPosition.Short)
&& (BarsSinceEntryExecution(0, "", 0) > -1)
&& (BarsSinceEntryExecution(0, "", 0) < 1)
&& (SendEmailONCE == false)
// Condition group 1
&& (((Close[0] + (1 * TickSize)) > Position.AveragePrice)
|| ((Close[0] + (-1 * TickSize)) < Position.AveragePrice)))
{
SendMail(@"[email protected]", @"Subject Message Here", Convert.ToString(Position.MarketPosition) + " Instrument " + Convert.ToString(Cbi.Instrument.GetInstrument(Inst rument.FullName, true)) + " Position Quantity " + Convert.ToString(Position.Quantity) + " Average Price " + Convert.ToString(Position.AveragePrice) + " Machine ID " + Convert.ToString(Cbi.License.MachineId));
SendEmailONCE = true;
}
Hope this helps someone and saves you some time.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
75 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
40 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
63 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
63 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
53 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment