| |
 |
2EMA system
|
 |
|
|
|
Views:
2122 |
| Added: November 16, 2008 |
| |
|
|
|
| This formula has not been rated yet |
| |
| |
email this link
|
| |
| |
| Tags:
MetaTrader, system
|
| |
 |
2EMA system 2 moving avg envelope trader for EUR 5 minute charts
Code:
/*[[
Name := 2EMA system
Author := Copyright © 2003, Gerry
Link := http://www.company.com/
Notes :=
Update on every tick := Yes
Enable Alerts := Yes
Disable alert once hit := No
Lots := 1
Stop Loss := 50
Take Profit := 2000
Trailing Stop := 15
]]*/
vars: Slippage(2),MATrendPeriod(60),n(0),m(0);
defines: CountBars(2),CountPeriods(2);
vars: sl(0),tp(0);
defines: Y(4),Z(1),W(1);
vars:ADX1(0),ADX2(0);
var: s(0);
var: b(0);
vars : cnt(0),first(0);
If Bars<100 or TakeProfit<10 then Exit;
If IsIndirect(Symbol)=TRUE then Exit;
If CurTime - LastTradeTime < 300 Then Exit;
b=5*Point+iATR(10,1)*4.5;
s=5*Point+iATR(10,1)*4.5;
//Y=4;
//Z=1;
//W=1;
If TotalTrades<1 then
{
sl=Bid+StopLoss*Point;
if
(iMA(300,MODE_SMA,2)
iMA(300,MODE_SMA,0)>iMA(30,MODE_EMA,0)*0.998)|
(iMA(300,MODE_SMA,2)
iMA(300,MODE_SMA,0)>iMA(30,MODE_EMA,0)*1.002 and
iMA(300,MODE_SMA,0)>iMA(30,MODE_EMA,0)*0.998 and //Bid
iSAR(0.02,0.2,0)>Bid
) and
iForce(6,MODE_SMA,PRICE_CLOSE,1)>iForce(6,MODE_SMA,PRICE_CLOSE,0)
then
{
SetOrder(OP_SELL,Lots,Bid,Slippage,sl,Bid-TakeProfit*Point,White);
Exit;
};
sl=Ask-StopLoss*Point;
if
(iMA(300,MODE_SMA,2)>iMA(30,MODE_EMA,2)*1.002 and
iMA(300,MODE_SMA,0)
(iMA(300,MODE_SMA,2)>iMA(30,MODE_EMA,2)*0.998 and
iMA(300,MODE_SMA,0)
iMA(300,MODE_SMA,0)Open[1]and
iSAR(0.02,0.2,0)
) and
iForce(6,MODE_SMA,PRICE_CLOSE,1)
then
{
SetOrder(OP_BUY,Lots,Ask,Slippage,sl,Ask+TakeProfit*Point,White);
Exit;
};
};
If TrailingStop<5 then {print(\"invalid Trailing Stop\");Exit;};
for cnt=1 to TotalTrades
Begin
If OrderValue(cnt,VAL_TYPE)=OP_BUY and
OrderValue(cnt,VAL_SYMBOL)=Symbol then
{
If Bid-OrderValue(cnt,Val_OPENPRICE)
Bid-OrderValue(cnt,Val_OPENPRICE)>(OrderValue(cnt,Val_OPENPRICE)*0.005) and
iSAR(0.0005,0.3,0)>Bid and
iForce(60,MODE_SMA,PRICE_CLOSE,0)<0 then
{
CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,Slippage,SlateBlue);
Exit;
};
If (Bid-OrderValue(cnt,VAL_OPENPRICE))>(b)then
{
If OrderValue(cnt,VAL_STOPLOSS)<(Bid-b) then
{
ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),
Bid-b,OrderValue(cnt,VAL_TAKEPROFIT),SlateBlue);
Exit;
};
};
};
If OrderValue(cnt,VAL_TYPE)=OP_SELL and
OrderValue(cnt,VAL_SYMBOL)=Symbol then
{
If OrderValue(cnt,Val_OPENPRICE)-Ask
OrderValue(cnt,Val_OPENPRICE)-Ask>(OrderValue(cnt,Val_OPENPRICE)*0.005) and
iSAR(0.0005,0.3,0)
iForce(60,MODE_SMA,PRICE_CLOSE,0)>0 then
{
CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,Slippage,Red);
Exit;
};
If (OrderValue(cnt,VAL_OPENPRICE)-Ask)>(s) then
{
If OrderValue(cnt,VAL_STOPLOSS)>(Ask+s) then
{
ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),
Ask+s,OrderValue(cnt,VAL_TAKEPROFIT),Red);
Exit;
};
};
};end;
Code to difficult? Find somebody to help you with coding here.
Author: Gerry
Source: www.xeatrade.com
all systems for MetaTrader
all systems
|