This is the first EA I'm posting in the web. I've coded and backtested a few ideas in the past, but would be irresponsible by me to post those.
Metatrader4 has many useful tools and with the last update (build 482, march 8th), they develop a one-click trade tool which allows to open buy or sell positions with just one click (obviously) but without any stoploss or take profit levels assigned at the moment of triggering the order. Some brokers have developed their own tools in the past, but this new feature of mt4 seems to be standard at the moment. My script just do that, it analyzes if you have opened a market order and specifies a stoploss and/or take profit level if required.
The main difference between this tool and many other EAs is that with this one, no trades are open, rather it helps to manage the positions already established. The main function of my script is to establish a breakeven level when your position has advanced determinated amount of points in your way, in other words if your position goes in the pretended direction by X amount of points, the stoploss level will be updated to break even.
Every variable is self-explanatory. I added a CommissionPer100k if you are using a ECN or similar commission-based broker and want to be consider this amount in the breakeven level, or even if you want to lock any amount of points in your favor.
I added one more feature to this tool, if you like to, it will plot an arrow at the moment you open a new trade. This arrows are color coded (blue-buy, red-sell) so you can actually see where you entered the market. I had to make this because I really didn't like the lack of visual information mt4 brings regarding this, compared with other platforms. This might also be used as a tool for further analysis... if you review your trades over the weekend now you can scream at your screen '... what... why the hell did I enter there?'
H_BreakEvenSL (mirror)
Parameters
BreakEven: Amount of points in which the StopLoss will be modified to break even level.
CommissionPer100K: Value to be considered at the break even level.
StopLoss: Stop loss level from the entry level in points.
TakeProfit: Take profit level from the entry level in points.
PlotArrows: If you want the arrows to be plotted or not.
PlotBE_level: Plots a horizontal line at the break even level.
Script: delete_arrowsBE (mirror)
This script is a complement of the H_BreakEvenSL algorithm. It allows to easily delete ALL orphan arrows and BE_Line elements of the chart where used. To run the script, just drag and drop, or double click the script just like any other indicator. A prompt would ask if you are sure to execute it or not.
If the H_BreakEvenSL tool is running, and there are active positions running, it will redraw arrows and breakeven lines them.
If in doubt, always test these tools in a demo account.
This script should be copied in ../MQL4/Scripts/
+----------------------------------------------------------------------------------------------------+
History:
Posted: April 14th 2013
Updated: May 25th 2013
Update: March 12th 2014. Added script for deletion of orphan elements
Metatrader4 has many useful tools and with the last update (build 482, march 8th), they develop a one-click trade tool which allows to open buy or sell positions with just one click (obviously) but without any stoploss or take profit levels assigned at the moment of triggering the order. Some brokers have developed their own tools in the past, but this new feature of mt4 seems to be standard at the moment. My script just do that, it analyzes if you have opened a market order and specifies a stoploss and/or take profit level if required.
The main difference between this tool and many other EAs is that with this one, no trades are open, rather it helps to manage the positions already established. The main function of my script is to establish a breakeven level when your position has advanced determinated amount of points in your way, in other words if your position goes in the pretended direction by X amount of points, the stoploss level will be updated to break even.
Every variable is self-explanatory. I added a CommissionPer100k if you are using a ECN or similar commission-based broker and want to be consider this amount in the breakeven level, or even if you want to lock any amount of points in your favor.
I added one more feature to this tool, if you like to, it will plot an arrow at the moment you open a new trade. This arrows are color coded (blue-buy, red-sell) so you can actually see where you entered the market. I had to make this because I really didn't like the lack of visual information mt4 brings regarding this, compared with other platforms. This might also be used as a tool for further analysis... if you review your trades over the weekend now you can scream at your screen '... what... why the hell did I enter there?'
H_BreakEvenSL (mirror)
Parameters
BreakEven: Amount of points in which the StopLoss will be modified to break even level.
CommissionPer100K: Value to be considered at the break even level.
StopLoss: Stop loss level from the entry level in points.
TakeProfit: Take profit level from the entry level in points.
PlotArrows: If you want the arrows to be plotted or not.
PlotBE_level: Plots a horizontal line at the break even level.
Note: 10 points equals 1 pip
Script: delete_arrowsBE (mirror)
This script is a complement of the H_BreakEvenSL algorithm. It allows to easily delete ALL orphan arrows and BE_Line elements of the chart where used. To run the script, just drag and drop, or double click the script just like any other indicator. A prompt would ask if you are sure to execute it or not.
If the H_BreakEvenSL tool is running, and there are active positions running, it will redraw arrows and breakeven lines them.
If in doubt, always test these tools in a demo account.
This script should be copied in ../MQL4/Scripts/
+----------------------------------------------------------------------------------------------------+
History:
Posted: April 14th 2013
Updated: May 25th 2013
Update: March 12th 2014. Added script for deletion of orphan elements