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

Re: [amibroker] Re: BarsSince(Buy == 1)



PureBytes Links

Trading Reference Links

What do you mean by this?
>>But it does have a major flaw vs other software
products. AFL code has NO ACCESS to your ACTUAL trade stats
(entryprice, bars in trade etc). <<
Scan and backtest gives you all of this
or
you can simply write an exploration to provide all that data and more

or maybe I missed your point!

buy=yourbuyconditions;
sell=yoursellconditions;
buy=exrem(buy,sell);
sell=exrem(sell,buy);

filter=1;
addcolumn(barssince(buy),"BarsInTrade",1);
addcolumn(valuewhen(buy,buyprice),"BuyPrice",1.3);
adddcolumn(c/valuewhen(buy,buyprice),"TradeMove",1.3);


etc





On 5/26/05, fanziguk <maxdanzig@xxxxxxxxxxxx> wrote:
> Ill put you out of your misery, Peter, and save you weeks if not
> months of mucking around as I have.
> 
> Amibroker is a wonderful program - uniquely fast with it's array
> based technology. But it does have a major flaw vs other software
> products. AFL code has NO ACCESS to your ACTUAL trade stats
> (entryprice, bars in trade etc). Unless you use the built in commands
> to do ultra simple stuff (Applystop etc), you are simply guessing
> based on the movement of the market. EXREM and EXREMSPAN just help
> you guess better!
> 
> Don't be too depressed though, as the new Custom Backtester does have
> access to the actual trade. But it is very cryptic (easy to make a
> mistake) and Tomasz appears reluctant to give support for it. I have
> written a piece of CB code that will do what you want. It looks
> correct but does not work presently. Tomasz has it and (hopefully!)
> one rainy day he might get around to correcting it. I will post it
> here if so. Or perhaps he would like to?
> 
> Max
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Peter" <pa299@xxxx> wrote:
> > Hi
> > I'm a new to AFL and need some help with code for a exit on first
> > profitable open.
> >
> > I've been using this code in a Commentary window to check if it
> > works.
> >
> > The problem I have is that at times after entering a long position
> > (Buy = false) the variable BuyBarsSince in the line
> > BuyBarsSince = BarsSince(Buy == 1);
> > will reset to 0 when Cond1 AND Cond2 AND Cond3 are all true
> >
> > The result is an exit below the entry price.
> >
> > My question is why at times does
> > BarsSince(Buy == 1)
> > reset to 0 when Buy = false?
> >
> >
> > Am I missing obvious?
> > Any help would be appreciated?
> > Thanks
> > Peter
> >
> >
> > //3Down Close Commentary
> >
> > Cond1 = Ref(C,1) > Ref(C,0);
> > Cond2 = Ref(C,-2) > Ref(C,-1);
> > Cond3 = Ref(C,-3) > Ref(C,-2);
> >
> > Buy = Cond1 AND Cond2 AND Cond3 ;
> > BuyPrice = Ref(Open,0);
> >
> > //------------------------------------------
> > // Exit 1st Profitable Open
> > // How many bars ago was the last Buy signal?
> > BuyBarsSince = BarsSince(Buy == 1);
> > // Actual Price of buy
> > Price4LastBuy = Ref(BuyPrice, -BuyBarsSince);
> >
> > SellCond1 = Cross(Open,Price4LastBuy);
> > SellCond2 = BarsSince(Buy == 1) > 0;
> >
> > Sell = SellCond1 AND SellCond2;
> > SellPrice = Ref(O,0);
> >
> > Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell);
> >
> >
> >
> > //------------------------------------------
> >
> > "3 Down Close Commentary";
> > "";
> > "Cond1 is " + WriteVal(Cond1);
> > "Cond2 is " + WriteVal(Cond2);
> > "Cond3 is " + WriteVal(Cond3);
> > "Buy is " + WriteVal(Buy);
> >
> > "";
> > "BuyPrice is " + WriteVal(Price4LastBuy );
> > "BarsSince(Buy)is " + WriteVal(BarsSince(Cond1 AND Cond2));
> > "Price4LastBuy is " + WriteVal(Price4LastBuy);
> >
> > "";
> > "SellCond1 is " + WriteVal(SellCond1 );
> > "SellCond2 is " + WriteVal(SellCond2 );
> >
> > "Sell is " + WriteVal(Sell );
> > "SellPrice is " + WriteVal(SellPrice );
> 
> 
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 


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


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

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

 
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:
    http://docs.yahoo.com/info/terms/