Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

personal share() service + email recipient = parameter inputs -> how ?

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

    personal share() service + email recipient = parameter inputs -> how ?


    Hi everyone,

    I am able to make this share() method, below, work perfectly when it is filled in the code with the Share Service name and recipient email.
    As soon as I try to make shareServiceName and shareToEmail parameter inputs, I find an error (object not set to an instance),
    I had a few try by using @"" in the code or in the parameters window without success.
    Is it possible to make those parameter inputs ? and how ?


    Code:
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    [B]shareServiceName [/B]= @"";
    [B]shareToEmail [/B]= @"";
    }
    }
    
    private void shareChartCapture()
    {
    // Share(string serviceName, string message, string screenshotPath, object[] args)
    
    Share(
    [B]shareServiceName[/B]
    , @"body of mail"
    , chartCapturePath + ChartName
    , new object[]
    {
    // email adress
    [B]shareToEmail[/B]
    // email subject
    , @"subject"
    } );
    }
    
    [NinjaScriptProperty] [Display(Name = "shareServiceName",
    Description = "name of the share service used",
    Order = 5, GroupName = "Parameters")]
    public string [B]shareServiceName [/B]{ get; set; }
    
    [NinjaScriptProperty] [Display(Name = "shareToEmail",
    Description = "recipient email",
    Order = 6, GroupName = "Parameters")]
    public string [B]shareToEmail [/B]{ get; set; }

    #2
    Hello Amedeus,

    What is the name of the share service you have setup?
    May we have a screenshot?

    These are strings. Yes you could have a public string variable using the NinjaScriptProperty attribute to make this an input.

    The string name needs to match the share service name exactly.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      hey Chelsea, thank you.

      You are right, the share() parameters should work and actually work.
      The error happens in OnStateChange as the output shows, when we implement the chartCapturePath property (not the emails) as it is in the code piece below.

      looking at the output with my feedback of what happens :
      after SDS SetDefaults and the error, the indicator does not work on the chart (it should render something at least, but nothing).
      if I reload the NS on the chart, the indicator partially works (some rendering appears letting us suggest it).
      also, we can see that the chartCapture.png is saved at its location (when the code is told to take a shot),
      but no "message sent" output... (this is why my taught were on the email in the 1st post)

      is there something about the use of Core.Globals.UserDataDir as a default parameter that we should know ? that would explain such behavior.

      piece of code
      Code:
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      chartCapturePath = Core.Globals.UserDataDir;
      shareServiceName = "";
      shareToEmail = "";
      }
      }
      
      [NinjaScriptProperty] [Display(Name = "chartCapturePath",
      Description = "path of chartCapture location (default is nt8 directory in Documents)",
      Order = 3, GroupName = "Parameters")]
      public string chartCapturePath { get; set; }
      output
      Code:
      SDS SetDefaults
      Indicator ' ': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
      chartCaptureDated saved to C:\Users\UserName\Documents\NinjaTrader 8\
      (edit) note that the output names the indicator Indicator ' ', but this is not the name of the indicator, does that tell us something ?
      Last edited by Amedeus; 04-04-2022, 10:25 AM.

      Comment


        #4
        Hello Amedeus,

        I would not expect the code you have shared to cause an error. This is assigning strings.

        Are you certain that specific code is causing the error? If you make a test script and add only that code you can reproduce the error?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hey Chelsea, thank you.

          found the why : in the chart parameter window we must be careful to add \ at the end of the file path :

          C:\Users\UserName\somewhere\
          instead of
          C:\Users\UserName\somewhere

          the issue was not in the code but in the user input parameter.

          thanks again and have a good one.

          Comment


            #6
            Hello Amedeus,

            Moving forward, be sure to include the specific line of code causing the error, if you want assistance with the error.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            566 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            330 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
            547 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            548 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X