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

Re: [amibroker] Re: Why so signals change after the bar closes?



PureBytes Links

Trading Reference Links

hi Tom,
 
Only when the bar is finished it will be known if a signal is permanent. This is because MACD uses the close price of the bar and also stockastics will use the close price. Therefor at the time the bar is developing a buy signal may appear only to disappear a few secons later.
 
To use permanet signals only you may shift the array like:
 
Buy1 = MACD(5,26) > Ref(MACD(5,26), -1); // macd 1 is going up.
Buy2 = MACD(12,26) > Ref(MACD(12,26), -1); // macd 2 is going up
Buy3 = StochK(14,3) > Ref(StochK(14.3), -1);
// Buy and Sell orders
Buy = Buy1 AND Buy2 AND Buy3;
 
Buy = Ref(Buy,-1); BuyPrice = O;
However, what you describe I think has to do with the fact that only the data visible on the chart are used to make the calculations. So adding:
 
SetBarsRequired(10000,10000);
to your code might help.
 
regards, Ed
 
 
 
 
----- Original Message -----
Sent: Saturday, December 06, 2008 8:46 AM
Subject: [amibroker] Re: Why so signals change after the bar closes?

--- In amibroker@xxxxxxxxxps.com, Aron <apforex@xxx> wrote:
>
> professor77747 wrote:
> > In my formula, I use only the macd and stochastic to determine a
buy
> > signal. Several times, I didn't have a buy signal after the bar
closes.
> > Call this bar 1. Then the next bar closes(bar 2) and still no
signal.
> > Then, during the next bar (bar 3), I get a signal on bar 1.
> >
> > When I backtest, the results are the same. No buy on bar 1. Then
run
> > again on bar 2 and there is no bar. Then, run again on bar 3 and
there
> > is a buy shown for bar 1.
> >
> > I use a 6 hour chart and hourly data.
> >
> > I thought that after a bar closes, the macd and stochastic would
not
> > change.
> >
> > Why does this happen?
> >
> > Tom
> >
> >
> Post your code.
>
It is just a simple test code, but the buy changes as explained.
Buy1 = MACD(5,26) > Ref(MACD(5,26), -1); // macd 1 is going up.
Buy2 = MACD(12,26) > Ref(MACD(12,26), -1); // macd 2 is going up
Buy3 = StochK(14,3) > Ref(StochK(14.3), -1);
// Buy and Sell orders
Buy = Buy1 AND Buy2 AND Buy3;

I just don't understand why 2 bars later that the buy signal changes.
I get a buy arrow on my chart and the backtest will also change 2
bars later and show a buy when it didn't show it before.

Tom

__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___