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

Problems with NT7

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

    Problems with NT7

    Hi I have a problem with NT7. I want that when an action is completed I draw an arrow and also send me an email. In variables I have it configured correctly and it sends me the emails but it sends me many more than it has to send, that is, the indicator when it paints an arrow has to send an email and on many occasions it sends an email and has not painted an arrow, so I would like to know if it is possible to put the mail within the order to send the arrow.
    Thank you.




    DrawArrowUp("IU" + CurrentBar.ToString(), true, ThisLow-1, Low[ThisLow-1] - (TickSize*MDF), DLC);
    if (emailPartFilled)
    {
    emailPartFilled = true;
    SendMail(fromEmailAddress, toEmailAddress, "NinjaTrader 7 UP Arrow", "Go UP");
    }

    Is it possible to include everything in one order? The arrow does it correctly, for example:


    DrawArrowUp("IU" + CurrentBar.ToString(), true, ThisLow-1, Low[ThisLow-1] - (TickSize*MDF), DLC, SendMail(fromEmailAddress, toEmailAddress, "NinjaTrader 7 UP Arrow", "Go UP");


    #2
    Hello punkiy2111,

    It sounds like your condition is just becoming true multiple times if you get more emails than you are expecting. You may need to add additional conditions to control how frequently this condition can become true.

    In regard to the arrow not appearing when the email is sent, that would be something you would need to debug by looking at the values used at that time.

    The SendMail command should not go within your DrawArrowUp syntax, you would just need to place those within the same condition:


    Code:
    if (emailPartFilled)
    {
    emailPartFilled = true;
    SendMail(fromEmailAddress, toEmailAddress, "NinjaTrader 7 UP Arrow", "Go UP");
    DrawArrowUp("IU" + CurrentBar.ToString(), true, ThisLow-1, Low[ThisLow-1] - (TickSize*MDF), DLC);
    }

    You can use Prints or also include the variables that you used here in the email to better understand whats happening when the object is not drawn. It may just be one of the values being used is incorrect for the use case and the object is not appearing where expected. It could also be the current structure of the script, from the excerpt that is really not enough detail for me to say whats happening.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      What I mean is that the arrow does draw it correctly. what it doesn't do is send the email. What I want to know is if there is a way for me to paint the arrow and send the email in the same order, that is, on the same line. What order could be the closest thing to this?

      DrawArrowUp("IU" + CurrentBar.ToString(), true, ThisLow-1, Low[ThisLow-1] - (TickSize*MDF), DLC, SendMail(fromEmailAddress, toEmailAddress, "NinjaTrader 7 UP Arrow", "Go UP");

      Comment


        #4
        Hello punkiy2111,

        You wouldn't want to try and combine those lines, they don't go together. You can call them one after the other like I had shown in my last post and that would happen at the same time.

        If you are not seeing the email but you do see the arrow you would need to check your email settings or make a test to find out what part of that is not working. If this was a historical condition it should not send any emails, it would only be in realtime.

        You can create a new empty indicator with the following code to test an email:

        Code:
        if(Historical)return;
        SendMail(fromEmailAddress, toEmailAddress, "NinjaTrader 7 UP Arrow", "Go UP");
        You could place this on a 10 second chart and it would try to send an email after 10 seconds elapses and a bar closes.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          No No, the arrow draws it correctly and the email is sent when you type the arrow ... the problem is because it sends more emails than it has to send, too many emails, so my goal is that in the command to write the arrow (which draws it correctly) send the email at the same time (all in the same command) to avoid sending too many emails.

          Comment


            #6
            Hello punkiy2111,

            As I had mentioned if it sends too many emails you would need to add logic to control that. You cannot combine the two lines, you can have them one after another like I had shown. Just as a side note, if you call the drawing object multiple times it won't draw multiple objects it will just update the existing object with the tag you used, the email will send multiple times because its an email.

            You could use a variable to make it happen once per bar or however frequent you wanted. One way is to use a NinjaScript variable like the CurrentBar if you wanted this once per unique bar.
            Code:
            private int myCurrentBar = -1;
            
            protected override void OnBarUpdate()
            {
                if(CurrentBar != myCurrentBar)
                {
                   //email logic in here
            
                    myCurrentBar = CurrentBar;
                }
            }
            when the myCurrentBar is set to the CurrentBar the condition would not be able to become true again until the next bar where its no longer equal. This would be used with CalculateOnBarClose = false type logic.


            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              I'm going to try everything you tell me, please follow the thread, I'll comment on you. Thank you very much, I will let you know. You have a good day.

              Comment


                #8
                I keep testing

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by f.saeidi, Today, 08:01 PM
                0 responses
                1 view
                0 likes
                Last Post f.saeidi  
                Started by Rapine Heihei, Today, 07:51 PM
                0 responses
                3 views
                0 likes
                Last Post Rapine Heihei  
                Started by frslvr, 04-11-2024, 07:26 AM
                5 responses
                96 views
                1 like
                Last Post caryc123  
                Started by algospoke, 04-17-2024, 06:40 PM
                6 responses
                49 views
                0 likes
                Last Post algospoke  
                Started by arvidvanstaey, Today, 02:19 PM
                4 responses
                11 views
                0 likes
                Last Post arvidvanstaey  
                Working...
                X