Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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 volIQ, 03-27-2024, 04:28 PM
|
3 responses
21 views
0 likes
|
Last Post
by RJay
Today, 05:41 AM
|
||
Started by Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
72 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
4 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
9 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
13 views
0 likes
|
Last Post Today, 02:00 AM |
Comment