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 Mindset, 04-21-2026, 06:46 AM
|
0 responses
88 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
135 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
68 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
119 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
69 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment