Trend Lines Breakout System

Status

You can learn a lot from this code but, I'm not currently trading with this EA nor using the strategy.

Strategy Tester Report

At the following links you will find two Strategy Testing Reports for the GBP/USD pair for the period January 2008 to January 2011. The first one is using 2% Risk and the other is using 5% Risk.

Trend Lines Breakout System Low Risk (2% Risk)

Trend Lines Breakout System High Risk (5% Risk)

Strategy Theory

Please find detailed information about this trading strategy at the following link: Trend Lines Brakout System

Quick guide

inpBrokerTimeZone

Is the Broker Time Zone difference from GMT. You should ask your Broker the Time Zone they use in their MT4 Servers. If they use GMT Time Zone this parameter should be 0, otherwise use the specified differences. For GMT+10, inpBrokerTimeZone = 10; for GMT-4, inpBrokerTimeZone = -4, etc.

inpETDaylightSavingTime

Set this parameter to true on Eastern Daylight Time(EDT) from the second Sunday in March to the first Sunday in November.

Set this parameter to false on Eastern Standard Time(EST) from the first Sunday in November to the second Sunday in March.

inpRisk

This is the percentage of the account balance to risk in every trade. For example, if this parameter is 2, then the EA will risk 2% of the account on every trade, this means that the EA calculates a different Lot size for every trade based on the Stop Loss that will be used for that trade, no matter how far or close the Stop Loss is, the EA will calculate the Lot size so that if the Stop Loss is hit, 2% of the account will be lost.

inpRiskMinLotSize

Minimum Lot Size to use when the EA calculates the lot size based on inpRisk parameter. If the calculated value for Lot Size is smaller than the value of inpRiskMinLotSize, then the value of inpRiskMinLotSize will be used for the trade.

inpRiskMaxLotSize

Maximum Lot Size to use when the EA calculates the lot size based on inpRisk parameter. If the calculated value for Lot Size is bigger than the value of inpRiskMaxLotSize, then the value of inpRiskMaxLotSize will be used for the trade.

If inpRiskMaxLotSize is 0, then the EA will not set a limit for Lot Size.

inpFixedLotSize

This parameter is ignored unless inpRisk is 0. If inpRisk is 0 then the value of inpFixedLotSize will be used for every trade.

inpPivotsStartHour

This is the Eastern Time Hour when Daily Pivot Points will be calculated. This EA has its own internal Pivot Points. These Daily Pivot Points will be calculated using 24 hours starting from the Hour indicated in inpPivotsStartHour. For example if inpPivotsStartHour is 0, then the previous 24 hours (0 to 23 ) will be used to calculate the Daily Pivot Points, if inpPivotsStartHour is 5, then the previous 24 hours (5 to 4) will be used to calculate the Daily Pivot Points.

inpMinPivotOpenDist

The rules of the strategy says that “We would also choose the second Pivot point level of support/resistance as our profit goal if the first Pivot level appears to be too close to our entry point.”

Use inpMinPivotOpenDist in pips to define the “too close” distance. If the distance between OpenPrice and the closest Pivot level is smaller than inpMinPivotOpenDist, then the next Pivot level will be used as our profit target.

inpPipsToBrakePivot

If during the first hour, the price break through the first pivot level, the EA will move the Stop Loss level to Break Even. The EA will do this if the price passes the pivot level by the value of inpPipsToBrakePivot in pips.

inpPivotTouchOffset

Distance in pips to a Pivot point to consider it as touched. This EA only sets the profit targets using Pivot point support/resistance levels. If inpPivotTouchOffset set to 0, the price should actually touch the pivot point level to hit the target.

inpPipsSLOffset

The rules of the strategy says that “A protective stop is placed just above/bellow the candle that broke through the trend line.” The EA will set a protective stop in the other trend line, if the other trend line does not exist the EA will set the protective stop at the High/Low of the entry bar +/- inpPipsSLOffset.

inpMaxSameDaySameSideTrades

If inpMaxSameDaySameSideTrades is 1, then only one buy and one sell per day will be triggered, even if the protective stop is hit and the price retest the trend lines. If you want to reenter on a trend line retest after a failed trade, then increase the value of inpMaxSameDaySameSideTrades.

inpMaxTradeTime

Sets the Hour when the trend lines will be deleted. This means that no more trades will be triggered after this hour.

inpSlipPagePoints

Set the Slip Page for every trade. The value is in points, not in pips. This means that if the broker uses 5 decimal prices, 30 points is the equivalent of 3 pips.

inpSMAFilter

This is an addition to the original rules. The value of inpSMAFilter will be used to calculate a SMA and that SMA will be used to filter Long or Short trades. By default SMA 150 is used. If the price if above SMA 150, only LONG trades will be triggered, if the price is below SMA 150, only SHORT trades will be triggered.

If inpSMAFilter is 0, then no filter will be used.

Disclaimer

This EA was tested with historical data and has proven to be profitable using the GBP/USD pair. Nevertheless, past performance does not guaranty future performance. In no event I will be liable for any damages whatsoever. Use at your own risk.

MetaTrader 4 Expert Advisor

Download the .mq4 file form the attachments section below and place it in your MetaTrader experts folder, usually C:\Program Files\MetaTrader\experts

Compile the EA using MetaEditor or just restart MetaTrader for automatic compilation.