Announcement

Collapse
No announcement yet.

Candle Reversal

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

  • Candle Reversal

    Happy Thansgiving Everyone;
    Could someone help me with this efs. My "Sell" position on my price chart is to the right of the candle. I want it to be on top of the candle. My "Buy" wording is correct, but I can't figure out how to change my "Sell" positioning.
    Also, the wave file plays the day after, is there a way to make the wave file play for today?
    Here is the efs.

    var vLastAlert = -1;


    function preMain() {

    setPriceStudy(true);
    setStudyTitle("ReversalCandlesr2");
    setComputeOnClose(true);
    }

    function main() {

    if (
    close() <= low(-1)
    ) onAction1()


    else if (
    close() >= high(-1)
    ) onAction2();


    return null;

    }

    function onAction1() {
    if (vLastAlert != 1) drawTextRelative(0, high(), "Sell", Color.white, null, Text.top|Text.top|Text.BOLD, "dungeon", 12);Alert.playSound("Ohno.wav");
    vLastAlert = 1;
    }

    function onAction2() {
    if (vLastAlert != 2) drawTextRelative(-1, low(), "Buy", Color.black, null, Text.top|Text.top|Text.BOLD, "dungeon", 12);;Alert.playSound("yea.wav");
    vLastAlert = 2;
    }

  • #2
    gwika
    Happy Thanksgiving to you too.
    - In both drawTextRelative() commands you have Text.top which is not a valid syntax. This should be Text.TOP if you want to align the top of the text to the Y-value or Text.BOTTOM if you want to align the bottom of the text. Also in both commands this flag is used twice.
    - In the drawTextRelative() command in function onAction2() you are using -1 as the X-value instead of 0. FYI you do not need to use -1 in the case of this script since it is being computed on closed bars only. If however you do want to locate the text on the prior bar ie at -1 then you should also use low(-1) as the Y-value.
    Also you have a double semi-colon at the end of this drawTextRelative() command.
    Anyhow for the "Sell" to be written in the location you want use the example enclosed below
    For more information on drawTextRelative() see this article in the EFS knowledgebase
    Alex

    PHP Code:
    drawTextRelative(0high(), "Sell"Color.whitenullText.BOTTOM|Text.CENTER|Text.BOLD"dungeon"12

    Comment


    • #3
      Alex;
      Made your suggested changes to the efs, and it works perfectly. Once again many thanks.
      Happy Holidays.....Greg

      Comment


      • #4
        Greg
        You are most welcome and thank you for the feedback.
        Happy Holidays to you too.
        Alex

        Comment


        • #5
          Candle Recersal error

          Alex;
          I'm getting this error
          Line 34: Parameter Number 4 of Function drawTextRelative is invalid.
          Here is my efs:

          var vLastAlert = -1;


          function preMain() {

          setPriceStudy(true);
          setStudyTitle("ReversalCandlesr2");
          setComputeOnClose(true);
          }

          function main() {

          if (
          close() <= low(-1)
          ) onAction1()


          else if (
          close() >= high(-1)
          ) onAction2();


          return null;

          }

          function onAction1() {
          if (vLastAlert != 1) drawTextRelative(0, high(), "Sell", Color.white, null, Text.BOTTOM|Text.CENTER|Text.BOLD, "dungeon", 18);
          vLastAlert = 1;
          }

          function onAction2() {
          if (vLastAlert != 2) drawTextRelative(0, low(), "Buy", Color.black, null, Text.TOP|Text.CENTER|Text.BOLD, "dungeon", 18);
          vLastAlert = 2;
          }



          I have worked on this for days trying to figure out why the error.Can you help?
          THX...Greg

          Comment


          • #6
            Re: Candle Recersal error

            Greg
            I am not getting any errors and as far as I can see the script is working fine
            Alex


            Originally posted by gwika
            Alex;
            I'm getting this error
            Line 34: Parameter Number 4 of Function drawTextRelative is invalid.
            Here is my efs:

            var vLastAlert = -1;


            function preMain() {

            setPriceStudy(true);
            setStudyTitle("ReversalCandlesr2");
            setComputeOnClose(true);
            }

            function main() {

            if (
            close() <= low(-1)
            ) onAction1()


            else if (
            close() >= high(-1)
            ) onAction2();


            return null;

            }

            function onAction1() {
            if (vLastAlert != 1) drawTextRelative(0, high(), "Sell", Color.white, null, Text.BOTTOM|Text.CENTER|Text.BOLD, "dungeon", 18);
            vLastAlert = 1;
            }

            function onAction2() {
            if (vLastAlert != 2) drawTextRelative(0, low(), "Buy", Color.black, null, Text.TOP|Text.CENTER|Text.BOLD, "dungeon", 18);
            vLastAlert = 2;
            }



            I have worked on this for days trying to figure out why the error.Can you help?
            THX...Greg

            Comment

            Working...
            X