Announcement

Collapse
No announcement yet.

Two Things

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

  • Two Things

    I have attached a simple break out EFS and was wondering how I might do the following two things.

    Is it possible to have the price of the lines on the chart to tell me what price was broken? eg if new high achieved and bar turns blue at what price is this and can the chart display this for every bar?

    Secondly if I wanted to back test this what code do I need to have to buy on stop the breakout once and then reverse on the next break out?


    Thanks for anyone who helps.


    James
    Attached Files

  • #2
    Re: Two Things

    Hello James,

    Originally posted by jsaitch
    I have attached a simple break out EFS and was wondering how I might do the following two things.

    Is it possible to have the price of the lines on the chart to tell me what price was broken? eg if new high achieved and bar turns blue at what price is this and can the chart display this for every bar?
    The price of the lines you are plotting appear in the cursor window. If you want to draw some text on the chart to also display that price, you could use the drawText() function. Call this drawing function inside your onAction functions and pass the Highs.getValue(-1) or Lows.getValue(-1) value for the text parameter. Use the AboveBar#/BelowBar# location constants for the location parameter.

    Secondly if I wanted to back test this what code do I need to have to buy on stop the breakout once and then reverse on the next break out?


    Thanks for anyone who helps.


    James
    To learn how to write a stop and reverse back testing formula, check out the Stop and Reverse example in section 2.1 from Back Testing Tutorial 2. You would apply nearly the same logic outlined in that example, but use your Highs and Lows series with the conditions from your formula.
    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


    • #3
      Is it possible to have the text (price) appear on the chart to show values of previos break outs?

      I will review tutorial thanks.


      James

      Comment


      • #4
        I tried this

        function onAction1() {
        setPriceBarColor(Color.red);
        drawText( low(), AboveBar1, Color.red)
        vLastAlert - 1;

        this results in data seried being printed on chart, I tried Highs.getValue(-1) and it says Highs not defined.

        Sorry to be pain


        James

        Comment


        • #5
          James,

          low() is a series, as is high(). I believe you should be using either low(0) or low(-1) for the present and last low values respectfully. A similar format for the high values woukld be high(0) or high(-1).

          hope this helps...


          Originally posted by jsaitch
          I tried this

          function onAction1() {
          setPriceBarColor(Color.red);
          drawText( low(), AboveBar1, Color.red)
          vLastAlert - 1;

          this results in data seried being printed on chart, I tried Highs.getValue(-1) and it says Highs not defined.

          Sorry to be pain


          James

          Comment


          • #6
            low(-1) works but Lows or Highs.getValue(-1) doesn't it says Lows or Highs not defined ?

            I must be missing something


            James

            Comment


            • #7
              Hi James,

              Please take a look at the modified file for the modifications.

              Most significant in your example is the difference between a series object, which constitutes a set of data representing all of the information loaded on the chart to that point, and a numerical value which is just one of the series object values.

              examples of series objects are low(), high(), Highs and Lows.

              examples of specific numerical valuers are low(0), high(0), Highs.getValue(0) and Lows.getValue(0).

              Series objects should not be returned to a chart in the return statement, numbers should

              Some of the changes in the code below are cosmetic changes, but others are required to ensure the code is functional. check out the output in the formula output window, you will see the difference in the data types.

              PHP Code:
              var vLastAlert = -1;


              function 
              preMain() {
               
              setPriceStudy(true);
               
              setStudyTitle("Trade Breakout");
               
              setColorPriceBars(true);
               
              setDefaultPriceBarColor(Color.RGB(0,0,0));
               
              setCursorLabelName("HStop"0);
               
              setCursorLabelName("LStop"1);
               
              setDefaultBarFgColor(Color.blue 0) ;
               
              setDefaultBarFgColor(Color.red 1) ;
               
              setDefaultBarThickness(20) ;
               
              setDefaultBarThickness(21) ;
               
              setPlotType(PLOTTYPE_FLATLINES,0);
               
              setPlotType(PLOTTYPE_FLATLINES,1);

               
               var 
              f1 = new FunctionParameter("TightStop"FunctionParameter.NUMBER);  
               
              f1.setDefault(5); 
              }

              var 
              bInit=false;
              var 
              Highs;
              var 
              Lows;

              function 
              main(TightStop) {
               if(!
              bInit){
                
              Highs highest(TightStop,high());
                
              Lows lowest(TightStop,low());
                
              bInit=true;
                
              debugPrintln("32: "+typeof(Highs));
                
              debugPrintln("33: "+typeof(Highs.getValue(0)));
                
              debugPrintln("34: "+typeof(high()));
                
              debugPrintln("35: "+typeof(high(0)));
               }

                
               if(
              open(-1) >= Lows.getValue(-1) && low(-1) < Lows.getValue(-1))
               {
                
              onAction1();
               }
               
               else if(
              open(-<= Highs.getValue(-1) && high(-1) > Highs.getValue(-1)){
                
              onAction2();
               }
               
               return new Array(
              Highs.getValue(0),Lows.getValue(0));
              }
                
              function 
              onAction1() {
               
              setPriceBarColor(Color.red);
               
              vLastAlert 1;
              }

              function 
              onAction2() {
               
              setPriceBarColor(Color.blue);
               
              vLastAlert 2;

              Last edited by Guest; 12-08-2006, 03:54 PM.

              Comment

              Working...
              X