Announcement

Collapse
No announcement yet.

Programming Problem

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

  • Programming Problem

    I have been trying to modify this code just to get some bars to change colour when levels broken.

    I entered from lines 124 to 131 but they do not work,


    also is it possible to start the statement with if time > xEnd so as to only colour bar breaks after the level has been finalised ?


    thanks in advance



    Jamie
    Attached Files

  • #2
    Jamie
    You need to insert the required logic in the main function. To accomplish what you want you first need to declare two variables (these can be local) to which you assign the corresponding series. In line 64 add the following
    PHP Code:
    var myHigh getSeries(xRange,0);
    var 
    myLow getSeries(xRange,1); 
    At this point you can add your conditions (note that I replaced vHigh2 used in your conditional statement with myHigh)
    PHP Code:
    if (close(-1) < myHigh &&
        
    close(-1) < myHigh &&
        
    close(-3) < myHigh &&
        
    high(0) > myHigh) {
                
    onAction1();

    You may need to review your conditions as there is a duplicate.
    Then in the return statement replace getSeries(xRange,0) and getSeries(xRange,1) with myHigh and myLow respectively. This is because at this point you have already declared the series and you don't need to do that again but can just use the variables.
    Then remove the lines of code you added in function calcOR()
    As to adding an if time > xEnd condition you don't really need to do that because by definition high(0) and low(0) will never be higher than myHigh or lower than myLow before the time defined by the xEnd parameter.
    Alex

    Comment


    • #3
      Thank you very much,

      and you were wright I had intended to use three different closes.




      thanks again




      Jamie

      Comment


      • #4
        Jamie
        My pleasure
        Alex

        Comment


        • #5
          Done it wrong again

          I am trying to adjust the EFS to have two sets of lines one for the UK open and one for the US open.

          I know I can just load the hilofirstxminutes EFS twice and have different times however this prevents the colour bars from working.


          I have started to adjust the following but it then got a bit complicated for me


          Cheers



          Jamie
          Attached Files

          Comment


          • #6
            Jamie
            The first thing you need to check is that you have all the opening { and closing } brackets in the appropriate places.
            Secondly in your efsInternal() call you are passing xStart2 and xEnd2 which are not valid parameters. What you instead need to do is to call the function calcOR() a second time through a separate instance of efsInternal() which will use xStart2 and xEnd2 as the parameters in place of (and not in addition to) xStart1 and xEnd1
            To do this you declare a new global variable called for example xRange1 and set that to null. Once you have done that initialize that variable inside the bInit statement after the first instance of efsInternal() ie
            PHP Code:
            xRange1 efsInternal("calcOR",xStart2,xEnd2,xDisplay,inv(xInterval)); 
            At this point assign to myHigh1 and myLow1 the newly created series ie getSeries(xRange1,0) and getSeries(xRange1,1)
            Then replace the elements of the return statement as I explained in my prior reply. This is because you have already created the individual series and you do not need to do it again. In fact the variable myHigh, myLow, myHigh1 and myLow1 are already series objects at this point.
            Lastly you need to add the appropriate statements in preMain() to set the plot type, color, name for the additional plots, etc
            Alex

            Comment


            • #7
              Thanks

              Alexis i'll give it a go


              Jamie

              Comment


              • #8
                Time Zones

                Trying to get this EFS to change start and end times automatically using code lines 63 to 74 but having problems


                thanks in advance for help



                Jamie
                Attached Files

                Comment


                • #9
                  Jamie
                  While it is possible to adapt HiLo_firstXminutes2.efs to do what you want you need to consider that it was not meant to be used in this way [which makes it less efficient] so I would suggest that at some point you write a new efs from the ground up designed specifically for this task.
                  Anyhow to modify the script declare two global variables called xStart and xEnd and set them initially to 0. Then remove xStart and xEnd from the main definition (ie from within the parenthesis of function main(xStart, xEnd,...).
                  Once you have done that insert the logic that determines each xStart and xEnd before intializing xRange. Also remove the bInit conditional statement that currently encloses the intialization of xRange.
                  In the following two images you can see a sample of the required logic and the results returned by this sample





                  Lastly, as I already suggested to you in another thread that deals with other variations of this same script replace getSeries(xRange,0) and getSeries(xRange,1) in the return statement with myHigh and myLow
                  Alex

                  Comment


                  • #10
                    Thanks very much Alexis for all your help in recent days



                    Jamie

                    Comment


                    • #11
                      Jamie
                      You are most welcome
                      Alex

                      Comment


                      • #12
                        Trading Ranges

                        trying to modify this EFS to get other levels, doe not give me any errors but also does not work

                        thanks in advance

                        Jamie
                        Attached Files

                        Comment


                        • #13
                          Jamie
                          In the main function you need to retrieve the additional series from the efsInternal() call using the getSeries() function eg.
                          var myLevel1 = getSeries(xRange,2);
                          etc

                          Also as I suggested to you in other posts that deal with variations of this same efs (see this post and this post) you should replace getSeries(xRange,0) and getSeries(xRange,1) in the return statement with myHigh and myLow
                          FYI I have now merged this thread with your other ones that are related to the same efs.
                          Alex

                          Comment


                          • #14
                            Thanks Alex for all you help on this and other posts

                            Jamie

                            Comment

                            Working...
                            X