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

Fwd: [amibroker] Quick code question please



PureBytes Links

Trading Reference Links

This is the updated code (thanks to people who have helped with this so far) if anyone else in the community is interested.  I just tried backtesting GBPJPY daily data with this and it does what I wanted (triggers a buy/sell order when a two bar high/low is created on next bar if it breaks).  I'm only working with historic data to help my edge when manual trading.

If anyone can run this on intraday let me know (very new to this) or if the trailing two bar stop can be made to be initially under the bar before the entry bar and only trail when a higher high is created (if long of course and the opposite when short).

Any interesting ways of trailing stop are of interest to me so would be cool to see people play with this.

best

AH

-------------

/* two bar high/low backtest.  trade entered when 1 pip higher than tbh or 1 pip lower than two bar low.  stop is trailed two bars behind extreme

*/


AbsHighDiff = abs(H - Ref(H, -1));

AbsLowDiff = abs(L - Ref(L, -1));

tbh = AbsHighDiff < 0.02; // max. 2 pips difference

tbl = AbsLowDiff < 0.02; // max. 2 pips difference



PositionSize = -33;

tbhyesterday = Ref( tbh, -1 ); // new array - tbh shifted forward 1 bar

tblyesterday = Ref( tbl, -1 ); // new array - tbl shifted forward 1 bar


HigherHigh = High > Ref( High, -1 );

LowerLow = Low < Ref( Low, -1 );

Buy = tbhyesterday AND HigherHigh;

BuyPrice = Ref ( High, -1 );

Sell = L < Ref(LLV(L,2),-1);

SellPrice = Ref(LLV(L,2),-1);

Short = tblyesterday AND LowerLow;

ShortPrice = Ref ( Low, -1 );

Cover = H > Ref( High, -2 );

CoverPrice = Ref ( High, -2 );

----------------------


__._,_.___

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




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

__,_._,___