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

Re: [amibroker] Re:New indicator



PureBytes Links

Trading Reference Links

Dear Manioc,

> > Also: I agree with Dimitris that writing trading systems using Ref 
> with positive
> > offsets (looking into the future) would give results that could not 
> be 
> > reproduced in real life. (unless you have time-machine :-)))
> 
> 
> Well, ref positive offsets would certainly help in back testing.
> I use back testing to know if a system would have peformed well in 
> history.
> 
> I have several system that require you to sell lets say at the open 5 
> day AFTER you bought, no matter what is the current quotation.
> If I could have a ref(close, open, high, low) +5 from the bought day, 
> it would certainly help backtesting those systems.

As you probably know the time is a relative thing and so are the words
"after", "before", "future", "past".

You should always consider the perspective you are talking about.

For the purpose of back testing the time is "0" for the current bar.
If you are using negative offsets in Ref() function you are referring
bars that precede the current bar. Using positive offsets in Ref() you
are referring bars that follow the current bar.
During backtest the current bar is moving from the first bar loaded
to the last one. This simulates real-world trading. Current bar"is
always "today" when the trading decisions are taken. You are not able
to make the decision today based on the tommorrows prices or 
tommorrows value of any variable simply because you don't know it today.
Therefore using positive offsets in ref() is not wise thing to do when
designing a realistic trading system.

On the other hand positive offsets are useful for writing pattern recognition
functions.
I have to stress that AmiBroker's Ref() function supports BOTH positive and
negative offsets since the very beginning of AFL implementation.


And back to your request: if you want to sell after 5 bars from buy 
what you really want is a NEGATIVE offset:
sell = ref( buy, -5 );
this is so because you want to generate a sell signal knowing that 5 bars ago
a buy occurred. You don't need to look into the future because buy aleady
happened. 

OK, let me finish now before I start writing AFL relativity theory :-))))

Best regards,
Tomasz Janeczko
===============
AmiBroker - the comprehensive share manager.
http://www.amibroker.com