Announcement

Collapse
No announcement yet.

Setting Variables

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

  • Setting Variables

    I am currently working on an EFS that will send an alert when it identifies if a False Bar exists and is also checking when the MACD is changing directions. I have reviewed several existing EFS's that deal with one of the variables but not both.
    The issue I am having is that when I combine the variables for both items, the system crashes. If anyone can assist me with this or point me in the right direction to get an answer, it would be greatly appreciated.

    I have already searched through existing EFS and had no luck finding anything that helped

    Here is the data I am using for identifying the existence of a False bar:

    PHP Code:
    var vStoch null;

    function 
    preMain() {
        
    setPriceStudy(true);

        var 
    fp1 = new FunctionParameter("Length"FunctionParameter.NUMBER);
        
    fp1.setLowerLimit(1);        
        
    fp1.setDefault(14); //Edit this value to set a new default
        
        
    var fp2 = new FunctionParameter("K"FunctionParameter.NUMBER);
        
    fp2.setLowerLimit(1);    
        
    fp2.setDefault(3); //Edit this value to set a new default
        
        
    var fp3 = new FunctionParameter("D"FunctionParameter.NUMBER);
        
    fp3.setLowerLimit(1);    
        
    fp3.setDefault(3); //Edit this value to set a new default
        
        
    var fp4 = new FunctionParameter("Upper"FunctionParameter.NUMBER);
        
    fp4.setLowerLimit(0);    
        
    fp4.setDefault(75); //Edit this value to set a new default
        
        
    var fp5 = new FunctionParameter("Lower"FunctionParameter.NUMBER);
        
    fp5.setLowerLimit(0);    
        
    fp5.setDefault(25); //Edit this value to set a new default
        
    }

    function 
    main(Length,K,D,Upper,Lower) {

        if(
    vStoch==nullvStoch = new GetStochStudy(LengthKD);



       if (
    vStoch.getValue(GetStochStudy.MARKS) == 1){
            
    drawShapeRelative(0,0,Shape.SQUARE,"",Color.black,Shape.RELATIVETOTOP|Shape.ONTOP,"MarksUp"BarCount);
            }else{
            
    removeShape("MarksUp"+BarCount);
        }
        if (
    vStoch.getValue(GetStochStudy.MARKS) == 2){
            
    drawShapeRelative(0,-4,Shape.SQUARE,"",Color.black,Shape.RELATIVETOBOTTOM|Shape.ONTOP,"MarksDn"BarCount);
            }else{
            
    removeShape("MarksDn"+BarCount);
        } 
    And here is the data related to MACD turning:

    PHP Code:
    var vMACD null;

    function 
    preMain() {
        
    setPriceStudy(false);

        var 
    fp1 = new FunctionParameter("Fast"FunctionParameter.NUMBER);
        
    fp1.setLowerLimit(1);        
        
    fp1.setDefault(5);
        
        var 
    fp2 = new FunctionParameter("Slow"FunctionParameter.NUMBER);
        
    fp2.setLowerLimit(1);        
        
    fp2.setDefault(12);
        
        var 
    fp3 = new FunctionParameter("Smoothing"FunctionParameter.NUMBER);
        
    fp3.setLowerLimit(1);        
        
    fp3.setDefault(10);
        
        var 
    fp4 = new FunctionParameter("Source"FunctionParameter.STRING);
        
    fp4.setName("Source");
        
    fp4.addOption("Close");
        
    fp4.addOption("High");
        
    fp4.addOption("Low");
        
    fp4.addOption("Open");
        
    fp4.addOption("HL/2");
        
    fp4.addOption("HLC/3");
        
    fp4.addOption("OHLC/4");
        
    fp4.setDefault("Close");
        
        var 
    fp5 = new FunctionParameter("TypeOsc"FunctionParameter.BOOLEAN);
        
    fp5.setName("SMA (Oscillator)");
        
    fp5.setDefault(false);
        
        var 
    fp6 = new FunctionParameter("TypeSig"FunctionParameter.BOOLEAN);
        
    fp5.setName("SMA (Signal)");
        
    fp5.setDefault(true);

    function 
    main(FastSlowSmoothingSourceTypeOscTypeSig) {

        if (
    vMACD == nullvMACD = new MACDStudy(FastSlowSmoothingSourceTypeOscTypeSig); 
    When I attempt to load the EFS I have created, it must not like something in the combination I have created and crashes.

    Thanks in advance for any assistence

    Sincerely

    Royce

  • #2
    Hello Royce,

    The stochastic code that you've posted is missing an end brace for main() (i.e. } ) and you do not have the "BarCount" variable declared.

    The first problem I see with the MACD code is that you are missing the end brace for both preMain() and main(). The other problem that I see with the code you've posted has to do with the fp6 function parameter. After you create the fp6 object you're trying to set the name and default for it using fp5 in error. Change the following code in preMain(),

    PHP Code:
        var fp6 = new FunctionParameter("TypeSig"FunctionParameter.BOOLEAN);
        
    fp5.setName("SMA (Signal)");
        
    fp5.setDefault(true); 
    to

    PHP Code:
        var fp6 = new FunctionParameter("TypeSig"FunctionParameter.BOOLEAN);
        
    fp6.setName("SMA (Signal)");
        
    fp6.setDefault(true); 
    In your combined formula check to see if you are making the same error with this fp6 function parameter.
    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