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

[amibroker] Re: Blanking a selected number of bars at the end of a ticker



PureBytes Links

Trading Reference Links










You need to treat the indicators in the same way as the
price plot

Without trying to sort your code (getting late here for me)
add in null for the indicators

 

Plot( iif( barindex()<= LastShownPriceBar, MACD(), Null ),
etc

 



Cheers,
Graham
http://e-wire.net.au/~eb_kavan/ 



<span
>-----Original Message-----
From: Dave Merrill
[mailto:dmerrill@xxxxxxx] 
Sent: Sunday, June 27, 2004 8:38
PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Blanking
a selected number of bars at the end of a ticker

<font size=2
face="Times New Roman"> 



<font size=2 color=blue
face="Courier New">Thanks for your reply Graham, but as I mentioned, I've tried that,
and it has problems.





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">Try the more complete setup below, with a couple of random
indicators added. Everything's fine with nothing blanked. Blank out one bar,
and the price plot still looks fine, but MACD and RSI spike to zero on the null
price bars, causing them to rescale, the MACD illegibly. Blank a few more
bars, past a SAR cross, and SAR does the same thing. 





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">For another approach, comment out the BlankAll() line, and
re-enable BlankAll2(), on the next line. This shifts everything to the right,
"off the page", and then back. I tried this because that seemed very
analgous to those bars really not existing. Turns out that AB seems to treat
them as missing data (makes sense), and uses the existing last value for the
missing bars. 



<font size=2 color=blue
face="Courier New"> 





<font size=2 color=blue
face="Courier New">Is there a way to work around all this? Of course, blank the
indicators too. But that means you have to recode every indicator on any pane
you want to do this with.





<font size=2 color=blue
face="Courier New"> 





<font size=2 color=blue
face="Courier New">I'd much rather just drop in a single function to adjust the price
bars, and have everything just work. But setting things to null doesn't really
do it. Any other ideas on a good blanking mechanism?







<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">What I'd really like is a built in feature that handled this
automatically, including blanking BuyPrice, ShortPrice etc, and any new built
in variables as they get added.





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">Clearer?





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">Dave





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">---------------





<font size=2 color=blue
face="Courier New">global gBI, gBarsBlanked;





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">gBarsBlanked = Param( "bars", 0, 100, 0, -1);
gBI = BarIndex();





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">function IsBlanked() {
 return gBI >= (BarCount - gBarsBlanked);
}
function Blank(array) {
 x = IIf(IsBlanked(), Null, array);
 return x;
}
function Blank2(array) {
 x = Ref(Ref(array, -gBarsBlanked), gBarsBlanked);
 return x;
}
function BlankAll() {
 O = Blank(O); H = Blank(H); L = Blank(L); C = Blank(C); 
 Avg = Blank(Avg); V = Blank(V);
}
function BlankAll2() {
 O = Blank2(O); H = Blank2(H); L = Blank2(L); C = Blank2(C); 
 Avg = Blank2(Avg); V = Blank2(V);
}
function OHLCTitle() {
 return 
  Interval(2) + " " + Date()
  + " Open = " + O
  + ", High = " + H
  + ", Low = " + L
  + ", Close";
}





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">BlankAll();
//BlankAll2();





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">GraphXSpace = 5;
Plot(C, OHLCTitle(), colorDefault, styleCandle);
Plot(V, "Volume", colorBlue, styleHistogram+styleOwnScale, 0,
LastValue(Highest(V)) * 2);
//Plot(IIf(IsBlanked(), 1, 0), "", colorLightGrey,
styleArea+styleOwnScale+styleNoLabel, 0, .5);





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">m = MACD(); r = RSI(); s = SAR();





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">Plot(m, "MACD", colorBlue, styleOwnScale);
Plot(r, "RSI", colorRed, styleOwnScale);
Plot(s, "SAR", colorYellow, styleDots+styleNoLine);
/*
Plot(Blank(m), "MACD", colorBlue, styleOwnScale);
Plot(Blank(r), "RSI", colorRed, styleOwnScale);
Plot(Blank(s), "SAR", colorYellow, styleDots+styleNoLine);
*/





<font size=2
face="Times New Roman"> 





<font size=2 color=blue
face="Courier New">---------------





<font size=2
face="Courier New">Try this as an example<font
face="Courier New">

x = Param( "bars", 1, 1, 10, 1);

Plot( IIf( BarIndex()<=BarCount-x, C, Null),
"", colorBlack, styleCandle);

Cheers,
Graham
http://e-wire.net.au/~eb_kavan/

-----Original Message-----
Sometimes when I'm working on an indicator, or
training my eye, I'd like to
blank out a Param-able number of bars at the end.
Not set them to zero, but
make it like they haven't happened and don't exist
yet. I don't want to see
them, and I don't want any indicators to be
effected by them, kind of a
controllable curtain over the end of the past.

Does anyone have a good way to do this?

Visually, setting the end bars to the background
color works fine, but
preventing indicators from seeing them is harder.
Setting them to null or
zero isn't the same thing; some indicators spike
to infinity, or do
something else besides just cut off there, the way
they do at the end of all existing
bars.

I've tried nested positive and negative Ref
functions, pushing the end bars
"off the map", then moving them back on,
but that seems to leave the
effected bars at the value of the last unaffected
bar.

Any ideas? If not, would anyone else like to see a
feature like this built into
AB?

Dave Merrill



<font size=2
face="Times New Roman">

Check AmiBroker web page at:<font
face="Courier New">
http://www.amibroker.com/

Check group FAQ at: <a
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html










Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Sponsor


  ADVERTISEMENT 












Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.