bonjour furynick,
Je suis aussi intéressé par l'exe et la Dll ,je t'envoi un MP
Je suis aussi intéressé par l'exe et la Dll ,je t'envoi un MP
La garantie Forexagone permet de vous assurer que votre gain ne soit pas perdu. Nous négocions les meilleurs taux avec les brokers agréés par l’AMF.
Concernant l'heure de prise de position, j'ai remarqué une récurrence (en tout cas sur l'eur/usd), on à souvent à l'ouverture 9h et 14h une correction de la tendance, ce serait donc peut-être mieux de prendre position à 9h30 et 14h30 @fury : ça fais plaisir que tu vienne faire un tour sur le thread pour nous donner tes conseil concernant l'ea, tu pense que ça améliorerai la rapidité de l'ea ?
if (TimeGMT(TimeCurrent()) > StrToTime(heure_close1) order_close(MAGICA1);
if (TimeGMT(TimeCurrent()) > StrToTime(heure_close2)) order_close(MAGICA2);
if(Volume[0] != 1) return(0) ;
datetime timeRef;
init () {
timeRef=Time[0];
}
start () {
if (timeRef == Time[0]) return(0);
timeRef=Time[0];
...
}
if ((OrderMagicNumber() == MAGICA1 || OrderMagicNumber() == MAGICA2) && OrderSymbol() == Symbol() )
bonjour furynick, Je suis aussi intéressé par l'exe et la Dll ,je t'envoi un MP
datetime timeRef;
init ()
{
timeRef=Time[0];
}
start ()
{
if (timeRef == Time[0]) return(0); timeRef=Time[0]; ...
}
//+------------------------------------------------------------------+
//| xSuperDonchian.mq4 |
//| JJFlash |
//| http://www.forexagone.com |
//+------------------------------------------------------------------+
#define MAGICA1 1234
#define MAGICA2 1123
#property copyright "JJFlash"
#property link "http://www.forexagone.fr"
datetime timeRef;
extern string text1 = "Si vous ne voulez pas mettre tout votre capital (capital_total = false), donnez le montant que vous voulez investire. Sinon mettez -true-." ;
extern bool capital_total = true ;
extern double capital_investi = 1000 ;
extern string text2 = "Paramètres money management et indicateurs techniques." ;
extern double takeprofit_pips = 15 ;
extern double risk = 5. ; // Risque par trades
extern int SuperTrend_period_1 = 10 ; // Periode de xSuperTrend
extern double SuperTrend_multiplicator_1 = 1.7 ; // Multiplicateur de xSuperTrend
extern int SuperTrend_period_2 = 10 ; // Periode de xSuperTrend
extern double SuperTrend_multiplicator_2 = 3 ; // Multiplicateur de xSuperTrend
extern int SuperTrend_period_3 = 10 ; // Periode de xSuperTrend
extern double SuperTrend_multiplicator_3 = 3 ; // Multiplicateur de xSuperTrend
extern int Donchian_period = 48 ; // Periode de Donchian
extern string text4 = " Définition du stoploss au choix : " ;
extern string text5 = "1 - Stoploss fixe (remplire stop_fixe)" ;
extern string text6 = "2 - Stop fixe avec Donchian " ;
extern string text7 = "3 - Stop suiveur avec Donchian" ;
extern int choix_du_stop = 2 ;
extern double stop_fixe = 50 ;
extern string text8 = " Horaires ouverture de positions \n" ;
extern bool first_trade = true ;
extern int heure_open1 = 07 ; // Heure du premier trade (heure de la plateforme !)
extern int minut_open1 = 00 ;
extern bool second_trade = true ;
extern int heure_open2 = 12 ; // Heure du deuxième trade (heure de la plateforme !)
extern int minut_open2 = 00 ;
extern string text9 = " Clôture automatiques des positions ?" ;
extern bool cloture_automatique = false ; // Choisir la cloture automatique des trades
extern string text10 = " Horaires clôture de positions " ;
extern int heure_close1 = 12 ; // Heure du premier trade (heure de la plateforme !)
extern int minut_close1 = 00 ;
extern int heure_close2 = 17 ; // Heure du deuxième trade (heure de la plateforme !)
extern int minut_close2 = 00 ;
double gadSuperTrend ;
double gadSuperTrend_1 ;
int value1, value2, value3 ;
int ticket ;
bool verif_choix = true ;
// Coefficient pour le yen
double coeff(string symbol)
{
if (StringFind(symbol,"JPY") >=0) { return(0.01) ; } else { return(0.0001) ; }
}
int check_open_trade(double period, double multi, int timefr)
{
int iNewBars, iCountedBars, i;
double dAtrx,dUpperLevelx, dLowerLevelx;
// Get unprocessed ticks
iNewBars = Bars ;
for(i=iNewBars; i>=0; i--)
{
// Calc SuperTrend
dAtrx = iATR(NULL, timefr, period, i) ;
dUpperLevelx = (High[i]+Low[i])/2 + multi*dAtrx ;
dLowerLevelx = (High[i]+Low[i])/2 - multi*dAtrx ;
// Set supertrend levels
if ( iClose(NULL, timefr, i) > gadSuperTrend_1 && iClose(NULL, timefr, i+1) <= gadSuperTrend_1 ) gadSuperTrend = dLowerLevelx ;
else if ( iClose(NULL, timefr, i) < gadSuperTrend_1 && iClose(NULL, timefr, i+1) >= gadSuperTrend_1 ) gadSuperTrend = dUpperLevelx ;
else if (gadSuperTrend_1<dLowerLevelx) gadSuperTrend = dLowerLevelx ;
else if (gadSuperTrend_1>dUpperLevelx) gadSuperTrend = dUpperLevelx ;
else gadSuperTrend = gadSuperTrend_1;
double test ;
if ( iClose(NULL, timefr, i) > gadSuperTrend || ( iClose(NULL, timefr, i) == gadSuperTrend && iClose(NULL, timefr, i+1) > gadSuperTrend_1 ) ) test = 1 ;
if ( iClose(NULL, timefr, i) < gadSuperTrend || ( iClose(NULL, timefr, i) == gadSuperTrend && iClose(NULL, timefr, i+1) < gadSuperTrend_1 ) ) test = 2 ;
gadSuperTrend_1 = gadSuperTrend ;
}
return(test) ;
}
double Stop(int whattrade)
{
double stop ;
if (choix_du_stop == 3 || choix_du_stop == 2)
{
if ( whattrade == 1 ) stop = iLow(Symbol(), PERIOD_M30, iLowest(Symbol(),Period(),MODE_LOW,Donchian_period,1)) ;
if ( whattrade == 2 ) stop = iHigh(Symbol(), PERIOD_M30, iHighest(Symbol(),Period(),MODE_HIGH,Donchian_period,1)) ;
}
if (choix_du_stop == 1)
{
RefreshRates() ;
if ( whattrade == 1 ) stop = Ask - stop_fixe*coeff(Symbol()) ;
if ( whattrade == 2 ) stop = Bid + stop_fixe*coeff(Symbol()) ;
}
return(stop) ;
}
double optim_lot(int whattrade)
{
double stop = Stop(whattrade) ;
double point ;
if (whattrade == 1) point = Ask ;
if (whattrade == 2) point = Bid ;
stop = MathAbs(stop - point) ;
double lot ;
if (capital_total == false) lot = capital_investi*risk*0.01*0.00001/(stop) ;
if (capital_total == true) lot = AccountBalance()*risk*0.01*0.00001/(stop) ;
return(lot) ;
}
int long(int MAGICA)
{
double lot = optim_lot(1) ;
double stop = Stop(1) ;
double take = takeprofit_pips*coeff(Symbol()) ;
RefreshRates() ;
ticket = OrderSend(Symbol(), OP_BUY, lot, Ask, 3, stop, Ask+take, 0, MAGICA, 0, Blue) ;
return(0) ;
}
int short(int MAGICA)
{
double lot = optim_lot(2) ;
double stop = Stop(2) ;
double take = takeprofit_pips*coeff(Symbol()) ;
RefreshRates() ;
ticket = OrderSend(Symbol(), OP_SELL, lot, Bid, 3, stop, Bid-take, 0, MAGICA, 0, Red) ;
return(0) ;
}
int order_close(int MAGICA)
{
for( int i = 0 ; i <= OrdersTotal() ; i++ )
{
if ( OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true )
{
if ( OrderMagicNumber() == MAGICA )
{
double price = OrderOpenPrice() ;
ticket = OrderTicket() ;
double lot = OrderLots() ;
RefreshRates() ;
if ( OrderType() == OP_BUY ) OrderClose(ticket, lot, Bid, 3, Red) ;
if ( OrderType() == OP_SELL ) OrderClose(ticket, lot, Ask, 3, Red) ;
}
}
}
return(0) ;
}
int Modify()
{
for (int i = 0 ; i<OrdersTotal() ; i++ )
{
if ( OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true )
{
if ( OrderMagicNumber() == MAGICA1 || OrderMagicNumber() == MAGICA2 )
{
double price = OrderOpenPrice() ;
ticket = OrderTicket() ;
double stop = OrderStopLoss() ;
double take = OrderTakeProfit() ;
double new_stop ;
RefreshRates() ;
if ( OrderType() == OP_BUY )
{
new_stop = Stop(1) ;
if (new_stop > stop) OrderModify(ticket, price, new_stop, take, 0, Purple) ;
}
if ( OrderType() == OP_SELL )
{
new_stop = Stop(2) ;
if (new_stop < stop) OrderModify(ticket, price, new_stop, take, 0, Purple) ;
}
}
}
}
return(0) ;
}
int start()
{
//----
if (timeRef == Time[0]) return(0);
timeRef=Time[0];
// Ouverture des trades
if ( first_trade == 1 && TimeHour(TimeCurrent()) == heure_open1 && TimeMinute(TimeCurrent()) == minut_open1 && verif_choix == true )
{
value1 = check_open_trade(SuperTrend_period_1, SuperTrend_multiplicator_1, PERIOD_M30) ;
value2 = check_open_trade(SuperTrend_period_2, SuperTrend_multiplicator_2, PERIOD_M30) ;
value3 = check_open_trade(SuperTrend_period_3, SuperTrend_multiplicator_3, PERIOD_H4) ;
if (value1 == 1 && value2 == 1 && value3 == 1) long(MAGICA1) ;
if (value1 == 2 && value2 == 2 && value3 == 2) short(MAGICA1) ;
}
if ( second_trade == 1 && TimeHour(TimeCurrent()) == heure_open2 && TimeMinute(TimeCurrent()) == minut_open2 && verif_choix == true )
{
value1 = check_open_trade(SuperTrend_period_1, SuperTrend_multiplicator_1, PERIOD_M30) ;
value2 = check_open_trade(SuperTrend_period_2, SuperTrend_multiplicator_2, PERIOD_M30) ;
value3 = check_open_trade(SuperTrend_period_3, SuperTrend_multiplicator_3, PERIOD_H4) ;
if (value1 == 1 && value2 == 1 && value3 == 1) long(MAGICA2) ;
if (value1 == 2 && value2 == 2 && value3 == 2) short(MAGICA2) ;
}
if (cloture_automatique == true)
{
// Fermeture des trades
if ( TimeHour(TimeCurrent()) == heure_close1 && TimeMinute(TimeCurrent()) == minut_close1 ) order_close(1234) ;
if ( TimeHour(TimeCurrent()) == heure_close2 && TimeMinute(TimeCurrent()) == minut_close2 ) order_close(1123) ;
}
if (choix_du_stop == 3) Modify() ;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
timeRef=Time[0];
if (choix_du_stop != 1 && choix_du_stop != 2 && choix_du_stop != 3)
{
MessageBox("Choix du stoploss erroné. Veuillez vérifier ce paramètre.", 0, 1) ;
verif_choix = false ;
}
if (capital_investi > AccountBalance() && capital_total == false)
{
MessageBox("Capital investi erroné. Veuillez vérifier ce paramètre.", 0, 1) ;
verif_choix = false ;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}