Announcement

Collapse
No announcement yet.

Simple Binary Inclination Code Problem

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

  • Simple Binary Inclination Code Problem

    Hi there again.
    I'm trying to make a simple code that indicates the inclination of an external line in a binary form, although the binary value would be defined by the user.
    I've checked everything but again no solution, the output is nothing!
    Thaks in advance. Here is the code.





    var fpArray = new Array();

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("Incl STO Med");
    setDefaultBarFgColor(Color.RGB(255, 255, 255), 0);
    setPlotType(PLOTTYPE_LINE,0);
    setDefaultBarThickness(1,0);
    setDefaultBarFgColor(Color.RGB(255, 255, 255), 1);
    setPlotType(PLOTTYPE_LINE,1);
    setDefaultBarThickness(1,1);

    var x=0;
    fpArray[x] = new FunctionParameter("Length_Stoch_RSI", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(10);
    }
    fpArray[x] = new FunctionParameter("Length_DEMA1", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(6);
    }
    fpArray[x] = new FunctionParameter("Length_DEMA2", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(4);
    }
    fpArray[x] = new FunctionParameter("CoefDEMA", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(0);
    setDefault(0.5);
    }
    fpArray[x] = new FunctionParameter("Incl_Value", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setDefault(1);
    }
    }

    function main(Length_Stoch_RSI,Length_DEMA1,Length_DEMA2,Co efDEMA,Incl_Value) {
    var sto = efsExternal("B.F. - StochRSI Med.efs", Length_Stoch_RSI,Length_DEMA1,Length_DEMA2,CoefDEM A);
    var sto0 = sto;
    var sto_1 = offsetSeries(sto,-1);

    function UPX(sto0,sto_1,Incl_Value){
    var sto00 = sto0.getValue(0);
    var sto_11 = sto_1.getValue(0);
    if(sto00 > sto_11) {
    Incl_Value
    }
    };
    function DNX(sto0,sto_1,Incl_Value){
    var sto00 = sto0.getValue(0);
    var sto_11 = sto_1.getValue(0);
    if(sto00 < sto_11) {
    Incl_Value
    }
    };

    return new Array(UPX,DNX);
    }

  • #2
    Just glancing at your code and not understanding fully what you're trying to do I have this comment:

    Where is your bInit "if block" at the start of your main function?

    The pattern is that you create your studies once in a bInit block at the start of your main and then you extract values from that study as new values come into the script.

    PHP Code:
    var bInit false;
    function 
    main()
    {
       if (
    bInit == false)
       {
         
    // init your studies here
         
    bInit true;
       }

       
    // Get values from your studies here
       // If any of them return null, then that means that you
       // don't have enough data points calculated yet to continue
       // further during this loop through your script, so simply "return;"
       // until all of them start producing non-null values.

    Last edited by SteveH; 09-18-2011, 02:09 PM.

    Comment


    • #3
      Thanks a lot for the tip!
      Problem solved!
      Sorry if the problems I present are simple... Those are my first codes.

      Comment

      Working...
      X