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
EA Comment
Hi
how I can insert the EA_Name in the comment field of the terminal box.
So I see the EA_Name in the AccountHistory also.
I let run a lot of EA's on a live Account with the same lotsize, but I don't know which EA's makes the trades.
Thanks
at the start of the "start" procedure of your EA
Hi
how I can insert the EA_Name in the comment field of the terminal box.
So I see the EA_Name in the AccountHistory also.
I let run a lot of EA's on a live Account with the same lotsize, but I don't know which EA's makes the trades.
ThanksHello everyone.. I have a problem with this ea, it infact opens tons of positions. But the funniest thing is that if i put in the ordersend magicnumber to 0 the problem is gone, but i still need the magicnumber...
#property link ""
#property indicator_separate_window
double Punto;
extern bool DisplayInfo=true;
extern string S1 ="Lotti da aprire, minimo 0.02 ";
extern double BE=15;
extern double Lotti=0.2;
extern string S2 ="Numero posizioni massime. Minimo 2";
extern int NPosMax=2;
static double trl;
extern double StopLoss = 15;
extern double TrailingStop = 7;
static int ticketTL, ticketTL2;
string Cross;
double buffer;
int TF,i;
string cmt;
int New_Bar;
bool NoTradeFlag;
datetime Time_0;
extern int MagicNumber=987569;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
Time_0=Time[0];
// Compatibility wiht 3,4,5 digits prices
if(Digits>=4) Punto = 0.0001;
else Punto = 0.01;
//----Gestione TimeFrame, =1 fino a 4h, =2 oltre
if (Period()<=240) TF=1;
else TF=2;
Cross=Symbol();
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//---Stampa informazioni su CHART
void PrintInfo;
{
bool setupBARb, setupBARs;
string cmt="";
cmt = "========================";
cmt = cmt + "\nAccount Name: [ " + AccountName() + " ]";
cmt = cmt + "\nAccount Leverage: [ " + DoubleToStr( AccountLeverage(), 0 ) + " ]";
cmt = cmt + "\nMin Lot: [ " + DoubleToStr( MarketInfo(Symbol(),MODE_MINLOT), 3 ) + " ]";
cmt = cmt + "\nLot Step: [ " + DoubleToStr( MarketInfo(Symbol(),MODE_LOTSTEP), 3 ) + " ]";
cmt = cmt + "\nCurrent Profit: [ " + DoubleToStr(AccountEquity()-AccountBalance(),2) + " ]";
cmt = cmt + "\nAccount Balance: [ " + DoubleToStr(AccountBalance(),2) + " ]";
cmt = cmt + "\nAccount Equity: [ " + DoubleToStr(AccountEquity(),2) + " ]";
cmt = cmt + "\n========================";
Comment(cmt);
}
//---Indicatori
double Atr=iATR(NULL,0,20,0);
double fastMA=iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0);
double slowMA=iMA(NULL,0,40,0,MODE_SMA,PRICE_CLOSE,0);
double Adx=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,0);
//---Funzione Buffer
if (TF==1) buffer=2*Punto;
else buffer=0.001*Close[0];
//--- verifica la presenza di ordini
int ordtot=OrdersTotal()-1;
for(i=ordtot;i>=0;i--){
OrderSelect(i,SELECT_BY_POS);
//--- c'è un ordine di questo EA
// if(OrderMagicNumber()==MagicNumber && OrderSymbol()==Cross) Gestisci();
}
//--- Se setup bar esiste setupBAR=true, altrimenti false
// setupbar per long
if (Low[1]>fastMA && Low[1]>slowMA && Close[1]>Open[1] && (Close[1]-Low[1])>(High[1]-Low[1])*0.7 && High[1]<High && (Close[1]-Open[1])25)
{setupBARb = true;}
else{setupBARb = false;}
// setupbar per short
if (Low[1]<fastMA && Low[1]<slowMA && Close[1]<Open[1] && (Close[1]-Low[1])Low && (Open[1]-Close[1])25)
{setupBARs = true;}
else setupBARs = false;
//---Funzione prezzo
double prezzo;
if(OrderType()==OP_BUY) prezzo=Ask;
if(OrderType()==OP_SELL) prezzo=Bid;
//--- Controllo numero ordini
double Spread=Ask-Bid;
int ticket;
//---Gestione TrailingStop. La variabile TrailingStop è external. Trailing è il nuovo livello di stoploss per ordini con trailingstop
double TSTP=TrailingStop*Punto;
// double Trailing;
//---Gestione ordini e modifica di trailingstop e targetprofit
int OrdTot=OrdersTotal();
if (setupBARb==true && !New_Bar() && OrdTot<NPosMax)
{
OrderSend(Symbol(),OP_BUY,Lotti/2,prezzo,3,Low[1]-buffer-Spread,prezzo+Atr,"Momentum Method",0,0);
OrderSend(Symbol(),OP_BUY,Lotti/2,prezzo,3,Low[1]-buffer-Spread,0,"Momentum Method",MagicNumber,0);
}
if (setupBARs==true && !New_Bar() && OrdTot<NPosMax)
{
OrderSend(Symbol(),OP_SELL,Lotti/2,prezzo,3,High[1]+buffer+Spread,prezzo-Atr,"Momentum Method",0,0,Green);
OrderSend(Symbol(),OP_SELL,Lotti/2,prezzo,3,High[1]+buffer+Spread,0,"Momentum Method",MagicNumber,0);
}
}//chiusura start
//*** gestisce gli ordini aperti
int Gestisci(){
static double trl;
double przopen= OrderOpenPrice();
double sl= OrderStopLoss();
double tp= OrderTakeProfit();
double lotti= OrderLots();
datetime open=OrderOpenTime();
int periodo= Period();
int shift=iBarShift(NULL,0,OrderOpenTime());
// ordine BUY
if(OrderType()==OP_BUY){
double prezzo=Bid;
// dopo 5 candele chiude l'ordine
if(Time[0]>open+(periodo*60)*4){
if(!OrderClose(OrderTicket(),lotti,prezzo,3,Yellow))
Print("Errore chiusura totale OP_BUY # "+GetLastError());
return(0);
}
// porta l'ordine in breakeven
if(sl<przopen){
if((Bid-przopen)>=BE)
if(!OrderModify(OrderTicket(),przopen,przopen,tp+BE,0))
Print("Errore modifica Breakeven BUY # "+GetLastError());
return(0);
}
// chiude la prima parte dell'ordine
if(lotti==Lotti){
if((tp-BE)<=Bid){
if(!OrderClose(OrderTicket(),lotti/2,prezzo,3,Yellow))
Print("Errore 1^ chiusura OP_BUY # "+GetLastError());
else trl=Bid-TrailingStop;
}
return(0);
}
// gestisce il trailing
if(Bid<=trl){
if(!OrderClose(OrderTicket(),lotti,prezzo,3,Yellow))
Print("Errore 2^ chiusura OP_BUY # "+GetLastError());
}else
if((Bid-TrailingStop)>trl) trl=Bid-TrailingStop;
return(0);
}
// ordine SELL
if(OrderType()==OP_SELL){
prezzo=Ask;
// dopo 5 candele chiude l'ordine
if(Time[0]>open+(periodo*60)*4){
if(!OrderClose(OrderTicket(),lotti,prezzo,3,Yellow))
Print("Errore chiusura totale OP_BUY # "+GetLastError());
return(0);
}
// porta l'ordine in breakeven
if(sl<przopen){
if((przopen-Ask)>=BE)
if(!OrderModify(OrderTicket(),przopen,przopen,tp-BE,0))
Print("Errore modifica Breakeven BUY # "+GetLastError());
return(0);
}
// chiude la prima parte dell'ordine
if(lotti==Lotti){
if((tp-BE)>=Ask){
if(!OrderClose(OrderTicket(),lotti/2,prezzo,3,Yellow))
Print("Errore 1^ chiusura OP_BUY # "+GetLastError());
else trl=Ask-TrailingStop;
}
return(0);
}
// gestisce il trailing
if(Ask>=trl){
if(!OrderClose(OrderTicket(),lotti,prezzo,3,Yellow))
Print("Errore 2^ chiusura OP_BUY # "+GetLastError());
}else
if((Ask-TrailingStop)>trl) trl=Ask-TrailingStop;
return(0);
}
}
//---Controlla se è nata una nuova candela
bool New_Bar(){
if (Time_0 != Time[0])
{
New_Bar = 1;
NoTradeFlag=false;
Time_0 = Time[0];
}
}
Hi Lemming,
Its not an Ea until you remove this
#property indicator_separate_window
your calling it an indicator.
Thanks
Hi Mladen
thanks for your fast respond
Add something like this : at the start of the "start" procedure of your EA
EA_Name in commentfield
Hi Mladen
I have insert the comment line, but no comments in Terminal and History
Here where I insert:
int start() {
Comment("FCM_TEST");
double l_istochastic_4;
double l_istochastic_12;
double l_istochastic_20;
double l_istochastic_28;
if (UseHourTrade) {
if (Hour() >= FromHourTrade && Hour() <= ToHourTrade) Comment("Trading Hours");
else {
Comment("Non-trading Hours");
return (0);
Thanks for help
Add something like this : at the start of the "start" procedure of your EA
To have it in terminal and history you have to use
instead (but be careful since it is going to print it on every tick, so your log file can grow very much). Comment srites out only on screen, nowhere else
Hi Mladen
I have insert the comment line, but no comments in Terminal and History
Here where I insert:
int start() {
Comment("FCM_TEST");
double l_istochastic_4;
double l_istochastic_12;
double l_istochastic_20;
double l_istochastic_28;
if (UseHourTrade) {
if (Hour() >= FromHourTrade && Hour() <= ToHourTrade) Comment("Trading Hours");
else {
Comment("Non-trading Hours");
return (0);
Thanks for helpNo Success
Hi Mladen
you are right: EA is printing every tick in the Expert Tab.
I see the comment in the Expert Tab, but not in the Terminal and History
Other Ideas ?
Thanks for your help
To have it in terminal and history you have to use instead (but be careful since it is going to print it on every tick, so your log file can grow very much). Comment srites out only on screen, nowhere else
That way it will print it only on a first tick of a new bar, and not on every tick
Hi Mladen
you are right: EA is printing every tick in the Expert Tab.
I see the comment in the Expert Tab, but not in the Terminal and History
Other Ideas ?
Thanks for your helpHi Mladen
I think with the print command the output will be in the expert folder too, and not in the comment field of the terminal how I wish. Right ?
Try something like this: That way it will print it only on a first tick of a new bar, and not on every tick
Yes. you are right.
If I understood you correctly, you wanted it to be visible in experts tab and log file. If you want it in experts tab an log file you have to use Print(). If showing it on screen only is enough, then Comment() should be used, and then you should use it on every tick (in case if some other code is writing out a comment, your comment line will be lost). If you want them on both places (screen and experts tab/log file) then you have ti use both commands (there is no single command that will do that)
Hi Mladen I think with the print command the output will be in the expert folder too, and not in the comment field of the terminal how I wish. Right ?