PureBytes Links
Trading Reference Links
|
Dans un courrier daté du 06/11/98 08:13:31 Heure d8iver Pari31 Madrid,
countach@xxxxxxxxxxxxxxxx a écrit :
(snip)
> >
> >The code works well on EOD data (I've cleaned it up a little). The
>problem
> occurs when it is applied to live intraday data. If the >hist is rising
> during a tick, then reverses, that bar becomes a >green bar with a red bar
> superimposed over it.
>
> The problem is that once a bar is painted, it stays in the graphics
> memory. If you paint over it it will disappear. If you paint over part
> of it, you get the second color and some of the first.
>
> The solution has been mentioned here before. You must repaint the
> previous value in the background color to obliterate it, then paint the
> new value in its color. This may be difficult, however, if updating on
> every tick, since TS updates variables only at the close of a bar, not
> by tick. The previous painted value (a tick) is gone, unless you use
> global variables to save it.
>
> donc
>
This is not true:
When updating every tick, TS calculates and plot the considered value like if
the last tick of the "underconstruction bar" was closed with a close value
that is precisely the last tick value.
The above quoted statement is true only for systems ( where update every
tick is impossible)
No need of global variable DLL or repainting with the background color.
Suffice to think on how TS works:
The code is executed from top to end.
The idea it to plot ( plot1 and 2) first with a zero value.
Then plot again (plot1 and 2) the colored histogram with the real value MACDD
that will be updated on every tick, and that will plot over a 0 amplitude
histogram ( e.g on a clear background).
Here is the TS code:
{
MaxBarsBack set to 1 ( yes!)
Plot1: green histogram
plot2: red histogram
}
Inputs: FastMA(12),SlowMA(26),MacdMA(9);
value1=MACD(Close,FastMA,SlowMA)-(XAverage(MACD(Close,FastMA,SlowMA),MacdMA));
{ Note that the MACD calculation here is not optimized for speed. It should
be... }
plot1(0,"+");
plot2(0,"-"); <======reset plot values to 0 before plotting the MACDD
values ( erases last bar value)
if value1>value1[1] then begin
plot1(value1,"+"); <=========plots according to MACD climbing
end else begin
plot2(value1,"-"); <=========plots according to MACD falling
end;
Sincerely,
-Pierre Orphelin
www.sirtrade.com
|