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!
See more
See less

Partner 728x90

Collapse

Send an email if one or more variables are met

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

    Send an email if one or more variables are met

    Hello, I have an indicator that I want you to send me an email if it happens:
    -to
    _b
    _c
    or a + b ... a + c ... a + b + c ...

    When I want him to send it to me if "a" is fulfilled he sends it correctly but if I ask him to send it to me when "b" is fulfilled or all the other variables he does not do it.
    I use the variable "emailPartFilled" and I tried to use "emailPartFilled_2" and "emailPartFilled_3" but it didn't work for me ... any ideas to differentiate the other variables?
    Thank you very much in advance.

    #2
    Hello punkiy2111,

    Thank you for your post.

    I'm not sure I follow what you're trying to achieve. Could you clarify the behavior you're wanting to see? If you can provide an actual code snippet of what you're trying, that may be helpful to clarify as well.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      I'm sorry I can't explain myself better, Now I'm far from my computer but basically that's what I have commented.
      I want to send an email for example:

      - If I have the email activated in true that I draw an ellipse
      - If I have the email address, draw me a reactangle
      -If I have activated the 2 emails, send me an email when the 2 conditions are met ...

      Can you help me create an example of what I tell you?
      Basically it is to send an email if one condition is met, and if both are met? have I to change the variable ??
      Thank you.

      Comment


        #4
        Hello punkiy2111,

        Thank you for your reply.

        I'm still not able to understand the logic you're wanting to occur, but the following may be of help:

        Emails can be sent with SendMail(). Below is a link to the help guide:

        https://ninjatrader.com/support/help...8/sendmail.htm
        https://ninjatrader.com/support/foru...546#post792546

        Below is a link to a forum post where my colleague has posted an example of using bools to trigger an action after a first condition is true and setting a bool, then having a second condition be true on a later bar and then triggering the action.

        https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/1130921-entering-trade-when-conditions-don-t-happen-simultaneasly?p=1131172#post1131172

        Order fills can be detected in an indicator using the Addon approach to attach a method to the <Account>.ExecutionUpdate event handler.
        https://ninjatrader.com/support/help...tionupdate.htm

        If you want to saved several execution messages and send these all at once in a single email, you could add these to a string, and use a timer to check periodically if there is a message to send, send the message with SendMail(), and then set the string back to an empty string.
        Below I am including a link to an example of using a timer.
        https://ninjatrader.com/support/foru...445#post496445

        Last, below is a link to a forum post with helpful information about getting started with NinjaScript and C#.

        https://ninjatrader.com/support/foru...31#post1168231

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          public class EXAMPLE: Indicator
          {
          private int barwidth = 2;
          private double vwt;
          private Series <double> [] value = new Series <double>[23];
          private bool emailPartFilled = false;
          private string toEmailAddress = @"[email protected]";
          private bool eod = true;


          protected override void OnBarUpdate()

          if (cond10 || (cond20 && sameday))

          {
          pl = 1; //Red
          if(emailPartFilled)
          {
          emailPartFilled = true;
          SendMail(toEmailAddress, "Bar Red", "Example 1");
          }


          if (cond1 || (cond11 && sameday))
          {
          pl = 2; //Black
          }

          ???????????

          if (cond2 || (cond13 && sameday))
          {
          pl = 3; //Green
          }

          ???????????

          Comment


            #6
            Hello basically the problem is that the first condition to send the email executes it well, I have a variable emailPartFilled correctly but I cannot use emailPartFilled again for the other 2 conditions so I ask what other variable I can put or what comes to mind You to send me an email if I want when I meet condition 1, condition 2, condition 3, or ... condition 1 and 3 ... or 3. Thank you very much.

            Comment


              #7
              Hello punkiy2111,

              Thank you for your reply.

              I'm still a little unclear exactly what you're trying to do, however, I have created a relatively simple example indicator that has three conditions and will either print a message regarding the combination of statements that are currently to the NinjaScript Output window (if the Print statements are left uncommented, so you can test without sending a whole bunch of emails) on each bar update, or will send an email with the same message if you uncomment the SendMail lines and replace "[email protected]" with the email you actually want it sent to. If you import this and view it in the NinjaScript Editor there are a number of comments explaining the logic.

              Please let us know if we may be of further assistance to you.
              Attached Files
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                Thank you very much Kate for your interest, I honestly think your work is very professional.
                The indicator you sent me is fine with me. Well now what I need is that when I add the indicator in the chart it asks me in a box if I want it to send me 1 email if it is true:
                the condition,
                conditionB,
                conditionC ...
                or .... conditionA and conditionB ... conditionA and conditionC, none of the 3 ... etc

                Indicators
                Properties
                Ctrl+I


                Parameters-Other

                To Email? [email protected]
                ConditionA yes? (X yes ) (blank space no) send email or not
                ConditionB yes? (X yes ) (blank space no) send email or not
                ConditionC yes? (X yes ) (blank space no) send email or not


                Thanks in advance.

                Comment


                  #9
                  Someone who can help me please?

                  Comment


                    #10
                    Hello Punkiy2111,

                    Thank you for your reply.

                    You could certainly create user inputs (these may be created in the Indicator Wizard when setting up a script) and use those input values to determine which emails or combination thereof to send.

                    For example, I could create three bool inputs which would give you checkboxes - if they are checked the bool would be true, if not checked, false. For the email input you would want to use a String user input.

                    You can then use these to decide which emails to send. I've updated the previous example with user inputs to control which emails would be sent. You'll need to uncomment the SendMail lines to actually send emails, but you can test using the prints in the NinjaScript Output window to easily see which emails would be sent with which combination of user inputs set to true.

                    Please let us know if we may be of further assistance to you.
                    Attached Files
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Kate I just added everything you told me but there is a main mistake. He sends me an email indicating if a condition is met or if the 3 conditions are met.
                      Perhaps I did not explain well, I apologize for this, but really what I am looking for through the email notice is that you only notify me when one of the conditions is met.

                      I mean that all 3 conditions can never be met together.
                      Let's imagine that I have 5 emas in the chart and of the 5 I will choose to notify me by email only at 3:
                      the ema of 30
                      the ema of 80
                      the 150-period ema.

                      Well, when the price touches the ema of 30 notify me by email (has it touched the ema of 30?
                      When I touch the 80 ema, notify me by email (have you touched the 80 ema?

                      When you touch the 150 ema, notify me by email (have you touched the 150 ema?

                      Of course, through the indicator panel I want to choose whether to notify me only with the 30 ema, only with the 80, only 2 ... 3 ... 1 and 3 ... etc

                      but you can never send me an email that has touched all 3 emas at the same time

                      You think you have to touch the logic code that you sent me. Very grateful for your help.

                      Comment


                        #12
                        Hello punkiy2111,

                        Thank you for your reply.

                        Our examples are meant as examples and are not intended for copy and paste purposes, but as jumping off points for you to create your own logic. You would simply want to check if ConditionATrue == true > if SendEmailForConditionA == true > SendEmail, and then repeat the same for conditions b and c.

                        You can also contact one of our professional NinjaScript Consultants or Educators who would be eager to create or modify your script at your request or assist you with your script. Please let me know if you would like a list of professional NinjaScript Consultants or Educators who would be happy to create or modify any script at your request or assist you in learning NinjaScript.

                        Please let us know if we may be of further assistance to you.
                        Kate W.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello again Kate, whenever I had a problem, her colleagues helped me and even broke into my computer. My indicator is simple and I just want to add the possibility of sending emails, anyway when I want a more complex indicator of course I will go to a programmer but for such a basic thing I think it would not be necessary.
                          Well, the indicator already works and it sends me the emails but if I deactivate the 3 boxes it continues to send me the email in the same way, there is a way to deactivate the emails when the box is not checked. If you are so kind as to answer me, I would also like to thank you for the service provided. Have a nice day.

                          Comment


                            #14
                            Hello punkiy2111,

                            Thank you for your reply.

                            Our support is not able to assist directly with programming logic over remote support.

                            If you'd like to post your current version of your script, I can take a look to see what the issue may be, but cannot program the script for you. As mentioned previously, our examples are just examples and are meant for you to build off of to design your own logic.

                            I am not seeing emails sent when all boxes are unchecked on my end in the example script provided. Did you remove the old version and re-add the newly imported script prior to testing?

                            Thanks in advance; I look forward to assisting you further.
                            Kate W.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by WHICKED, Today, 12:56 PM
                            2 responses
                            14 views
                            0 likes
                            Last Post WHICKED
                            by WHICKED
                             
                            Started by Felix Reichert, Today, 02:12 PM
                            0 responses
                            1 view
                            0 likes
                            Last Post Felix Reichert  
                            Started by Tim-c, Today, 02:10 PM
                            0 responses
                            1 view
                            0 likes
                            Last Post Tim-c
                            by Tim-c
                             
                            Started by cre8able, Today, 01:16 PM
                            2 responses
                            9 views
                            0 likes
                            Last Post cre8able  
                            Started by chbruno, 04-24-2024, 04:10 PM
                            3 responses
                            49 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Working...
                            X