Announcement

Collapse
No announcement yet.

Attaching Arrows

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

  • Attaching Arrows

    I was attempting to add Xover arrows to the code below and got lost along the way. Can someone familiar with EFS2 offer some assistance/guidance. The syntax error(s) are at line 80, 85

    Thanks
    Doug


    var lastrawtime = 0;
    var BarCount = 0;

    var fpArray = new Array();
    var amLib = addLibrary("amStudies.efsLib");

    function preMain() {

    setStudyTitle("MTF NormMACD1");
    setCursorLabelName("MACD",0);
    setCursorLabelName("MACDSig",1);
    setDefaultBarFgColor(Color.blue,0);
    setDefaultBarFgColor(Color.red,1);
    setPlotType(PLOTTYPE_LINE,0);
    setPlotType(PLOTTYPE_LINE,1);
    setDefaultBarThickness(1,0);
    setDefaultBarThickness(1,1);
    setDefaultBarThickness(1,2);
    askForInput();

    var x=0;
    fpArray[x] = new FunctionParameter("Fast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(12);
    }
    fpArray[x] = new FunctionParameter("Slow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(26);
    }
    fpArray[x] = new FunctionParameter("Smoothing", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(5);
    }
    fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
    with(fpArray[x++]){
    addOption("Open");
    addOption("High");
    addOption("Low");
    addOption("Close");
    setDefault("Close");
    }
    fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
    with(fpArray[x++]){
    setDefault("");
    }
    fpArray[x] = new FunctionParameter("Interval", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setDefault("");
    }
    }

    var bInit = false;
    var vSymbol = null;

    function main(Fast,Slow,Smoothing,Source,Symbol,Interval){

    if(bInit == false){
    addBand(0,PS_SOLID,1,Color.aqua,"Centerline");
    if(Symbol == null) Symbol = getSymbol();
    if(Interval == null) Interval = getInterval();
    vSymbol = Symbol+","+Interval;
    bInit = true;

    }

    var xMACD = amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,Smoot hing,Source,sym(vSymbol)));
    var xSig = wma(Smoothing,xMACD);

    var space = 1;

    if (lastrawtime != getValue("rawtime", 0)) {
    BarCount += 1;
    lastrawtime = getValue("rawtime", 0);
    }

    if(xMACD.getValue(amLib.amDEMA(2,efsInternal("rati o",Fast,Slow,Smoothing,Source,sym(vSymbol)))) > xSig.getValue(wma(Smoothing,xMACD) && xMACD.getValue(amLib.amDEMA(2,efsInternal("ratio", Fast,Slow,Smoothing,Source,sym(vSymbol))),-1) < xSig.getValue(wma(Smoothing,xMACD),-1){
    drawTextRelative(0,low()-(space*1.0),"é",Color.lime,null,Text.TOP|Text.CENT ER|Text.BOLD,"Wingdings",10,"Up"+ BarCount);
    }else{
    removeText("Up"+BarCount);
    }
    if(xMACD.getValue(amLib.amDEMA(2,efsInternal("rati o",Fast,Slow,Smoothing,Source,sym(vSymbol)))) < xSig.getValue(wma(Smoothing,xMACD) && xMACD.getValue(amLib.amDEMA(2,efsInternal("ratio", Fast,Slow,Smoothing,Source,sym(vSymbol))),-1) > xSig.getValue(wma(Smoothing,xMACD),-1){
    drawTextRelative(0,high()+(space*1.0),"ê",Color.re d,null,Text.BOTTOM|Text.CENTER|Text.BOLD,"Wingding s",10,"Dn"+ BarCount);
    }else{
    removeText("Dn"+BarCount);
    }


    return new Array (xMACD,xSig);
    }


    function ratio(){

    var x = 0;
    var sht = wma(12);
    var lng = wma(26);

    var ratio = (Math.min(sht,lng)/Math.max(sht,lng));

    var ret = sht>lng?((2-ratio)-1)*100(ratio)-1)*100;

    return ret;
    }

  • #2
    Doug,

    You have some problems with parenthesis matching on your if statements. I would suggest assigning each of the sections of the if statement as separate variables. That would allow you to get a better idea where they are not matching up. Further, it would reduce the number of times you are calling each function, which reduces the resources required.

    Also, you are performing this every tick, which can be quite resource intensive. May I suggest enclosing in the lastrawtime if statement.

    Also, I think you need to add this section

    var xMACD = amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,Smoot hing,Source,sym(vSymbol)));
    var xSig = wma(Smoothing,xMACD);

    into the binit section. Since you are defining xMACD as an instance of the amLib.amDEMA class with those variables, you only need to do this once. To support this, you will have to define xMACD and xSig as global variables outside main.

    Finally, I believe in the if statement, this

    xMACD.getValue(amLib.amDEMA(2,efsInternal("ratio", Fast,Slow,Smoothing,Source,sym(vSymbol))))

    should be this

    xMACD.getValue(0)

    since you are already defining xMACD as an object, you do not need to repeat the variable structure.

    One more thing, this line is also in error var ret = sht>lng?((2-ratio)-1)*100(ratio)-1)*100;, you are missing a : in the conditional expression.

    edit

    One more thing which I should have noticed... regarding efsInternal(), you are calling
    efsInternal("ratio",Fast,Slow,Smoothing,Source,sym (vSymbol)

    All of the variables after "ratio" are optional parameters, required by the user-defined function you are calling. However, the ratio function below has no parameters in the function name, therefore, these really do not mean anything in the context of this function.
    Last edited by Guest; 05-09-2005, 07:25 PM.

    Comment


    • #3
      Hi Steve

      Thanks for the reply and the great feedback. Made most of your suggested changes but still not right. Can you take another look when you have a chance. Also, I'm including the original version without the arrowswhich seems to work fine for comparison.

      Thanks
      Doug

      var lastrawtime = 10;
      var BarCount = 0;

      var fpArray = new Array();
      var amLib = addLibrary("amStudies.efsLib");

      function preMain() {

      setStudyTitle("MTF NormMACD1");
      setCursorLabelName("MACD",0);
      setCursorLabelName("MACDSig",1);
      setDefaultBarFgColor(Color.blue,0);
      setDefaultBarFgColor(Color.red,1);
      setPlotType(PLOTTYPE_LINE,0);
      setPlotType(PLOTTYPE_LINE,1);
      setDefaultBarThickness(1,0);
      setDefaultBarThickness(1,1);
      setDefaultBarThickness(1,2);
      askForInput();

      var x=0;
      fpArray[x] = new FunctionParameter("Fast", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setLowerLimit(1);
      setDefault(12);
      }
      fpArray[x] = new FunctionParameter("Slow", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setLowerLimit(1);
      setDefault(26);
      }
      fpArray[x] = new FunctionParameter("Smoothing", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setLowerLimit(1);
      setDefault(5);
      }
      fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
      with(fpArray[x++]){
      addOption("Open");
      addOption("High");
      addOption("Low");
      addOption("Close");
      setDefault("Close");
      }
      fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
      with(fpArray[x++]){
      setDefault("");
      }
      fpArray[x] = new FunctionParameter("Interval", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setDefault("");
      }
      }

      var bInit = false;
      var vSymbol = null;
      var xMACD = amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,Smoot hing,Source,sym(vSymbol)));
      var xSig = wma(Smoothing,xMACD);

      function main(Fast,Slow,Smoothing,Source,Symbol,Interval){

      if(bInit == false){
      addBand(0,PS_SOLID,1,Color.aqua,"Centerline");
      if(Symbol == null) Symbol = getSymbol();
      if(Interval == null) Interval = getInterval();
      vSymbol = Symbol+","+Interval;
      bInit = true;

      }



      var space = 1;

      if (lastrawtime != getValue("rawtime", 10)) {
      BarCount += 1;
      lastrawtime = getValue("rawtime", 10);
      }

      if(xMACD.getValue(0)) > xSig.getValue(wma(Smoothing,xMACD)) && (xMACD.getValue(0),-1) < xSig.getValue(wma(Smoothing,xMACD),-1){
      drawTextRelative(0,low()-(space*1.0),"é",Color.lime,null,Text.TOP|Text.CENT ER|Text.BOLD,"Wingdings",10,"Up"+ BarCount);
      }else{
      removeText("Up"+BarCount);
      }
      if(xMACD.getValue(0)) < xSig.getValue(wma(Smoothing,xMACD) && (xMACD.getValue(0),-1) > xSig.getValue(wma(Smoothing,xMACD),-1){
      drawTextRelative(0,high()+(space*1.0),"ê",Color.re d,null,Text.BOTTOM|Text.CENTER|Text.BOLD,"Wingding s",10,"Dn"+ BarCount);
      }else{
      removeText("Dn"+BarCount);
      }


      return new Array (xMACD,xSig);
      }


      function ratio(){

      var x = 0;
      var sht = wma(12);
      var lng = wma(26);

      var ratio = (Math.min(sht,lng)/Math.max(sht,lng));

      var ret = sht>lng?((2-ratio)-1)*100(ratio)-1)*100;

      return ret;
      }

      =====================================

      var fpArray = new Array();
      var amLib = addLibrary("amStudies.efsLib");

      function preMain() {

      setStudyTitle("MTF NormMACD1");
      setCursorLabelName("MACD",0);
      setCursorLabelName("MACDSig",1);
      setDefaultBarFgColor(Color.blue,0);
      setDefaultBarFgColor(Color.red,1);
      setPlotType(PLOTTYPE_LINE,0);
      setPlotType(PLOTTYPE_LINE,1);
      setDefaultBarThickness(1,0);
      setDefaultBarThickness(1,1);
      setDefaultBarThickness(1,2);
      askForInput();

      var x=0;
      fpArray[x] = new FunctionParameter("Fast", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setLowerLimit(1);
      setDefault(12);
      }
      fpArray[x] = new FunctionParameter("Slow", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setLowerLimit(1);
      setDefault(26);
      }
      fpArray[x] = new FunctionParameter("Smoothing", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setLowerLimit(1);
      setDefault(5);
      }
      fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
      with(fpArray[x++]){
      addOption("Open");
      addOption("High");
      addOption("Low");
      addOption("Close");
      setDefault("Close");
      }
      fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
      with(fpArray[x++]){
      setDefault("");
      }
      fpArray[x] = new FunctionParameter("Interval", FunctionParameter.NUMBER);
      with(fpArray[x++]){
      setDefault("");
      }
      }

      var bInit = false;
      var vSymbol = null;

      function main(Fast,Slow,Smoothing,Source,Symbol,Interval){

      if(bInit == false){
      addBand(0,PS_SOLID,1,Color.aqua,"Centerline");
      if(Symbol == null) Symbol = getSymbol();
      if(Interval == null) Interval = getInterval();
      vSymbol = Symbol+","+Interval;
      bInit = true;

      }

      var xMACD = amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,Smoot hing,Source,sym(vSymbol)));
      var xSig = wma(Smoothing,xMACD);



      return new Array (xMACD,xSig);
      }


      function ratio(){

      var x = 0;
      var sht = wma(12);
      var lng = wma(26);

      var ratio = (Math.min(sht,lng)/Math.max(sht,lng));

      var ret = sht>lng?((2-ratio)-1)*100(ratio)-1)*100;

      return ret;
      }

      Comment


      • #4
        Hi Doug,

        Well, I would put your effort fairly high on the complexity scale. As such, I recommend taking small steps, and each step verifying full functionality.

        One thing I noticed is that when you post your code as you did, this step in your ratio function

        var ret = sht>lng?((2-ratio)-1)*100(ratio)-1)*100;

        has a sad Smilie instead of code, which is perhaps the source of one of the errors I saw yesterday. That is why when posting code, you should either attach it, or preferably post it using the PHP option. That way, it is not inadvertantly modified when a specific sequence of keystrokes is detected. (see posting guidelines )

        Regarding the code you posted, it is not too clear to me which set of code is which. In hindsight, that may be the reason I had this error this morning when I ran your code...




        Also, here is a screenshot of the amDEMA syntax



        The way you have it formatted (var xMACD = amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,Smoot hing,Source,sym(vSymbol)));) , the efsInternal is the source for the DEMA calculation and since you are calling the ratio function, all of the variables after "ratio" have no meaning.

        Regarding format of the conditional if statement, you are almost there. It should be more like this I believe:

        PHP Code:
        if(xMACD.getValue(0)) > xSig.getValue(0) && (xMACD.getValue(-1) < xSig.getValue(-1)){ 
        Regarding this snippet of code, the global definition of the xMACD variable is going to error out since you are using variables you have not defined yet in the code (in main):
        PHP Code:
        var bInit false;
        var 
        vSymbol null;
        var 
        xMACD amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,Smoothing,Source,sym(vSymbol)));
        var 
        xSig wma(Smoothing,xMACD);

        function 
        main(Fast,Slow,Smoothing,Source,Symbol,Interval){

        if(
        bInit == false){
        addBand(0,PS_SOLID,1,Color.aqua,"Centerline");
        if(
        Symbol == nullSymbol getSymbol();
        if(
        Interval == nullInterval getInterval();
        vSymbol Symbol+","+Interval;
        bInit true;


        That is why you would define xMACD like this var xMACD; as a global variable, then place xMACD = amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,Smoot hing,Source,sym(vSymbol))); in the binit section.

        Having said that, I believe the format for the xMACD to be in error. Rather, it should look more like this xMACD = amLib.amDEMA(2,efsInternal("ratio"));

        To carry this thought through, here is my recommendation for the code snippet posted above:

        PHP Code:
        var bInit false;
        var 
        vSymbol null;

        var 
        xMACD;
        var 
        xSig;

        function 
        main(Fast,Slow,Smoothing,Source,Symbol,Interval){

        if(
        bInit == false){
        addBand(0,PS_SOLID,1,Color.aqua,"Centerline");
        if(
        Symbol == nullSymbol getSymbol();
        if(
        Interval == nullInterval getInterval();
        vSymbol Symbol+","+Interval;
        xMACD amLib.amDEMA(2,efsInternal("ratio"));
        xSig wma(Smoothing,xMACD);
        bInit true;


        One reservation regarding this is defining xSig in this manner. Since xMACD is changing, perhaps xSig will have to be defined every time you call it, I am not sure. I would have to run the efs to confirm this, however, I will be not be able to run this after the market closes today.

        Hope this gets you there, if not, we can work on tonight.
        Last edited by Guest; 05-10-2005, 06:01 AM.

        Comment


        • #5
          Hey Steve

          I agree 100% with your approach and I really appreciate the education. As a newbie with no programming background/skills everything I do is learned from folks like you and Alex, from studying other code or direct cut and paste of sections from other code. In this case, the code for the original NormMACD was provided by Alex (bless her) and I made the mods to MTF and then subsequently to try and add the arrows.

          You are correct about the sad face and the missing (

          WIth regard to your observations about this line;

          The way you have it formatted (var xMACD = amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,Smoot hing,Source,sym(vSymbol))) , the efsInternal is the source for the DEMA calculation and since you are calling the ratio function, all of the variables after "ratio" have no meaning.
          I tried it your way in the original code(which does run) and although it runs it only produces the standard NormMACD without regard to symbol or interval. So that can't be right. I don't know why, but it would seem that it does need to be coded the way I have it.

          I made the rest of the changes as you suggested to the format/syntax of the conditional statements
          PHP Code:
          if(xMACD.getValue(0)) > xSig.getValue(0) && (xMACD.getValue(-1) < xSig.getValue(-1)){ 
          but that is where the current synatx errors continue to come from. I have attached the current working version without arrows for you to look at. I have no doubt that it may not be the most eloquent piece of code or even 100% correct but it does run and produces the desired plot minus the arrows.

          Let me know what you think I should try next.

          Best Regards
          Doug
          Attached Files

          Comment


          • #6
            Doug,

            You are welcome. Here is the code Alex had posted:
            PHP Code:
            function preMain(){
                
            setStudyTitle("Norm MACD");
                
            setCursorLabelName("MACD",0);
                
            setCursorLabelName("Signal",1);
                
            setCursorLabelName("Hist",2);
                
            setDefaultBarFgColor(Color.blue,0); 
                
            setDefaultBarFgColor(Color.red,1);
                
            setDefaultBarFgColor(Color.magenta,2); 
                
            setPlotType(PLOTTYPE_LINE,0);
                
            setPlotType(PLOTTYPE_LINE,1);
                
            setPlotType(PLOTTYPE_HISTOGRAM,2); 
            }

            var 
            amLib addLibrary("amStudies.efsLib");

            function 
            main(){

                if(
            getCurrentBarCount()<35) return;

                var 
            Mac    amLib.amDEMA(2,efsInternal("ratio"));
                var 
            Signal wma(9,Mac);

                return new Array (
            Mac,Signal,(Mac-Signal));
            }

            function 
            ratio(){

                var 
            0;
                var 
            sht wma(12);
                var 
            lng wma(26);
                
                var 
            ratio = (Math.min(sht,lng)/Math.max(sht,lng));
                
                var 
            ret sht>lng? ((2-ratio)-1)*100: ((ratio)-1)*100;

                return 
            ret;

            You will see the format of the efsInternal call relative to the ratio function is amLib.amDEMA(2,efsInternal("ratio"));

            To make it work the way you have it, you would need variables within the parenthesis, e.g. function ratio(a,b,c,d,e) where the variable "a" cooresponds to Fast, "b" cooresponds to Slow, "c" cooresponds to Smoothing, "d" cooresponds to Source, and "e" cooresponds to sym(vSymbol). Since there are no variables within the parenthesis, in reality, you are not passing any variables to the ratio function which in efs2 terms is your "internal efs". I am very surprised you are getting results that are different.

            again, hope this helps a little, hopefully we will get this fixed up tonight.

            Comment


            • #7
              Steve

              I hear you and I understand what you mean but I also know that when I added the MTF functionality to Alex's original code I too had origianlly tried it the way you suggested and it didn't work which is why I ended up with it the way it is now which does seem to work although I don't pretend to understand exactly why.

              I know you are busy now, but later when you have time, please run the EFS I sent you and then make the modification you suggested and run it again. Then tell if I'm seeing/interpreting it wrong.

              Thanks
              Doug

              Comment


              • #8
                Doug,

                While what you had put together worked (kind of) with this line, the format was wrong. This had me spinning in place several hours as I could not figure out why it was working as it was. It was wrong though and it caused lots of problems.

                PHP Code:
                var xMACD2 amLib.amDEMA(2,efsInternal("ratio"Fast,Slow,Smoothing,Source,sym(vSymbol))); 
                As I said previously, you picked a difficult efs, however, a good education for both of us, as I had to get help on this as well, however, in my case, one of them had long wavy hair ;>).

                First, the Source function parameter definitions, the open, close, etc text values have to all be lower case. You had them as upper case.

                Second, add these two lines outside the main and premain sections

                PHP Code:
                var xMACD null;
                var 
                xSig null
                Third, modify the bInit section.

                PHP Code:
                if(bInit == false){
                        
                addBand(0,PS_SOLID,1,Color.aqua,"Centerline");
                        if(
                Symbol == nullSymbol getSymbol();
                        if(
                Interval == nullInterval getInterval();
                        
                vSymbol Symbol+","+Interval;
                        
                xMACD amLib.amDEMA(2,efsInternal("ratio",Fast,Slow,eval(Source)(sym(vSymbol))));
                        
                xSig wma(Smoothing,getSeries(xMACD));
                        
                bInit true;

                The xMACD and xSig commands do not need to be called as they were in the bInit section again.

                Fourth, modify the ratio function as follows:

                PHP Code:
                //you need to pass the parameters to the function
                function ratio(fast,slow,source){

                    
                //var x = 0;
                    
                var sht wma(fast,source);
                    var 
                lng wma(slow,source);

                    var 
                ratio = (Math.min(sht,lng)/Math.max(sht,lng));

                    var 
                ret sht>lng?((2-ratio)-1)*100: ((ratio)-1)*100;

                    return 
                ret


                now, the up and down arrow sections **will work** for you as we had discussed in an earlier post with the getValue functionality. ** Understand that the study is not outputting to the price pane, so the arrows will appear in the non-price pane with the indicators. Your study has you are placing the arrows based on prices, with space = 1. Because of this, the arrows will not be visible as they will be out of sight, high. You must place them much closer to the value that you are outputting to the non-price pane. There are some tricks that can be used that I have been shown that we can discuss tomorrow. Provided you adjust the spacing from the indicators however, you should be able to get it to work well. We can also work on getting the arrows in the price pane, however, that involves some other details that we can discuss tomorrow as well.

                Finally, and very important regarding the syncronization between timeframes (in real time). This can be accomplished by using the getSeries() functionality in the return statement as follows:

                PHP Code:
                return new Array (getSeries(xMACD),getSeries(xSig)); 

                Comment


                • #9
                  Hey again Steve

                  You may not have long wavey hair but I still appreciate your time and expertise :-)

                  I made all the changes you spelled out. However, I am still getting a syntax error at the arrows section

                  PHP Code:
                      if(xMACD.getValue(0)) > xSig.getValue(0) && (xMACD.getValue(0),-1) < xSig.getValue(0),-1){ 
                  PHP Code:
                      if(xMACD.getValue(0)) > xSig.getValue(0) && (xMACD.getValue(0),-1) < xSig.getValue(0),-1){ 
                  I left the syntax the way you had previously instructed, was this wrong?? Should I have changed it back to the way I originally had it??

                  Also, I'm confused by the following:

                  Finally, and very important regarding the syncronization between timeframes (in real time). This can be accomplished by using the getSeries() functionality in the return statement as follows:
                  PHP Code:
                  return new Array (getSeries(xMACD),getSeries(xSig)); 
                  How in the world did I get it to work before given that I had it so wrong??

                  I look forward to hopefully completing this tonight. I honestly had no idea it would be so complex/difficult. I used to work with Metastock and I could have done this by myself in less than 10 min on that platform. I guess I was hoping that EFS2 was going to offer the same promise. Clearly, it is moving in that direction but it may be sometime before it gets there.

                  Thanks again.

                  Regards
                  Doug

                  Comment


                  • #10
                    Doug
                    FWIW you are not using the same syntax suggested by Steve for the conditional statement (see the PHP box enclosed below showing Steve's code example)
                    Alex

                    PHP Code:
                    if(xMACD.getValue(0)) > xSig.getValue(0) && (xMACD.getValue(-1) < xSig.getValue(-1)){ 

                    Comment


                    • #11
                      Hi Alex

                      Of course, you are 100% correct as always :-) I made the adjustment but still get an error. Here is what the whole section looks like.

                      PHP Code:
                          var space 1;
                          
                          if (
                      lastrawtime != getValue("rawtime"10)) {
                           
                      BarCount += 1;
                           
                      lastrawtime getValue("rawtime"10);
                          }   

                          if(
                      xMACD.getValue(0)) > xSig.getValue(0) && (xMACD.getValue(-1) < xSig.getValue(-1)){
                             
                      drawTextRelative(0,low()-(space*.1),"é",Color.lime,null,Text.TOP|Text.CENTER|Text.BOLD,"Wingdings",10,"Up"BarCount);
                             }else{
                             
                      removeText("Up"+BarCount);
                          }  
                          if(
                      xMACD.getValue(0)) < xSig.getValue(0) && (xMACD.getValue(-1) > xSig.getValue(-1){
                             
                      drawTextRelative(0,high()+(space*.1),"ê",Color.red,null,Text.BOTTOM|Text.CENTER|Text.BOLD,"Wingdings",10,"Dn"BarCount);
                             }else{
                             
                      removeText("Dn"+BarCount);    
                          }
                          
                       
                          
                          return new Array (
                      getSeries(xMACD),getSeries(xSig));

                      Do you see any other errors??

                      Thanks
                      Doug

                      Comment


                      • #12
                        Doug
                        In both conditional statements you have some mislpaced parenthesis. In the first one

                        if(xMACD.getValue(0)) > xSig.getValue(0) && (xMACD.getValue(-1) < xSig.getValue(-1)){

                        should be

                        if(xMACD.getValue(0) > xSig.getValue(0) && xMACD.getValue(-1) < xSig.getValue(-1)){

                        In the second statement you have

                        if(xMACD.getValue(0)) < xSig.getValue(0) && (xMACD.getValue(-1) > xSig.getValue(-1){

                        and it should be as the example above.
                        Also replace getValue("rawtime", 10)) with getValue("rawtime", 0))
                        Alex

                        Comment


                        • #13
                          Hi Alex

                          Thanks for the quick reply. There were actually a couple of other errors too but I managed to correct them and I now have a plot. Only thing is I still have no arrows. I even changed the space to =.01 but it had no effect. I think I may be missing some code in the main but I'm not sure. I attached the EFS in case you have time and want to take a look.

                          Regards
                          Doug
                          Attached Files

                          Comment


                          • #14
                            Doug
                            Look at what values (the second parameter in drawTextRelative()) you are placing the arrows ie at either low()-(space*.1) or high()+(space*.1). These are off the chart as far as the scale of the indicator is concerned. You need to anchor those drawn objects to values that are meaningful to the scale of the indicator hence either xMACD.getValue(0) or xSig.getValue(0)
                            Alex

                            Comment


                            • #15
                              Hi Doug,

                              Your problem is that your Y-axis location is low()-(space*.01) on line 82 and high()+(space*.01) on line 87.


                              Understand that the study is not outputting to the price pane, so the arrows will appear in the non-price pane with the indicators. Your study has you placing the arrows based on prices, e.g. high () and low(). Think for a minute where the arrows would be relative to the scaling of indicator you are plotting on the non - price pane.

                              Because of this, the arrows will not be visible as they will be out of sight, high. You must place them much closer to the value that you are outputting to the non-price pane. Provided you adjust the spacing from the indicators however, you should be able to get it to work well.

                              As an aside, only 10 minutes with Metastock eh? ;>)

                              Comment

                              Working...
                              X