Announcement

Collapse
No announcement yet.

Aroon Osc over 2 time periods

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

  • Aroon Osc over 2 time periods

    I have a script on the 5min interval, but uses inv(60) indicators to valide entry. I can succesfully do this for mosdt indicators, but not for the Aroon.

    I am using the Aroon.efs to provide me with the Aroon Up and Aroon Down lines. How can I run the trading script on the 5min but call the external aroon.efs based on teh 60 min interval?

    It seems that when running the script it uses the bars from the timeframe where the trading script runs.

    Any help wo9uld be awesome.

  • #2
    Aroon Up on different time intervals

    [QUOTE=tbfx;145367]I have a script on the 5min interval, but uses inv(60) indicators to valide entry. I can succesfully do this for mosdt indicators, but not for the Aroon.

    I am using the Aroon.efs to provide me with the Aroon Up and Aroon Down lines. How can I run the trading script on the 5min but call the external aroon.efs based on teh 60 min interval?

    It seems that when running the script it uses the bars from the timeframe where the trading script runs.

    Any help wo9uld be awesome


    I modified the Aroon Up as follows, but it does not provide me with the Aroon Up for the 60 min when the chart that I ran it on is the 5min chart.

    function main(nInputPeriod){

    var vState = getBarState();
    nstate = getBarStateInterval("60");
    if (vState == BARSTATE_ALLBARS || bInit == false){
    nInterval = getInterval();
    if (nInterval == 60) {
    AryClose = new Array(nInputPeriod);

    }
    bInit = true;
    }

    if (nstate == BARSTATE_NEWBAR) {
    AryClose.pop();
    AryClose.unshift(high(0));
    } else {
    AryClose[0] = high(0);
    }
    if (AryClose[AryClose.length-1] == null) return;
    var vIndex = findHighIndex(AryClose);
    value = ((nInputPeriod-vIndex)/nInputPeriod)*100 ;
    debugPrintln("xArnUP " + value);
    return ((nInputPeriod-vIndex)/nInputPeriod)*100;
    }

    Comment


    • #3
      Try the following script making sure that it is in the same directory as "AroonUp.efs" and "AroonDown.efs":
      PHP Code:
      /****************************************************************************************************
      Copyright © eSignal, a division of Interactive Data Corporation. 2006. 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.
      *****************************************************************************************************/
      //added interval
      function preMain() {
          
      setStudyTitle("Aroon UP/DN");
          
      setCursorLabelName("ArnUp",0);
          
      setCursorLabelName("ArnDn",1);
          
      setDefaultBarFgColor(Color.green,0);
          
      setDefaultBarFgColor(Color.red,1);
          
          var 
      fp1 = new FunctionParameter("nInputPeriod"FunctionParameter.NUMBER);
              
      fp1.setName("Length");
              
      fp1.setLowerLimit(1);
              
      fp1.setDefault(14);
          var 
      fp2 = new FunctionParameter("Interval"FunctionParameter.STRING);
              
      fp2.setName("Interval");
              
      fp2.setDefault();
      }

      var 
      bInit false;
      var 
      xArnUp null;
      var 
      xArnDn null;

      function 
      main(nInputPeriod,Interval) {
          if (
      bInit == false) {
              if(
      Interval==nullInterval getInterval();
              
      xArnUp efsExternal("AroonUP.efs"nInputPeriod,inv(Interval));
              
      xArnDn efsExternal("AroonDown.efs"nInputPeriod,inv(Interval));
              
      bInit true;
          }
          
          return new Array(
      xArnUp.getValue(0), xArnDn.getValue(0));

      If you prefer to have it all in one script then try this:
      PHP Code:
      /****************************************************************************************************
      Copyright © eSignal, a division of Interactive Data Corporation. 2006. 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.
      *****************************************************************************************************/
      //added interval & efsInternal
      function preMain() {
          
      //setStudyTitle("Aroon UP/DN");
          
      setCursorLabelName("ArnUp",0);
          
      setCursorLabelName("ArnDn",1);
          
      setDefaultBarFgColor(Color.green,0);
          
      setDefaultBarFgColor(Color.red,1);
          
          var 
      fp1 = new FunctionParameter("nInputPeriod"FunctionParameter.NUMBER);
              
      fp1.setName("Length");
              
      fp1.setLowerLimit(1);
              
      fp1.setDefault(14);
          var 
      fp2 = new FunctionParameter("Interval"FunctionParameter.STRING);
              
      fp2.setName("Interval");
              
      fp2.setDefault();
      }

      var 
      bInit false;
      var 
      xArn null;
      var 
      xArnUp null;
      var 
      xArnDn null;

      function 
      main(nInputPeriod,Interval) {
          if (
      bInit == false) {
              if(
      Interval==nullInterval getInterval();
              
      xArn efsInternal("fAroon"nInputPeriod,inv(Interval));
              
      xArnUp getSeries(xArn,0);
              
      xArnDn getSeries(xArn,1);
              
      bInit true;
          }
          
          return new Array(
      xArnUp.getValue(0), xArnDn.getValue(0));
      }
      var 
      AryCloseUp;
      var 
      AryCloseDn;
      var 
      cInit false;
      var 
      High,Low;
      function 
      fAroon(nInputPeriod){
          var 
      vState getBarState();
          
          if (
      vState == BARSTATE_ALLBARS || !cInit){
              
      High high();
              
      Low low();
              
      AryCloseUp = new Array(nInputPeriod);
              
      AryCloseDn = new Array(nInputPeriod);
              
      cInit true;
          }
          
          if (
      vState == BARSTATE_NEWBAR) {
              
      AryCloseUp.pop();
              
      AryCloseUp.unshift(High.getValue(0));
              
      AryCloseDn.pop();
              
      AryCloseDn.unshift(Low.getValue(0));
          } else {
              
      AryCloseUp[0] = High.getValue(0);
              
      AryCloseDn[0] = Low.getValue(0);
          }
          
          if (
      AryCloseUp[AryCloseUp.length-1] == null) return;
          if (
      AryCloseDn[AryCloseDn.length-1] == null) return;

          var 
      vIndexUp findHighIndex(AryCloseUp);
          var 
      vIndexDn findLowestIndex(AryCloseDn);
          
          return [((
      nInputPeriod-vIndexUp)/nInputPeriod)*100,((nInputPeriod-vIndexDn)/nInputPeriod)*100];
      }

      function 
      findHighIndex(AryIn){
          var 
      vHighIndex 0;
          var 
      vHigh 0.0;
          
      vHigh AryIn[0];
          for(var 
      1AryIn.lengthi++){
              if (
      vHigh AryIn[i]){ //new High found
                  
      vHigh AryIn[i];
                  
      vHighIndex i;
              }
          }
          
          return 
      vHighIndex;
      }
      function 
      findLowestIndex(AryIn){    
          var 
      vLowest 0.0;
          var 
      vIndex 0;
          
      vLowest AryIn[0];
          for (var 
      1AryIn.lengthi++){
              if (
      vLowest AryIn[i]){ //new Low found
                  
      vLowest AryIn[i];
                  
      vIndex i;
              }
          }
          
          return 
      vIndex;


      Wayne

      Comment

      Working...
      X