Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Send Value of a variable in an e-mail

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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("[email protected]", "[email protected]", " 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("[email protected]", "[email protected]", " 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, 03:02 PM. Reason: Take out personal cell phone info

    #2
    Hi DaveN,

    What is not working exactly? What does a simple print show of this?
    Print(Variable0.ToString());
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      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

      Comment


        #4
        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?
        Ryan M.NinjaTrader Customer Service

        Comment


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

          SendMail("[email protected]", "[email protected]", " 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

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          58 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          39 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          19 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          21 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          51 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X