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

Re: [amibroker] Newbie - strange ExRem problem in the trading system



PureBytes Links

Trading Reference Links

Generally you would be best to write a loop code to allow sell to reference
the actual buy
Because the sell is before the exrem statement the buy = true still applies
for every signal , not just the first

You might try adding the line after the trade statements, plus much better
to make the buy a straight condition for single bar where possible, ie use
Cross function, to remove many extraneous signals

Buy = Cross( yrHi*0.8, C);
Sell = Cross( C, ValueWhen(Buy,C)*1.1 );
Equity(1);

Some ways to use Equity function
Equity(1,1); shows backtest signals only based on the time dates of start of
test
Equity(1,0) shows singals based on the backtest stareting at beginning of
data (fist bar)
See the help screen for more information on this


-- 
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com


On 11/11/06, trader_1119 <inv12345@xxxxxxxxx> wrote:
>
> I have recently started coding the AFL.
> I am trying to build a simple system which will buy @ 20% or more
> bellow year high and sell @ 10% profit
> Here is the code...
>
> --------------------
> _SECTION_BEGIN("test");
>
>
> SetBarsRequired(10000,10000);
> SetFormulaName("Test1 System");
> SetTradeDelays( 1, 1, 1, 1 );
> SetOption( "initialequity", 100000 );
> PositionSize = -10;
> SetOption( "MaxOpenPositions", 10 );
> SetOption( "CommissionMode", 1 );
> SetOption( "CommissionAmount", 0.059);
> SetOption( "ReverseSignalForcesExit", False);
> SetOption( "UsePrevBarEquityForPosSizing", 1 );
>
> //Trade system
> /*
> Buy when today's close is 20% or more bellow from 52 week high
> Sell when today's Close is more than 10% of the buying price
> There is no stop loss
> */
>
> yrHi = HHV(High,260);
>
> Buy = (yrHi*0.8) >= C;
> //Sell = Cross( C, ValueWhen(Buy,C)*1.1);
> Sell = C > (ValueWhen(Buy,C)*1.1);
>
>
> //Filter = Buy OR Sell;
> Filter = 1;
>
> Buy   = ExRem(Buy, Sell);
> Sell  = ExRem(Sell, Buy);
>
> AddTextColumn( FullName(), "Company Name" );
> AddColumn( Buy, "Buy");
> AddColumn( Sell, "Sell");
> AddColumn( C, "Close", 1.1 );
> AddColumn( yrHi, "52wk High", 1.1 );
> AddColumn( yrHi*0.8, "Buy@/Bellow");
> AddColumn( (yrHi*0.8) >= C, "(yrHi* 0.8) >= C");
>
> _SECTION_END();
> ------------------
>
> The Buy and Sell signals are generated properly, but strangely ExRem
> calls remove first few Buy signals and then buys at some arbitrary
> signals. If I try to comment out ExRem calls, it buys properly but
> then excess signals are not getting removed. I have gone through many
> examples but everything seems to be correct in the code.
>
> Also, it sells at around 50% loss (which is not coded!)
>
> Can somebody guide me as to what is wrong with the code? I am using
> Amibroker 4.80.1.
>
> Thanks & Regards,
> PS
>
>
>
>
>
> 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 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
>
> Yahoo! Groups Links
>
>
>
>
>

Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.11/542 - Release Date: 11/20/2006