Announcement

Collapse
No announcement yet.

3 formulas ... help pls

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 3 formulas ... help pls

    Hi there i have coded a formula which calls 3 formulas to check if the conditions are true....

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Special - Ver. 2 Beta");
        
    setDefaultBarFgColor(Color.blue,0);
        
    setDefaultBarFgColor(Color.red,1);
    }
    var 
    study = new MAStudy(35,0"OHLC/4"MAStudy.WEIGHTED);
    function 
    main() {
    //-AUSGABE-
    var out 0;
    //-Ausgabe-
    var = -1;
    var 
    sBTMA 3;
    var 
    sPREF 3;
    var 
    study.getValue(MAStudy.MA);
    var 
    vRSI = -2;
    var 
    vStochRSI;
    //PREF
    var test = new Array(2);
    test call("/Eric/Pref.efs","main");
    return new Array(
    test1,test2);

    if (
    MAVtx<MAVt1x)
        if (
    sPREF != 2)new Number(out 1);    
        
    sPREF 2;
    if (
    MAVtx>MAVt1x)
        if (
    sPREF != 1)new Number(out 1);    
        
    sPREF 1;    
    //BTMA
    if(close() >= v) {
        if (
    sBTMA != 1)new Number(out 1);    
        
    sBTMA 1;
        }
    if(
    close() < v) {
        if (
    sBTMA != 2)new Number(out 1);    
        
    sBTMA 2;
        }
    //RSI
    vStochRSI call("/Eric/RSI.efs","main");
    if(
    vStochRSI >= 100){
            
    1;
        }
        if(
    vStochRSI <= 0){
            
    0;
        }

        if(
    == && vStochRSI 0){ 
            
    //HOCH
            
    if (vRSI != 1)new Number(out 1);
            var 
    vRSI 1;

        }
        if(
    == && vStochRSI 100){ 
            
    setBarBgColor(Color.RGB(255,0,0));
            
    //RUNTER
            
    if (vRSI != 2)new Number(out 1);
            var 
    vRSI 2;
         }
    //HAUPT!
    if ( out <= -){
    setBarBgColor(Color.RGB(255,0,255));
    Alert.addToList(getSymbol(), "Runter!"Color.RGB(0,0,0), Color.RGB(195,0,0));
    }
    if ( 
    out >= ){
    setBarBgColor(Color.RGB(0,128,128));
    Alert.addToList(getSymbol(), "Hoch!"Color.RGB(0,0,0), Color.RGB(0,255,0));

    }


    return 
    vStochRSI;
    return 
    v;

    i use the btma35, the stochrsi and the preffered stochastic...

    i dont know if i can attach 3 files but i will test it

    regards erilein
    Attached Files

  • #2
    pref stoch...
    Attached Files

    Comment


    • #3
      btma35...
      Attached Files

      Comment


      • #4
        erilein
        There seem to be some errors in your formula that combines the signals amongst which is using call() with the syntax of callFunction().
        With regards to this subject you may want to check this thread to which I am about to add a second part dedicated to calling efs(s) that return arrays.

        In the mean time attached is an example of your btma35 that uses pref.efs to confirm signals. In fact only when btma35 and pref.efs are both long or short is the corresponding signal generated (see enclosed chart with pref plotted for comparison).
        This is only an example to illustrate the use of callFunction in light of what you are trying to achieve. Save it in the same directory in which you have pref.efs.

        I still believe it would be easier to first compute the conditions and generate the signals in the individual efs(s) as suggested in this message then simply combine those signals into one "calling" efs.
        Alex

        Attached Files

        Comment


        • #5
          yes i read the threads ... but i dont know where the bug is...

          and i also dont know how to get the signals of 3 formulas to 1...
          it would be great if there is a way to save vars to a textfile and read it with another...

          i think at a script wich does the following ...

          ...e.g. we take the up trend:

          -> Get var 1 from signal.txt
          -> Write var 1(maybe + 1) in signal.txt

          is this possible...
          regards erilein

          --EDIT--
          Sorry i didnt see that thread where exactly this is written in...
          so dont notice that

          Comment


          • #6
            erilein
            Click here to go to the thread where the read/write to file method is explained by Brad.
            However while it is certainlu possible I think that is a much more complex way of doing it than setting up a call() or callFunction().
            Alex

            Comment


            • #7
              i read the thread now and it does only reply a large (ok 1 kb ) text file... where do i define that he only should get the first entry add 1 and then replace it...

              i am looking @ the help central but couldnt find it this time...

              regards

              Comment


              • #8
                PHP Code:
                ...
                if (
                MAVtx>MAVt1x){
                setBarBgColor(Color.RGB(100,255,100));
                f.open("rt+");
                line f.writeln( <<< OLD NUMBER ->>>);                      
                f.close(); 
                ... 
                how do i realize that the old number - 1 is the new value of the textfile ?!

                Comment


                • #9
                  erilein
                  Here is the problem when using callFunction() with pref.efs as it was posted.
                  When you use callFunction() in your combined formula you are going to get an error "ref[0] invalid parameter". The reasons for that error are explained in this thread.
                  Here is the pref.efs formula

                  PHP Code:
                  /****************************************************************************************************
                  Copyright © eSignal, a division of Interactive Data Corporation. 2003. All rights reserved. 
                  This sample eSignal Formula Script (EFS) may be modified and saved under a new 
                  filename; however, eSignal is no longer responsible for the functionality once modified.
                  eSignal reserves the right to modify and overwrite this EFS file with each new release.
                  *****************************************************************************************************/
                  /***  5/9/03  Corrected Version
                          * Fixed flat-line bug for infrequently traded securities
                  ***/

                  addBand(80PS_SOLID1Color.grey"Upper");
                  addBand(20PS_SOLID1Color.black"Lower");


                  function 
                  preMain(){
                      
                  setStudyTitle("Preferred Stochastic TEST!!!");
                      
                  setCursorLabelName("percentK"0);
                      
                  setCursorLabelName("percentD"1);
                      
                  setDefaultBarFgColor(Color.black0);
                      
                  setDefaultBarFgColor(Color.blue1);
                      
                  setColorPriceBars(true);
                      
                  setDefaultPriceBarColor(Color.black);
                      
                  }

                  var 
                  MAVt null;
                  var 
                  MAVt1 null;
                  var 
                  MAVt_1 0;
                  var 
                  MAVt1_1 0;
                  var 
                  BarCntr 0

                  //----ATTENTION - CALLFUNCTION WORKS FROM HERE ONWARDS - IT DOES NOT SEE WHAT IS BEFORE THIS LINE-----
                  function main(nLengthnSmoothingnSmoothings) {
                      if(
                  nLength == null)
                          
                  nLength 14;
                      if(
                  nSmoothing == null)
                          
                  nSmoothing 6;
                      if(
                  nSmoothings == null)
                          
                  nSmoothings 11;

                      var 
                  percentK;
                      var 
                  ll 0hh 0;
                      var 
                  sum 0;
                      var 
                  vHigh getValue("High"0, -nLength);
                      var 
                  vLow getValue("Low"0, -nLength);
                      var 
                  temp 0;
                      
                      if(
                  vHigh == null || vLow == null)
                          return;


                      for(
                  0nLengthj++) {
                          if(
                  == 0) {
                              
                  ll vLow[j];    
                              
                  hh vHigh[j];
                          } else {
                              
                  hh Math.max(hhvHigh[j]);
                              
                  ll Math.min(llvLow[j]);
                          }
                      }
                      
                          
                      
                  percentK = ((close() - ll) / (hh ll)) * 100;
                      if (
                  isNaN(percentK) == falseMAVt MAVt_1 + (percentK MAVt_1) / nSmoothing;
                      if (
                  getBarState() == BARSTATE_NEWBARMAVt_1 MAVt;
                      if (
                  isNaN(percentK) == falseMAVt1 MAVt1_1 + (MAVt MAVt1_1) / nSmoothings;
                      if (
                  getBarState() == BARSTATE_NEWBARMAVt1_1 MAVt1;
                      
                      
                      if(
                  getBarState()==BARSTATE_NEWBAR){
                       
                  BarCntr += 1
                      } 
                      if (
                  BarCntr 8) {
                      var 
                  vRef ref(-1,-2); 
                      var 
                  MAVtx vRef[0][0];
                      var 
                  MAVt1x vRef[0][1];
                      var 
                  MAVtxx vRef[1][0];
                      var 
                  MAVt1xx vRef[1][1];
                      }
                      
                      if (
                  MAVtx<MAVt1x)
                          
                  setBarBgColor(Color.RGB(255,100,100));
                      if (
                  MAVtx>MAVt1x)
                          
                  setBarBgColor(Color.RGB(100,255,100));
                      
                          
                      return new Array (
                  MAVt,MAVt1);

                  Notice that just before main() I added a line of text that says "ATTENTION - CALLFUNCTION WORKS FROM HERE ONWARDS - IT DOES NOT SEE WHAT IS BEFORE THIS LINE".
                  If you notice outside of main() is var BarCntr=0 which is needed by ref() to retrieve the prior values of MAVt and MAVt1.
                  The problem is callFunction() does not use that variable therefore it generates an error in the called efs.
                  So the first thing to do is move var BarCntr=0 into main().
                  Once you do that the error disappears as you will see in the next message
                  Alex

                  Comment


                  • #10
                    erilein
                    Having gone through the reasons why callFunction() could not work with pref.efs as it was written I would like to revisit my original suggestion which is that of generating the signals in the individual efs(s) and then calling and combining these signals from another efs.
                    Attached is a zip file with rsi(2).efs, pref(2).efs and Calling.efs. Save all three to the Eric folder (or any folder so long as they are all in the same folder).
                    Both rsi(2).efs and pref(2).efs have been modified to return only a 1 if Long or -1 if Short. If you were to load them on a chart you would only see a line that oscillates between these two values. Both efs have also been cleaned up where necessary.
                    Calling.efs instead uses callFunction to retrieve the signals from each efs and then if both are Long (ie 1) it will paint the bars in green and if both are Short (ie -1) it will paint the bars in red.
                    In the image below I have also added the individual plots of each called efs.
                    Hope this helps
                    Alex

                    Attached Files

                    Comment


                    • #11
                      well nice looks very good... now i am trying to get the ma in there... i tried to get the background color when u >= 2 or u <= -2
                      and i am trying to add +1 and -1 to u on trendchange on all the indicators ...
                      --- ok i got it ---
                      thanks for the great support... and sorry for my unusual posting times... i arrived from school just...

                      regards erilein
                      Last edited by erilein; 11-24-2003, 06:30 AM.

                      Comment

                      Working...
                      X