Announcement

Collapse
No announcement yet.

Stuck...AGAIN!! Please could someone help me???

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

  • Stuck...AGAIN!! Please could someone help me???

    here is my problem ...I need to be able to compare each new (completed) bar to a specific bar in the recent past...i have read and looked at nearly everything and cant find the answer..im so freaking frustrated..please can someone help...
    on the chart below i've marked a bar with a small blue X and highlighted it with a white box (for visual aid)...some how i need the code to be able to compare each new completed bar with that bar marked x...what i tried to do was code an if statement saying ( this is an example for the sake of ease, btw..) "if (open (-1) < close (-2) draw a blue X on (-2)" ..and i got that to work!! but when i tried to make a var. with the results of the same if statement, so that i could compare each new bar to that var., it won't work!!! what am i doing wrong???Click image for larger version

Name:	picturechart.jpg
Views:	1
Size:	97.5 KB
ID:	246853 thank you very much to anyone who can help and Merry Christmas to everyone!!!

  • #2
    maybe i can make my question easier to explain ...in the chart i posted below, how can i code the computer to do a set of instructions once a new candle has closed above the close of the candle i have marked with the blue X???? hope that better explains things...thanks again, john

    Comment


    • #3
      no my last post was not a better explanation....basically in the chart i posted "how can i code a way to enter a trade when the current price bar closes above the open of the bar i have marked??? Thats what i am having trouble figuring out!!! please help and thank you in advance ...john

      Comment


      • #4
        Post your code and I'll take a look.

        Your problems may be more related to Javascript coding in general than the right EFS functions to call.

        Comment


        • #5
          thank you steve...

          Click image for larger version

