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

[amibroker] Re: Help needed on a simple code:



PureBytes Links

Trading Reference Links

Dave's loop looks really good. I modified the code a little so that now you can easily change your yesterday's high-low hours and today's plot hours. I entered some weird hours here just to make it easier to test how all this works.

Lester

/*** START ***/

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

Plot(C, "", colorTan, styleCandle);

// Enter your time ranges here
yestStartTime = 110000;
yestEndTime   = 140000;
plotStartTime = 103000;
plotEndTime   = 150000;

BarTime = TimeNum();

dKeepL = 9999999;
dKeepH = 0;

YDayH = Null;
YDayL = Null;

for(i=1; i<BarCount; i++)
{
 dKeepH[i] = dKeepH[i-1];
 dKeepL[i] = dKeepL[i-1];
 YDayH[i] = YDayH[i-1];
 YDayL[i] = YDayL[i-1];

// New Day
 if (BarTime[i] < BarTime[i-1]) 
 {
 YDayH[i] = dKeepH[i-1];
 YDayL[i] = dKeepL[i-1];
 dKeepH[i] = 0;
 dKeepL[i] = 9999999;
 }
 if 
 (BarTime[i] >= yestStartTime AND 
 BarTime[i] <= yestEndTime)
 {
 if (dKeepH[i] < H[i])
 dKeepH[i] = H[i];
 if (dKeepL[i] > L[i])
 dKeepL[i] = L[i];
 }
}

YDayH_plot = IIf(TimeNum()>=plotStartTime 
AND TimeNum()<=plotEndTime, YDayH, Null);

YDayL_plot = IIf(TimeNum()>=plotStartTime 
AND TimeNum()<=plotEndTime, YDayL, Null);

Plot(YDayH_plot, "",colorLightBlue,styleDots+styleNoLine+styleNoRescale);
Plot(YDayL_plot, "",colorOrange,styleDots+styleNoLine+styleNoRescale);

SetChartOptions(0, chartShowDates);
GraphXSpace = 3;

/*** END ***/


