Jump to content

(REQ Plz) Simple Take Profit EA based on Bollinger Bands


Recommended Posts

  • Replies 274
  • Created
  • Last Reply

Top Posters In This Topic

Hi Kenny. I have 2 minilots open on GU, the price went over +80 pips (24 pips away from the middle BB's) but the SL has only moved to b/e (It was set to move after +40). I'd like it to start trailing as well after 40 pips profit. Yesterday it seemed to be working ok.

http://i683.photobucket.com/albums/vv197/alright_01/GU_2010-09-15_0745.png

 

BTW, New Zealand is GMT +12 :) I'm located in Italy, 9am here now and nobody is in the chat...

Link to comment
Share on other sites

For some reason I thought yesterday I had a trade which started to trail before the middle BB. Was surely dreaming. It's probably worth anyway adding this option, because I witnessed a few good trades going even up to almost 100 without touching the middle BB and then retracing to negative territory. It's a shame to let all those pips go...
Link to comment
Share on other sites

New version 4 enhanced

 

Ok, guys, here is the latest version with some nifty scripting features.

 

http://www.multiupload.com/Y8CP41L9FN

http://www.multiupload.com/BBKIDR0GFR

http://www.multiupload.com/UO1KP68FCK

http://www.multiupload.com/3S152S3YIK

 

This time the package consists of 4 files. In the order of the links above we have :-

 

Bol_TP_v4_Enhanced.mq4.............this is the main EA. I assume you know where this goes.

Bol_TP_Include.mqh......................this file goes in your "\experts\include" folder.

Bol_TP_BUY.mq4 & Bol_TP_SELL.mq4.....these go in your "experts\scripts" folder.

 

The settings are as follows(new ones in bold) :-

 

Use_MagicNo.....if set to true, EA will generate its own unique 8 digit Magic Number for use with the script. If set to false, Magic Number will be 0 which is the same as a manual trade.

Personal_Magic....if for some reason the auto magic number is not unique enough for you, you can add from 0 to 100 to the generated magic number.

Set_SL.............enables/disables the automatic stoploss entry

SL_Buffer.........the buffer between previous bars high/low for stoploss. Set to -1 to use auto buffer determination.

SL_Bars...........number of previous bars to use for stoploss entry. Includes the current bar.

Use_Move_BE......Enable/disable move to break even;

BE_Pips.........Move SL to break even when the profit is BE_Pips. Leave at zero to use the auto BE_Pips which equals the SL_Buffer.

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

TP_Use_Timer...updates the TP2 at predetermined intervals rather than every tick. EA updates each new bar by default. This setting overides new bar and sets the TP more often.

TP_Update........number of seconds interval when changing TP2

Use_TP2_Close....use market order to close at TP2 instead of server side stop. This overides all other TP2 methods.

Show_TP_Line.....enables or disables the visual TP1 line

TP_Color.............ok, if you need help with this one, you are in the wrong place.

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

Use_Trail...............enables or disbles the trailing stop function

Trail_Percent.........this is the % of profit to trail by ie 50 pips profit = 25 pips trail.

Trail_Max..............stop will trail by the % you set eg 50% until the trail is equal to Trail_Max. Then the EA will trail at this fixed value. Set to -1 to use auto trail max which is the same as your SL_Buffer. Auto buffer is a function of ATR.

Use_Decay.............my little pride and joy. Ever watched the Price action hang within 1 pip of your TP and then reverse. With this option, the trailing stop is tightened as the Price approaches the TP2. The trail is equal to TP - Price, so if you are 5 pips short of TP, your trailing stop will equal 5 pips.

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

Use_Script..........this enables/disable the EA setting for the scripts. If set to false, you will get an error if you try and use the script. You must make a manual entry if this is set to false.

Risk..................this tells the script how much you want to risk. It is a % of your account balance. If you have it set to 1% and you have a $5000 account, the EA will calculate the trade size is limited to ensure that your loss at full stoploss = $50(1% of your account). So, the further you are from your stoploss at trade entry, the smaller the trade will be.

Fixed_Lots.........you can overide the risk setting and have the EA/script trade fixed lotsizes for you. In this case the EA will calculate and display your loss at full stoploss, as well as the risk level. Leave it at zero to use EA risk setting.....anything more than zero overides the risk setting.

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

Auto_SL_Ref.............this is a reference to adjust the Auto_SL_Buffer. If you feel that the buffer is too big or too small, use this parameter to adjust.

Mod_Threshold..........this is the EA's own internal stoplevel. Basically you don't want it sending orders to change things by 1 tenth of a pips, so I have set it here by default to only change any order if the modification will be more than half a pip. This can also be used as a jumping stop by entering a bigger number like 5 or 10 pips.

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

The rest of the settings are for the Bollinger bands. They should stay at default unless you have good reason to change them.

 

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

