Announcement

Collapse
No announcement yet.

Adx

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

  • Adx

    Hi,
    how to change this wizard code, that only the current drawtextrelativ-text is drawn? Not the Alerts before.
    Thanks


    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vLastAlert = -1;
    //}}EFSWizard_Declarations


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(true);
    setStudyTitle("adxAlert2");
    //}}EFSWizard_PreMain

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if (
    adx(14, 14) > 30
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    adx(14, 14) <= 30
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return null;
    //}}EFSWizard_Return

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    if (vLastAlert != 1) drawTextRelative(0, low(), "ALERT", Color.RGB(155,0,0), Color.RGB(255,255,255), Text.LEFT, "Arial", 18);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    drawTextRelative(0, low(), "OK", Color.RGB(155,0,0), Color.RGB(255,255,255), Text.LEFT, "Arial", 18);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions

  • #2
    Bugeleisen
    In the drawTextRelative parameters you need to add a tagName that is unique to that text object (see the example and explanation shown in the enclosed screenshot). This way only the last one gets drawn because all the text objects drawn by that command will have the same tagName.
    Alex

    Comment


    • #3
      Thank you. Now it looks better.
      But:
      How to change the code, that only the drawTextRealtive of the current bar/last Bar ist drawn?

      Comment


      • #4
        Bugeleisen
        Use the same tagName for both drawTextRelative commands (ie the one that writes ALERT and the one that writes OK).
        Also you need to move the drawTextRelative command that writes ALERT from the "...while the following will happen only the first time" section to the "...then the following will happen everytime" section
        Alex

        Comment


        • #5
          Same Problem: Both, "ALERT" and "OK" are displayed at the same time on the chart.
          What`s wrong?
          Thanks


          //{{EFSWizard_Description
          //
          // This formula was generated by the Alert Wizard
          //
          //}}EFSWizard_Description


          //{{EFSWizard_Declarations
          var vLastAlert = -1;
          //}}EFSWizard_Declarations


          function preMain() {
          /**
          * This function is called only once, before any of the bars are loaded.
          * Place any study or EFS configuration commands here.
          */
          //{{EFSWizard_PreMain
          setPriceStudy(true);
          setStudyTitle("adxAlert3");
          //}}EFSWizard_PreMain

          }

          function main() {
          /**
          * The main() function is called once per bar on all previous bars, once per
          * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
          * in your preMain(), it is also called on every tick.
          */

          //{{EFSWizard_Expressions
          //{{EFSWizard_Expression_1
          if (
          adx(14, 14) > 30
          ) onAction1()
          //}}EFSWizard_Expression_1

          //{{EFSWizard_Expression_2
          else if (
          adx(14, 14) <= 30
          ) onAction2();
          //}}EFSWizard_Expression_2

          //}}EFSWizard_Expressions


          //{{EFSWizard_Return
          return null;
          //}}EFSWizard_Return

          }

          function postMain() {
          /**
          * The postMain() function is called only once, when the EFS is no longer used for
          * the current symbol (ie, symbol change, chart closing, or application shutdown).
          */
          }

          //{{EFSWizard_Actions
          //{{EFSWizard_Action_1
          function onAction1() {
          drawTextRelative(0, low(), "ALERT", Color.RGB(255,0,0), Color.RGB(255,255,255), Text.LEFT, "Arial", 20, "ALERT");
          vLastAlert = 1;
          }
          //}}EFSWizard_Action_1

          //{{EFSWizard_Action_2
          function onAction2() {
          drawTextRelative(0, low(), "OK", Color.RGB(155,0,0), Color.RGB(255,255,255), Text.LEFT, "Arial", 8);
          vLastAlert = 2;
          }
          //}}EFSWizard_Action_2

          //}}EFSWizard_Actions
          Last edited by Bügeleisen; 10-25-2007, 03:19 PM.

          Comment


          • #6
            Bugeleisen
            If the same tagName is used in both drawTextRelative commands as I suggested in my prior reply the ALERT and OK text should not display at the same time. Post the code that you are using and I will take a look at it
            Alex


            Originally posted by Bügeleisen
            Same Problem: Both, "ALERT" and "OK" are displayed at the same time on the chart.
            What`s wrong.
            Thnaks

            Comment


            • #7
              Look at the code before. That`s the current code after your suggested changes.

              Comment


              • #8
                Bugeleisen

                Look at the code before. That`s the current code after your suggested changes
                I notice that you edited your message adding the code after I posted my reply. Keep in mind that editing a post does not generate an email notification so those [like myself] who rely on this tool to read messages posted to a thread or forum may not be aware of any edits that are subsequently applied to a message.

                Same Problem: Both, "ALERT" and "OK" are displayed at the same time on the chart.
                That is because you are not using the same tagName in both drawTextRelative commands as I suggested earlier (see enclosed screenshots). Actually one of the drawTextRelative commands does not have a tagName at all so it will write the text on each bar in which the condition is true (see my prior suggestion regarding this issue).
                Alex






                Originally posted by Bügeleisen
                Look at the code before. That`s the current code after your suggested changes.

                Comment


                • #9
                  My mistake. Sorry.
                  Now it`s ok.

                  thanks a lot.

                  Comment


                  • #10
                    Bugeleisen
                    No problem. I am glad to hear that it is working fine now.
                    Alex


                    Originally posted by Bügeleisen
                    My mistake. Sorry.
                    Now it`s ok.

                    thanks a lot.

                    Comment

                    Working...
                    X