Name:	stev.jpg
Views:	1
Size:	95.7 KB
ID:	242825hey Steve H.....thank you for your time....my code is really simple and straight forward..basically its just an if statement ...

          if ( close (-1) > close (-2) && close (-2) > close (-3) ) { draw text....blah blah blah}....

          what im trying to code the computer to alert me when i get 3 higher highs and price breaks down past the open of the 3rd higher high..see chart
          but i cant find anything that tells me how to do it...id like to make a variable out of the 3rd higher high and alert when price breaks the open of that bar...or draw a horizontal bar from the open of the 3rd higher high and alert when price breaks that level.
          any ideas on how to accomplish this ??? thanks again for your time ...really appreciate it!!!...john

          Comment


          • #6
            Please post the sample script (to the best of your ability to solve the problem) and I'll modify it to work. Thanks.

            Comment


            • #7
              hey Steve...that would be so awesome !!!! would truly appreciate it!!!! ....below is what i've written so far...here the code will draw a blue X on the bars that qualify...havent gotten to the alert part yet, but i can code that....i just cant figure out how to tell computer to recognize when the close ( or" open" on the upbars) of the bars marked has been breached by the current price...anything you can do is again greatly appreciated...i've been racking my brain trying to figure this out , to no avail...thanks again, john

              function preMain() {
              setPriceStudy(true);
              setStudyTitle("Breakouts");
              setShowCursorLabel(false);
              setComputeOnClose()
              }


              function main() {
              var Q = open (-1) - close (-1);
              var R = open (-2) - close (-2);
              var S = open (-3) - close (-3);
              // the below section of the code just converts the return value of the down bars to a positive integer

              if ( Q < 0 )
              Q = - Q ;

              if ( R < 0 )
              R = - R ;

              if ( S < 0 )
              S = - S ;




              if ( Q > R && R > S ){
              drawTextRelative(-1, high-1), "X", Color.blue, null,
              Text.BOLD|Text.BOTTOM|Text.FRAME, null, 6);
              }

              }

              i dont want the computer to enter a trade based on just this ..thats why i want it to alert me when the set up occurs so i can decide for myself if its a good place to enter...just cant figure out how to tell the computer to know when its reached a certain predetermined price level.. anything further i can do please just let me know...john
              Last edited by pleaman2; 12-26-2012, 09:32 PM.

              Comment


              • #8
                From the pic you showed, it seems more like you want to track the most recent set of 3 successively higher HLC's, not just the highs or the closes. Because you could have a run of 10 successively higher HLC's and all you're really interested in is the breach of the last set of 3 in the sequence. Otherwise, you wouldn't have marked up the chart the way you did. There were 3 successive higher highs (or closes) starting several bars back from where you were interested in looking for the turn.

                What starts the count? [3 consecutive higher HLC's?]

                Does anything nullify the count to start over aside from getting a breakdown signal (close below the open of the third consecutive higher HLC)?

                You could get all kinds of combos. You could have 3 higher HLC's, some sideways which doesn't breach the open of the 3rd HLC and then 2 more higher HLC's and then where is your breach? Does it stay with the original 3rd HCL's open and only moves if another set of 3 should come along in the uptrend?

                Comment


                • #9
                  hmmm... all very good points steve..i see where your coming from...but just to keep it simple...lets just go with a break down of the open of the 3rd candle...how would i code that...do i make a variable of that 3 candle??? or is it possible to draw a horizontal line from the open and when current price breaks the line i get an alert??? i think creating a variable out of the candle would be the most efficient ...but how do i do that??? Is it possible to create a variable with the results of an IF statement..( ie. If ( open (-1) > close (-1)) = var A)??? i know thats not how its done, i just cant find any info on how this would be accomplished...any suggestions?? thanks so much for your time with this...john

                  Comment


                  • #10
                    I'll come up with something this weekend and post it.

                    Comment


                    • #11
                      oh that'd be great...thanks again for all your time and efforts....john

                      Comment


                      • #12
                        Alexis.....Would you help with this?

                        Alexis i found a quote you posted some time ago ...(Lex
                        Alternatively instead of saving the rawtime value you could save the value returned by the getCurrentBarCount() function. Then when you need to refer back to that data you could just calculate the difference between the current bar count and the value you saved which will be the bart index relative to the current bar
                        Alex)...would you mind elaborating on how to do this...lets say i have a bar in the past that ive specified and i want to code an alert when the current bars high breaks the high of that specified bar...(see attached chart)...how would i code this...is there another way you would suggest or is the quote above the better way?..if anyone else has a suggestion please post it...thank you , johnClick image for larger version

Name:	capture-20130101-192807.jpg
Views:	1
Size:	101.1 KB
ID:	242826

                        Comment


                        • #13
                          ..if anyone else has a suggestion please post it...
                          Try (NOTE: as SteveH noted there are many combinations apart from your criteria [if ( high(-1) > high(-2) && high(-2) > high(-3) )] but this code should give you a basis from which to start):
                          PHP Code:
                          //gives bar count for bars at specific times
                          //blue arrows mark the 3rd bar in the sequence of 3 higher high bars 
                          //red horizontal lines mark the open of the 3rd bar in the sequence of 3 higher high bars starting at that bar and ending on the bar that breaks below it.
                          //green horizontal lines mark the high of the bar that broke below the open of the 3rd bar in the sequence of 3 higher high bars starting at that bar and ending on the bar that broke above that high
                          //NOTE: horizontal lines are only drawn when a bar breaks below the open of the 3rd bar in the sequence of 3 higher high bars 
                          debugClear();
                          function 
                          preMain(){
                              
                          setPriceStudy(true);
                          }
                          var 
                          bInit false;
                          var 
                          grID 0;
                          var 
                          openTrigger,highTrigger;
                          var 
                          TriggerBar 0;
                          var 
                          TriggerBar1 0;

                          function 
                          main( ){
                              var 
                          barCnt,barCnt1;
                              if(
                          getBarState()==BARSTATE_ALLBARS){ //resets variables upon loading more bars via scrolling chart back in time
                                  
                          openTrigger null;
                                  
                          highTrigger null;
                                  
                          TriggerBar 0;
                                  
                          TriggerBar1 0;
                              }
                              if(!
                          bInit){
                                  
                          setCursorLabelName("barCnt: "0); //used here only for debug purposes
                                  
                          setCursorLabelName("openTrigger: "1); //used here only for debug purposes
                                  
                          setCursorLabelName("barCnt1: "2); //used here only for debug purposes
                                  
                          setCursorLabelName("highTrigger: "3); //used here only for debug purposes
                                  
                          bInit true;
                              }
                              if ( 
                          high(-1) > high(-2) && high(-2) > high(-3) ) { //you describe sequence of 3 higher highs yet your example conditional uses close instead of high which won't necessarily give you 3 consecutive higher highs
                                  
                          openTrigger open(-1); // the open of the 3rd bar in the sequence of 3 higher high bars
                                  
                          TriggerBar getCurrentBarCount() - 1//logs the bar count at the time the conditional is true
                                  
                          drawShapeRelative(-1BelowBar3Shape.UPARROWnullColor.blueShape.PRESET"a"+gID());   //to mark the 3rd bar in the sequence of 3 higher high bars
                              
                          }
                              if(
                          openTrigger != nullbarCnt getCurrentBarCount() - TriggerBar//tracks the bar index # of the 3rd bar in the sequence of 3 higher high bars
                              
                          if(high(0) > openTrigger && low(0) < openTrigger){ //"instead of "low(0)" use "close(0)" for realtime only, for backtesting use "low(0) or Math.min(close(0),open(0))" if you only want to trigger based on the candle body
                                  
                          highTrigger high(0); //logs the high of the bar that broke below the open of the 3rd bar in the sequence of 3 higher high bars
                                  
                          TriggerBar1 getCurrentBarCount(); //logs the bar count at the time the conditional is true
                                  
                          drawLineRelative( -barCntopenTrigger0openTriggerPS_SOLID2Color.red"x1"+gID());
                                  
                          openTrigger null;
                              }
                              if(
                          highTrigger != nullbarCnt1 getCurrentBarCount() - TriggerBar1//tracks the bar index # of bar that broke below the open of the 3rd bar in the sequence of 3 higher high bars
                               
                          if(low(0) < highTrigger && high(0) > highTrigger){
                                  
                          drawLineRelative( -barCnt1highTrigger0highTriggerPS_SOLID2Color.green"x2"+gID());
                                  
                          highTrigger null;
                              }
                              return [
                          barCnt+"",openTrigger+"",barCnt1+"",highTrigger+""]; //used here only for debug purposes
                          }
                          //== gID function assigns unique identifier to graphic/text routines
                          function gID() {
                              
                          grID ++;
                              return( 
                          grID );

                          Click image for larger version

Name:	img.PNG
Views:	1
Size:	39.2 KB
ID:	242834

                          Good luck,
                          Wayne
                          Last edited by waynecd; 01-15-2013, 07:05 PM.

                          Comment


                          • #14
                            A Correction.

                            FWIW, in the above code my comments refer to: "the 3rd bar in the sequence of 3 higher high bars"

                            but in reality your criteria: "if ( high(-1) > high(-2) && high(-2) > high(-3) ) { "

                            only identifies the second high in a sequence of 2 higher highs.

                            Wayne
                            Last edited by waynecd; 01-16-2013, 01:51 PM.

                            Comment


                            • #15
                              hey thats great weynecd...thank , very much , for taking the time to respond...i did manage to figure a way out to do it, using an array...but your code looks great and i can use the horizontal line section..thanks again....can i ask you a quick question ? How do i stop an if statement if it returns true?? in simply terms lets say "if high (-1) > high (0) then drawtext...(but i want it to stop there and not keep drawing text EVERY time it proves true after the first time? thanks for any help in advance...jk

                              Comment

                              Working...
                              X