[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: How To Get HHV( High, between 09:30 and 10:30 )



PureBytes Links

Trading Reference Links

yes Lester your code using the plugin looks good except for the fact that the Close price line disappears when you switch away from the 1-minute time frame or when the close price at endTime does not exist, since

cls = deValueWhenTime(C, endTime); 

looks at the value for C at a specific bar. The only way to avoid this (in my opinion ofcourse ..) is using code that does not look within a specific bar labelled by time. 


// High and Low in a specified time frame 
startTime = 153000; 
endTime = 163000; 

tt = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,1,0); 
dtt = tt - Ref(tt,-1); 

// add-on plugin functions 
hgh = deTimeRangeHHV (H, startTime, endTime); 
lwl = deTimeRangeLLV (L, startTime, endTime); 
//cls = deValueWhenTime(C, endTime); 

H_plot = IIf(TimeNum()>=endTime, hgh, Null); 
L_plot = IIf(TimeNum()>=endTime, lwl, Null); 
//C_plot = IIf(TimeNum()>=endTime, cls, Null); 
C_Plot = IIf(!tt,ValueWhen(Ref(dtt,1) == -1,C),Null); 

Plot(H_plot, "", colorLightBlue, styleLine); 
Plot(L_plot, "", colorOrange, styleLine); 
Plot(C_plot, "", colorDarkYellow, styleLine); 

SetChartOptions(0, chartShowDates); 
Plot(C,"",26,64); 