When you want to trade, simply drag a Bol_TP BUY or SELL script onto the chart. You can also set hotkeys if you wish.

 

I am sure there will be many issue, so as always please report your bugs here with as much detail as possible.

 

Enjoy!

Edited by kennyhubbard
Link to comment
Share on other sites

U been working day and night on this EA, kenny? LOL

Thank you very much. I appreciate your passion and will put it in use. As Benny pointed out, we need some more precaution in picking our trades. In strong trends this system could be very dangerous, so we need to refine our criteria to spot reversals.

 

Lol, yeah, I have been putting a bit of work in.....we up to almost 1000 lines of code. Its an interesting challenge........

 

The refining of your criteria is the reason why I haven't dived into a full blown EA. Once the criteria is more refined we can start looking for automated entries. Until then, at least you have the tools to make the trading easier.....all you have to do is find the entries and everything else is taken care of.

 

I also forgot to mention in my previous post, you cannot place this EA on a second chart of the same TF and Pair that you already have an instance running on. Not sure if anyone would ever do it but I suppose if a guy wanted to try this on one chart and still make manual trades using the EA to exit on another chart of same pair/TF.........anyway, the EA just removes itself from the new chart if you try to do this.

 

Well, next week we can start working on the dashboard......that should be interesting.

Link to comment
Share on other sites

Have been following this thread from the start. Nothing much to contribute yet, but am impressed with the idea behind the "decay" idea. Will follow with interest and contribute if I have something worthwhile. Exits are always harder to get right that entries, so by getting this right from the start, I think the EA has good potential. Great work.
Link to comment
Share on other sites

Hi Benny,

 

Any progress with those issues discussed yesterday? I am unable to duplicate the issue on my system. I also tried the system on FXDD platform(MM) and it worked fine.......

 

I have also resolved the issue of what happens when the centre line crosses the order open price. The user will now have the option to select whether the EA still does a partial close(like a partial stoploss if you want), or whether the trade is just left alone. I have also included de-initialisation warnings, so if you change the timeframe, or close the chart with a trade running that the EA owns, it will warn you.

 

I will probably only post the update over the weekend after further testing.

Link to comment
Share on other sites

Hi kenny can you plz move the writting to the right side underneath the expert and just have the stoploss in pips showing away from the open position and also how many pips it is from open to the center BB and also outer BB thanks. For example if i put in a sell position,then the expert automaticaly puts in my stoploss 20 pips above the high can I have showing how many pips it is from the stoploss to my open position, and also how many pips it is from the center and outer thanks

 

http://i51.tinypic.com/28wl2iv.jpg

Edited by benny3
Link to comment
Share on other sites

Thank you for your kind words, Dave.

 

Benny, it turns out that your request for Pips to SL & TP is not quite as easy as that. You probably only make one trade at a time, but in order to be thorough, I cannot assume that all traders make only one trade.

 

Not to worry, I have found a work around......if you make a second trade on the same chart, the EA will compute a weighted cost average of all entries and display that figure as your entry price. It will also be able to use this entry in the move to break even function. So when you have, say 20 cost averaged pips in profit, it will work out the SL so that the sum of all trades is zero at break even.

 

I am still pondering how to deal with hedge trades but for now I will probably just tell the EA not to show anything in a hedge situation, until I can figure out how to work them into the calculation.

Edited by kennyhubbard
Link to comment
Share on other sites

Thank you for your kind words, Dave.

 

Benny, it turns out that your request for Pips to SL & TP is not quite as easy as that. You probably only make one trade at a time, but in order to be thorough, I cannot assume that all traders make only one trade.

 

Not to worry, I have found a work around......if you make a second trade on the same chart, the EA will compute a weighted cost average of all entries and display that figure as your entry price. It will also be able to use this entry in the move to break even function. So when you have, say 20 cost averaged pips in profit, it will work out the SL so that the sum of all trades is zero at break even.

 

I am still pondering how to deal with hedge trades but for now I will probably just tell the EA not to show anything in a hedge situation, until I can figure out how to work them into the calculation.

 

thanks Kenny but i'm making about 3 trades at the same time, depends what the setups look like.

Link to comment
Share on other sites

Latest Update + Dashboard

 

Hi guys,

 

Herewith the latest......

 

http://www.multiupload.com/0928INKJZG

http://www.multiupload.com/92FIR913TO

http://www.multiupload.com/T0Z1I9BEZG

http://www.multiupload.com/CPLNZR8C0O

http://www.multiupload.com/6AQ21Z5Y5L

 

The files are in the same order as the previous posting with the script. Please replace all files. There is an extra file "Bol_TP_Dashboard" which is an indicator......goes in your \experts\indicators folder. More about this later....

 

New settings over and above those mentioned previously :-

 

