Announcement

Collapse
No announcement yet.

How to add a new series created by efsInteral() together?

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

  • How to add a new series created by efsInteral() together?

    The following is my codes:

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("vTotvVOL");
    setCursorLabelName("vTotvVOL",0);
    setPlotType(PLOTTYPE_LINE,0);
    setDefaultBarThickness(1,0);

    }

    var vVOL = 0;
    var vLASTvVOL = 0;
    var vTotvVOL = 0;




    function main(){

    var vVOL= efsInternal("sVOL");



    if (getBarState() == BARSTATE_NEWBAR) {

    vLASTvVOL = vTotvVOL;
    }


    vTotvVOL = vVOL + vLASTvVOL;
    return vTotvVOL;


    }



    function sVOL(){
    return ((volume() + volume(-1))/((hhv(2,high())-llv(2,low())) * 100));
    }



    what i am trying to do is to add all vVOL together, but i get response of "<none>".

    I try " return vVOL" instead of vTotvVOL, and i can see the series of vVOL but when i change it back to vTotvVOL, it doesnot work.

    Does this mean that i have to create a new function for adding vVOL together?

    Any suggestions?

  • #2
    Re: How to add a new series created by efsInteral() together?

    proptrader
    Assuming I understand correctly what you are trying to do I think you are making it more complicated than it needs to be.
    Just use the ref() function to retrieve the prior value returned by the efs [ie vTotvVOL] and assign it to the variable vLASTvVOL and then add that to the variable that stores the result of your equation [ie vVOL] as shown in the enclosed example
    For the description, syntax and examples of the use of the ref() function see the link to the article in the EFS KnowledgeBase. Also search the EFS Library in the KnowledgeBase as there are other examples of the use of this function
    Alex

    PHP Code:
    function main(){
        if(
    getCurrentBarCount()<2) return;
        var 
    vLASTvVOL ref(-1);//retrieves the prior value of the item returned by the efs
        
    var vVOL = ((volume(0) + volume(-1))/((hhv(2,high())-llv(2,low())) * 100));
        var 
    vTotvVOL vVOL vLASTvVOL;
        return 
    vTotvVOL;


    Originally posted by proptrader
    The following is my codes:

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("vTotvVOL");
    setCursorLabelName("vTotvVOL",0);
    setPlotType(PLOTTYPE_LINE,0);
    setDefaultBarThickness(1,0);

    }

    var vVOL = 0;
    var vLASTvVOL = 0;
    var vTotvVOL = 0;




    function main(){

    var vVOL= efsInternal("sVOL");



    if (getBarState() == BARSTATE_NEWBAR) {

    vLASTvVOL = vTotvVOL;
    }


    vTotvVOL = vVOL + vLASTvVOL;
    return vTotvVOL;


    }



    function sVOL(){
    return ((volume() + volume(-1))/((hhv(2,high())-llv(2,low())) * 100));
    }



    what i am trying to do is to add all vVOL together, but i get response of "<none>".

    I try " return vVOL" instead of vTotvVOL, and i can see the series of vVOL but when i change it back to vTotvVOL, it doesnot work.

    Does this mean that i have to create a new function for adding vVOL together?

    Any suggestions?

    Comment


    • #3
      Ref() works in my case, thx.

      However, what if I want to build a moving average line based on the values of vTotvVol? I try to use sma(10 , vTotvVol), but it doesnot work. Is this possible that I can put all your cods into a funtion such that I can have a series of vTotvVol?

      Comment


      • #4
        proptrader

        Is this possible that I can put all your cods into a funtion such that I can have a series of vTotvVol?
        Yes it is possible
        Alex


        Originally posted by proptrader
        Ref() works in my case, thx.

        However, what if I want to build a moving average line based on the values of vTotvVol? I try to use sma(10 , vTotvVol), but it doesnot work. Is this possible that I can put all your cods into a funtion such that I can have a series of vTotvVol?

        Comment

        Working...
        X