Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detecting Share Service Type

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

    Detecting Share Service Type

    Hello,

    Currently working on updating an indicator that interacts with wide range bars in various manners. One of them is the ability to alert the user when this happens. Currently sound alerts and alerts added to Alerts log is implemented. Since feature request SFT-4164 is not added yet, the functionality for Share Service alerts have to be added manually from the ninja script.

    Pretty much all of the functions are coded in. The user is able to select a share service, add a custom message, and customize the 'send to' parameter for the email option. I have three questions.

    1) How would the code distinguish between an email share service vs a text message?

    At the moment the user has to toggle a bool to signal that its a text message. The code uses this
    PropertyEditor("NinjaTrader.Gui.Tools.AlertsShareS erviceEditor") to select the correct service. But this is simply a string value and not a specific object type. This is problem as it has to distinguish between the two as the Share() method takes additional arguments for the email. Thus the required explicit distinction between them.

    2) I noticed there's a SendMail() method that works the same. Any reason to use one over the other? I presume the other one is the legacy method. SendMail() is clearer to use. I use the Share() for now.

    3) What PropertyEditor denotes the drop down menu for the alert message text?

    If we go to the alert page (right click the chart then Alerts...) then message text, there's a input field with a drop down with the available properties to include with @. Eventually I would like the user to have more control on what information they can send in the alert.

    Best regards,

    Unsuitable
    Ocean Trading Indicators.
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable,

    You would have to design your code to use specific services, there is not a way to differentiate service types.

    SendMail is just for sending an email and can be used in locations where Share cannot. In most cases using Share is suggested.

    I am not sure what property editor that would be, the @ text are replacement texts that will be filled in automatically.

    Comment


      #3
      Hello Jesse,

      How does ninja internal code which overload method to use? The latest version of NT can set alerts using email or sms services (the other options appear to be deprecated), so it must know the correct type to run.

      I tried using a try catch but the internal Share() seems to already handle errors it self and logs them. So its not as if I can brute force both overloads.

      For the @ texts. I wanted to replicate that functionality within the indicator parameters. I went through the list of classes of NinjaTrader.Gui.Tools and had no luck. Perhaps it some other class. Not a major concern. Could always include a instructions via the tools tip then handle everything on the backend.

      Best regards,

      Unsutiable
      Ocean Trading Indicators
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment


        #4
        Hello Unsuitable,

        How does ninja internal code which overload method to use? The latest version of NT can set alerts using email or sms services (the other options appear to be deprecated), so it must know the correct type to run.
        ​I am not sure what overloads you are referring to here, can you provide more detail?

        The methods like Share should have internal handling applied so you get log messages or popup errors from the platform.

        If you wanted to replicate the @ text replacement you would do just that, you would replace those strings from your input into a variable.

        string myNewVariable = MyInputProperty.Replace("@something", "MyReplacementStringorVariable");

        Returns a new string in which all occurrences of a specified Unicode character or String in the current string are replaced with another specified Unicode character or String.

        Comment


          #5
          Hello Jesse,

          Ninja is able to toggle an alert and set a share service. It then detects the type of share service and request the additional information required for email. Presumably its uses the correct way to call the method since Ninja know the service type. See pictures below.

          Click image for larger version

Name:	ex1.png
Views:	70
Size:	32.7 KB
ID:	1318066 Click image for larger version

Name:	ex2.png
Views:	76
Size:	22.8 KB
ID:	1318067 Click image for larger version

Name:	ex3.png
Views:	80
Size:	25.7 KB
ID:	1318068

          Here's the code for SMS then Email. The actual code includes an extra if statement to check if the service is a phone number or email. But this is set by the user, its not done automatically.

          Code:
          // For SMS
          Share(AlertShareService, message);
          
          // For Email
          Share(AlertShareService, message, new object[]{SendToEmail, alert });
          Best regards,

          Unsuitable
          Ocean Trading Indicators.
          Attached Files
          Unsuitable
          NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

          Comment


            #6
            Hello Unsuitable,

            I wouldn't have any details on how that menu is coded to work internally, there is not an exposed input that I am aware of for NinjaScript use that would determine the type of share service. For your custom item the most simple way to delegate your logic would be to add a bool input that say something like "SMS" to check if you are using a phone number. Alternatively you could check if the email string is in a certain format like everything before the @ is numbers.

            Also if you are not aware you can create a share service picker using the following code:

            [NinjaScriptProperty]
            [Display(Name="MyShareService", Order=1, GroupName="Parameters")]
            [PropertyEditor("NinjaTrader.Gui.Tools.AlertsShareS erviceEditor")]
            public string MyShareService
            { get; set; }​

            Comment


              #7
              Hello Jesse,

              Yeah thats what I'm doing. The only other way is something that could expose the properties of a share service and check for numbers or @s. The send to input parameter could be used but its not guaranteed like a bool or custom enum. I likely change it to a enum so its more intuitive.

              The share service picker is the current implementation. Unfortunately its just a string at the end of the day.

              Thanks for the help anyways!

              Best regards,

              Unsuitable
              Ocean Trading Indicators
              Unsuitable
              NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              579 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X