Use_WCA_MBE...........in the event of multiple trades on the same pair/TF, the EA can calculate the weighted cost average of your entry. Using the WCA_MBE(weighted cost entry move to break-even), the EA uses the same SL for all trades, calculated so that the sum of the profit/loss amounts to zero ie break even, rather than letting each trade reach its own independant BE point(still an option if you prefer to use that).

 

Offside_Close............you may recall we discussed the issue of what happens when a trade is negative and the middle MA line crosses your entry price? Well now you can elect to have the EA ignore the middle band if this presents itself, or you can still have it close half the trade(my own preference) in a sort of partial stoploss. If set to true, the half the trade will close.

 

Deinit_Alert..............I tend to do stupid things sometimes. Setting this to true will pop up a warning if you change the chart(pair or TF) that is currently managing a trade. It just warns you that there is a trade in progress.

 

Show_Comment.......if you want to hide the info in the top right corner, you can disable the display with this setting.

 

There are still some issue needing attention, like the cost averaging function. If you have multiple trades, you may have a different stoploss and the EA does not cost average those, it simply takes the stoploss of the newest trade and bases its info on that. We can fix this later down the line.

 

Now, the dashboard. You are looking at version 1.....and this will be patently obvious from the display. Remember this is work in progress, so don't laugh. I have simply used numbers for now, and I am looking for ideas on how to color code the system.

 

What the dashboard does for you, is allows you to monitor the price action across max 14 currency pairs and all timeframes except M1 which I felt was useless. I simply limited the pairs to 14 to conserve resouceses. IF and this is a big IF, there is some-one crazy enough to wanna trade more than 14 pairs, I will consider increasing, but for now 14 is the limit.

 

Now pay carefull attention because this is gonna get complicated............in order to define the currency pairs, I have created a special procedure. First run the indicator on a blank chart......it should immediately give you an alert with some instructions, the gist of which follows here.

 

The alert tells you that the EA has successfully managed to write all the currencies in the marketwatch window to a csv file, which is located in the expert\files folder and will be named XYZ_Broker_My_Dashboard......in case it is not clear, you replace XYZ_Broker with whatever your broker's name is.

 

Open this csv file in excel and delete all the currencies that you do not wish to trade. Be sure to delete the entire row, so that the file consists of 14(or less) currency pair each right below one another. There must be no open rows.....the indicator will read these and try and display them, with the cosequent errors.

 

Once you have the limited currency set, save the file with its old name and so forth.

 

Now you can re-initialise the indicator(delete it from the chart and reload it). You can select the time frames you wish to display. The text is in blue by default simply because my chart background is white. Select a color that suits you.

 

The display at the moment is very basic, as is the information presented. I have used a simple numbering system to illustrate the data. The numbers are as follows :-

 

5..........The high of the current bar has pierced the upper BB

1..........The price action is within the 14 day ATR number of pips from the upper band. Effectively means that price action is able to achieve the BB within 1 chart period.

0..........Price action not of any interest....it too far from the bands.

-1.........same as 1 except the PA is within reach of the lower band.

-5.........Same 5 except PA has pierced the lower band.

-10........There is no data for the selected Pair/TF. The easiest here is to open the chart of the missing data seperately and then drag left to 'look' at the history, this will download the data you need. Do this on each timeframe and you should see the '-10' changing as the data is accessed.

10..........This means that the data is available but there is not enough bars in the chart. You need 20 bars to be able to calculate a 20 period average = almost 2 years on MN1, so it only really happens on the monthly chart.

 

There as some settings for fast and slow moving averages, but they are theer for future functionality. It does nothing yet.

 

Anyway, that is my bit. I look forward to ideas on how to improve the function as well as the information presentation of the dashboard.

 

Enjoy.

Link to comment
Share on other sites

This is one reason I love this system. Have a look at the trade below :-

 

http://img830.imageshack.us/img830/2866/tradev.jpg

 

This trade is a long that I took on the GBPJPY. I don't recall why I took it, probably just testing. My point is that the price action went nowhere after the trade was made. I have this theory in FX that a trade should not last more than 12 bars. To understand this, look at an extreme version.......if you make a trade on the 5 minute chart, do you really still want to be in that trade after 2 weeks. I believe that after x number of bars(you may prefer 20 or 100, it doesn't matter as long as you are aware of it), the factors that promoted that trade have been forgotten by the market. This is the problem with old school TP & SL.....it ignores price action after entry.....and price action is 'all-knowing'.

 

Looking at the trade above it was a bad trade but the EA took care of it exiting after 13 bars or just over 6 hours later for a slight loss, followed by the second exit again about 10 bars further on. Looking at the trade now, it is in the middle of the band and could go either way......to be quite honest I would rather not be in the trade........you could argue that it may move in my favour and that closure was unnessesary, but that would be tantamount to trading on luck.

Edited by kennyhubbard
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...