[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [amibroker] How to set the "amount" in ApplyStop(stopTypeTrailing, stopModePoint,amount,1,1,1)
PureBytes Links
Trading Reference Links
|
I've given up using the applystop function for anything but the most basic things, i found it never worked the way i expected, not sure if thats because i cant code or if there are some issues with it. You can do anything with loops, and at least you know what they are doing, i suspect you will end up doing the same. It has certainly saved me a lot of time and energy.
sorry i cant be of more help.
On 1/10/06, Joe Bolton <j0etr4der@xxxxxxxxx> wrote:
Greetings, I am trying to implement the Elder Safe Zone stop from code I got from the library and elsewhere. Try as I might (and it's been a while), I cannot determine how to convert the stop price I get from the SZ calculation into the "amount" for a trailing stop. I have searched Help, the AB site and newsgroups here but have not found any useful information on how to make this work or how AB handles a trailing stop.
As you can see below, I have approximated a trailing stop, but it has the disadvantage of using the the next day's open when the actual stop is greater than the next day's prices and it does not exit intraday.
The setup for EOD trading, exiting intraday is in my formula -- the profit stop I've coded works as expected. Following the work-around for the trailing stop is the code I started for the trailing Applystop, but of
course the code for the "amount" is wrong. What is there is the closest I could come to getting the right amount and it's very wrong. Thank you for any help you can provide.
TrailingStop = 4; //simulate trailing stop LookbackPeriod = 8;//Optimize("SZLkBk",12,4,12,1); //Set Lookback period
AvgDnPenCoeff = 1.9;//;//Optimize("SZLongCoeff", 1.35, 1.5, 3.5, 0.1); // DownPen = IIf(Low
< L1, L1 - Low, 0); //Identify amount of each penetration -- O=none DownPenSum = Sum(DownPen,LookbackPeriod);
//Total volume of penetrations during the lookback
period DownPenCount = Sum(Low < L1, LookbackPeriod); //Number of penetrations during lookback period AvgDownPen = DownPenSum/DownPenCount;
//Average penetration amount during lookback period AvgDownPen = Nz(AvgDownPen, 0);//Insure it is not NAN
DownPenSum = Sum(DownPen, LookbackPeriod); //Total volume of penetrations during the lookback period SafeZoneLong = L1 - (AvgDownPen*AvgDnPenCoeff);
// "Place your stop at a multiple of yesterday's AveDownPen below yesterday's low." SafeZoneTrailLong = HHV( SafeZoneLong,
BarsSince(Buy) + 1 );//stop can't drop
during trade SZStopLong = IIf( Low <= Ref( SafeZoneTrailLong, -1), True, False);
//the stop is trigger SZStopLong = ExRem(SZStopLong, Buy);//mask off secondary SZ signals //Trailing stop workaround
for ( i = 0; i < BarCount; i++ ) { if( SZStopLong[i] == True
) { SellPrice[i] = SafeZoneTrailLong[i]; Sell[i] = TrailingStop;
} } Plot (SafeZoneTrailLong, " SellStop"
, colorYellow, styleStaircase); //How to make this work?
SZTrailLong_Amount = High - Ref(SafeZoneTrailLong, - 1); //Wrong
SZTrail_ExitAtStop = 1; SZTrail_Volatile = True; SZTrail_ReEntryDelay =
1; ApplyStop (stopTypeTrailing, stopModePoint, SZTrailLong_Amount, SZTrail_ExitAtStop, SZTrail_Volatile, SZTrail_ReEntryDelay);
Best regards, Joe
Yahoo! Photos – Showcase holiday pictures in hardcover
Photo Books. You design it and we'll bind it!
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
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
|
- Prev by Date:
[amibroker] RSI gone missing!
- Next by Date:
RE : [amibroker] RSI gone missing!
- Previous by thread:
[amibroker] How to set the "amount" in ApplyStop(stopTypeTrailing, stopModePoint,amount,1,1,1)
- Next by thread:
Re: [amibroker] How to set the "amount" in ApplyStop(stopTypeTrailing, stopModePoint,amount,1,1,1)
- Index(es):
|
|
|