Cdlt
Recherche code pour mon Ea
Modérateur : Administrateurs
Recherche code pour mon Ea
Bonsoir a tous je suis en train de modifier un Ea et il me manque le code pour trader de tel heure à tel heure si quelqu'un peu m'aider.
Cdlt
Cdlt
Re: Recherche code pour mon Ea
Voilà ce que j'utilise :
Code : Tout sélectionner
if( Hour()>=HeureDebut && hour()<HeureFin )
"The market is like a beautiful woman-endlessly fascinating, endlessly complex, always changing, always mystifying." The Money Game - Adam Smith
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
Re: Recherche code pour mon Ea
madjes a écrit :Voilà ce que j'utilise :
Code : Tout sélectionner
if( Hour()>=HeureDebut && hour()<HeureFin )
j utilise ceci
int gi_136 = 08;
int gi_140 = 20;
remplace 08 par l'heure du début de ton choix et 20 par l'heure de de ton choix.
Re: Recherche code pour mon Ea
Lol, il manquerai pas un petit bout de code?4b4z a écrit :
j utilise ceci
int gi_136 = 08;
int gi_140 = 20;
remplace 08 par l'heure du début de ton choix et 20 par l'heure de de ton choix.
Re: Recherche code pour mon Ea
Je dirai même la partie principale
"The market is like a beautiful woman-endlessly fascinating, endlessly complex, always changing, always mystifying." The Money Game - Adam Smith
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
Re: Recherche code pour mon Ea
Si possible un code complet je vérifie ce soir si quelqu'un a autre chose.
Cdlt
Cdlt
Re: Recherche code pour mon Ea
Sa ne fonctionne pas
Re: Recherche code pour mon Ea
salut,crazy95 a écrit :Sa ne fonctionne pas
laches nous une partie de ton code pour voir
Re: Recherche code pour mon Ea
si mon code ne fonctionne pas c'est que tu l'as mal placé ou que t'as mal copié. T'as bien remplacé "heuredebut" et "heurefin" par l'heure que tu voulais ?
"The market is like a beautiful woman-endlessly fascinating, endlessly complex, always changing, always mystifying." The Money Game - Adam Smith
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
Re: Recherche code pour mon Ea
Dsl je fais mes premiers pas en mql4, et comme crazy je bidouille sur un ea.madjes a écrit :Je dirai même la partie principale
La suite du code si vous pouviez me dire ce qu'il faut en retenir pour les horaires.
int gi_136 = 08;
int gi_140 = 20;
bool gi_144 = TRUE;
double gd_148 = 2.0;
double gd_156 = 1.0;
double gd_164 = 0.7;
bool gi_172 = TRUE;
bool gi_176 = TRUE;
bool gi_180 = TRUE;
double gd_184 = 0.2;
double gd_192 = 0.4;
double gd_200 = 1.0;
int g_slippage_208 = 1;
int gi_212 = 1;
int gi_216 = 20;
double gd_unused_220 = 2.0;
bool gi_228 = FALSE;
bool gi_232 = FALSE;
int gi_236 = 18;
//string gs_240 = "";
int gi_248 = 2;
double g_pips_252 = 0.0;
j'ai repéré aussi cela
"\n TimeZone : ", gi_276,
"\n Time Current : ", TimeHour(TimeCurrent()), ":", TimeMinute(TimeCurrent()),
Mon ea ne trade pas le vendredi, j'ai repéré ceci
int g_day_of_week_472 = 99;
Sur cette ea j'ai réussi à modifier les horaires de trading, tp, sl et les lots max.
Maintenant, je voudrai qu'il trade le vendredi, qu'il prennent uniquement un trade par paire et le nombre de lot par position selon mon choix.
J ai fais beaucoup de recherche sur le net qui sont resté sans suite.
Re: Recherche code pour mon Ea
Voici une partie du code si quelqu'un peu me le modifier en ajoutant le bon code
Cdlt:
Cdlt:
Code : Tout sélectionner
#property copyright "crazy95"
#property link ""
#define buy -2
#define sell 2
//---- input parameters
extern string separator_01="---- General Settings ----";
extern bool use_daily_target=false;
extern double daily_target=100;
extern bool trade_in_fri=true;
extern int magic=22;
extern double start_lot=0.1;
extern double range=25;
extern bool rge_multiplier=false;
extern double r_multiplier=1.5;
extern int level=10;
extern string separator_02="---- Lot & TP Settings ----";
extern bool lot_multiplier=true;
extern double l_multiplier=2.0;
extern double increment=0.1;
extern bool power_lots=true;
extern bool tp_by_level=true;
extern double tp_1=25;
extern double tp_2=0;
extern bool use_sl_and_tp=false;
extern double sl_std=60;
extern double tp_std=30;
extern double tp_in_money=5.0;
extern bool stealth_mode=true;
extern string separator_03="---- Hedge Settings ----";
extern bool hedge=true;
extern int h_level=3;
extern int h_top_level=100;
extern double h_tp=80;
extern double h_sl=25;
extern double b_even_set=10;
extern double h_offset=20;
extern double h_factor=1.05;
extern bool level_limit=false;
extern string separator_04="---- Indicator Settings ----";
extern bool use_bb=true;
extern int bb_period=20;
extern int bb_deviation=2;
extern int bb_shift=0;
extern bool use_stoch=true;
extern int k=5;
extern int d=3;
extern int slowing=3;
extern int price_field=0;
extern int stoch_shift=0;
extern int lo_level=30;
extern int up_level=70;
extern bool use_rsi=true;
extern int rsi_period=12;
extern int rsi_shift=0;
extern int lower=30;
extern int upper=70;
extern string separator_00="---- RSI - Foward Trend ----";
extern bool forward_trend=false;
extern int rsi_period_1=30;
extern int rsi_shift_1=0;
extern int lower_min=35;
extern int lower_max=33;
extern int upper_min=65;
extern int upper_max=67;
extern bool use_velocity=true;
extern int fv_period=10;
extern int fv_offset=20;
extern string separator_05="---- RSI - Hedge Entry ----";
extern bool h_rsi_entry=true;
extern int rsi_period_2=14;
extern int rsi_shift_2=0;
extern int lower_2=25;
extern int upper_2=75;
extern bool h_velocity=false;
extern bool use_h_rsi=false;
extern int vel_period=13;
extern int vel_offset=50;
extern string separator_06="---- RSI - Hedge Exit ----";
extern bool h_rsi_exit=true;
extern int rsi_period_3=14;
extern int rsi_shift_3=0;
extern int lower_3=50;
extern int upper_3=50;
extern double sl_threshold=0;
extern string separator_07="---- RSI - TP Override ----";
extern bool tp_override=true;
extern int rsi_period_4=14;
extern int rsi_shift_4=0;
extern int lower_4=25;
extern int upper_4=75;
extern string separator_08="---- Additional ----";
extern string separator_09="---- Trading Sessions ----";
extern bool use_trading_sessions=false;
extern bool asian_session=true; // 0:00 - 8:00 GMT
extern bool euro_session=true; // 6:00 - 16:00 GMT
extern bool ny_session=true; // 12:00 - 21:00 GMT
extern int gmt_shift=1;
extern bool daylight_savings=false;
extern string separator_10="---- Asian Daily / GMT ----";
extern bool asian_daily=true;
extern int sun_asian_open=0, sun_asian_close=8;
extern int mon_asian_open=0, mon_asian_close=8;
extern int tue_asian_open=0, tue_asian_close=8;
extern int wed_asian_open=0, wed_asian_close=8;
extern int thu_asian_open=0, thu_asian_close=8;
extern int fri_asian_open=0, fri_asian_close=8;
extern string separator_11="---- European Daily / GMT ----";
extern bool euro_daily=true;
extern int sun_euro_open=6, sun_euro_close=16;
extern int mon_euro_open=6, mon_euro_close=16;
extern int tue_euro_open=6, tue_euro_close=16;
extern int wed_euro_open=6, wed_euro_close=16;
extern int thu_euro_open=6, thu_euro_close=16;
extern int fri_euro_open=6, fri_euro_close=16;
extern string separator_12="---- New York Daily / GMT ----";
extern bool ny_daily=true;
extern int sun_ny_open=12, sun_ny_close=21;
extern int mon_ny_open=12, mon_ny_close=21;
extern int tue_ny_open=12, tue_ny_close=21;
extern int wed_ny_open=12, wed_ny_close=21;
extern int thu_ny_open=12, thu_ny_close=21;
extern int fri_ny_open=12, fri_ny_close=21;
bool t_day[5];
datetime mtd_time;
double pt;
double minlot;
double stoplevel;
double std=0.1;
double rge;
double balance;
double bal_2=0;
double b_hedge;
double s_hedge;
double p_lot;
double pl_bal=0;
double st_lot;
double pl_factor;
double t_profit=0;
int prec=0;
int b_cnt;
int s_cnt;
int h_cnt;
int m;
int end_cycle;
bool e_cycle_set;
bool closeall;
bool h_b_e;
datetime get_time;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
if(Digits==3 || Digits==5) pt=10*Point;
else pt=Point;
minlot = MarketInfo(Symbol(),MODE_MINLOT);
stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
if(start_lot<minlot) Print("lotsize is to small.");
if(sl_std<stoplevel) Print("stoploss is to tight.");
if(tp_std<stoplevel) Print("takeprofit is to tight.");
if(minlot==0.01){ prec=2; std=10.0; }
if(minlot==0.1) { prec=1; std=1.0; }
//----
range*=pt;
rge=range;
sl_std*=pt;
tp_std*=pt;
tp_1*=pt;
tp_2*=pt;
h_tp*=pt;
h_sl*=pt;
h_offset*=pt;
b_even_set*=pt;
sl_threshold*=pt;
if(h_velocity) h_level=1;
if(hedge && level_limit) level=h_level;
//----
if(use_sl_and_tp) stealth_mode=false;
//----
if(!GlobalVariableGet("bal_2"+Symbol()+magic)) GlobalVariableSet("bal_2"+Symbol()+magic,0);
if(GlobalVariableGet("bal_2"+Symbol()+magic)>0) bal_2=GlobalVariableGet("bal_2"+Symbol()+magic);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if(use_daily_target && dailyprofit()>=daily_target)
{
Comment("\ndaily target achieved.");
return(0);
}
if(!trade_in_fri && DayOfWeek()==5 && T()==0)
{
Comment("\nstop trading in Friday.");
return(0);
}
//+------------------------------------------------------------------+
//| start of ecTrage mod - crazydunker95@hotmail.com |
//+------------------------------------------------------------------+
h_cnt=0; b_cnt=0; s_cnt=0; double LOOP, lot2, h2_lot;
for(int i=0; i<OrdersTotal(); i++) // additional
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
//----
if(OT2()=="H"){ h_cnt++; } else {
if(cmd()<2) if(cmd()==0) b_cnt++; if(cmd()==1) s_cnt++; }
}
if(h_cnt==0) h_b_e=false;
//+------------------------------------------------------------------+
double AE=AccountEquity();
if(power_lots)
{
if(pl_bal==0){ pl_bal=AE; st_lot=start_lot; }
if(T()==0){ pl_factor=AE/pl_bal; st_lot=start_lot*pl_factor; }
}
//+------------------------------------------------------------------+
if(lot_multiplier) lot2=NormalizeDouble(st_lot*MathPow(l_multiplier,T()),prec);
else lot2=NormalizeDouble(st_lot+(increment*T()), prec);
if(rge_multiplier) rge=range*MathPow(r_multiplier,T());
//+------------------------------------------------------------------+
int o_send=2; if(use_trading_sessions){ o_send=order_send(); } else {
if(signal()==buy) o_send=0; if(signal()==sell) o_send=1; }
//----
if(e_cycle_set) end_cycle++; if(end_cycle>1){ e_cycle_set=false; end_cycle=0; }
if(T()==0){ closeall=false; get_time=TimeCurrent(); }
//----
if(!closeall && end_cycle==0 && h_cnt==0) // additional
{
if(T()<level)
{
if(o_send==0 || (b_cnt>0 && Ask<=LOOP()-rge)) // BUY
{
if(hedge && T()==0) s_hedge=Bid-rge;
OrderSend(Symbol(),0,lot2,Ask,3,0,0,"L"+(b_cnt+1),magic,0,Blue);
}
if(o_send==1 || (s_cnt>0 && Bid>=LOOP()+rge)) // SELL
{
if(hedge && T()==0) b_hedge=Ask+rge;
OrderSend(Symbol(),1,lot2,Bid,3,0,0,"L"+(s_cnt+1),magic,0,Red);
}
}
//----
if(hedge() && h_rsi_entry) // HEDGE
{
if(h_velocity)
{
if(s_cnt>0 && Ask>=b_hedge && ((!use_h_rsi && h_velo()>vel_offset)
|| (use_h_rsi && h_entry()>upper_2)))
OrderSend(Symbol(),0,h_lot(),Ask,3,0,0,"H"+(s_cnt+1),magic,0,Blue);
//----
if(b_cnt>0 && Bid<=s_hedge && ((!use_h_rsi && h_velo()<-vel_offset)
|| (use_h_rsi && h_entry()<lower_2)))
OrderSend(Symbol(),1,h_lot(),Bid,3,0,0,"H"+(b_cnt+1),magic,0,Red);
}
if(!h_velocity)
{
if(s_cnt>0 && Ask>=LOOP() && Ask<=LOOP()+h_offset && h_entry()>upper_2)
OrderSend(Symbol(),0,h_lot(), Ask,3,0,0,"H"+(s_cnt+1),magic,0,Blue);
//----
if(b_cnt>0 && Bid<=LOOP() && Bid>=LOOP()-h_offset && h_entry()<lower_2)
OrderSend(Symbol(),1,h_lot(), Bid,3,0,0,"H"+(b_cnt+1),magic,0,Red);
}
}
}
//+------------------------------------------------------------------+
double OOP, OSL, OTP, sl_0=sl_std, tp_0=tp_std, h2_tp=h_tp;
for(i=0; i<OrdersTotal(); i++) // additional
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1) continue;
OOP=OrderOpenPrice();
if(OT2()=="H")
{
if(cmd()==0)
{
if(tp_override && h_tp_over()>upper_4) h2_tp=0;
OSL=OOP()-h_sl; if(h_sl==0) OSL=0; OTP=OOP()+h2_tp; if(h2_tp==0) OTP=0;
if(Ask>=OOP()+b_even_set) h_b_e=true; if(h_b_e) OSL=OOP()+(2*pt);
OrderModify(OrderTicket(),0,OSL,OTP,0,CLR_NONE);
}
if(cmd()==1)
{
if(tp_override && h_tp_over()<lower_4) h2_tp=0;
OSL=OOP()+h_sl; if(h_sl==0) OSL=0; OTP=OOP()-h2_tp; if(h2_tp==0) OTP=0;
if(Bid<=OOP()-b_even_set) h_b_e=true; if(h_b_e) OSL=OOP()-(2*pt);
OrderModify(OrderTicket(),0,OSL,OTP,0,CLR_NONE);
}
//----
if(h_rsi_exit)
{
if((cmd()==0 && Ask>OOP()-sl_threshold && h_exit()<lower_3)
|| (cmd()==1 && Bid<OOP()+sl_threshold && h_exit()>upper_3))
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
}
}
//+------------------------------------------------------------------+
double deviate=0, h_dev=0; sl_0=sl_std; tp_0=tp_std;
for(i=0; i<OrdersTotal(); i++) // additional
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1) continue;
OOP=OrderOpenPrice(); OTP=OrderOpenPrice();
if(LCT()==1)
{
if(cmd()==0 && Ask<=OOP()) deviate=OOP()-Ask;
if(cmd()==1 && Bid>=OOP()) deviate=Bid-OOP();
}
if(OT2()=="H")
{
if(cmd()==0 &&Ask<=OOP()) h_dev=OOP()-Ask;
if(cmd()==1 &&Bid>=OOP()) h_dev=Bid-OOP();
}
if(tp_by_level){ tp_0=tp_1; if(LCT()>1) tp_0=tp_2; }
if((!stealth_mode || tp_by_level) && OT2()!="H")
{
if(cmd()==1){ sl_0*=-1; tp_0*=-1; }
if(use_sl_and_tp) OSL=OOP-sl_0;
OTP=OOP+tp_0; if(tp_0==0) OTP=0; if(sl_0==0) OSL=0;
if(OrderTakeProfit()==0) OrderModify(OrderTicket(),0,OSL,OTP,0,CLR_NONE);
}
}
Re: Recherche code pour mon Ea
Ce que tu copies ici abaz, c'est seulement les variables
Tu devrais ouvrir un post pour tes questions
Tu devrais ouvrir un post pour tes questions
"The market is like a beautiful woman-endlessly fascinating, endlessly complex, always changing, always mystifying." The Money Game - Adam Smith
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
Re: Recherche code pour mon Ea
Normalement ça devrait être bon comme ça
Code : Tout sélectionner
#property copyright "crazy95"
#property link ""
#define buy -2
#define sell 2
//---- input parameters
extern int HeureDebut=8;
extern int HeureFin=20;
extern string separator_01="---- General Settings ----";
extern bool use_daily_target=false;
extern double daily_target=100;
extern bool trade_in_fri=true;
extern int magic=22;
extern double start_lot=0.1;
extern double range=25;
extern bool rge_multiplier=false;
extern double r_multiplier=1.5;
extern int level=10;
extern string separator_02="---- Lot & TP Settings ----";
extern bool lot_multiplier=true;
extern double l_multiplier=2.0;
extern double increment=0.1;
extern bool power_lots=true;
extern bool tp_by_level=true;
extern double tp_1=25;
extern double tp_2=0;
extern bool use_sl_and_tp=false;
extern double sl_std=60;
extern double tp_std=30;
extern double tp_in_money=5.0;
extern bool stealth_mode=true;
extern string separator_03="---- Hedge Settings ----";
extern bool hedge=true;
extern int h_level=3;
extern int h_top_level=100;
extern double h_tp=80;
extern double h_sl=25;
extern double b_even_set=10;
extern double h_offset=20;
extern double h_factor=1.05;
extern bool level_limit=false;
extern string separator_04="---- Indicator Settings ----";
extern bool use_bb=true;
extern int bb_period=20;
extern int bb_deviation=2;
extern int bb_shift=0;
extern bool use_stoch=true;
extern int k=5;
extern int d=3;
extern int slowing=3;
extern int price_field=0;
extern int stoch_shift=0;
extern int lo_level=30;
extern int up_level=70;
extern bool use_rsi=true;
extern int rsi_period=12;
extern int rsi_shift=0;
extern int lower=30;
extern int upper=70;
extern string separator_00="---- RSI - Foward Trend ----";
extern bool forward_trend=false;
extern int rsi_period_1=30;
extern int rsi_shift_1=0;
extern int lower_min=35;
extern int lower_max=33;
extern int upper_min=65;
extern int upper_max=67;
extern bool use_velocity=true;
extern int fv_period=10;
extern int fv_offset=20;
extern string separator_05="---- RSI - Hedge Entry ----";
extern bool h_rsi_entry=true;
extern int rsi_period_2=14;
extern int rsi_shift_2=0;
extern int lower_2=25;
extern int upper_2=75;
extern bool h_velocity=false;
extern bool use_h_rsi=false;
extern int vel_period=13;
extern int vel_offset=50;
extern string separator_06="---- RSI - Hedge Exit ----";
extern bool h_rsi_exit=true;
extern int rsi_period_3=14;
extern int rsi_shift_3=0;
extern int lower_3=50;
extern int upper_3=50;
extern double sl_threshold=0;
extern string separator_07="---- RSI - TP Override ----";
extern bool tp_override=true;
extern int rsi_period_4=14;
extern int rsi_shift_4=0;
extern int lower_4=25;
extern int upper_4=75;
extern string separator_08="---- Additional ----";
extern string separator_09="---- Trading Sessions ----";
extern bool use_trading_sessions=false;
extern bool asian_session=true; // 0:00 - 8:00 GMT
extern bool euro_session=true; // 6:00 - 16:00 GMT
extern bool ny_session=true; // 12:00 - 21:00 GMT
extern int gmt_shift=1;
extern bool daylight_savings=false;
extern string separator_10="---- Asian Daily / GMT ----";
extern bool asian_daily=true;
extern int sun_asian_open=0, sun_asian_close=8;
extern int mon_asian_open=0, mon_asian_close=8;
extern int tue_asian_open=0, tue_asian_close=8;
extern int wed_asian_open=0, wed_asian_close=8;
extern int thu_asian_open=0, thu_asian_close=8;
extern int fri_asian_open=0, fri_asian_close=8;
extern string separator_11="---- European Daily / GMT ----";
extern bool euro_daily=true;
extern int sun_euro_open=6, sun_euro_close=16;
extern int mon_euro_open=6, mon_euro_close=16;
extern int tue_euro_open=6, tue_euro_close=16;
extern int wed_euro_open=6, wed_euro_close=16;
extern int thu_euro_open=6, thu_euro_close=16;
extern int fri_euro_open=6, fri_euro_close=16;
extern string separator_12="---- New York Daily / GMT ----";
extern bool ny_daily=true;
extern int sun_ny_open=12, sun_ny_close=21;
extern int mon_ny_open=12, mon_ny_close=21;
extern int tue_ny_open=12, tue_ny_close=21;
extern int wed_ny_open=12, wed_ny_close=21;
extern int thu_ny_open=12, thu_ny_close=21;
extern int fri_ny_open=12, fri_ny_close=21;
bool t_day[5];
datetime mtd_time;
double pt;
double minlot;
double stoplevel;
double std=0.1;
double rge;
double balance;
double bal_2=0;
double b_hedge;
double s_hedge;
double p_lot;
double pl_bal=0;
double st_lot;
double pl_factor;
double t_profit=0;
int prec=0;
int b_cnt;
int s_cnt;
int h_cnt;
int m;
int end_cycle;
bool e_cycle_set;
bool closeall;
bool h_b_e;
datetime get_time;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
if(Digits==3 || Digits==5) pt=10*Point;
else pt=Point;
minlot = MarketInfo(Symbol(),MODE_MINLOT);
stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
if(start_lot<minlot) Print("lotsize is to small.");
if(sl_std<stoplevel) Print("stoploss is to tight.");
if(tp_std<stoplevel) Print("takeprofit is to tight.");
if(minlot==0.01){ prec=2; std=10.0; }
if(minlot==0.1) { prec=1; std=1.0; }
//----
range*=pt;
rge=range;
sl_std*=pt;
tp_std*=pt;
tp_1*=pt;
tp_2*=pt;
h_tp*=pt;
h_sl*=pt;
h_offset*=pt;
b_even_set*=pt;
sl_threshold*=pt;
if(h_velocity) h_level=1;
if(hedge && level_limit) level=h_level;
//----
if(use_sl_and_tp) stealth_mode=false;
//----
if(!GlobalVariableGet("bal_2"+Symbol()+magic)) GlobalVariableSet("bal_2"+Symbol()+magic,0);
if(GlobalVariableGet("bal_2"+Symbol()+magic)>0) bal_2=GlobalVariableGet("bal_2"+Symbol()+magic);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
if( Hour()>=HeureDebut && hour()<HeureFin )
{
//----
if(use_daily_target && dailyprofit()>=daily_target)
{
Comment("\ndaily target achieved.");
return(0);
}
if(!trade_in_fri && DayOfWeek()==5 && T()==0)
{
Comment("\nstop trading in Friday.");
return(0);
}
//+------------------------------------------------------------------+
//| start of ecTrage mod - crazydunker95@hotmail.com |
//+------------------------------------------------------------------+
h_cnt=0; b_cnt=0; s_cnt=0; double LOOP, lot2, h2_lot;
for(int i=0; i<OrdersTotal(); i++) // additional
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
//----
if(OT2()=="H"){ h_cnt++; } else {
if(cmd()<2) if(cmd()==0) b_cnt++; if(cmd()==1) s_cnt++; }
}
if(h_cnt==0) h_b_e=false;
//+------------------------------------------------------------------+
double AE=AccountEquity();
if(power_lots)
{
if(pl_bal==0){ pl_bal=AE; st_lot=start_lot; }
if(T()==0){ pl_factor=AE/pl_bal; st_lot=start_lot*pl_factor; }
}
//+------------------------------------------------------------------+
if(lot_multiplier) lot2=NormalizeDouble(st_lot*MathPow(l_multiplier,T()),prec);
else lot2=NormalizeDouble(st_lot+(increment*T()), prec);
if(rge_multiplier) rge=range*MathPow(r_multiplier,T());
//+------------------------------------------------------------------+
int o_send=2; if(use_trading_sessions){ o_send=order_send(); } else {
if(signal()==buy) o_send=0; if(signal()==sell) o_send=1; }
//----
if(e_cycle_set) end_cycle++; if(end_cycle>1){ e_cycle_set=false; end_cycle=0; }
if(T()==0){ closeall=false; get_time=TimeCurrent(); }
//----
if(!closeall && end_cycle==0 && h_cnt==0) // additional
{
if(T()<level)
{
if(o_send==0 || (b_cnt>0 && Ask<=LOOP()-rge)) // BUY
{
if(hedge && T()==0) s_hedge=Bid-rge;
OrderSend(Symbol(),0,lot2,Ask,3,0,0,"L"+(b_cnt+1),magic,0,Blue);
}
if(o_send==1 || (s_cnt>0 && Bid>=LOOP()+rge)) // SELL
{
if(hedge && T()==0) b_hedge=Ask+rge;
OrderSend(Symbol(),1,lot2,Bid,3,0,0,"L"+(s_cnt+1),magic,0,Red);
}
}
//----
if(hedge() && h_rsi_entry) // HEDGE
{
if(h_velocity)
{
if(s_cnt>0 && Ask>=b_hedge && ((!use_h_rsi && h_velo()>vel_offset)
|| (use_h_rsi && h_entry()>upper_2)))
OrderSend(Symbol(),0,h_lot(),Ask,3,0,0,"H"+(s_cnt+1),magic,0,Blue);
//----
if(b_cnt>0 && Bid<=s_hedge && ((!use_h_rsi && h_velo()<-vel_offset)
|| (use_h_rsi && h_entry()<lower_2)))
OrderSend(Symbol(),1,h_lot(),Bid,3,0,0,"H"+(b_cnt+1),magic,0,Red);
}
if(!h_velocity)
{
if(s_cnt>0 && Ask>=LOOP() && Ask<=LOOP()+h_offset && h_entry()>upper_2)
OrderSend(Symbol(),0,h_lot(), Ask,3,0,0,"H"+(s_cnt+1),magic,0,Blue);
//----
if(b_cnt>0 && Bid<=LOOP() && Bid>=LOOP()-h_offset && h_entry()<lower_2)
OrderSend(Symbol(),1,h_lot(), Bid,3,0,0,"H"+(b_cnt+1),magic,0,Red);
}
}
}
//+------------------------------------------------------------------+
double OOP, OSL, OTP, sl_0=sl_std, tp_0=tp_std, h2_tp=h_tp;
for(i=0; i<OrdersTotal(); i++) // additional
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1) continue;
OOP=OrderOpenPrice();
if(OT2()=="H")
{
if(cmd()==0)
{
if(tp_override && h_tp_over()>upper_4) h2_tp=0;
OSL=OOP()-h_sl; if(h_sl==0) OSL=0; OTP=OOP()+h2_tp; if(h2_tp==0) OTP=0;
if(Ask>=OOP()+b_even_set) h_b_e=true; if(h_b_e) OSL=OOP()+(2*pt);
OrderModify(OrderTicket(),0,OSL,OTP,0,CLR_NONE);
}
if(cmd()==1)
{
if(tp_override && h_tp_over()<lower_4) h2_tp=0;
OSL=OOP()+h_sl; if(h_sl==0) OSL=0; OTP=OOP()-h2_tp; if(h2_tp==0) OTP=0;
if(Bid<=OOP()-b_even_set) h_b_e=true; if(h_b_e) OSL=OOP()-(2*pt);
OrderModify(OrderTicket(),0,OSL,OTP,0,CLR_NONE);
}
//----
if(h_rsi_exit)
{
if((cmd()==0 && Ask>OOP()-sl_threshold && h_exit()<lower_3)
|| (cmd()==1 && Bid<OOP()+sl_threshold && h_exit()>upper_3))
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
}
}
//+------------------------------------------------------------------+
double deviate=0, h_dev=0; sl_0=sl_std; tp_0=tp_std;
for(i=0; i<OrdersTotal(); i++) // additional
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1) continue;
OOP=OrderOpenPrice(); OTP=OrderOpenPrice();
if(LCT()==1)
{
if(cmd()==0 && Ask<=OOP()) deviate=OOP()-Ask;
if(cmd()==1 && Bid>=OOP()) deviate=Bid-OOP();
}
if(OT2()=="H")
{
if(cmd()==0 &&Ask<=OOP()) h_dev=OOP()-Ask;
if(cmd()==1 &&Bid>=OOP()) h_dev=Bid-OOP();
}
if(tp_by_level){ tp_0=tp_1; if(LCT()>1) tp_0=tp_2; }
if((!stealth_mode || tp_by_level) && OT2()!="H")
{
if(cmd()==1){ sl_0*=-1; tp_0*=-1; }
if(use_sl_and_tp) OSL=OOP-sl_0;
OTP=OOP+tp_0; if(tp_0==0) OTP=0; if(sl_0==0) OSL=0;
if(OrderTakeProfit()==0) OrderModify(OrderTicket(),0,OSL,OTP,0,CLR_NONE);
}
}
}
"The market is like a beautiful woman-endlessly fascinating, endlessly complex, always changing, always mystifying." The Money Game - Adam Smith
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
Re: Recherche code pour mon Ea
Merci pour ta réponse MADJE, je vais continuer mes recherches et aussi voir ou tu as apporté des modifs dans le code de CRAZY.
Re: Recherche code pour mon Ea
Alors dans le code de crazy j'ai ajouté 2 variables que tu peux régler via mt4 au début du code
Et j'ai ajouté le filtre pour l'heure juste après la fonction start(), ce qui peut-être un problème pour la gestion de la sortie du trade. Mais j'avais pas envie de tout lire le code, c'était pour l'exemple
Code : Tout sélectionner
extern int HeureDebut=8;
extern int HeureFin=20;
Code : Tout sélectionner
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
if( Hour()>=HeureDebut && hour()<HeureFin )
{
....
}
"The market is like a beautiful woman-endlessly fascinating, endlessly complex, always changing, always mystifying." The Money Game - Adam Smith
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
L'art d'être tantôt très audacieux et tantôt très prudent est l'art de réussir-Napoléon Bonaparte
Re: Recherche code pour mon Ea
madjes si je t'envoie L"ea tu peu le modifie parce que sa ne fonctionne pas donne moi ton adresse mail stp
Re: Recherche code pour mon Ea
madjes a écrit :Alors dans le code de crazy j'ai ajouté 2 variables que tu peux régler via mt4 au début du codeEt j'ai ajouté le filtre pour l'heure juste après la fonction start(), ce qui peut-être un problème pour la gestion de la sortie du trade. Mais j'avais pas envie de tout lire le code, c'était pour l'exempleCode : Tout sélectionner
extern int HeureDebut=8; extern int HeureFin=20;
Code : Tout sélectionner
//+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { Que veut dire extern et int? C'est une question de newbie? J ai des connaissance de base en sql, pour info. if( Hour()>=HeureDebut && hour()<HeureFin ) { .... }
Re: Recherche code pour mon Ea
Sa ne marche pas desoler
- Fabien LABROUSSE
- Administrateur
- Messages : 17014
- Inscription : 17 mars 2008, 19:41
- Localisation : Paris, France
Re: Recherche code pour mon Ea
Merci de partager l'expert sur le forum.crazy95 a écrit :madjes si je t'envoie L"ea tu peu le modifie parce que sa ne fonctionne pas donne moi ton adresse mail stp
Sinon ça revient à prendre uniquement sans donné (tu me suis?).
Voici le code que j'utilise pour ajouter un filtre horaire à un expert advisor:
Dans les paramètres externes:
Code : Tout sélectionner
extern int StartTime = 0;
extern int EndTime = 24;
Code : Tout sélectionner
int TradeSession() {
if (StartTime < EndTime && TimeHour(TimeCurrent()) < StartTime || TimeHour(TimeCurrent()) >= EndTime) return (0);
if (StartTime > EndTime && (TimeHour(TimeCurrent()) < StartTime && TimeHour(TimeCurrent()) >= EndTime)) return (0);
if (EndTime == 0) EndTime = 24;
if (Hour() == EndTime - 1 && Minute() >= 55) return (0);
return (1);
}
Par exemple:
Code : Tout sélectionner
if (MyOrdersTotal(Magic)==0 && TradeSession() == 1 && StoUnikFranchReb==1 && StoReb==1 && sto<StoNiveauHausseReb && sto1>StoNiveauHausseReb && close<sma&& StoReb==0)
{
OrderSend(Symbol(),OP_SELL,FirstLot,Bid,Slippage,0,0,comment,Magic,0,Red);
}
La Structure (par VideoBourse) : Formation sur mesure et évolutive pour optimiser compréhension et résultats en trading
Informations et inscriptions : https://forms.gle/A2vnZduSwv2wPFSS7
Contact et échanges avec la communauté : Discord, mail, téléphone, LinkedIn...
Marchés en aparté : Témoignages de traders, investisseurs, analystes et économistes sur les marchés financiers
Re: Recherche code pour mon Ea
extern sert à déclarer une variable qui sera modifiable en externe, c'est à dire quand t'ajoutes un indicateur ou un ea, il y a toujours une boite de dialogue qui s'ouvre et qui te demande de parametttrer ton indic, bein extern ça sert à ça.4b4z a écrit :madjes a écrit :Alors dans le code de crazy j'ai ajouté 2 variables que tu peux régler via mt4 au début du codeEt j'ai ajouté le filtre pour l'heure juste après la fonction start(), ce qui peut-être un problème pour la gestion de la sortie du trade. Mais j'avais pas envie de tout lire le code, c'était pour l'exempleCode : Tout sélectionner
extern int HeureDebut=8; extern int HeureFin=20;
Code : Tout sélectionner
//+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { Que veut dire extern et int? C'est une question de newbie? J ai des connaissance de base en sql, pour info. if( Hour()>=HeureDebut && hour()<HeureFin ) { .... }
"int" indique que ta variable doit être un nombre entier, tu peux changer "int" par "double" si tu veux déclarer un nombre décimal à la place, ou par "string" si tu veux déclarer une chaine de caractère
Re: Recherche code pour mon Ea
Merci fab je teste actuellement en réel donc apres je partage .
Pour le bout de code ce soir a voir si sa fonctionne.
Pour le bout de code ce soir a voir si sa fonctionne.
- Fabien LABROUSSE
- Administrateur
- Messages : 17014
- Inscription : 17 mars 2008, 19:41
- Localisation : Paris, France
Re: Recherche code pour mon Ea
D'ailleurs je comprend pas pourquoi ils ont fait une classe spéciale pour les nombres entiers, vu que ceux sont aussi des décimaux?jahben974 a écrit :"int" indique que ta variable doit être un nombre entier, tu peux changer "int" par "double" si tu veux déclarer un nombre décimal à la place, ou par "string" si tu veux déclarer une chaine de caractère
Peut-être est-ce pour empêcher l'utilisateur de pouvoir mettre des valeurs qui ne seraient pas valides?
Coolcrazy95 a écrit :Merci fab je teste actuellement en réel donc apres je partage .
La Structure (par VideoBourse) : Formation sur mesure et évolutive pour optimiser compréhension et résultats en trading
Informations et inscriptions : https://forms.gle/A2vnZduSwv2wPFSS7
Contact et échanges avec la communauté : Discord, mail, téléphone, LinkedIn...
Marchés en aparté : Témoignages de traders, investisseurs, analystes et économistes sur les marchés financiers
Re: Recherche code pour mon Ea
Salut,dreamfab a écrit :D'ailleurs je comprend pas pourquoi ils ont fait une classe spéciale pour les nombres entiers, vu que ceux sont aussi des décimaux?jahben974 a écrit :"int" indique que ta variable doit être un nombre entier, tu peux changer "int" par "double" si tu veux déclarer un nombre décimal à la place, ou par "string" si tu veux déclarer une chaine de caractère
Peut-être est-ce pour empêcher l'utilisateur de pouvoir mettre des valeurs qui ne seraient pas valides?
en fait c'est pour économiser la memoire vive de l'ordinateur, enfin c'était il y a longtemps cette histoire de mémoire, maintenant les machines sont assez puissant il n'y a plus vraiment de problème de ce coté là
Re: Recherche code pour mon Ea
Pourquoi quand je teste L'EA en expert consultant il Trade tout le temps alors que j'ai sélectionner 20 heure à 24h
- Fabien LABROUSSE
- Administrateur
- Messages : 17014
- Inscription : 17 mars 2008, 19:41
- Localisation : Paris, France
Re: Recherche code pour mon Ea
Merci pour l'explication.jahben974 a écrit :Salut,
en fait c'est pour économiser la memoire vive de l'ordinateur, enfin c'était il y a longtemps cette histoire de mémoire, maintenant les machines sont assez puissant il n'y a plus vraiment de problème de ce coté là
Quel code utilises-tu?crazy95 a écrit :Pourquoi quand je teste L'EA en expert consultant il Trade tout le temps alors que j'ai sélectionner 20 heure à 24h
La Structure (par VideoBourse) : Formation sur mesure et évolutive pour optimiser compréhension et résultats en trading
Informations et inscriptions : https://forms.gle/A2vnZduSwv2wPFSS7
Contact et échanges avec la communauté : Discord, mail, téléphone, LinkedIn...
Marchés en aparté : Témoignages de traders, investisseurs, analystes et économistes sur les marchés financiers