Announcement

Collapse
No announcement yet.

EMA lines Changing Color according to direction

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

  • EMA lines Changing Color according to direction

    Hello All, I have found the following EFS prepared by Alexis and am wondering if it is possible to make the following changes;

    -1- How do I get the MA lines to output on a separate window as opposed to the price bar window ?

    -2- Is it possible to modify the color of the moving average for both lines, eg. if the MA is going up paint the line green and if the MA is going down, paint the line red, and apply to both lines ?

    I have tried to set the line color by using the following type command, but only end up with an entirely lime green line representing the 10 period MA line

    if((vMA1.getValue(MAStudy.MA)) > (vMA1.getValue(MAStudy.MA), -1)){
    setBarFgColor(Color.lime,1);
    }
    if((vMA1.getValue(MAStudy.MA)) < (vMA1.getValue(MAStudy.MA), -1))
    setBarFgColor(Color.red,1);

    I have attached the original EFS, thanks in advance for any assistance.

    Sincerely,

    Royce Hamaguchi
    Attached Files

  • #2
    Re: EMA lines Changing Color according to direction

    Royce
    1. In preMain change the following statement
    PHP Code:
    setPriceStudfy(true
    to
    PHP Code:
    setPriceStudy(false
    2. In the main function replace the following lines of code in your script
    PHP Code:
    if(vMA1.getValue(MAStudy.MA)>vMA2.getValue(MAStudy.MA)) 
    setBarFgColor(Color.lime,1); 

    if(
    vMA1.getValue(MAStudy.MA)<vMA2.getValue(MAStudy.MA)) 
    setBarFgColor(Color.red,1); 
    with the following
    PHP Code:
    if(vMA1.getValue(MAStudy.MA)>=vMA1.getValue(MAStudy.MA,-1))//if the current value of vMA1 is greater than the value of vMA1 at prior bar
    setBarFgColor(Color.lime,0);//color the first element of the return array in lime
    else setBarFgColor(Color.red,0);//else color the first element of the returned array in red

    if(vMA2.getValue(MAStudy.MA)>=vMA2.getValue(MAStudy.MA,-1))//if the current value of vMA2 is greater than the value of vMA2 at prior bar
    setBarFgColor(Color.lime,1);//color the second element of the returned array in lime
    else setBarFgColor(Color.red,1);//else color it in red 
    Once you implement these changes the averages will plot in a separate pane and will be colored in green when rising and red when falling
    Alex.



    Originally posted by Royce
    Hello All, I have found the following EFS prepared by Alexis and am wondering if it is possible to make the following changes;

    -1- How do I get the MA lines to output on a separate window as opposed to the price bar window ?

    -2- Is it possible to modify the color of the moving average for both lines, eg. if the MA is going up paint the line green and if the MA is going down, paint the line red, and apply to both lines ?

    I have tried to set the line color by using the following type command, but only end up with an entirely lime green line representing the 10 period MA line

    if((vMA1.getValue(MAStudy.MA)) > (vMA1.getValue(MAStudy.MA), -1)){
    setBarFgColor(Color.lime,1);
    }
    if((vMA1.getValue(MAStudy.MA)) < (vMA1.getValue(MAStudy.MA), -1))
    setBarFgColor(Color.red,1);

    I have attached the original EFS, thanks in advance for any assistance.

    Sincerely,

    Royce Hamaguchi

    Comment


    • #3
      Hi Alexis, I have implemented the code in your reply. The result I am getting is not exactly what I was hoping for, it is probably a simple adjustment.

      The result I get is that the MA line does change color but it is one period out of sync.

      Instead of changing the line color in the current period, it changes the line color for the next period ?? Therefore the colors are out of sync by one period.

      Thanks again for your assistance

      Royce

      Comment


      • #4
        Royce
        See this thread for an explanation of what is happening and a solution.
        Alex


        Originally posted by Royce
        Hi Alexis, I have implemented the code in your reply. The result I am getting is not exactly what I was hoping for, it is probably a simple adjustment.

        The result I get is that the MA line does change color but it is one period out of sync.

        Instead of changing the line color in the current period, it changes the line color for the next period ?? Therefore the colors are out of sync by one period.

        Thanks again for your assistance

        Royce

        Comment


        • #5
          Thanks Alexis

          Your experience and knowledge is always greatly appreciated. The amount of time you save all of us eSignal customers is worth a fortune to us all.

          Your guidence to the proper previous posting explained everything perfectly, and my EFS is working correctly.

          Thanks so much for the assistance.

          Royce

          Comment


          • #6
            Royce
            You are most welcome and thank you for the kind words. They are very much appreciated
            Alex


            Originally posted by Royce
            Thanks Alexis

            Your experience and knowledge is always greatly appreciated. The amount of time you save all of us eSignal customers is worth a fortune to us all.

            Your guidence to the proper previous posting explained everything perfectly, and my EFS is working correctly.

            Thanks so much for the assistance.

            Royce

            Comment

            Working...
            X