Announcement

Collapse
No announcement yet.

StochasticOf_Montage.efs

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

  • StochasticOf_Montage.efs

    Thanks that is perfect...
    none

  • #2
    Can anyone help me change the color on this EFS, say, green for up and red for down?

    Thank you for your help.

    Mike

    Comment


    • #3
      Hello Mike,

      Make a copy of the formula with a new name and then replace lines 603-608 with the following.

      PHP Code:
      if(MAType=="Exponential"){
          if(
      aValue[LengthD-1] != nullvEMA EMA(LengthDaValue);  
          if (
      sum vEMAsetBarBgColor(Color.green);
          else 
      setBarBgColor(Color.grey);
          return new Array (
      sum,vEMA);
      }else{
          if (
      sum vSMAsetBarBgColor(Color.green);
          else 
      setBarBgColor(Color.grey);
          return new Array (
      sum,vSMA);



      Note that I used grey instead of red since that conflicts with the defaults. Feel free to change it. Also, I assumed that by up you meant %K above %D and that it was the color of the background you wanted to change. If not, please give me more details for what you had in mind.
      Jason K.
      Project Manager
      eSignal - an Interactive Data company

      EFS KnowledgeBase
      JavaScript for EFS Video Series
      EFS Beginner Tutorial Series
      EFS Glossary
      Custom EFS Development Policy

      New User Orientation

      Comment


      • #4
        Hi Jason,
        Many thanks for your prompt reply.
        My last post wasn't very clear, I'm sorry but what I need is - "how to change the color of the two lines", something like below.

        Mike
        Attached Files

        Comment


        • #5
          Mike
          Replace the same section of code indicated by Jason with the following
          Note that the setBarFgColor() commands with 0 color the %K plot while those with 1 color %D. If you only wish to color one of the plots remove or comment out the commands for the other.
          Alex

          PHP Code:
          if(MAType=="Exponential"){
                  if(
          aValue[LengthD-1] != nullvEMA EMA(LengthDaValue);  
                      if (
          sum vEMA) {
                          
          setBarFgColor(Color.lime,0);
                          
          setBarFgColor(Color.green,1);
                      }else{
                          
          setBarFgColor(Color.red,0);
                          
          setBarFgColor(Color.magenta,1);
              }
              return new Array (
          sum,vEMA);
              }else{
                  if (
          sum vSMA) {
                      
          setBarFgColor(Color.lime,0);
                      
          setBarFgColor(Color.green,1);
                  }else{
                      
          setBarFgColor(Color.red,0);
                      
          setBarFgColor(Color.magenta,1);
              }
              return new Array (
          sum,vSMA);

          Comment


          • #6
            Alex,
            Thank you! But I guess I should say sorry again.
            I try to make my question more clear.
            I want to modify this wonderful code to two separate EFS. So I need plot the signal line with different color when it goes up/down. Just like below:
            PHP Code:
                    if ( vADXDM.getValue(ADXDMStudy.ADX) > vADXDM.getValue(ADXDMStudy.ADX, -1)
                        
            setBarFgColor(Color.lime);
                    }else{
                        
            setBarFgColor(Color.red);
                    } 
            I think we should add more var like: sum1, vSMA1, vEMA1.
            if (sum > sum1)...
            if (vSMA > vSMA1)...
            if (vEMA > vEMA1)...

            Mike

            Comment


            • #7
              Mike
              I think I now understand what you want.
              First thing remove var from var vSMA = nSum/LengthD; in line 600 of the efs.
              Then declare the following Global variables
              var SMA = null;
              var SMA1 = null;

              At the very beginning of main() add the following
              if(getBarState()==BARSTATE_NEWBAR){
              vSMA1 = vSMA;
              }

              Lastly replace the section of code indicated by Jason with the following
              Alex

              PHP Code:
              if(MAType=="Exponential"){
                      if(
              aValue[LengthD-1] != nullvEMA EMA(LengthDaValue);  
                      if (
              aValue[0] > aValue[1]) {
                          
              setBarFgColor(Color.lime,0);
                      }else{
                          
              setBarFgColor(Color.red,0);
                      }
                      if(
              vEMA>vEMA1){
                          
              setBarFgColor(Color.green,1);
                      }else{
                          
              setBarFgColor(Color.magenta,1);
                      }
                  return new Array (
              sum,vEMA);
                  }else{
                      if (
              aValue[0] > aValue[1]) {
                          
              setBarFgColor(Color.lime,0);
                      }else{
                          
              setBarFgColor(Color.red,0);
                      }
                      if(
              vSMA>vSMA1){
                          
              setBarFgColor(Color.green,1);
                      }else{
                          
              setBarFgColor(Color.magenta,1);
                      }
                  return new Array (
              sum,vSMA);

              Comment


              • #8
                Alex,

                Thanks, it looks pretty good!

                Mike
                Last edited by howcool; 01-12-2005, 06:13 AM.

                Comment

                Working...
                X