I've developed a plugin DLL for AmiBroker to generate trailing stop plots from any type of data. It calculates a proper trailing stop array from a specified buy date, where the buy date can either come from a portfolio-like file or be passed from the AFL code. With the sample AFL code provided, the latter is used when a date range has been set, making the beginning of the range the buy date.
The DLL also includes a Guppy Count Back Line function to allow that to be used for trailing stops (there's no Count Back entry function though).
The attached ZIP file includes the following files:
GP_Stops.dll - the plugin code
GP_ATRStop.afl - AFL code for an ATR trailing stop indicator
GP_CBStop.afl - AFL code for a Guppy Count Back trailing stop indicator
GP_EMAStop.afl - AFL code for a simple EMA trailing stop indicator
GP Stops DLL.pdf - an instruction sheet
Pfolio1.csv - a sample portfolio file
See the PDF file for instructions.
These files can be freely distributed and modified. The only thing I ask is that if you modify the AFL code and pass it on to someone else, make it clear that it's not my original code by changing the filename or adding a comment to that effect.
Let me know if you have any problems with it or any comments.
Cheers,
GP
GreatPig
20th-December-2005, 05:04 PM
A sample chart showing the three included trailing stop plots on SYB.
Cheers,
GP
wayneL
20th-December-2005, 05:26 PM
Awesome GP!
Great work and thanks for sharing it.
Cheers
wayneL
20th-December-2005, 05:32 PM
Damn! I wish I could do stuff like that! I'd make short versions of each!
GreatPig
20th-December-2005, 10:43 PM
I'd make short versions of each!
Okay, since you asked so nicely :D
And here's what they look like on a short (hope I've got this right, as I've never done a short).
Cheers,
GP
[If someone could copy this second version into the first message would be good, so that latest version is there]
GreatPig
20th-December-2005, 11:22 PM
Oops... I just realised I haven't done the Guppy count back correctly. No wonder it gave different results to the version I was using before :o
Although I actually think mine's a bit better - especially for stocks like SYB at the moment. I was starting the count back from the current bar, whereas it should start from the most recent high in the current trend (basically since purchase).
Anyway, will get that fixed shortly.
GP
GreatPig
21st-December-2005, 12:40 AM
On second thoughts, I'm going to leave it like it is. Finding the most recent high in the current trend is a little tricky and I think mine is better in those few situations where it's different.
Attached is a diagram of how the proper Guppy Count Back works, where the count back should always start from the most recent high. The method doesn't mention anything though about preventing the stop from falling (in a long position) if the new high also has a low lower than the low of the previous high, as shown in the attachment. This means that over the period of the long position, there could be times where the stop actually drops in situations like this. I think he's done it this way so that he doesn't need to track an ongoing stop position, and thus it can be quickly done at a glance on an unmarked chart.
The way I've done it is by always starting the count back from the current day and tracking the highest value it's ever been since purchase. If the current day's value is less than the highest value, it stays at the highest value. In situations like in the attachment, this allows the stop to keep going up if there are inside days after the long bar with lows much higher than the long bar. With the proper Guppy method, the stop won't move any higher until there's a new high day in that case.
So unless someone can see a problem with the way I'm doing it, which I think will only be noticeably different in rare situations like in the attachment (and currently in SYB), I'm going to leave it like it is.
Cheers,
GP
tech/a
21st-December-2005, 07:18 AM
GP.
Is this your own work or did you paste it up?
Have you tried it on stocks as a stop and reverse swing trade method?
GreatPig
21st-December-2005, 08:34 AM
Tech/a,
Is this your own work or did you paste it up?
I wrote it all myself. I've had count back and ATR trailing stop indicators for a while now, but just separated them out into a separate plugin and modified them to be more generic.
Have you tried it on stocks as a stop and reverse swing trade method?
I haven't tried any sort of back testing with them yet. I mainly use these as visual comparisons with my own system.
Cheers,
GP
kaveman
21st-December-2005, 09:28 AM
I thought the Countback used the low of the highest high bar, then went back to next low lower than this low etc.
Same as lowest low gives the high start point and goes back to next higher high
GreatPig
21st-December-2005, 11:02 AM
Kaveman,
I thought the Countback used the low of the highest high bar, then went back to next low lower than this low etc.
Yes, that's how it's supposed to work.
However, I don't really see how the low of the highest high is more relevant than the low of the current day. I think Guppy does it that way for simplicity, because the highest high is typically going to be close to the highest low as well, and thus you don't need to track the high value of a trailing stop when working it out.
The only time there's going to be a great difference is in cases like my attachment, which just happens to be the case with SYB at the moment (at least the way I handled the demerger). Because the highest high day had a very long bar, the low is very low compared to more recent days, which keeps the stop pretty low. For example, SYB closed at 3.47 yesterday but the proper count back stop was only at 2.815, compared to a 2.5xATR stop at 3.34 and 3.50 for my variation of the count back stop.
But regardless of that, my way is a lot easier to handle in software, as I don't need to find the most recent high when calculating the count back array.
Cheers,
GP
professor_frink
16th-March-2006, 02:20 PM
hi there great pig,
wondering if you could help someone out who is semi retarded when it comes to AFL :(
I copied and pasted the c/b line stop into amibroker and it doesn't seem to be working for me properly. I get the blue line in my chart like the ones you posted earlier, but mine zig zags below the price action, never getting hit!
Any help would be appreciated.
stevo
16th-March-2006, 06:13 PM
GP
Nice work - especially the CBL's. I have never got my head around how to code the CBL's.
I was wondering if anyone has done any backtesting on the Guppy countback lines? It would be nice to compare the original CBL's with the modified lines and ATR style stops. I don't know if they work all that well - I did some testing in MetaStock years ago with CBL's.
stevo
professor_frink
16th-March-2006, 06:35 PM
stevo- did you get this working ok? Any idea what I've done wrong?
God I must be an idiot :D
GreatPig
16th-March-2006, 08:40 PM
Prof Frink,
That looks like just the countback plot without it being turned into a stop-loss.
I'm not running that particular function, as I have another version that's tied in with my own portfolio manager, but from looking in the documentation, one of the AFL parameters selects whether you want to view just the raw countback data or as a stop/loss plot. Make sure that is selecting stop/loss plot.
To find the parameter, right-click over that chart and select Parameters, then I think it's the last one.
Another thing is I think you might need to have an entry for the stock in the file mentioned in the documentation, so that it has a starting date. Try double-clicking somewhere on the chart to set a region start date. Does it look right then?
GP
professor_frink
16th-March-2006, 08:48 PM
thanks for that GP. Looks like I won't be able to use it unless I've set up a portfolio for it to track(is that right?).
I was just hoping to to get the indicator so I could plot it in a similar fashion to ezy chart. Oh well, another negative tick for amibroker here!
GreatPig
16th-March-2006, 08:56 PM
I was wondering if anyone has done any backtesting on the Guppy countback lines?
I've done some testing of my own system using CBL as part of it (where ultimately it was better without it), but not a system using that alone. Plus I haven't done any code for countback entry.
The method Guppy often talks about using CBLs is rather subjective, so difficult to code. He looks for certain characteristics with his GMMA to select a stock then often uses CBL to manage it. To mechanise that I think would require making up some rules combining various aspects of GMMA and other qualities for stock selection, perhaps CBL entry for timing (although he doesn't often mention that), then CBL stop/loss for exit.
Cheers,
GP
GreatPig
16th-March-2006, 09:10 PM
Looks like I won't be able to use it unless I've set up a portfolio for it to track(is that right?).
Well, to plot a stop/loss you need to have a start date, as the stop price can only ever go up from that date. With no start date specified, there's no base to start climbing from. A stop/loss starting from the beginning of the chart would be meaningless today.
That's why I also allowed a region to be marked, so that you can manually set any arbitrary start date. If you double-click on the desired start date, the plot should look correct from that date onwards.
I don't know what EzyChart does or looks like, but I can't see how they can plot a stop/loss without a starting date either.
GP
[Edit: damn, these are ATR plots, but it's the same with countback]
gotcha. thanks for your help GP. Basically in Ezychart you just clicked on countbackline under the line section and dragged it to your start date. It looks just like guppy plots it as in his books. Now that I've got it working it's pretty well doing the same thing. Sorry to all the fine folk at amibroker for trashing their product. I'm just a very moody person :D .
Now how did you plot in on the short side?
P.s sorry to be such a pain in the ass :)
GreatPig
16th-March-2006, 11:00 PM
how did you plot in on the short side?
If you're not using the portfolio file, there's another parameter to select either long or short.
GP
Milk Man
17th-March-2006, 03:59 AM
Great work dude! What I want to know is, how did I not see this in december :banghead:Im currently doing up a swing trading system for forex. I'll keep you posted how it works with that.
professor_frink
17th-March-2006, 06:51 AM
Thanks for all your help GP. Most appreciated.
stevo
17th-March-2006, 07:37 AM
I have been using the following code for years for ATR trailing stops. Drag and drop it onto any chart and adjust the parameters.
// ATR Trailing stop - stevo 2006
// When stop line drops exit is triggered.
multiplier = Param("ATR Multiplier", 2, 0, 10, 0.1);
myATR= multiplier*ATR(10); // calculate ATR
initial=C-myATR; // raw stop - not racheted
stop[ 0 ] = Close[ 0 ];
for( i = 1 ; i < BarCount; i++)
{
if( Close[ i ] > stop[ i - 1])
{
temp = Close[ i ] - myATR[ i ];
if( temp > stop[ i - 1 ] ) stop[ i ] = temp;
else stop[ i ] = stop[ i - 1 ];
}
else
stop[ i ] = initial[ i ];
}
If you're going to download it, get the latest version from message #5.
Cheers,
GP
wayneL
17th-March-2006, 12:30 PM
Stevo, GP,
Thanks for posting your codes for these stops. Anyone who has played around with either AFL or metamumbojumbo will surely be in awe, as I am. Very elegant.
Cheers
rubles
3rd-September-2006, 10:45 PM
Hi All
I'm kind of hoping someone has got a little time to help me out... before I throw my computer through the window :mad:
I have recently got Amibroker, and I'm wanting to put in the Guppy count back line - Great Pig, thanks for this post, it looks exactly like what I'm after, only I'm having a little (actually a large) challenge trying to get it onto amibroker as an indicator.
I have gone into the Charts/Custom area, and can open up the formulas Great Pig wrote, but thats where my capabilities have ended. When I try to use the formula, I just get a blank indicator section that says "ERROR:Formula File not Found or empty". When I go back into the Custom formula area, GP's formula has gone, even though I saved it.
I hope someone can help
Thanks
rubles
GreatPig
3rd-September-2006, 11:03 PM
Rubles,
What are you doing when you say "try to use the formula"? If you can see it in the Charts/Custom list, you should just be able to double-click it and it should then appear as a chart.
GP
rubles
3rd-September-2006, 11:22 PM
GP,
I went into the charts/custom list, then created a folder. Went to edit, went into the formula (at this stage blank) then opened up your formulas. Then, clicked on save, went out of the edit area. Tried to double click so it appeared as an indicator, then I get a blank indicator section that says "ERROR:Formula File not Found or empty". When I go back into the Custom formula area, click on the newly created file and then edit to have a look, the formula is no longer there.
thanks
rubles
GreatPig
4th-September-2006, 02:11 PM
Sorry, but I'm not familiar with adding AFL files that way.
All I do is use Windows Explorer to copy the file directly into the Formulas\Custom folder under where AmiBroker is installed. Can you try that?
GP
rubles
4th-September-2006, 02:56 PM
Thanks Great Pig, I appreciate your help.
It seems the way I was trying to do it is not the way it is done, evenutally I tried what you just mentioned and that worked - there are still errors, but I've been looking around just now on the 'net and it seems that perhaps the lines are "wrapped".
So, I'll fix that up tonight and see if the error goes away.
Thanks for your help
Cheers
rubles
GreatPig
27th-August-2007, 09:20 AM
Updated version of the stops DLL.
Cheers,
GP
PS: the attachment is a ZIP file that I've appended .XLS to so I can upload it. Could a moderator please change it back to a ZIP file by removing the .XLS extension.
R0n1n
1st-September-2007, 11:56 AM
GP,
got this error when I tried to Apply the Indicator.
The GP_Stops.dll is in the C:\Program Files\AmiBroker\Plugins folder.
I checked the file permissions but they are ok. Did I miss something ?
GreatPig
1st-September-2007, 01:34 PM
Sorry, the AFL files are set to read-only, something that my revision control system does. For some reason AmiBroker always gives that error when trying to load a read-only AFL file (don't ask me why it needs to write to the file).
Anyway, select all the AFL files and then go into the Properties dialog and uncheck the Read-Only checkbox.
Despite that error though, the indicator should still load and work.
Cheers,
GP
R0n1n
1st-September-2007, 04:08 PM
Sorry, the AFL files are set to read-only, something that my revision control system does. For some reason AmiBroker always gives that error when trying to load a read-only AFL file (don't ask me why it needs to write to the file).
Anyway, select all the AFL files and then go into the Properties dialog and uncheck the Read-Only checkbox.
Despite that error though, the indicator should still load and work.
Cheers,
GP
that fixed it. thanx. How would I go about plumbing this into an existing system so that I can use it for exit ?
GreatPig
1st-September-2007, 06:43 PM
Here's some sample code for a very simple system using a 30/60 day EMA crossover to buy and a 20 step countback line trailing stop (intended as a longer-term system). It does the following:
- Creates an auto-resetting trailing stop from the countback line data.
- Creates the buy array from the EMA crossover.
- Creates the sell array using the trailing stop.
- Removes redundant buy & sell signals.
- Masks the stop line data so it will only plot between buys & sells.
- Plots the results.
And if you want short versions, set the final function parameters to False instead of True.
For backtesting, add some position sizing, liquidity & other filters, etc. Just tried that myself using this simple system and did a few Monte Carlo runs. Results weren't too bad - better than the random system I played with.
Hope this helps.
Cheers,
GP
GreatPig
1st-September-2007, 07:25 PM
Some quick backtest results for this system using a 100-pass Monte Carlo run over (nearly) all current stocks. Other conditions were:
- Initial capital = $200K
- Position Size = fixed $20K, subject to volume limiting
- Volume < 10% of 100 day EMA
- Volume < 20% of buy day volume
- Unlimited open positions
- Minimum purchase = $5K
- Maximum purchase = $100K
- 100 day volume EMA times buy price >= $50K
- Buy on high, sell on low
- $30 commission
- Random position score
- 1/1/1997 to 31/12/2006
Max Profit: $2,278,361 (28.6% pa)
Min Profit: $211,096 (7.5% pa)
Average Profit: $1,132,707 (20.9% pa)
Median Profit: $855,123 (18.1% pa)
Profit StdDev: $610,485 (15% pa)
Average MaxDD: -28.9%
Median MaxDD: -27.6%
Results were somewhat better if changed to buy/sell on close (average profit 26.9% pa and median profit 27.8% pa). If nothing else, perhaps a good starting point as an introduction to developing a longer-term system.
Cheers,
GP
R0n1n
1st-September-2007, 07:35 PM
GP, what app did u use for Monte Carlo testing ?
GreatPig
1st-September-2007, 08:18 PM
Just AmiBroker using random position score and randomly rejecting a certain percentage of buy signals.
Cheers,
GP
Seaking
1st-September-2007, 09:03 PM
I can't seem to do anything with this file except opening it in Excel. Can anyone tell me how to access the dll file and AFL files.
R0n1n
1st-September-2007, 10:26 PM
I can't seem to do anything with this file except opening it in Excel. Can anyone tell me how to access the dll file and AFL files.
Seaking, rename the file to ZIP and it will work just fine.
Seaking
2nd-September-2007, 08:32 AM
Thanks R0n1n
I was trying to rename it after I downloaded, not before. All good now..
And thankyou GP for all the work you have posted here, awesome..
R0n1n
2nd-September-2007, 12:05 PM
Thanks R0n1n
I was trying to rename it after I downloaded, not before. All good now..
And thankyou GP for all the work you have posted here, awesome..
yeah than GP, he is the one whos done all the work....
sam007
26th-October-2007, 12:24 AM
Hello GP,
Thank you so much for your contributions on this forum.
I have been attempting to code up some systems in Amibroker, I think I'm OK at native AFL, but have not been game to tackle looping. I have now discovered that I need loops to do what I need to do for my system...
Your code sample in post 35 was a great help to illustrate how to incorporate your great DLL function into my own system. I have been toying around with it.
Basically I have a fairly simple system for long entries and short entries, the difference with it that I am finding a challenge is that it is a 'stop loss and reverse' type system.
Basically, I want to get it to exit at the countback line or ATR level that I define as my stoploss. But I ALSO want to place a reverse when it is stopped out. So, say I have opened a long trade, I want the system to exit at the stop (sell) and also place another sell (to open) trade.
So basically, my entries are both Short and long and are defined, but my exits and subsequent trades are defined by the stops.
I also want to define that this happens a limited number of times (but I'd be happy to get the first bit working for now...).
A bit tricky I've found...
I have attempted to arrange it so it is a long and short system as below, but then I am not sure where to turn...
Buy = My defined Buy signal;
Short = My defined Short Signal;
Could your stops be used in a stop loss and reverse system like this?
I would appreciate your help if you have a chance.
Thanks
Sam
GreatPig
26th-October-2007, 09:06 AM
Sam,
You can use the stops DLL to create a stop-and-reverse system using the stops as triggers, but it is a little more complicated if you want to do it properly.
The simplest, but least accurate, way would be to just create long and short auto-resetting stops and use those as the stop-loss lines for every trade. However, that line won't always match the stop-loss line you'd get if you started it properly on a particular entry date.
If you want to actually start the stop properly from each entry date, but use the stop-loss as the only exit signal, then it's more complicated and slower. The latest DLL version allows you to pass entry and exit arrays, but I haven't allowed for the stop itself to be the only exit (something I might have to consider adding, but it would be complicated in a SAR system where both long and short stops would need to be used consecutively).
I think I tried this myself some time ago and had to use a loop, where inside the loop I'd create a new stop-loss plot from each entry date to figure out the exit date. If there are a lot of bars and only short periods between reversals, so a lot of entry and exit signals, then the calculation can be quite slow due to the number of calls to the stop calculation function. Ultimately it might be quicker to do the whole thing just in a loop in AFL. The stop/loss function is fairly trivial in AFL, but the CBL one isn't so easy if that's the stop you're using.
With regard to looping, there's a document I wrote called "Looping in AmiBroker AFL.pdf". I think I posted it here somewhere, but also on the AmiBroker Yahoo forum in the files area there. If you can't find it, send me a PM with an email address and I'll email it to you.
Cheers,
GP
sam007
27th-October-2007, 11:36 AM
Thanks GP,
I will read up on looping and give it a go. I will post what I come up with once I have it.
I really appreciate your help and for taking the time to write a document on looping, and for your contributions here.
Thanks!
Sam
dman
1st-January-2008, 03:53 PM
Thanks GP for this code,
I'm just getting into trading and AmiBroker - just starting to realise that exits are MUCH harder then entries!
It's really useful to have the stop loss referencing your entry postion via the CSV files.
However I was wondering how to also plot just a horizontal line showing my buy price - do you have any pointers on how to do this?
Cheers,
dman
GreatPig
1st-January-2008, 11:55 PM
dman,
There's a function called "GP_GetBuyPrice" to obtain the purchase price of a stock in a portfolio. If you have multiple purchases, then it gives a weighted average price over all the purchases.
The sample AFL code already has that in there for proper stop-loss plots, in the form:
BuyPrice = GP_GetBuyPrice(sname, pfId);
Since BuyPrice is a pre-defined array, that will set the whole array to the purchase price of the stock (can't remember now if I used that name on purpose or not). So you should just be able to plot that array, eg:
Put that statement at the end of the block where the "BuyPrice = " statement is (ie. after the plot of dummy2).
Cheers,
GP
dman
2nd-January-2008, 10:17 AM
Thanks GP,
Just what I was wanting (except that I would prefer that the line was under the current price for more of my stocks :banghead:)
Cheers,
DMan
kp6
11th-January-2008, 12:16 PM
Great Pig,
I am new to share trading and new to Amibroker. Your AFL code and plugin have greatly helped me understand AFL. Thanks very much for sharing.
I have some programming experience (just a little) and have recently bought ms visual studio (when I found that AFL is not able to handle string arrays). I was wondering if you could also share your program code for your GP_Stops.dll so that I can learn how "traditional programming languages" interact with AFL. What language is GP_Stops written in ?
Thanks and Regards,
KP6
I've developed a plugin DLL for AmiBroker to generate trailing stop plots from any type of data. It calculates a proper trailing stop array from a specified buy date, where the buy date can either come from a portfolio-like file or be passed from the AFL code. With the sample AFL code provided, the latter is used when a date range has been set, making the beginning of the range the buy date.
The DLL also includes a Guppy Count Back Line function to allow that to be used for trailing stops (there's no Count Back entry function though).
The attached ZIP file includes the following files:
GP_Stops.dll - the plugin code
GP_ATRStop.afl - AFL code for an ATR trailing stop indicator
GP_CBStop.afl - AFL code for a Guppy Count Back trailing stop indicator
GP_EMAStop.afl - AFL code for a simple EMA trailing stop indicator
GP Stops DLL.pdf - an instruction sheet
Pfolio1.csv - a sample portfolio file
See the PDF file for instructions.
These files can be freely distributed and modified. The only thing I ask is that if you modify the AFL code and pass it on to someone else, make it clear that it's not my original code by changing the filename or adding a comment to that effect.
Let me know if you have any problems with it or any comments.
Cheers,
GP
GreatPig
11th-January-2008, 01:14 PM
kp6,
The DLL is written in C/C++ using MS Visual Studio 6. To develop plugins, you need to download the ADK (development kit) from the AmiBroker website. It used to be restricted to members only, but I see that was changed a while ago to be unrestricted, so I can now make this information available.
The complete project has a number of files, most of which haven't significantly changed from what comes in the ADK. The one file with all the function code in it is called "Functions.cpp", which I've attached here with a different name (and ending in ".txt" so that it's possible to attach it here).
I did a quick clean-up of the file to remove some old code and stuff, but haven't tried to pretty it up for presentation too much. Don't bet the farm on all the comments being exactly correct - like most programmers, I sometimes change code and forget to update comments accordingly. They should mostly be okay though.
For a beginner, the most difficult part will likely be all the file handling for the portfolio. That involves setting up a watch folder in Windows and running a separate thread, so requires some knowledge of Windows programming. It also uses linked lists, a common programming construct. The code for the functions called from AFL should be more straight-forward though.
As you are probably aware already, programming code is usually viewed with a non-proportional font (like Courier New). If you use a proportional one, some of the code mightn't line up properly, as I use spaces for indenting rather than hard tabs (except where my editor occasionlly whacks in a hard tab just to annoy me... :D).
Cheers,
GP
kp6
11th-January-2008, 10:09 PM
GP,
Thanks VERY much for your reply and the attachment. It will take me a while to understand the program and will, very much, be a very good learning exercise for me.
So, thanks again for your prompt reply, the clean-up and your various advice in your email.
Regards,
KP6
Tipene
14th-January-2008, 07:46 PM
GP
Thanks for your plugin, I've been using it purely for the Count Back Line function, and it has been great.
Just built a new PC with XP64 and 64 bit Amibroker. One problem, 32 bit dll does not go. When I found your recent post with the code I thought I would be right, but the ADK is 32 bit.
I'm out of my depth here, but what I think I need is a complier that will compile your code as a 64 bit dll, then I treat it just as I did with your original in the 32 bit version.
Is this a simple thing to do, or will it be like the 64 bit speech engines which just don't seem to be developed yet?
Thanks in advance.
GreatPig
14th-January-2008, 09:08 PM
Sorry, 64-bit machines and software are things I've had no experience with yet. I'm guessing the 32-bit plugin won't work with the 64-bit Amibroker, but I don't have a 64-bit machine or compiler, so have no idea what's involved in building a 64-bit plugin.
You could maybe try asking Amibroker support or on the Yahoo forum.
Cheers,
GP
Tipene
15th-January-2008, 05:00 AM
GP
Thanks for the prompt reply. Yes, they definitely don't work. 64 bit machine wont read 32 bit dll's, when installed as part of the main (64bit) application.
Not all is lost, as you can run 32 bit applications on 64 bit machines, which is what I am doing with Amibroker at present.
I suspect its a significant job, as the 64 bit Amibroker plugin to read Metastock data is still pending. If it was just a simple recompile I'm sure it would have been bundled with the application.
cheers
Tipene
wiitch
31st-January-2008, 12:55 PM
GP.
Very fine code that you are sharing with us.
I believe the ATR system is ultimate solution toward proper stop-loss setting.
alot thx indeed
cheers
wiitch:banghead:
dan82au
21st-November-2009, 02:46 AM
Thanks for contributing this snippet GP. I was glad I found this post without having to search through your entire post history (forum search function worked well for once!) Remember seeing a it a while back and never downloaded it because I was running fcharts. Finally purchased amibroker a few months ago.
edit - did they reset our post counts here on asf?
Wysiwyg
21st-November-2009, 02:53 AM
Thanks for contributing this snippet GP. I was glad I found this post without having to search through your entire post history (forum search function worked well for once!) Remember seeing a it a while back and never downloaded it because I was running fcharts. Finally purchased amibroker a few months ago.
edit - did they reset our post counts here on asf?
I am new to Ami. too and I don't know the AFL very well. With the trailing stops is it just a matter of pasting the code anywhere into a formula?
No post count reset. Have you posted before?
dan82au
21st-November-2009, 03:01 AM
I am new to Ami. too and I don't know the AFL very well. With the trailing stops is it just a matter of pasting the code anywhere into a formula?
No post count reset. Have you posted before?
Hey Wysiwyg, I haven't messed around with AFL to much but I do come from a programming background(more specifically object orientated languages like VB and java script). I've pretty much printed out the amibroker manual to get an idea of the functions and conditional statements tonight. I can send you a PM when I attempt running GP's stop plot code with instructions to implement it if you like.
Yeah I've posted before, even entered the competition a few times. That's one bonus I guess I can meet the daily post count again to enter it.
GP seems to have explained it fairly simply in the PDF file but let me know if you need hand with it.
Wysiwyg
21st-November-2009, 03:20 AM
Hey Wysiwyg, I haven't messed around with AFL to much but I do come from a programming background(more specifically object orientated languages like VB and java script). I've pretty much printed out the amibroker manual to get an idea of the functions and conditional statements tonight. I can send you a PM when I attempt running GP's stop plot code with instructions to implement it if you like.
Yeah I've posted before, even entered the competition a few times. That's one bonus I guess I can meet the daily post count again to enter it.
I tried backtesting trade formulas from the Ami. site but throwing darts would give better backtest results. :cool: I plan to grow into AFL formulas with Ami. so in no hurry.
Need not send the PM matey, thanks anyway. Strange how your post count has disappeared but your actual posts will still be on the site. Remember any threads ?
dan82au
21st-November-2009, 03:47 AM
I tried backtesting trade formulas from the Ami. site but throwing darts would give better backtest results. :cool: I plan to grow into AFL formulas with Ami. so in no hurry.
Need not send the PM matey, thanks anyway. Strange how your post count has disappeared but your actual posts will still be on the site. Remember any threads ?
I think I probably forgot my orginal username I guess though I tend to use the same for most forums I have joined(it would of had 82au on the end because I not that original and tend to use it a lot).
Haven't had a chance to mess with the stop plot yet but I imagine it will involve putting the dll file in the amibroker plugin folder and in the formula editor loading the .afl indicator from the zip file you want. Then applying the indicator. If you already have a few formulas I don't see any problems in pasting it in the same window as long as there isn't a function with an identical name. Setting the variables for the plot is a bit beyond me at the moment. I've really only started looking at backtesting so you are one step ahead of me.
Wysiwyg
21st-November-2009, 04:12 AM
To use these indicators, create new indicators with appropriate names and load the supplied code into them.
I don't understand. The ATR trailing stop plot is to close a trade (as in formula backtest) not an indicator. :confused:
Wysiwyg
21st-November-2009, 08:25 AM
I don't understand. The ATR trailing stop plot is to close a trade (as in formula backtest) not an indicator. :confused:Got it now. Just had to read the instruction. Plot on chart.:rolleyes:
Wysiwyg
21st-November-2009, 07:06 PM
Haven't had a chance to mess with the stop plot yet but I imagine it will involve putting the dll file in the amibroker plugin folder and in the formula editor loading the .afl indicator from the zip file you want. Then applying the indicator.
For riding a trend I would use the ATR trailing stop later as the trend matures or in other words not from trade open. Much prefer to use S/R levels initially to avoid missing a good chunk of the trend and/or choosing to re-enter.
As an alternative, setting the ATR multiplier to 5 will keep the trade alive longer and tightening up the multiplier to 2 as the trend matures, profit contentment reached or exchange action changes. All pending risk appetite of course.
ATR with 2.5 multiplier in this chart.
Superboot
12th-March-2010, 09:02 PM
Hi all,
New to Amibroker and trying to replicate GP's plugin results. I am close but hoping someone can save me a bit of time....
Not sure how to get the 'buy' arrow on the buy date. I think I have the sell sorted.
Cheers
Here is my indicator code...
stopArray = GP_CreateStop(Close - 2.5*ATR(15), Name(), 1, -1);
Buy = GP_GetBuyDate(Name(), 1);
Sell = Close < Ref(stopArray , -1);
Does anyone have GP's Short version of the trailing stop. I've got the original one working fine but also want one to use for short trades?
Thanks,
Matt
Wysiwyg
2nd-March-2011, 02:29 AM
Does anyone have GP's Short version of the trailing stop. I've got the original one working fine but also want one to use for short trades?
Thanks,
Matt
1 - right click on the chart that has the GP Plot (can drag plot onto chart).
2 - left click on"parameters" at the top of the window that opened.
3 - the "parameters" window opens and see at number 4. Short = 0, Long = 1?
4 - left click the space alongside 4. Short = 0, Long = 1? and a slider will appear.
5 - slide it to 0 for Short.
You're welcome and leave the money on the fridge. :D
pavilion103
9th-March-2011, 08:11 PM
1 - right click on the chart that has the GP Plot (can drag plot onto chart).
2 - left click on"parameters" at the top of the window that opened.
3 - the "parameters" window opens and see at number 4. Short = 0, Long = 1?
4 - left click the space alongside 4. Short = 0, Long = 1? and a slider will appear.
5 - slide it to 0 for Short.
You're welcome and leave the money on the fridge. :D
This is how mine looks! What do I do to make it go short?
41784
Wysiwyg
9th-March-2011, 08:55 PM
This is how mine looks! What do I do to make it go short?
41784
These are the seven parameters poster Great Pig had in his original code. You don't have #4 which is "isLong"
Ok that makes sense. I made the changes in the formula and it now shows up in parameters. I clicked on the graph again however and it is still only going long. It doesn't seem to matter whether I select 0 or 1. Any thoughts?
41786
excite
12th-January-2012, 12:47 PM
Hi all, I found this plugin very interesting and useful, but I can not get this plugin installed, I am using Amibroker 5.4 64bit, and copied the file "GP_Stops.dll" into the AmiBroker "Plugins" folder, but after I start Amibroker, this plugin is not loaded when looking at "Tools->Plug-ins". Is it the 64bit version casing the problem?
captain black
12th-January-2012, 01:13 PM
Is it the 64bit version casing the problem?
Yeh, 32 bit plugins wont work with 64 bit Amibroker.
http://www.amibroker.com/x64/
Limitations:
old 32 bit plugins do not work with 64 bit applications
Not sure if GP is still around but you may be able to recompile the plugin for 64 bit application if GP wants to release the source code.
colion
16th-January-2012, 06:19 AM
ATR stop fans might be interested in this code http://www.traders.com/documentation/FEEDbk_docs/2009/06/TradersTips (http://www.traders.com/documentation/FEEDbk_docs/2009/06/TradersTips.html)