Announcement

Collapse
No announcement yet.

Apply formula to user defined bars

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

  • Apply formula to user defined bars

    How do I set up a formula that can be applied to a user defined set of bars, versus all the bars on the chart ? Basically the user will indicate the starting bar and ending bar and the I want to perform a calculation on the inclusive set...Is this possible ? Can someone point me in the direction to get started ?

    Many thanks -
    Jennifer

  • #2
    Array solution

    Hi Jennifer,

    One approach would be to use an array, or an array of arrays to keep a permanent record of all of the bars in the chart. Then you can work with a subset of the array that corresponds to the bars that the user is interested in. The array structures might look like:

    //global array to keep track of all bars in the chart
    var aAllBars = new Array()
    var nrBars=0;

    //for each new bar
    var aBar = new Array()

    // create an array of data for the current bar
    aBar.Open= open()
    aBar.Close = close()
    aBar.High = high()
    aBar.Low = low()
    aBar.Vol =volume
    aBar.Index = getCurrentBarIndex ()

    // now save the array globally
    aAllBars [nrBars++] = aBar

    Once the data has loaded, you can cylce thru the aAllBars array, selecting any subset you want based on what the user is interested in.

    Hope this helps,

    Scott
    Scott Masters
    www.tic2tic.com
    [email protected]

    Comment


    • #3
      WOW ! That helps a lot...Now, how do I know what the user selected...the user will apply a trend line on the chart connecting the high of the start bar with the low of the end bar ( or vice versa); how do I capture that input in my formula ?
      THANKS !

      Comment


      • #4
        Mouse functions

        Jennifer,

        See the mouse functions in the EFS help files. In particular,
        you can receive events when the user clicks on bars, like:

        function onLButtonDown( barIndex, yValue) {

        debugPrintln("LeftDown: " + barIndex + ", " + yValue);

        updateClickInfo(barIndex, yValue);

        }

        Scott
        Scott Masters
        www.tic2tic.com
        [email protected]

        Comment


        • #5
          Re: Reply to post 'Apply formula to user defined bars'

          Most people do this be defining the start and end times and only running the
          efs when the time is within the defined range.

          Comment


          • #6
            I am looking through the EFS Help files to find the mouse functions and not having any luck...can anybody out there give me a location where I can find them...
            THANKS !

            Comment


            • #7
              Jennifer
              The online EFS Help Center and Library may not have been updated yet.
              Click here and download the EFS Help Files from Chris Kryza's group in FileShare.
              Alex

              Comment


              • #8
                Fantastic ! This is the first step. I can get the bar from a single left click....Anyway to tie this into a drawn Trend Line. The line starts with a left click and ends with a left click, but it seems when I am in that mode on my chart the formula is not picking up the clicking...
                Many thanks !
                Jennifer

                Comment


                • #9
                  Jennifer....

                  I would suggest you control the clicking by using a "staging" variable. In you don't use this, then every time you click on a chart with your EFS loaded, it may try to re-initiate the trendline drawing functions.

                  The staging variable would simply allow you to enable/disable your function.

                  VStaging = 0 TL drawing off.
                  VStaging = 1 TL drawing on - choose first location.
                  VStaging = 2 TL drawing on - choose second location.

                  Now your staging veriable goes back to 0 and the line is drawn.

                  Brad
                  Brad Matheny
                  eSignal Solution Provider since 2000

                  Comment

                  Working...
                  X