Announcement

Collapse
No announcement yet.

drawLineRelative on top of setBarBgColor

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

  • drawLineRelative on top of setBarBgColor

    I have two moving averages, I'm using the code below to color between the two moving averages.

    setBarBgColor(Color.lime,0,vMA1.getValue(MAStudy.M A),vMA2.getValue(MAStudy.MA));

    My Problem in the same EFS I'm also using drewLine command to connect the moving average but drawLineRelative is placed underneath the setBarBgColor.

    drawLineRelative(0, vMA1.getValue(MAStudy.MA), 0, vMA1.getValue(MAStudy.MA), PS_SOLID, 2, Color.black, 0 );

    Is there any way I can make the drawLineRelative on top of the setBarBgColor?

    or is there another command I can use to fill between the two moving averages and that will let the drawLineRelative be on top?

    Thank you

    Ketoma

  • #2
    Ketoma
    Try reversing the order of the drawLineRelative() and setBarBgColor() commands.
    Alex

    Comment


    • #3
      Thank you very much for the respond Alexis

      I tried both and still not working the same thing happens.

      Puting drawLineRelative() - setBarBgColor()
      and setBarBgColor() - drawLineRelative()


      Thank you

      Ketoma
      Last edited by ketoma21; 12-29-2004, 02:53 PM.

      Comment


      • #4
        Ketoma
        I just tried it and the lines are plotted on top of the background either way.
        However in looking at the sample code you provided I see that you are plotting only one line with your drawLineRelative() command and that is on the last bar in which the condition that draws the line is true. This is because you have 0 as the Tag Name and there will only be one line drawn if the Tag Name is always the same.
        Try the enclosed code and see the how the Tag Names used in the two conditions return different results
        Hope this helps
        Alex

        PHP Code:
        var vMA1 = new MAStudy(100"Close"MAStudy.SIMPLE);
        var 
        vMA2 = new MAStudy(300"Close"MAStudy.SIMPLE);

        function 
        preMain() {
            
        setPriceStudy(true);
            
        setStudyTitle("MAx2");
            
        setCursorLabelName("MA1"0);
            
        setCursorLabelName("MA2"1);
            
        setDefaultBarFgColor(Color.blue0);
            
        setDefaultBarFgColor(Color.red1);
        }

        var 
        Cntr 0;//define the variable as Global Variable

        function main() {

            if(
        getBarState()==BARSTATE_NEWBAR){//at every new bar
                
        Cntr++;//increase Cntr by 1
            
        }    
            
        //the following will draw a line on each bar where the condition is true
            
        if(vMA1.getValue(MAStudy.MA)>vMA2.getValue(MAStudy.MA)){
                
        drawLineRelative(0,vMA1.getValue(MAStudy.MA),0,vMA2.getValue(MAStudy.MA),PS_SOLID,2,Color.red,"line"+Cntr);
                
        setBarBgColor(Color.yellow,0,vMA2.getValue(MAStudy.MA),vMA1.getValue(MAStudy.MA))
            }
            
        //the following will draw a line only on the last bar where the condition is true
            
        if(vMA1.getValue(MAStudy.MA)<vMA2.getValue(MAStudy.MA)){
                
        drawLineRelative(0,vMA1.getValue(MAStudy.MA),0,vMA2.getValue(MAStudy.MA),PS_SOLID,2,Color.lime,0);
                
        setBarBgColor(Color.yellow,0,vMA2.getValue(MAStudy.MA),vMA1.getValue(MAStudy.MA))
            }

            return new Array (
        vMA1.getValue(MAStudy.MA),vMA2.getValue(MAStudy.MA));  

        Comment


        • #5
          Thank you very Much Alexis

          The Problem is wierd here is what happened,

          I took your code tried it on my esignal 7.6 and I got the same problem, then on another machine I installed esignal 7.8 tried your code and mine they both work great.

          I don't know why would that be the problem esignal 7.6?

          I guess I have to upgrade my main machine

          Thank you again

          Ketoma

          Comment

          Working...
          X