Announcement

Collapse
No announcement yet.

De Marker

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

  • De Marker

    Try to do a De Marker indicator in EFS.

    The agorithem is

    1) If currenty bar price high is higher than the previous one, assign it the difference, otherwise 0

    if high()>high(-1) {

    DeMax=high()-high(-1);
    }
    else {

    DeMax=0;

    }

    2) Same for current bar price low

    if low()<low(-1) {

    DeMin=low(-1)-low();
    }
    else {
    DeMin=0;
    }

    3) Need to make them a SMA 14, here I don't know how to code:

    DeMark=SMA(DeMax, 14)/(SMA(DeMax,14)+SMA(DeMin,14));

    Need help, thanks.

  • #2
    shaster
    If you are using EFS2 then you would create two separate functions in the script, one called DeMax and the other DeMin. For example the DeMax would be as follows

    PHP Code:
    function DeMax(){

        if(
    high()>high(-1)){
            var 
    DeMax high()-high(-1);
        } else {
            var 
    DeMax 0;
        }
        return 
    DeMax;

    At this point you would add the DeMin function. Then in main() you would create a simple moving average of each function using the new efsInternal() function. The average of DeMax would be for example as follows

    PHP Code:
    var avgDeMax sma(14,efsInternal("DeMax")); 
    Repeat for the DeMin average. In the return you then write your equation using avgDeMax and avgDeMin.
    For more information and the required syntax on the efsInternal() function see this article in the EFS KnowledgeBase. See also this thread for detailed examples on how to use the function.
    Alex

    Comment


    • #3
      Alexis,

      Thanks. I did as you suggested and run the script. It told me a script error with "sma is not defined."

      Comment


      • #4
        shaster
        Post your script and I will take a look at it
        Note that you must be running version 7.9 to use EFS2
        Alex

        Comment


        • #5
          Alex,

          You're right. My Esignal is 7.8, just upgrade to 7.9. The De Marker pane is showing up, but no display. My OK window did show numbers. So I may miss some command here. Here is the script:

          function preMain() {
          setStudyTitle("De Marker");
          setCursorLabelName("De Marker", 0);
          setDefaultBarFgColor(Color.blue, 0);
          setStudyMin(0);
          setStudyMax(100);
          addBand(30, PS_SOLID, 1, Color.RGB(0,0,0));
          addBand(70, PS_SOLID, 1, Color.RGB(0,0,0));
          }


          function main() {

          var avgDeMax= sma(14,efsInternal("DeMax"));
          var avgDeMin= sma(14,efsInternal("DeMin"));
          return avgDeMax/(avgDeMax+avgDeMin);
          }

          function DeMax() {

          if (high()>high(-1)) {
          var DeMax=high()-high(-1);
          }
          else {
          var DeMax=0;
          }
          return DeMax;
          }

          function DeMin () {

          if (low()<low(-1)) {
          var DeMin=low(-1)-low();
          }
          else {
          var DeMin=0;
          }
          return DeMin;
          }

          Comment


          • #6
            shaster
            Try removing setStudyMax(100) and setStudyMin(0) from preMain.
            Alex

            Comment


            • #7
              Yes. I just figure out. I set 0 and 1 instead of 0 to 100, and addBand with 0.3 and 0.7. It works. Thanks alot. This weekend I will try to write a back test. Really appreciate.

              Comment

              Working...
              X