Easylanguage or general programming question

Discussion in 'Trading Software' started by m4a1, Aug 20, 2006.

  1. m4a1

    m4a1

    I am creating a custom indicator and I have the "update on every tick" checked. I have many lines of code, but there is a certain portion of my code where I only want it process the very first tick of each bar. For example, process the first tick at the start of a 5 minute bar, but don't process the ticks thereafter. When the next 5 minute bar starts, only process its first tick too. and so on...

    I have tried the following code, but it doesn't seem to work perfectly. It will "leak" extra ticks into the if statement.

    Code:
    if time<>cb then begin
         do first thing
         do second thing
         do third thing
    end;
    cb=time;
    
    Does anyone know what's wrong or what I need to do?
     
  2. You didn't say which version of T$ but have you looked at BarStatus?
     
  3. m4a1

    m4a1

    thanks. i'm using 2000i. do you think the code below will work. i cannot test it until the market opens on Monday. the easylanguage help says barstatus is generally used with activitybar studies.

    Code:
    if barstatus(1)=0 then begin
         do first thing
         do second thing
    end;
    
    a more general programming question. if you keep passing values into an if statement, does the if statement block the next value until it has processed the first one? or does it let several of them through at once and process them together?
     
  4. "but there is a certain portion of my code where I only want it process the very first tick of each bar"

    The first tick of any bar is a built-in variable called the Open, e.g.,

    if (Open . . . ) then
    . . .


    AnyVariable = Open + xyz;

    etc.
     
  5. m4a1

    m4a1

    how can i code this in easylanguage:

    if current tick=first tick of current bar then...

    i could not get barstatus to work because the open flag refers to the open for the next bar. does anyone know of a workaround?

     
  6. xiaohu

    xiaohu

    If you are using a 1 minute chart you can plot a tick chart and use
    time<>time[1]

    you can construct your own minute bar from ticks.