Sei sulla pagina 1di 9

Strategy Name: Alhamdullila V2 Strategy H1

Trading Rules to Create Alhamdullia EA

Project Description

To Create an Expert Advisor in Met trader MQ4 language, which takes automatic Forex trade
signals using the specific entry criteria and specific conditions indicator values. The expert Advisor
also manages (Moves the stop Loss, takes profit and exits the trade using specific predefined
instruction.

Attach with this document:

With this trade Strategy I will also attached

1. Code for Slope directional Line Indicator EA (SDL) called Alhamdullila SDL with
Alert.mq4 (from here onwards called SDL)

2. Code called ManageTPv2-4.mq4, which I would like you to add to the final
Alhamdullia EA with Trailing Stop loss (Fully working multiple profit level EA).

3. Code for Customer MACD indicator- called Alhamdullila V2 Macd 2 colour Histogram-
(from here onwards called MACD Histogram)

4. Explanation of how the ManageTPv2-4.mq4 works

5. Some picture of the Alhamdullia trade strategy entries and exits.

6. Flow Chart to assist in creating this EA

Indicators used this strategy:

1. Alhamdullila SDL with Alert.mq4


Settings: (period=40, Method= 3, Price = 0)

2. ADX (21) Average directional movement

3. ATR (6) - Average true range indicator (9)

4. Special MACD indicator called Alhamdullila V2 macd 2 colour Histogram


Settings (FastEMA=5, slowEMA=35, signalSMA=5)
How the Alhamdullila V2 strategy works:
The actual final EA is very simple as follows (also see the flow chart below):
Long Entry
Enter a LONG position when all following conditions are met:

Entry Condition 1- New Trend Entry:


1. After the close of the candle;
2. SDL changes to color blue (compared to the last candle)
3. ADX (21) >20.
Enter Long position!

Entry Condition 2.a Delayed Trend Entry


(*See explanation on page 4 and the Flow chart on page 5)
1. After the close of the candle;
2. When ADX (21) > 20 (Trending market);
3. ATR test: for 4 digit pair ATR (6) > 0.21 and for 5 digit pair ATR (6) > 0.0021
4. Macd Histogram > 0 (positive)
5. And SDL indicators color = blue
Enter Long position!

Entry Condition 2.b Pull-back Entry (this is done by pull-back flag see flow chart)
(*See explanation on page 4 and the Flow chart on page 5)
1. On a continuously trending Market (SDL remains Blue), wait for MACD to go below zero,
then rise back again above zero, then if
2. After the close of the candle;
3. ADX (21) > 20
4. ATR test: for 4 digit pair ATR (6) > 0.21 and for 5 digit pair ATR (6) > 0.0021
5. Macd Histogram > 0 (positive)
6. And SDL indicators color = blue
Enter Long position

Short Entry
Enter a short position when all following conditions are met:

Entry Condition 1- New Trend Entry:


1. After the close of the candle;
2. SDL changes to color Red (compared to the last candle)
3. ADX (21) >20.
Enter Short position!

Entry Condition 2.a Delayed Trend Entry


1. After the close of the candle;
2. When ADX (21) > 20
3. ATR test: for 4 digit pair ATR (6) > 0.21 and for 5 digit pair ATR (6) > 0.0021
4. Macd Histogram < 0 (negative)
5. And SDL indicators color = RED
Enter Short position!

Entry Condition 2.b Pull-back Entry (this is done by pull-back flag see flow chart)
1. On a continuously trending Market (SDL remains RED), waited for MACD to go above zero,
then fall back again below zero, then if
2. After the close of the candle;
3. When ADX (21) > 20 (Trending market);
4. ATR test: for 4 digit pair ATR (6) > 0.21 and for 5 digit pair ATR (6) > 0.0021
5. Macd Histogram < 0 (negative)
6. And SDL indicators color =RED
Enter Short position!
Stop loss and Exit
Exit trade with which ever of the following is met (this is all done by the manageTpV2-4
code:
1. Stop-Loss reached -(make this user variable- can be adjusted my user).
2. Profit targets reached -(make this user variable- can be adjusted my user).

Profit Targets
To manage the trade use similar code/criteria as in ManageTPv2-4. (Supplied) and add the trailing
stop to the last "lot". That its once the stop is moved to its 2nd stage "Second_Stop" the stop will
trail by a predefined value.
Add this management EA (managetp2.4) to the final EA.
Use your part of the EA to enter and to code add my managetp2.4 to manage the trade.

Currently Im entering manually and using the EA managetpv2.4 to manage my trade with great
success. All I do is enter the trade, with 0.3 lot size, and it divides it into 3 lots of 0.1 and takes
profit at various set levels. User parameter is used to set exit lot size of 0.1 and various profit
level... see the description... its very easy to follow.

Example, I want to enter with 0.3 lots to start off. As trading account increase in future, I want
to increase my lot size and have various multiple profit level . I want to be able to exit at various
levels. I can do this at the moment using EA managetpv2.4.

The code for EA for the multiple profits taking is enclosed. Its called ManageTPv2-4. Please used
this code and add it to the Alhamdullia EA. Also enclosed is the explanation as to how the
ManageTPv2-4
The multiple level of the profit taking is user-defined parameters.
Generally the users will enter it as such:

a. Profit Target 1 at 25 pips- Move stop to 2


b. Profit Target 2 at 50 pips, move stop to +20pip
c. Profit Target 3 at 75 (turn on Trailing Stop of 25pips)
d. Profit Target 4 at 100 etc

As mentioned above the only thing to add to the trade management is Trailing stop feature,
which can be turned on after the stop is moved for the second the time (Second_stop).
These are very important points to consider

1. The EA should have a feature where we are be able to turn the Condition 2 Entry trade OFF
(both a and b OFF). When this is done only Condition 1 type Entry is permitted to be traded.
Condition 1 New-Trend-Entry type entry is high probability trend trade and in difficult
volatile market it can be a wise idea to turn Condition 2 (a and b) OFF.

2. For Condition 2.a Delayed-Trade-Entry, by testing ADX first, we will be able to enter into
a trade when the ADX rises from below level 20, even if this happens after SDL and MACD
indicators confirms. (*See Fig 2 below and flow chart.

3. For condition 2.b Pull-back-Entry, the EA checks for MACD histogram to cross zero line.
This is so that once we get out of a trade and the SDL color remains the same; we dont get back
into a new trade unless the MACD Histogram crosses zero line. This prevents the EA from taking
continuous trades after exiting it, until MACD HISTO cross has zero line. This also allows us to enter
back in a trending market, after pullbacks. This can be tested by turning a pull_back_flag
within the code. (*see the Flow chart on page 5 for better explanation)

4. By testing ATR (6) (ATR test: for 4 digit pair ATR (6) > 0.21 and for 5 digit pair ATR (6) >
0.0021) we check that the market is trending well and this prevent trading when there is
any obvious support and resistance in the market

5. Only one trade permitted per chart.

6. Pair = Any

7. Timeframe = Any- Recommended Time frame = 1Hour

8. Position will be executed only when the above criteria is met after the close of the candle.

9. If Internet connection broken, this EA has ability to continue it's function or at least and if
the Internet disconnects, trade will base on the set Stop-loss & Profit-target only. When
Internet connection comes back, it will continue the EA monitoring automatic as long as the
EA attached is ON.

10. The EA should be able to auto detect of 4 digit or 5 digit broker. Note for the 4 digit pair
the ATR value test is such: ATR (6) > 0.21 and for 5 digit pair ATR (6) > 0.0021

11. Add management code similar to manageTP2-4V EA and add a trailing stop feature to the last lot, i.e.
after the Second_Stop is executed. The Second stop function moves the stop to a second chosen level,
when the trade move in profit. Please add a Trailing stop so that after the Second_stop is moved the
Stop-loss will trail the price by user defined external variable.

12. Included in the project:


The programmer is also required to create an indicator based on the following criteria:
For Long Alert For Short Alert
1. MACD cross zero and 1. MACD cross zero and
2. ADX level >20 and 2. ADX level >20 and
3. ATR (9) > ATR (21) 3. ATR (9) > ATR (21)
4. MACD >0 4. MACD <0
5. SDL= Blue 5. SDL= RED

Supplied is an indicator based of "MACD Cross with email Alert Arif.mq4, SDL indicator
called Alhamdullila SDL with Alert.mq4 and ADX level Indicator called
ADX_Level_Crossing_Alert.mq4.

The EA is need by 30 Dec 2009. Once completed, the Expert Advisor will be tested and the
programmer is expected to fix any bugs in the software and make minor modifications within
reasonable time and specification.
Expected Price: $100 USA (via pay-pal is recommended)
Flow Chart for Alhamdullila Strategy

Start Initialize etc-

Turn the Pull_Back_Flag = OFF

No Wait for the


candle to close. Is
candle closed?

Entry Condition 2a
Yes
No
Is ADX>20?
Entering an Exsiting Trend,
Entry due to delayed confirmation
Condition 1 from ADX>20 or after a pull-
Yes

back confirmed as MACD


Start of a Did the SDL
new TREND change color since
the last candle?
Yes No
No

Turn the Pull_Back_Flag = OFF ATR test: for 4 digit pair ATR (6) > 0.21 and
for 5 digit pair ATR (6) > 0.0021

Entry Condition 2b
Yes
Is SDL Blue or Red
Is the Pull back Re-entry,
Pull_Back_Flag = ON? once MACD cross 0
ON
Blue Red OFF
Turn the Pull_Back_Flag = OFF

Take a Take a
Long Position Short Position No
Is MACD > 0 or Has MACD cross
Is MACD < 0 ? Zero?
Macd >0
Macd < 0

Is SDL Blue Is SDL RED Yes

Turn the
Yes No Yes Pull_Back_Flag =ON
No
Take a
Long Position

Run Trade management


routine- manageTPv2-4 Take a
Short
Position
Trade Exited- Profit or
Stopped
Explanation of the Alhamdullila Strategy EA

1. The EA starts

2. It waits for the current candle to complete

3. Turns the Pull back flag on.

4. Next the EA will test if ADX is more than 20

5. Then checks if the SDL color has changed since the last candle.

a. If it has, it will take a trade depending on its color. This is condition 1


Entry

b. If SD color has not been changed since last candle the ATR and Tests if
the Pull_Back_Flag is On

i. If the Pull_Back_Flag is on EA enters in condition 2a mode. Next it


tests the MACD and SDL and takes a trade depanding on the SDL
color
ii. If the Pull_Back_Flag is Off (this is condition2b) the EA waits until
MACD histogram crosses the zero line, it then turns the
Pull_Back_Flag On and proceed with the test in condition 2a

6. Once in a long or short position the EA runs the trade management and exits when the Stop-
loss or trailing Stop-loss or the profit target is reached. Once exited the EA will start looking
for a new set-up at the close of the next candle.
Pictures to Illustrate Alhamdullila Strategy:
Fig1 Condition 1

FIG2 condition 2a and 2b


*Note2. By testing ADX first, we will be able to enter into a trade when the ADX raise
from below level 20, even if this happens after SDL and MACD confirms. And using
Pull_back_flag we enter when MACD crosses zero line.
Notes on ManageTPv2-4 ( multiple profit taking)

I will attach the ManageTPv2-4.mq4 file, which you can use to add to the Final
Alhamdullia EA to create multiple profit takings.
Here how the ManageTPv2-4.mq4 works.

The expert works by taking profit out of a trade at various take profit levels. It also
moves stop losses at designated levels. You have the ability to customize the following
parameters:

First_Target: This is the first take profit target, in pips, that you specify.
Target_Increment: Once the first profit target is reached, the next target will
increment by the amount specified by the target increment variable.
Close_Lots: This is how many lots you want to take out at each target. For
example, if you have 10 lots, you can take 1 lot out at each of 10 profit targets,
or 5 lots out at each of two targets. It's up to you.
Move_Stops: Set to true if you want the expert to move stops based on the
First_Stop and Stop_Differential parameters. Otherwise, set to false if you don't
want stops moved automatically.
First_Stop_Target: This is the amount in pips the trade moves before your stop
loss is moved to the First_Stop level.
First_Stop: This will move your stop loss when a target, in pips, is reached. The
number represents the number of pips from entry and can be postive or
negative.
Second_Stop_Target: This is the amount in pips the trade moves before your
stop loss is moved to the Second_Stop level.
Second_Stop: This will move your stop loss when a target, in pips, is reached.
The number represents the number of pips from entry and can be postive or
negative.
Use_Max_Loss: Set to true if you want to input your own stoploss and hide your
stop value from your broker. This is the maximum loss you'll risk on the trade.
It's irrelevant if Move_Stops is set to true AND Move_Stops was triggered.
Max_Loss: This is the maximum pip loss you'll accept on the trade. If set to 0,
this function is disabled.
Magic_Number: You can use this to ensure the expert only manages trades with
a particular magic number. This will allow you to trade the same pair using
different systems without this expert interfering with the take profit points of the
other trade(s).

The image below represents example parameters that can be set for the expert. I'll
explain each one with a scenario. Assume you place a 1 lot sell order for EURUSD at
1.2100 (1.2103/1.2100 - ask/bid). (Assume a 3 pip spread.)

The expert will take .1 lots ("Close_Lots"), or 1/10th of this scenario's order, out
at +10 pips ("First_Target"), or 1.2090/1.2087.
After that, the next profit target will increment 8 pips ("Target_Increment") to
1.2082/1.2079. and another .1 lots will be taken out at that level. The expert
continues to increment the preceding profit target by 8 pips until the original
order is closed. In this example, the maximum pips gained would be 10 + (8*9),
or 82 pips. (First target pips + increment pips * number of times to increment,
which would vary depending on the original order size and the "Close_Lots"
parameter.)
When the trade reaches +15 pips ("First_Stop_Target"), the stop loss will be
moved to -5 pips ("First_Stop") from the order entry price. In this case, the order
entry price was 1.2100, so the new price would be 1.2105. This means that you
would lose 5 pips if the trade turned. Set the "Stop_Differential" parameter to "0"
in order to move stops to breakeven (1.2100). If this parameter were, for
example, set to 5, then the stop loss would be moved to 1.2095, and you would
have a 5 pip increase if the move turned against you and stopped you out.
When the trade reaches +30 pips (Second_Stop_Target), the SL is moved to
Entry Price + 10 pips.
If you don't want the expert to move the order's stop loss, then set the
"Move_Stops" parameter to "false". I think this works, but haven't fully tested it.

SDL - (slope directional line) settings:

-------------------------END-------------------------

Potrebbero piacerti anche