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

What's wrong with this Alert

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

    What's wrong with this Alert

    This alert goes on without any raison (sometimes when it don't ).
    private bool setAlert = true;
    Code:
    if ( (rsiValue > rsiOB) && (mfiValue > mfiOB) && (bolPerc > bPercOB) && (imiValue > imiOB) && (stosValue > stosOB ) && (tsiLevel > tsiOB)){
                    DrawText("Sell"+CurrentBar, false, "S", 0, High[0] + textOffset ,0, Color.Red, txtFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
                    if (setAlert) Alert("myAlert", NinjaTrader.Cbi.Priority.High, "Reached threshold", "Alert4.wav", 2, Color.Black, Color.Yellow); return; }
    thanks
    Last edited by mate41; 03-09-2016, 09:17 AM.

    #2
    Hello mate41,

    The syntax on your code is incorrect. A semi-colon is used to terminate a command. If the semi-colon is added at the end of the if statement the next line of code will not be within the action block of that branching command.


    f ( (rsiValue > rsiOB) && (mfiValue > mfiOB) && (bolPerc > bPercOB) && (imiValue > imiOB) && (stosValue > stosOB ) && (tsiLevel > tsiOB)){
    DrawText("Sell"+CurrentBar, false, "S", 0, High[0] + textOffset ,0, Color.Red, txtFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);

    By having a semi-colon at the end of this, this entire branching command is not used.

    The alert will go off if setAlert is true, ignoring the if statement above.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Removing the (; in red) create an error and can't compile.
      The first (if) stay between brackets ({}) as you can see, within a second (if) and a return.

      Code:
      if ( (rsiValue > rsiOB) && (mfiValue > mfiOB) &&  (bolPerc > bPercOB) && (imiValue > imiOB) &&  (stosValue > stosOB ) && (tsiLevel > tsiOB))[COLOR=Red][B]{[/B][/COLOR]
                      DrawText("Sell"+CurrentBar, false, "S", 0, High[0] +  textOffset ,0, Color.Red, txtFont, StringAlignment.Center,  Color.Transparent, Color.Transparent, 0)[B][COLOR=DarkRed][U];
      [/U][/COLOR][/B][COLOR=Black]if (setAlert) Alert("myAlert", NinjaTrader.Cbi.Priority.High, "Reached threshold", "Alert4.wav", 2, Color.Black, Color.Yellow);[/COLOR][COLOR=Black]return;[/COLOR][COLOR=DarkRed][B][COLOR=Red]}[/COLOR][/B]
      [/COLOR]

      Comment


        #4
        Hi mate41,

        That was my mistake. This looked all like the same if statement.

        Have you added any prints to your code to find out what the state of every variable in the condition is? This would let you know why the condition is evaluating as true when the alert is triggered.

        Do you want assistance creating a print?
        https://www.youtube.com/watch?v=K8v_...tu.be&t=48m45s

        If you have created prints, can you post the output from the output window?
        At what time have you gotten alerts in the Alerts window that were unexpected?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          It's printed on the chart. I confirm alert is done sometimes when i doesn't.
          Visible on the chart, no doubt, someting is wrong with that alert.
          Attached Files

          Comment


            #6
            Hello mate41,

            I don't have any way of testing these values without the full script that sets these values.

            But a print would look like this:

            Code:
            Print(string.Format("{0} | (rsiValue: {1} > rsiOB: {2}) && (mfiValue: {3} > mfiOB: {4}) && (bolPerc: {5} > bPercOB: {6}) && (imiValue: {7} > imiOB: {8}) && (stosValue: {9} > stosOB : {10}) && (tsiLevel: {11} > tsiOB: {12}) && setAlert: {13}",
            Time[0], rsiValue, rsiOB, mfiValue, mfiOB, bolPerc, bPercOB, imiValue, imiOB, stosValue, stosOB, tsiLevel, tsiOB, setAlert));
            Please include the output from this print along with a screenshot of the alert from the alert window showing the time the alert was triggered.

            For each bar we will see the values here, and we can compare the values for that bar with the time in the Alerts window of the alert.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Ok, here is the screenshot & the file. File to long, so have cut some.
              Attached Files

              Comment


                #8
                Hello mate41,

                Unfortunately, the output included in the file does not coordinate to the times of the alerts shown in the screenshot (they don't match up).

                If you want to discuss and alert that appears in the Alert window that is not showing in the Output, I will need to see the Alert in the alert window, and the output from the same time.

                If the alert incorrect alert is the alert on the ES that says Reached threshold repeatedly focusing on the alert at 14:58:59, I would need to see the Output at 14:58:59 (2:58:59 PM).

                Also, the print needs to be made from the same script instance running that is creating the alert. Alerts only appear in real-time, so we need a new alert made in real-time, and the output at the time the new alert is created.

                As long as this is the condition that triggers the alert, we should see the conditions show the condition was true.

                Can you also post the complete print and alert code that you added?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I've found it I think. Another intrument is running in the background (RIG).
                  But I can't see it ??? How can i remove a running invisible instrument (chart?) ?
                  ....
                  That instrument was running in another workspace, so i removed this workspace en cross the fingers

                  Sorry for your time ChelseaB.
                  Last edited by mate41; 03-10-2016, 11:06 AM.

                  Comment


                    #10
                    Hello mate41,

                    There is not a way to list the sources of all alerts. You will need to look through the workspace on every window for every indicator / strategy or for every alert filter in every Market Analyzer window.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      I come back about this problem.....
                      I had 2 workspaces but only 1 in USE with an indicator with his alert at some level.
                      In the second workspace NOT IN USE, there is also an indicator, also with his alert on some level.

                      The problem:
                      Why is this alert in workspace 2 who's not in use ACTIVATED and disturb my indicator in the actived workspace 1 ?
                      To solve the problem the indicator in the 2d workspace has to be removed.

                      Comment


                        #12
                        Hello mate41,

                        If a workspace is closed, there would not be any running scripts from it.

                        If you can demonstrate that and indicator can create an alert from a workspace that is not listed in the File -> Workspaces menu under the separator line (meaning it is closed), then this would be a bug that we need to report.

                        Just to double check, I have created an indicator that triggers constant alerts and saved this in a workspace. When I closed the workspace the alerts stopped.

                        Are you able to demonstrate that an Alert will continue being triggered after the workspace is closed?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          I can't have 2 workspaces similtanneous open, right ?
                          So an indicator can't run on a closed workspace, right ?
                          Since i removed the indicator in the CLOSED workspace, the problem was solved.
                          best regards

                          Comment


                            #14
                            Hi mate41,

                            Yes, you can have many workspaces open simultaneously.
                            (That I know of, there isn't a limit to the number of workspaces that can be open simultaneously)

                            Any workspaces listed under the separator line in the File -> Workspaces menu is open and running.

                            No, an indicator cannot run from a workspace that has been closed. (File -> Workspaces -> Close Workspace)

                            From the sound of it, closing the workspace caused the indicator to stop triggering alerts and there would be no bug to submit. Is this correct?
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              My bad. More than 1 workspace can be opened simultanously.
                              But deleting the untitlet1 can't and this workspace contained the indicator with an alert on it running.
                              So problem solved and thanks for your time, was very helpfull.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Perr0Grande, Today, 08:16 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Perr0Grande  
                              Started by elderan, Today, 08:03 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post elderan
                              by elderan
                               
                              Started by algospoke, Today, 06:40 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post algospoke  
                              Started by maybeimnotrader, Today, 05:46 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by quantismo, Today, 05:13 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post quantismo  
                              Working...
                              X