NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support

Miscellaneous Support Miscellaneous support issues.

Reply
 
Thread Tools Display Modes
Old 08-15-2011, 03:01 PM   #1
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 331
Thanks: 0
Thanked 11 times in 8 posts
Default Send Value of a variable in an e-mail

I am running a strategy which trades pretty often, and to make my testing a little easier, I set up a send mail method to send a message to me containing the realized profits everytime profit changes by +/- a profit variable (right now at a value of $250).

The Send Mail function works when I use this construct:

SendMail("name@gmail.com", "phonenumber@vtext.com", " PnL Notice", "Variable")

What I get in the message is the word variable, but that tells me that the messaging is working but my conversion to get the variable value doesn't work. I've tried several different ways, but right now this is what I am using:

Code:
        protected override void Initialize()
        {
         SendPnL = new StringSeries(this);
         }
        protected override void OnBarUpdate()
        {
                 Variable0 = Performance.AllTrades.TradesPerformance.Currency.CumProfit;
	real_pnl = Variable0;
	SendPnL.Set(Variable0.ToString());

     // Messaging and Notifications
	if (Performance.AllTrades.TradesPerformance.Currency.CumProfit > real_pnl 
                    + PnL_Check
                    || Performance.AllTrades.TradesPerformance.Currency.CumProfit < real_pnl
                    - PnL_Check)
	{
	real_pnl =performance.AllTrades.TradesPerformance.Currency.CumProfit;

	SendMail("user_name@gmail.com", "phonenumber@vtext.com", " PnL
                        Notice",Variable0.ToString());
So I capture the value of the realized profit in Variable0, then try and send it in an e-mail
message using, "Variable0.ToString()). But it doesn't work. How do I convert realized profit into a text value I can send to my phone as an e-mail message?

Thanks
DaveN
Last edited by daven; 08-15-2011 at 03:02 PM. Reason: Take out personal cell phone info
daven is offline  
Reply With Quote
Old 08-15-2011, 03:23 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi DaveN,

What is not working exactly? What does a simple print show of this?
Print(Variable0.ToString());
NinjaTrader_RyanM is offline  
Reply With Quote
Old 08-15-2011, 04:24 PM   #3
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 331
Thanks: 0
Thanked 11 times in 8 posts
Default

That particular statement wouldn't compile, but I put these print statements in the code, and this is what I got:

protected override void OnBarUpdate()
{
Variable0 = Performance.AllTrades.TradesPerformance.Currency.C umProfit;
real_pnl = Variable0;
SendPnL.Set(Variable0.ToString());
Print( " Variable0 = " + Variable0);
Print(" SendPnL = " + SendPnL[0]);
Print(" real_pnl = " + real_pnl);

And I got this in the output file, the value of which agrees with my performance statement about the strategy:

Variable0 = 24640.7200000003
SendPnL = 24640.7200000003
real_pnl = 24640.7200000003

So from a print standpoint, the data acquisition seems to be working, but when I try to send, it doesn't send, in fact the messages don't even go out.
DaveN
daven is offline  
Reply With Quote
Old 08-15-2011, 04:36 PM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Great the value is working - so we can isolate the issue to SendMail? SendMail() is a real time only method. Is your script returning true for that block on a real time bar?
NinjaTrader_RyanM is offline  
Reply With Quote
Old 08-15-2011, 06:25 PM   #5
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 331
Thanks: 0
Thanked 11 times in 8 posts
Default

Okay, it's working now. I changed the line to:

SendMail("name@gmail.com", "number@vtext.com", " PnL Notice", real_pnl.ToString());

and now I'm gettng a pnl readout on every new bar. I just need to fix the logic so I can trigger it
only on a threshold change in PnL.

Thanks so much for your help Ryan.
DaveN
daven is offline  
Reply With Quote
Reply

Tags
convert variable to text, send mail, variable

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Failure to send mail. marcusplexus Miscellaneous Support 12 09-21-2011 08:08 AM
Can't send mail to Support michi08 Miscellaneous Support 1 09-08-2010 11:20 AM
Send Mail problems rightcoast Miscellaneous Support 8 06-20-2009 06:39 AM
Can't Send Mail b-rock Miscellaneous Support 9 06-19-2009 06:52 PM
send mail vk2205 Strategy Development 1 01-03-2009 02:50 PM


All times are GMT -6. The time now is 04:04 PM.