--- In amibroker@xxxxxxxxxxxxxxx, "nebt1" <nebt1@xxx> wrote:
>
> Hi David,
> Thanks for your help, looks like the loop idea does it. This also 
> starts printing the lines from midnight today, so i changed back into 
> 9:30 and changed closing time to 155959 since it uses bar open.
> Best regards,
> Tom
> ======================
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "dbw451" <dbw451@> wrote:
> > I assumed you had your database settings set to your market hours.  
> You
> > could try changing your database settings for intraday to "Show day 
> session
> > only" with your trading hours set to 07:45 to 16:00.  If that is not
> > feasible, you could always use a loop to brute force your daily 
> high/low
> > values:
> > 
> >  
> > 
> > BarTime = TimeNum();
> > 
> >  
> > 
> > dKeepL = 9999999;
> > 
> > dKeepH = 0;
> > 
> > YDayH = Null;
> > 
> > YDayL = Null;
> > 
> > for(i=1; i<BarCount; i++) {
> > 
> >        dKeepH[i] = dKeepH[i-1];
> > 
> >        dKeepL[i] = dKeepL[i-1];
> > 
> >        YDayH[i] = YDayH[i-1];
> > 
> >        YDayL[i] = YDayL[i-1];
> > 
> >  
> > 
> >        if (BarTime[i] < BarTime[i-1]) {  // New Day
> > 
> >               YDayH[i] = dKeepH[i-1];
> > 
> >               YDayL[i] = dKeepL[i-1];
> > 
> >               dKeepH[i] = 0;
> > 
> >               dKeepL[i] = 9999999;
> > 
> >        }
> > 
> >        if (BarTime[i] >= 74500 AND BarTime[i] <= 160000) {
> > 
> >               if (dKeepH[i] < H[i])
> > 
> >                      dKeepH[i] = H[i];
> > 
> >               if (dKeepL[i] > L[i])
> > 
> >                      dKeepL[i] = L[i];
> > 
> >        }
> > 
> > }
> > 
> >  
> > 
> > Plot
> (YDayH, "YDayH",colorWhite,styleDots+styleNoLine+styleNoRescale);
> > 
> > Plot(YDayL, "YDayL",colorGold,styleDots+styleNoLine+styleNoRescale);
> > 
> >  
> > 
> >  
> > 
> > Regards,
> > 
> >  
> > 
> > David
> > 
> >  
> > 
> >   _____  
> > 
> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] 
> On Behalf
> > Of nebt1
> > Sent: 02/17/2007 5:20 PM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Re: Help needed on a simple code:
> > 
> >  
> > 
> > Hi David,
> > Just find out that idea with color does not work. When I have high 
> > say at 16:10, it plots that high the next day. So code must be a 
> > function of time and not color. Hope some one has solution for this 
> > simple code.
> > Tia, Tom
> > 
> > --- In amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> 
> ps.com,
> > "nebt1" <nebt1@> wrote:
> > >
> > > Hi David,
> > > Thanks for your suggestion. It certainly better that what I had 
> > > before. Just one more thing needed:
> > > yesterday high and low lines appearing on today chart from 9:30 
> > till 
> > > 16:00. I would like those lines to start appearing say at 7:45 in 
> > > case there are premarket news or there is a gap open in the 
> morning
> > > and we need to see yesterday high/low ahead of time.
> > > For example my yesterday close line starts at 16:00 yesterday 
> time 
> > > and keep going till 16:00 today:
> > > 
> > > marketclosetime= deValueWhenTime(O, 160000);
> > > Plot
> > > 
> > 
> (marketclosetime, "",colorCustom10,styleDots+styleNoLine+styleNoRescal
> > > e);
> > > 
> > > So wondering how to make those two lines (yesterday high and low) 
> > to 
> > > start appearing from 7:45 today time.
> > > Regards, Tom
> > > 
> > > 
> > > --- In amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> 
> ps.com,
> > "dbw451" <dbw451@> wrote:
> > > >
> > > > Tom,
> > > > 
> > > > 
> > > > 
> > > > The way I do it is I set the line color to my background color 
> > > whenever the
> > > > line is outside my range of interest. For example, if your 
> > > background color
> > > > is black:
> > > > 
> > > > 
> > > > 
> > > > clrBg = colorBlack; // set to your background color
> > > > 
> > > > BarTime = TimeNum();
> > > > 
> > > > 
> > > > 
> > > > clrYDayH = iif (BarTime < 93000 OR BarTime > 160000, clrBg, 
> > > colorWhite);
> > > > 
> > > > Plot(YDayH,"", clrYDayH,styleDots+styleNoLine+styleNoRescale);
> > > > 
> > > > 
> > > > 
> > > > I would be curious to know if there is a better way (like it 
> > would 
> > > be cool
> > > > to have a "no color"). Actually I guess another way would be to 
> > > plot each
> > > > day's line as a separate trend line.
> > > > 
> > > > 
> > > > 
> > > > Regards,
> > > > 
> > > > 
> > > > 
> > > > David
> > > > 
> > > > 
> > > > 
> > > > _____ 
> > > > 
> > > > From: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> 
> ps.com 
> > [mailto:amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> 
> ps.com] 
> > > On Behalf
> > > > Of nebt1
> > > > Sent: 02/17/2007 2:18 PM
> > > > To: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> 
> ps.com
> > > > Subject: [amibroker] Help needed on a simple code:
> > > > 
> > > > 
> > > > 
> > > > Hi,
> > > > I am running a 24 hour intraday chart and I need to draw 
> > Horizontal 
> > > > line for Yesterday Low and Horizontal line for Yesterday High 
> on 
> > > > Todays chart. Those lines should refer to Yesterday prices 
> > starting 
> > > > from 9:30 and ending at 16:00.
> > > > 
> > > > Here is what I got:
> > > > 
> > > > YDayH = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
> > > > YDayL = TimeFrameGetPrice("L", inDaily, -1); // yesterdays low
> > > > 
> > > > Plot(YDayH, "",colorWhite,styleDots+styleNoLine+styleNoRescale);
> > > > Plot(YDayL, "",colorGold,styleDots+styleNoLine+styleNoRescale);
> > > > 
> > > > My problem is that I am getting lines drawn for high and low 
> for 
> > 24 
> > > > hours yesterday data, but I need for 9:30 to 16:00 only.
> > > > 
> > > > Please help,
> > > > tia, Tom



Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.18.2/692 - Release Date: 2/18/2007 4:35 PM