- EA TREND SIGNAL.mq4
- (2.72 Kio) Téléchargé 313 fois
MEME SUJET
Modérateur : Administrateurs
Re: MEME SUJET
Tien
//+------------------------------------------------------------------+
//| EA TREND SIGNAL.mq4 |
//| Copyright 2012, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Igateway.mq4 |
//| Copyright © 2011, Nicolas Tuffier |
//| http://www.furyweb.fr/forex/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Nicolas Tuffier"
#property link "http://www.furyweb.fr/forex/"
//--- input parameters
extern string tradeComment="Gateway Managed";
extern double lotSize=0.01;
extern int slippage=2;
string clsVar="TrendSignal";
string opnVar="TrendSignal";
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
//----
opnVar=StringConcatenate("SignalOpen", Symbol(), Period());
clsVar=StringConcatenate("SignalClose", Symbol(), Period());
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
//----
int op;
double price;
color col;
if (GlobalVariableCheck(opnVar)) {
op = GlobalVariableGet(opnVar);
GlobalVariableDel(opnVar);
if (op == OP_BUY) {
col = Lime;
price = Ask;
}
if (op == OP_BUY) {
col = Red;
price = Bid;
}
OrderSend(Symbol(), op, lotSize, price, slippage, 0, 0, tradeComment, 0, 0, col);
}
if (GlobalVariableCheck(clsVar)) {
op = GlobalVariableGet(clsVar);
GlobalVariableDel(clsVar);
if (op == OP_BUY) {
col = Lime;
price = Bid;
} else {
col = Red;
price = Ask;
}
int n = OrdersTotal();
for (int i = 0; i < n; i++)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if (OrderType() == op && OrderComment() == tradeComment)
OrderClose(OrderTicket(), OrderLots(), price, slippage, col);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| EA TREND SIGNAL.mq4 |
//| Copyright 2012, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Igateway.mq4 |
//| Copyright © 2011, Nicolas Tuffier |
//| http://www.furyweb.fr/forex/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Nicolas Tuffier"
#property link "http://www.furyweb.fr/forex/"
//--- input parameters
extern string tradeComment="Gateway Managed";
extern double lotSize=0.01;
extern int slippage=2;
string clsVar="TrendSignal";
string opnVar="TrendSignal";
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
//----
opnVar=StringConcatenate("SignalOpen", Symbol(), Period());
clsVar=StringConcatenate("SignalClose", Symbol(), Period());
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
//----
int op;
double price;
color col;
if (GlobalVariableCheck(opnVar)) {
op = GlobalVariableGet(opnVar);
GlobalVariableDel(opnVar);
if (op == OP_BUY) {
col = Lime;
price = Ask;
}
if (op == OP_BUY) {
col = Red;
price = Bid;
}
OrderSend(Symbol(), op, lotSize, price, slippage, 0, 0, tradeComment, 0, 0, col);
}
if (GlobalVariableCheck(clsVar)) {
op = GlobalVariableGet(clsVar);
GlobalVariableDel(clsVar);
if (op == OP_BUY) {
col = Lime;
price = Bid;
} else {
col = Red;
price = Ask;
}
int n = OrdersTotal();
for (int i = 0; i < n; i++)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if (OrderType() == op && OrderComment() == tradeComment)
OrderClose(OrderTicket(), OrderLots(), price, slippage, col);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
//----
//----
return(0);
}
//+------------------------------------------------------------------+