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

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 PhillT, 04-19-2024, 02:16 PM
            4 responses
            31 views
            0 likes
            Last Post PhillT
            by PhillT
             
            Started by ageeholdings, 05-01-2024, 05:22 AM
            5 responses
            36 views
            0 likes
            Last Post ageeholdings  
            Started by reynoldsn, Today, 02:34 PM
            0 responses
            8 views
            0 likes
            Last Post reynoldsn  
            Started by nightstalker, Today, 02:05 PM
            0 responses
            15 views
            0 likes
            Last Post nightstalker  
            Started by llanqui, Yesterday, 09:59 AM
            8 responses
            30 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Working...
            X