Announcement

Collapse
No announcement yet.

Study at X time

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

  • Study at X time

    Hi all

    I have one (hopefully final) question.

    I need something to return the value of the upper donchian channel at a set time. In my case 1500.

    It may sound simple, but it's really confused me

    Thanks
    Mark

  • #2
    Mark
    I think this should do it
    if((getHour()*100)+getMinute()==1500){
    addBand(getValue(your_Donchian_function.UPPER),PS_ SOLID,1,Color.magenta,"1500");
    }
    I used addBand as an example but you could plot it any other way (ie drawTextRelative, etc).
    Alex

    Comment


    • #3
      Solution..

      It is much more difficult to "go back in time" to find the exact level you want - after it has passed.

      The best solution is to build a system that "records" the levels you want at "1501" - of course recording one bar BACK.

      Think of it like a live concert. If you record the whole thing, then wanted to go back to a specific minute and hear what was played - it is much more difficult than recording specific minutes of the concert that are clearly labeled.

      Just created a variable.

      var DonchUpper1500;

      Then, at 1501 on the chart, record the donchian level of the previous 1 minute bar.

      BRad
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Mark
        As i said in my prior message the condition example I gave you should work.
        Attached is an efs that plots the Donchian channel and records its value at 1500 as can be seen in the image below
        Alex

        Attached Files
        Last edited by ACM; 09-08-2003, 01:19 PM.

        Comment


        • #5
          Hi Both

          Thank you very much
          It'll give me something to work on

          Mark

          Comment


          • #6
            Hi Alex

            I've got this error come up from your coding

            downloads\donchian_at_1500.efs line 45: Parameter Number 3 of Function drawTextRelative is invalid

            This is line 45

            Code:
            drawTextRelative(0,vDonch.getValue(DonchianStudy.UPPER),vDonch.getValue(DonchianStudy.UPPER),Color.white,Color.magenta,Text.BOTTOM|Text.CENTER|Text.BOLD,"Arial",11)
            There's no error on the formual output window, only when I load it into the chart
            Have a missed something

            Mark

            Comment


            • #7
              Do you have the line defing the donchian channel at the top of the efs?

              var vDonchian = new DonchianStudy(20, 0);


              or something like that?

              Comment


              • #8
                Hi David

                This is the code

                Code:
                /*********************************************************
                Alexis C. Montenegro © July 2003                          
                Use and/or modify this code freely. If you redistribute it
                please include this and/or any other comment blocks and a 
                description of any changes you make.                      
                **********************************************************/
                
                var vDonch = null;
                
                function preMain() {
                    setPriceStudy(true);
                    setStudyTitle("Donchian");
                    setCursorLabelName("DCUpr", 0);
                    setCursorLabelName("DCMid", 1);
                    setCursorLabelName("DCLwr", 2);
                    setDefaultBarFgColor(Color.blue, 0);
                    setDefaultBarFgColor(Color.red, 1);
                    setDefaultBarFgColor(Color.blue, 2);
                    setDefaultBarThickness(1,0);
                    setDefaultBarThickness(1,1);
                    setDefaultBarThickness(1,2);
                    checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicDonchian.efs"); //Comment this line out if modifying the code
                        
                    var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
                	fp1.setLowerLimit(1);		
                	fp1.setDefault(20); //Edit this value to set a new default
                	
                	var fp2 = new FunctionParameter("Offset", FunctionParameter.NUMBER);
                	fp2.setDefault(0); //Edit this value to set a new default
                	
                }
                
                function main(Length, Offset) {
                   
                    if (vDonch == null) vDonch = new DonchianStudy(Length, Offset);
                 
                /*************************************************
                Insert your code following this text block        
                Use vDonch.getValue(DonchianStudy.UPPER) and      
                vDonch.getValue(DonchianStudy.BASIS) and          
                vDonch.getValue(DonchianStudy.LOWER) for your code
                **************************************************/
                
                if((getHour()*100)+getMinute()==1500){
                drawTextRelative(0,vDonch.getValue(DonchianStudy.UPPER),vDonch.getValue(DonchianStudy.UPPER),Color.white,Color.magenta,Text.BOTTOM|Text.CENTER|Text.BOLD,"Arial",11)
                }
                
                
                    
                    return new Array (vDonch.getValue(DonchianStudy.UPPER),vDonch.getValue(DonchianStudy.BASIS),vDonch.getValue(DonchianStudy.LOWER));
                }
                The fp1 and fp2 section has got me a little baffled

                Mark

                Comment


                • #9
                  Mark
                  My apologies, forgot to add one parameter in drawTextRelative.
                  Substitute that line with the following
                  PHP Code:
                  drawTextRelative(0,vDonch.getValue(DonchianStudy.UPPER),vDonch.getValue(DonchianStudy.UPPER),Color.white,Color.magenta,Text.BOTTOM|Text.CENTER|Text.BOLD,"Arial",11,""
                  Alex

                  PS. I have replaced the original efs with one containing the above correction.
                  Last edited by ACM; 09-08-2003, 01:22 PM.

                  Comment


                  • #10
                    Thanks Alex
                    That's got it

                    Mark

                    Comment


                    • #11
                      ....Ok Now I'm really confused.

                      This is part of the coding I'm concerned with

                      if((getHour()*100)+getMinute()==1500){
                      //drawTextRelative(0,vDonch.getValue(DonchianStudy.L OWER),vDonch.getValue(DonchianStudy.LOWER),Color.w hite,Color.magenta,Text.BOTTOM|Text.CENTER|Text.BO LD,"Arial",11,"")
                      DUpper=vDonch.getValue(DonchianStudy.UPPER)
                      DLower=vDonch.getValue(DonchianStudy.LOWER)
                      debugPrintln(DLower)


                      //LONG 30min BREAK
                      if (DUpper > 40 ){
                      //-DLower) / (DUpper-DLower))) > 0.90 {
                      debugPrintln("It's fired2")
                      }
                      }
                      //debugPrintln(((close()-DLower) / (DUpper-DLower)))



                      It says that DUpper isn't defined when I believe it is (Red coloured) and the error is coming on line 53 (Blue coloured). What am I missing

                      Mark

                      Comment


                      • #12
                        Define the study..

                        Probably, the Donchian study is not devined in your code.

                        You need to add..

                        var vDonch = new DonchianStudy(20,0);

                        to the top of your file. Thus, defining the study as vDonch and allowing your code to return a value from it.

                        Brad
                        Brad Matheny
                        eSignal Solution Provider since 2000

                        Comment


                        • #13
                          Hi Brad.

                          It's go that code. This is what's really confusing. Here's the complete code

                          Code:
                          /*********************************************************
                          Alexis C. Montenegro © July 2003                          
                          Use and/or modify this code freely. If you redistribute it
                          please include this and/or any other comment blocks and a 
                          description of any changes you make.                      
                          **********************************************************/
                          
                          var vDonch = null;
                          
                          
                          function preMain() {
                              setPriceStudy(true);
                              setStudyTitle("Testmon");
                              setCursorLabelName("DCUpr", 0);
                              setCursorLabelName("DCMid", 1);
                              setCursorLabelName("DCLwr", 2);
                              setDefaultBarFgColor(Color.blue, 0);
                              setDefaultBarFgColor(Color.red, 1);
                              setDefaultBarFgColor(Color.blue, 2);
                              setDefaultBarThickness(1,0);
                              setDefaultBarThickness(1,1);
                              setDefaultBarThickness(1,2);
                              //checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicDonchian.efs"); //Comment this line out if modifying the code
                                  
                              var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
                          	fp1.setLowerLimit(1);		
                          	fp1.setDefault(20); //Edit this value to set a new default
                          	
                          	var fp2 = new FunctionParameter("Offset", FunctionParameter.NUMBER);
                          	fp2.setDefault(0); //Edit this value to set a new default
                          	
                          }
                          
                          function main(Length, Offset) {
                             
                              if (vDonch == null) vDonch = new DonchianStudy(6, 0);
                           
                          /*************************************************
                          Insert your code following this text block        
                          Use vDonch.getValue(DonchianStudy.UPPER) and      
                          vDonch.getValue(DonchianStudy.BASIS) and          
                          vDonch.getValue(DonchianStudy.LOWER) for your code
                          **************************************************/
                          
                          if((getHour()*100)+getMinute()==1500){
                          //drawTextRelative(0,vDonch.getValue(DonchianStudy.LOWER),vDonch.getValue(DonchianStudy.LOWER),Color.white,Color.magenta,Text.BOTTOM|Text.CENTER|Text.BOLD,"Arial",11,"")
                          DUpper=vDonch.getValue(DonchianStudy.UPPER)
                          DLower=vDonch.getValue(DonchianStudy.LOWER)
                          debugPrintln(DUpper)
                          
                          
                          //LONG 30min BREAK
                          if (DUpper > 40 ){
                          //-DLower) / (DUpper-DLower))) > 0.90 { 
                          debugPrintln("It's fired2")
                          }
                          }
                          //debugPrintln(((close()-DLower) / (DUpper-DLower)))
                          
                              
                           //THIS NEXT LINE PUTS THE LINES ON THE CHART
                             return new Array (vDonch.getValue(DonchianStudy.UPPER),vDonch.getValue(DonchianStudy.BASIS),vDonch.getValue(DonchianStudy.LOWER));
                          //debugPrintln("hello")
                          
                          
                          }
                          The debugPrintln(DUpper) returns the right value though

                          Mark

                          Comment


                          • #14
                            You had a bunch of syntax errors, try this
                            Attached Files

                            Comment


                            • #15
                              Hi David

                              Thank you for amending that
                              Working fine now

                              Mark
                              Last edited by FTSE Beater; 09-25-2003, 07:39 AM.

                              Comment

                              Working...
                              X