![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Name := 2EMA system-v03
Author := Copyright © 2003, Smoky
Link := http://www.company.com/
Notes := 2 ema I use 5 minute on EUR
Update on every tick := Yes
Positions := Long & Short
Enable Alerts := Yes
Disable alert once hit := No
Lots := 1
Stop Loss := 50
Take Profit := 360
Trailing Stop := 15
]]*/
Defines: Slip(5),
lp(300),
risk(40),
sp(30),
mm(-1),
munth(9);
vars: direction(0),
orders(0),
first(0),
mode(0),
cnt(0),
Ilo(0),
sym(0),
b(0);
Comment(\"Account: \",AccNum,\" - \",AccName,
\"\\n\",\" StopLoss \", b,
\"\\n\",\" Lots \",Ilo);
//if month < munth then exit;
If Bars If IsIndirect(Symbol)=TRUE then Exit;
If CurTime - LastTradeTime < 1800 Then Exit;
b=5*Point+iATR(4,1)*5.5;
/**********************************Money and Risk Management***************************************
Changing the value of mm will give you several money management options
mm = 0 : Single 1 lot orders.
mm = -1 : Fractional lots/ balance X the risk factor.(use for Mini accts)
mm = 1 : Full lots/ balance X the risk factor up to 100 lot orders.(use for Regular accounts)
***************************************************************************************************
RISK FACTOR:
risk can be anything from 1 up.
Factor of 5 adds a lot for every $20,000.00 added to the balance.
Factor of 10 adds a lot with every $10.000.00 added to the balance.
The higher the risk, the easier it is to blow your margin..
**************************************************************************************************/
if mm < 0 then {
Ilo = ceil(Balance*Risk/10000)/10;
If Ilo > 100 then {
Ilo = 100;
}
} else {
Ilo = lots;
};
if mm > 0 then
{
Ilo = ceil(Balance*Risk/10000)/10;
If Ilo > 1 then
{
Ilo = ceil(Ilo);
}
if Ilo < 1 then
{
Ilo = 1;
}
If Ilo > 100 then
{
Ilo = 100;
}
};
//------------------------------------------------------------------------------------------------
If TotalTrades<1 then
{
if
(iMA(lp,MODE_SMA,3) iMA(lp,MODE_SMA,0)>iMA(sp,MODE_EMA,0)*0.998) &
iSAR(0.02,0.2,6) O
then
{
SetOrder(
OP_SELL,
ILO,
Bid,
Slip,
Bid+Stoploss*Point,
Bid-TakeProfit*Point,
Red);
Exit;
};
if
(iMA(lp,MODE_SMA,3)>iMA(sp,MODE_EMA,3)*1.002 &
iMA(lp,MODE_SMA,0) iSAR(0.02,0.2,6)>O[6] & iSAR(0.02,0.2,0) then
{
SetOrder(
OP_BUY,
ILO,
Ask,
Slip,
Ask-Stoploss*Point,
Ask+TakeProfit*Point,
White);
Exit;
};
};
//----------------------------------------Order Control-------------------------------------------
orders=0;
sym=0;
For cnt=1 to TotalTrades
begin
If Ord(cnt,Val_Symbol)=Symbol then
{
sym=cnt;
orders=1;
};
mode=Ord(sym,VAL_TYPE);
If mode=OP_BUY &
Ord(sym,VAL_SYMBOL)=Symbol then
{
If Ord(sym,Val_OPENPRICE)>Ord(sym,VAL_STOPLOSS) &
Bid-Ord(sym,Val_OPENPRICE)>(Ord(sym,Val_OPENPRICE)*0.004) &
iMA(lp,MODE_SMA,3) iMA(lp,MODE_SMA,0)>iMA(sp,MODE_EMA,0)*0.9978
then
{
CloseOrder(
Ord(sym,VAL_TICKET),
Ord(sym,VAL_LOTS),
Bid,
Slip,
Red);
Exit;
};
If (Bid-Ord(sym,VAL_OPENPRICE))>(b)then
{
If Ord(sym,VAL_STOPLOSS)<(Bid-b) then
{
ModifyOrder(
Ord(sym,VAL_TICKET),
Ord(sym,VAL_OPENPRICE),
Bid-b,
Ord(sym,VAL_TAKEPROFIT),
LimeGreen);
Exit;
};
};
};
If mode=OP_SELL &
OrderValue(sym,VAL_SYMBOL)=Symbol then
{
If Ord(sym,Val_OPENPRICE) Ord(sym,Val_OPENPRICE)-Ask>(Ord(sym,Val_OPENPRICE)*0.004) &
iMA(lp,MODE_SMA,3)>iMA(sp,MODE_EMA,3)*1.002 &
iMA(lp,MODE_SMA,0) then
{
CloseOrder(
Ord(sym,VAL_TICKET),
Ord(sym,VAL_LOTS),
Ask,
Slip,
Red);
Exit;
};
If (Ord(sym,VAL_OPENPRICE)-Ask)>(b) then
{
If Ord(sym,VAL_STOPLOSS)>(Ask+b) then
{
ModifyOrder(
Ord(sym,VAL_TICKET),
Ord(sym,VAL_OPENPRICE),
Ask+b,
Ord(sym,VAL_TAKEPROFIT),
HotPink);
Exit;
};
};
};
End;