Title = "\\c11"+Interval(2)+" "+ 
Date()+"\\c-1 H="+H+" L="+L+" C="+C; 



 



  ----- Original Message ----- 
  From: Lester Vanhoff 
  To: amibroker@xxxxxxxxxxxxxxx 
  Sent: Monday, February 12, 2007 5:32 PM
  Subject: [amibroker] Re: How To Get HHV( High, between 09:30 and 10:30 )


  Ed: I coded it using the plugin. However again if you change the timeframe from 1-minute to 5-minute it seems to give problem,

  My code from message 106471 (using plugin's functions) seems to be working ok with different periodicities (1, 2, 3, 5, 10 ,15, 30 and 60 min charts).

  Lester

  --- In amibroker@xxxxxxxxxxxxxxx, "Edward Pottasch" <empottasch@xxx> wrote:
  >
  > i didn't know about this plugin.
  > 
  > I coded it using the plugin. However again if you change the timeframe from 1-minute to 5-minute it seems to give problem,
  > 
  > Ed
  > 
  > 
  > 
  > startTime = 153000; 
  > EndTime = 163000; 
  > 
  > hgh = deTimeRangeHHV( H, startTime, endTime); 
  > lwl = deTimeRangeLLV( L, startTime, endTime); 
  > 
  > phgh = deValueWhenTime( hgh, endTime); phgh = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,Null,phgh); 
  > plwl = deValueWhenTime( lwl, endTime); plwl = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,Null,plwl); 
  > pcls = deValueWhenTime ( C, endTime); pcls = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,Null,pcls); 
  > 
  > SetChartOptions(0, chartShowDates); 
  > Plot(C,"",1,64); 
  > Plot(phgh,"high",colorGold,styleLine); 
  > Plot(plwl,"high",colorBrightGreen,styleLine); 
  > Plot(pcls,"close",colorLightBlue,styleLine); 
  > 
  > 
  > 
  > 
  > 
  > 
  > ----- Original Message ----- 
  > From: Lester Vanhoff 
  > To: amibroker@xxxxxxxxxxxxxxx 
  > Sent: Monday, February 12, 2007 1:50 PM
  > Subject: [amibroker] Re: How To Get HHV( High, between 09:30 and 10:30 )
  > 
  > 
  > Thanks, Anthony. This looks like the easiest solution. I'll check that later:
  > 
  > deTimeRangeHHV( array, starttime, endtime);
  > deTimeRangeLLV( array, starttime, endtime);
  > deValueWhenTime ( array, time);
  > 
  > Lester
  > 
  > --- In amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso" <ajf1111@> wrote:
  > >
  > > Lester,
  > > 
  > > Using the deDateTime.dll plugin from the 3rd party area...I have never had any problems accessing the data at certain times...
  > > 
  > > Anthony
  > > ----- Original Message ----- 
  > > From: Lester Vanhoff 
  > > To: amibroker@xxxxxxxxxxxxxxx 
  > > Sent: Monday, February 12, 2007 7:11 AM
  > > Subject: [amibroker] Re: How To Get HHV( High, between 09:30 and 10:30 )
  > > 
  > > 
  > > Thanks for help. There are two issues here.
  > > 
  > > 1) Bill's formula is shorter but on some days it somehow excludes the first bar (09:30:00 one) from calculations. For example on NQ-H7 five minute chart:
  > > 
  > > - 2006-12-13: incorrect High
  > > - 2007-01-19: incorrect Low
  > > - 2007-01-26: incorrect High
  > > 
  > > I double checked my one-minute data and there is nothing missing there. It would be interesting to find out why this is happening.
  > > 
  > > http://img227.imageshack.us/img227/1142/02122007062358ca3.png
  > > 
  > > 2) Edward's formula is the hell of a code. I tried to add Lowest Low plot but adding the following line simply wouldn't work:
  > > 
  > > // assign lowest low within the interval assigned to rest of day
  > > lwl = IIf(!tt,LLV(ltt,bs2),Null);
  > > 
  > > Plot(lwl,"",colorOrange,styleLine);
  > > 
  > > Here is what I get:
  > > 
  > > http://img225.imageshack.us/img225/530/02122007063634gx1.png
  > > 
  > > After marking out Plot(lwl, ... ) statement everything is back to normal.
  > > 
  > > Also, there are no problems with Highs or Lows on days when Bill's code generates incorrect values.
  > > 
  > > http://img243.imageshack.us/img243/8375/02122007064123bq7.png
  > > 
  > > Both formulas, with lines for Lowest Low added and a few minor cosmetic changes, are posted below.
  > > 
  > > /*** Bill's code ***/
  > > 
  > > // High and Low in a specified time frame
  > > startTime = 093000;
  > > endTime = 103000;
  > > 
  > > start = BarsSince(TimeNum()==startTime);
  > > end = BarsSince(TimeNum()==endTime);
  > > per = (start - end);
  > > 
  > > hgh = ValueWhen(TimeNum()==endTime, HHV(H, per));
  > > lwl = ValueWhen(TimeNum()==endTime, LLV(L, per));
  > > cls = ValueWhen(TimeNum()==endTime, C);
  > > 
  > > H_plot = IIf(TimeNum()>=endTime, hgh, Null);
  > > L_plot = IIf(TimeNum()>=endTime, lwl, Null);
  > > C_plot = IIf(TimeNum()>=endTime, cls, Null);
  > > 
  > > Plot(H_plot, "", colorLightBlue, styleLine);
  > > Plot(L_plot, "", colorOrange, styleLine);
  > > Plot(C_plot, "", colorDarkYellow, styleLine);
  > > 
  > > Plot(C,"",26,64);
  > > SetChartOptions(0, chartShowDates);
  > > 
  > > Title = "\\c11"+Interval(2)+" "+
  > > Date()+"\\c-1 H="+H+" L="+L;
  > > 
  > > /*** END ***/
  > > 
  > > // +++++++++++++++++++++++++++++++ //
  > > 
  > > /*** Edward's code ***/
  > > 
  > > // High and Low in a specified time frame
  > > startTime = 093000;
  > > endTime = 103000;
  > > 
  > > // assign an array tt having a value 1 inside the interval
  > > tt = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,1,0);
  > > // high within interval
  > > htt = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,H,0);
  > > // low within interval
  > > ltt = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,L,0);
  > > // start bar of interval is 1, end bar is -1
  > > dtt = tt - Ref(tt,-1);
  > > 
  > > // calculate the cumulative number of bars inside the interval
  > > bs = BarsSince( dtt == 1 ) + 1;
  > > // find number of bars at the end of interval
  > > bs2 = IIf(dtt == -1,bs,Null);
  > > // assign highest high within the interval assigned to rest of day
  > > hgh = IIf(!tt,HHV(htt,bs2),Null);
  > > // assign lowest low within the interval assigned to rest of day
  > > lwl = IIf(!tt,LLV(ltt,bs2),Null);
  > > // close price at end of interval assigned to rest of day
  > > // old code: cls = IIf(!tt,ValueWhen(dtt == -1,C),Null);
  > > cls = IIf(!tt,ValueWhen(Ref(dtt,1) == -1,C),Null);
  > > 
  > > Plot(hgh,"",colorLightBlue,styleLine);
  > > // Plot(lwl,"",colorOrange,styleLine); // this must be fixed
  > > Plot(cls,"",colorDarkYellow,styleLine);
  > > 
  > > Plot(C,"",26,64);
  > > 
  > > Title = "\\c11"+Interval(2)+" "+
  > > Date()+"\\c-1 H="+H+" L="+L;
  > > 
  > > SetChartOptions(0, chartShowDates);
  > > 
  > > /*** END ***/
  > > 
  > > 
  > > 
  > > 
  > > 
  > > 
  > > ----------------------------------------------------------
  > > 
  > > avast! Antivirus: Inbound message clean. 
  > > 
  > > Virus Database (VPS): 000712-6, 02/11/2007
  > > Tested on: 2/12/2007 7:21:15 AM
  > > avast! - copyright (c) 1988-2007 ALWIL Software.
  > >
  >



   
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.17.37/682 - Release Date: 2/12/2007 1:23 PM