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

Share Service setup

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

    Share Service setup

    I created the service share correctly. The test email has been confirmed. But when my strategy makes a trade I still do not get an email or text alert. Is the correct syntax:

    if( A + B)
    {
    Share("Google", "Test Message", new object[]{ "[email protected]", "Test Subject Line" });
    Share("Google Text", "Test Message", new object[]{ "[email protected]", "Test Subject Line" });
    }

    Or

    else if (State == State.Realtime)
    {
    Share("Google", "Test Message", new object[]{ "[email protected]", "Test Subject Line" });
    Share("Google Text", "Test Message", new object[]{ "[email protected]", "Test Subject Line" });
    }

    #2
    Hi AdeptistJune, the email in the Arg[0] should be the email you want to send the message to. Try this out and let me know if this does not resolve.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hey Chris,

      I'm using your Email Indicator. It works perfectly, just need it to let me know where a long or short was entered:

      private void OnExecutionUpdate(object sender, ExecutionEventArgs e)

      {
      if(e.Execution.Order != null)
      {
      if (e.Execution.Order.OrderState == OrderState.Filled)
      {
      SendMail(ToEmail, "Execution on your account",
      string.Format("Instrument: {0} Quantity: {1} Price: {2}",e.Execution.Instrument.FullName, e.Quantity, e.Price)
      );
      }

      if (EmailPartFilled && e.Execution.Order.OrderState == OrderState.PartFilled)
      {
      SendMail(ToEmail, "Partial execution on your account",
      string.Format("Instrument: {0} Quantity: {1} Price: {2}",e.Execution.Instrument.FullName, e.Quantity, e.Price)
      );
      }
      }

      NinjaTrader.Code.Output.Process(string.Format("Ins trument: {0} Quantity: {1} Price: {2}",

      e.Execution.Instrument.FullName, e.Quantity, e.Price), PrintTo.OutputTab1);

      }

      Comment


        #4
        Hi AdeptistJune, The Execution object has a MarketPosition value that you can access that tells you if the execution was a buy or a sell:



        Kind regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hello, Chris

          When using the Email Indicator, when closing a long position, the text will say Market Position: Short.

          Is it possible to get the text to read "Sell" instead of "Short" when a long position is closed?

          Also, is it possible to get the text to read the name of the entry or exit signal?

          Thanks.

          Comment


            #6
            Hi AdeptistJune, thanks for your reply.

            You would have to translate it in the script itself. E.g. when a "Short" execution comes through and the position is going from Long to flat, you would write "Sell". The execution object that I already linked has all the available information that you can get from the OnExecutionUpdate method. Please look there for all of the available information.

            Kind regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thanks for the update Chris,

              I know your team is extremely busy today, but whenever you have time, can you explain how "I would translate it in the script itself." Do I translate in the OnStateChange method or the OnBarupdate Method?

              Thanks.

              Comment


                #8
                Hi AdeptistJune, thanks for your reply.

                You can use C# if statements to write "Sell" instead of Short. e.g.

                Code:
                //in OnExecutionUpdate
                
                if(e.Execution.MarketPosition == MarketPosition.Short)
                {
                    Print("Sell order");
                }
                
                if(e.Execution.MarketPosition == MarketPosition.Long)
                {
                    Print("Buy order");
                }
                Make sure you are using Print() while you work on scripts so you can see the data coming from the script.

                Kind regards,
                -ChrisL
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hello, Chris,

                  Sorry for the confusion, but I don't know how to translate the script. Am I re-assigning variable? I've tried but it's still showing Long or Short as exits.

                  if(e.Execution.MarketPosition == MarketPosition.Short) { e.Execution.MarketPosition =="Sell order"; }?

                  I've tried, and I still can't get it to work. I have multiple trading signals and I still can't get it to identify which signal was executed.

                  Is there a thread I can learn from?

                  Thanks

                  Comment


                    #10
                    Hi AdeptistJune, You would modify the script using C# if statements like this:
                    Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks, Chris,

                      I see exactly how to do it now.

                      I have a new issue. I'm no longer getting the email alerts using your Email Indicator. I checked my setting and sent a test email, and it will through successfully. I even did SendMail(), and it work as it should.

                      But Share() doesn't work and your Email Indicator doesn't work.

                      Any troubleshooting techniques I can use to get down to the issue?

                      Thanks, again for your patience and willingness to help.

                      Comment


                        #12
                        Hi, the original script works as long as you have a share service set up. Do you see any errors in the Log tab of your Control Center?
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello, Chris

                          No. I don't see any errors. I didn't change anything in the script so I have no clue as to what happened. I'm still troubleshooting, backtracking my steps to see what I find.

                          I may need to delete the share service set up and re-do it.

                          Comment


                            #14
                            Good morning Chris,

                            Is possible for me to write a script to show the PnL of the trade it just made in the email text?

                            Comment


                              #15
                              Hi AdeptistJune, It is posisble. Use the OnPositionUpdate method and SendMail to do this:



                              The scripts that are up on the ecosystem website come As Is, so I will not be able to add any more functionality to this example, but it is definitely possible.
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by arvidvanstaey, Today, 02:19 PM
                              4 responses
                              11 views
                              0 likes
                              Last Post arvidvanstaey  
                              Started by samish18, 04-17-2024, 08:57 AM
                              16 responses
                              61 views
                              0 likes
                              Last Post samish18  
                              Started by jordanq2, Today, 03:10 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post jordanq2  
                              Started by traderqz, Today, 12:06 AM
                              10 responses
                              18 views
                              0 likes
                              Last Post traderqz  
                              Started by algospoke, 04-17-2024, 06:40 PM
                              5 responses
                              48 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X