Announcement

Collapse
No announcement yet.

Study Error

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

  • Study Error

    when i run the following code. i dont get anythign but null.... what could be the error. Second, If i want to have two studies on the same chart .. lets say MA (which will be on Prices) and CCI which will be in the indicator panel. How can i put in these two studies in my efs and retrieve values from them. i need the code for PreMain()..

    *******************************
    function main() {
    var vCCI34 = new CCIStudy(144, "HLC/3");
    var vBollinger_of_vCCI34 = new BollingerStudy(34, vCCI34, CCIStudy.CCI, 1.618);

    mytemp = new Array();
    mytemp[0]= vCCI34.getValue(CCIStudy.CCI, -1);
    mytemp[1] = vCCI34.getValue(CCIStudy.CCI,0);
    BasisVal = vBollinger_of_vCCI34.getValue(BollingerStudy.BASIS );

    }
    If i check the values of all these variables. they always come out to be null.

  • #2
    Hello subhiii,

    You should move your study objects outside of main. These should always be global variables.

    You are probably getting nulls because you do not have enough data loaded in your chart for the studies to return a valid result or you just need to add a return statement at the end of main and return one of your study outputs. You can force more data to load into the chart by scrolling the chart back or set up a time template to load more data.

    PHP Code:
    var vCCI34 = new CCIStudy(144"HLC/3");
    var 
    vBollinger_of_vCCI34 = new BollingerStudy(34vCCI34CCIStudy.CCI1.618);

    function 
    main() {
        var 
    mytemp = new Array(2);
        
    mytemp[0]= vCCI34.getValue(CCIStudy.CCI, -1);
        
    mytemp[1] = vCCI34.getValue(CCIStudy.CCI,0);
        
    BasisVal vBollinger_of_vCCI34.getValue(BollingerStudy.BASIS);
        
        return 
    mytemp;

    You can create as many built in studies within a single formula as you want. However, you cannot plot in both the price pane and indicator pane at the same time.

    For example of preMain() code, search the forums or view the code from some of the formulas in our EFS Library.
    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

    Working...
    X