Hello,

A must read for everyone wanting to write AFL formulas:
http://www.amibroker.com/guide/h_understandafl.html

Read slowly and analyse the example tables that are included in that article,
it will help you understand.

Best regards,
Tomasz Janeczko
amibroker.com

On 2010-04-23 06:56, Keith McCombs wrote:


Mike --
I didn't know that,
"Buy = Ref( Buy, -1 ) is not ambiguous.
It will behave exactly has you have proposed in your workaround (i.e. will internally create a temporary array holding Ref(Buy, -1) which will then be assigned to Buy)."

Is that explained somewhere in the User's guide or Help?

BTW, I didn't really know "SellPrice = Ref(O, 1);" was wrong until I found out why in the User's Manual, page 141 (after about an hour of looking): "During back-testing AmiBroker will check if the values you assigned to buyprice, sellprice, shortprice, coverprice fit into high-low range of given bar. If not, AmiBroker will adjust it to high price (if price array value is higher than high) or to the low price (if price array value is lower than low)"

It's these kind of things that make AB harder than it should be.
-- Keith

On 4/22/2010 22:13, Mike wrote:

Keith,

Buy = Ref( Buy, -1 ) is not ambiguous.

It will behave exactly has you have proposed in your workaround (i.e. will internally create a temporary array holding Ref(Buy, -1) which will then be assigned to Buy).

It does, however, require that Buy has already been initialized before this statement.

Mike

--- In amibroker@yahoogroups.com <mailto:amibroker%40yahoogroups.com>, Keith McCombs <kmcco...@...> wrote:
>
> I gave this thread a new name because TJ's response brought up a much
> more general concern, for me, than the original title expressed.
>
> I thought that statements such as "Buy = ref( Buy, -1 );" were ambiguous
> and therefore should not be used. The reason being that if the array
> valuation moves forward in time (Buy[n] evaluated before Buy[n+1]) then
> all Buys will be equal to Buy[0]. However if valuation moves backward
> (Buy[n+1] before Buy[n]) then a much different result is produced.
>
> Therefore, one should instead use something like this:
> temp = ref(Buy, -1);
> Buy = temp;
>
> Hopefully someone will clear up my confusion.
> Thank you.
> -- Keith
>
> On 4/20/2010 19:10, Tomasz Janeczko wrote:
> >
> > Hello,
> >
> > >SellPrice = Ref(O, 1);
> >
> > Wrong advice.
> > Once again: NEVER move trading prices using ref().
> >
> > Instead delays SIGNALS
> > Buy = ref( Buy, -1 );
> > Sell = ref( Sell, -1 );
> >
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> >
> > On 2010-04-21 00:54, hiscores wrote:
> > > There are numerous ways to do this, but here is a simple one
> > >
> > > Buy = C> MA(C, 20);
> > > BuyPrice = C;
> > >
> > > StopLoss = C< MA(C, 50);
> > > ProfitTarget = C> MA(C, 10);
> > >
> > > Sell = StopLoss OR ProfitTarget;
> > > // If we exit due to stop loss take the 50 MA otherwise
> > > // by process of elimination we exit at target 10 MA
> > > SellPrice = iif(StopLoss, MA(C, 50), MA(C, 10));
> > >
> > > This is here so you can learn how to code such rules, but I should
> > point out that your strategy is unrealistic! You are making a rule
> > where if at the END of a bar we are below an MA we should sell at a
> > price ABOVE the close (ie the MA price that price action is now
> > below). Furthermore the MA will not settle to its final value until
> > the bar is finished (since the MA is calculated on closing prices).
> > You should probably set your sell prices to the open of the next bar
> > >
> > > SellPrice = Ref(O, 1);
> > >
> > > -hi
> > >
> > > --- In amibroker@yahoogroups.com <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>,
> > "dralexchambers"<dralexchambers@> wrote:
> > >
> > >> Hi,
> > >>
> > >> How would I put together a backtest for the following. My Buy
> > signal is:
> > >>
> > >> Buy = C>MA(C,20);
> > >>
> > >> How do I do a multiple sell signal for the following:
> > >>
> > >> StopLoss is hit is when C< MA(C,50) Stoploss price is MA50.
> > TakeProfit is when C> MA(C,10), and TP price is MA10.
> > >>
> > >> I can only see one Sell& Sellprice variable. How do I put both of
> > these conditions into Sell& Sellprice?
> > >>
> > >> Thanks,
> > >> Alex
> > >>
> > >>
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > **** IMPORTANT PLEASE READ ****
> > > This group is for the discussion between users only.
> > > This is *NOT* technical support channel.
> > >
> > > TO GET TECHNICAL SUPPORT send an e-mail directly to
> > > SUPPORT {at} amibroker.com
> > >
> > > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> > > http://www.amibroker.com/feedback/ <http://www.amibroker.com/feedback/> <http://www.amibroker.com/feedback/ <http://www.amibroker.com/feedback/>>
> > > (submissions sent via other channels won't be considered)
> > >
> > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > > http://www.amibroker.com/devlog/ <http://www.amibroker.com/devlog/> <http://www.amibroker.com/devlog/ <http://www.amibroker.com/devlog/>>
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> >
> >
>




Reply via email to