Could anyone please help me with setting up an email alert for this indicator?
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 an email laert
Collapse
X
-
Hello cachevery,
With Ninjascript there is a function called SendMail() that you can use when you would like a email to be sent.
One thing to note is a valid SMTP server needs to be set up in the options menu (Control Center -> Options -> Misc) the section is Mail Setup.
Here is a reference for setting up email in Ninjatrader
http://www.ninjatrader.com/support/f...008#post262008
Here is an example for usage.
We do not provide custom code modifications, but this is how you would use it in a condition and should get you started.
Code:// SendMail(string from, string to, string subject, string text) // The line below generates an email message if(variable == true) { SendMail("[email protected]", "[email protected]", "Trade Alert", "Buy Buy Buy"); }
JesseNinjaTrader Customer Service
-
Hello,
You could have it email the name of the instrument by using the property value of Instrument.FullName(Help Guide Link on this). You can getl the property value of Position.AvgPrice to return the average price of your position(Help Guide link on this) and you can get the property value of the direction of the position by using Position.MarketPosition(Help Guide link on this)
If we can be of any other assistance please let us know.Cody B.NinjaTrader Customer Service
Comment
-
I put sendmail in the stop logic section and its giving emails from every instrument i have enabled even with no trade on a continuous basis.
How can I go about having it show the stoploss price?Last edited by brucelevy; 03-06-2016, 07:25 PM.
Comment
-
Hello,
Do you have a check before the SendMail() method?
When are you wanting the email to be sent?
Can you clarify are you wanting to get the execution price of the Stop Loss or are you wanting the price that the Stop Loss is submitted at before it is executed?Cody B.NinjaTrader Customer Service
Comment
-
Well, I'm now receiving current bid or ask and initial stop-loss placement upon execution.
I'd like to receive subsequent stop-loss price level adjustments but when I put sendmail into the exit logic I get an email on every bar update.
Also, I am having an issue with putting a space between the instrument name and current ask price:
Live Long Entry $USDCAD1.33333 Stop: 1.33216
HTML Code:SendMail("@gmail.com", "@messaging.sprintpcs.com", "Live Long Entry " +Instrument.FullName +ask,"Stop: "+initialStop);
Last edited by brucelevy; 03-08-2016, 06:02 AM.
Comment
-
Hello,
Please clarify do you have the SendMail() method within OnBarUpdate() without any checks or is it within an if statement?
Can you provide a code snippet of where you are using the SendMail() method?
If you are wanting a space within the string you will need to add in the space. To do that you can add a space in between by doing "Live Long Entry " +Instrument.FullName + " " + ask,"Stop: "+initialStop for the string.Cody B.NinjaTrader Customer Service
Comment
-
Thank you Cody,
At the moment I have sendmail within an if statement...
if xyz met
{
enterlong
sendmail
}
I am receiving many sendmail notifications for the entry notifications..even getting mail overflow messages. https://gyazo.com/04d760e42472cd09afa69c7d2bea0aaa
Perhaps I need some sort of check? I get hundreds of these notification windows and emails.Last edited by brucelevy; 03-08-2016, 11:32 PM.
Comment
-
Hello,
It would appear that XYZ may be getting met on each OnBarUpdate call.
I would recommend to add a Print() statement within the if statement to check when XYZ is getting met. Please see the following link on using Print statements to debug: http://ninjatrader.com/support/forum...ead.php?t=3418Cody B.NinjaTrader Customer Service
Comment
-
CalculateOnBarClose=false;
So it is probably getting triggered multiple times in the same area...
I'm trying to add a trigger check so it only triggers sendmail once but I'm getting an error: "the name Value does not exist"... how should I add that in?
#region Variables
private int last = 0;
private bool triggered = false;
private bool resetAfterTrigger = false;
#endregion
if (condition1 == true)
{
Value.Set(1);
last = 1;
triggered = true;
}
if (condition2 == true)
{
Value.Set(-1);
last = -1;
triggered = true;
}
else if (resetAfterTrigger == true && triggered == true)
{
Value.Set(0);
triggered = false;
}Last edited by brucelevy; 03-10-2016, 07:57 AM.
Comment
-
Hello,
You will need to add in a custom data series that you are setting the Value to. For information on the DataSeries class please see the following link: http://ninjatrader.com/support/helpG...ries_class.htmCody B.NinjaTrader Customer Service
Comment
-
OK I was able to add the custom dataseries for Value but I ended up getting repeated mail queue errors.
A functioning sample would be great, I haven't seen any solid information on this.
if (condition == true)
{
enterlong
sendmail
Value.Set(1);
last = 1;
triggered = true;
}
I have also tried the following which does nothing:
protected override void OnExecution(IExecution execution)
{
if (entryOrder != null && execution.Name == "L1")
{
SendMail("@gmail.com", "@messaging.sprintpcs.com", "Long Trade Alert", execution.ToString()+Instrument.MasterInstrument.N ame+ Instrument.FullName+ Instrument.Id+ Instrument.Expiry+BarsPeriod.Id+BarsPeriod.Value);
Print("L1");
}
if (entryOrder != null && execution.Name == "S1")
{
SendMail("@gmail.com", "@messaging.sprintpcs.com", "Short Trade Alert", execution.ToString()+Instrument.MasterInstrument.N ame+ Instrument.FullName+ Instrument.Id+ Instrument.Expiry+BarsPeriod.Id+BarsPeriod.Value);
Print("S1");
}Last edited by brucelevy; 03-11-2016, 01:32 AM.
Comment
-
Hello,
From the code you provide for your check it does not appear that you are checking what the value is set to which would cause the logic within the check to continue to process but without actually utilizing the check. I have provided an example below of what you could do.
Code:protected override void OnBarUpdate() { if(condition == true && Value[0] == 0) { Value.Set(1); SendMail(); } if(condition == true && Value[0] == 1) return; if(resetCondition == true && Value[0] == 1) { Value.Set(0); } }
If you add in a print to check the execution order name does L1 or S1 appear as the name? To print the execution order name you would use Print(execution.Order)Cody B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by benmarkal, Yesterday, 12:52 PM
|
3 responses
23 views
0 likes
|
Last Post Today, 05:22 AM | ||
Started by helpwanted, Today, 03:06 AM
|
1 response
19 views
0 likes
|
Last Post Today, 03:35 AM | ||
Started by Brevo, Today, 01:45 AM
|
0 responses
11 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
244 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
388 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
Comment