![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 using Semafor ZZ indicator
Hi,
I have written an EA using MACD and 3_Level_Semafor_ZZ indicators. My EA covers all the 24 pairs and 4 timeframes -- M15, H1, H4 and daily charts. Before adding the 3_Level_semafor_ZZ indicator, the running of my EA is good. After adding the semafor indicator, the entire system slows down drastically. I use iCustomr to access the value of the indicator for every tick that comes in. When I click on the Experts tab, I see repeating messages on 3_Level_Semafor_ZZ being initialized, deinitialized, then removed for the 4 timeframes for EACH of the 24 pairs. I guess that is the reason of slowing down the entire system.
My questions are,
1. I also access MACD value for every tick using iCustom too, but I don't see messages on MACD being initialized and deinitialized and removed for the 4 time frames on every pair. Why is 3_Level_Semafor_ZZ indicator has to be initialized and deinitialized for every time frame while other indicators such as MACD, MA are not ?
2. Does it mean that I have to drop this indicator in order to address the performance issue?
Thanks....
Novalight
Need help for Expert Advisor Programming Issue
Hi, I'm a new expert advisor programmer and I have issue with my new expert advisor!
I used SUFX Expert Advisor Builder to build this basic Expert and the only thing that I whant him to do is to open a position when my custom Indicator draw an arrow. A long position when I get an upTrend Arrow and a short position when I get a downTrend Arrow!
Thank you for your help!
Gabriel
My indicator (In search of solution I've added a third Buffer in my indicator : TrendSignal):
/////////////////////
//Indicator property
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Blue
double Uptrend[];
double Downtrend[];
double TrendSignal[];
//--------------
//Arrows indicators init
int init()
{ SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
SetIndexArrow(0, 236);
SetIndexBuffer(0, Uptrend);
SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
SetIndexArrow(1, 238);
SetIndexBuffer(1, Downtrend);
SetIndexStyle(2, DRAW_NONE, EMPTY, EMPTY);
SetIndexBuffer(2, TrendSignal);
return(0);}
//--------------
//Indicators functions
int start()
{ int Limit, I, Counter;
double SlowerEMAprevious, SlowerEMAcurrent;
double FasterEMAprevious, FasterEMAcurrent;
double IntegerMACDbase, IntegerMACDsignal;
double IntegerMACDprevious, IntegerMACDfuture;
double IntegerLGprevious, IntegerLGcurrent, IntegerLGfuture;
double IntegerLGvar1, IntegerLGvar2, IntegerMACDvar1;
double Range, AvgRange;
int Counted_Bars = IndicatorCounted();
//--------------
//Error Check
if(Counted_Bars < 0) return (-1);
if(Counted_Bars > 0) Counted_Bars--;
Limit=Bars-Counted_Bars;
//--------------
//Active state loop
for(I = 0; I <= Limit; I++)
{ Counter = I;
Range = 0;
AvgRange = 0;
for (Counter=I; Counter <= I+9; Counter++)
{ AvgRange = AvgRange + MathAbs(High[Counter] - Low[Counter]);}
Range = AvgRange/10;
//////
SlowerEMAprevious = iCustom(NULL, 0, "MAVCUSTOM", 8, 0, MODE_EMA, PRICE_CLOSE, I+2);
SlowerEMAcurrent = iCustom(NULL, 0, "MAVCUSTOM", 8, 0, MODE_EMA, PRICE_CLOSE, I );
FasterEMAprevious = iCustom(NULL, 0, "MAVCUSTOM", 4, 0, MODE_EMA, PRICE_CLOSE, I+2);
FasterEMAcurrent = iCustom(NULL, 0, "MAVCUSTOM", 4, 0, MODE_EMA, PRICE_CLOSE, I );
///
IntegerMACDprevious = iCustom(NULL, 0, "MACDCUSTOM", 5, 35, 5, PRICE_CLOSE, MODE_BASE, I+2);
IntegerMACDbase = iCustom(NULL, 0, "MACDCUSTOM", 5, 35, 5, PRICE_CLOSE, MODE_BASE, I );
IntegerMACDsignal = iCustom(NULL, 0, "MACDCUSTOM", 5, 35, 5, PRICE_CLOSE, MODE_SIGNAL, I );
IntegerMACDfuture = iCustom(NULL, 0, "MACDCUSTOM", 5, 35, 5, PRICE_CLOSE, MODE_BASE, I-2);
IntegerMACDvar1 = 0;
///
IntegerLGprevious = iCustom(NULL, 0, "LaGuerreCUSTOM", 0.66, 950, 0, I+2);
IntegerLGcurrent = iCustom(NULL, 0, "LaGuerreCUSTOM", 0.66, 950, 0, I );
IntegerLGfuture = iCustom(NULL, 0, "LaGuerreCUSTOM", 0.66, 950, 0, I-2);
IntegerLGvar1 = 0.20;
IntegerLGvar2 = 0.80;
//////
if ((IntegerLGprevious IntegerLGvar1) &&
(IntegerLGprevious IntegerLGcurrent) &&
(IntegerMACDbase > IntegerMACDsignal) && (IntegerMACDfuture > IntegerMACDbase) )
{Uptrend = Low - Range*0.5;
TrendSignal = 1.00;}
else if
((IntegerLGprevious > IntegerLGcurrent) && (IntegerLGcurrent < IntegerLGvar2) &&
(IntegerLGprevious > IntegerLGvar2) && (IntegerLGfuture < IntegerLGcurrent) &&
(IntegerMACDbase < IntegerMACDsignal) && (IntegerMACDfuture < IntegerMACDbase) )
{Downtrend = High + Range*0.5;
TrendSignal = 2.00;}}
return(0);}
//--------------
My Expert :
///////////////////////
#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 0.01;
extern int Slippage = 0;
extern bool UseStopLoss = True;
extern int StopLoss = 5000;
extern bool UseTakeProfit = False;
extern int TakeProfit = 0;
extern bool UseTrailingStop = True;
extern int TrailingStop = 100;
int BarCount;
int Current;
bool TickCheck = False;
//Expert Initialisation
int init() {
BarCount = Bars;
if (EachTickMode) Current = 0; else Current = 1;
return(0);}
//Expert Functions
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
//Indicator Variable
double OrderSignal = iCustom(NULL, 0, "TrendFollowCUSTOM", 2, 0);
//Check position
bool IsTrade = False;
for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
IsTrade = True;
if(OrderType() == OP_BUY) {
//Close BUY
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//BUY Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
} else {
//Close SELL
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//SELL Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
}
}
}
//Market Entry Signal
if (OrderSignal == 1.00) Order = SIGNAL_BUY;
if (OrderSignal == 2.00) Order = SIGNAL_SELL;
//Buy Function
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;
Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
//Sell Function
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;
Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else {
Print("Error opening SELL order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
if (!EachTickMode) BarCount = Bars;
return(0);
}trendfollowcustom.mq4test449.mq4
Need Help, EA for the small investor ($ 50)
I implore the help of coding experts to perfect my EA. I designed this EA for the small investor ($ 50). Whosoever there who are willing to help you enhance this EA please send a PM your email and I'll send this EA to your email. Thank you.
RICH EA $$$ Back Testing
Hi,
I found this EA and back tested it and unrealistic profits were produced. I tried to forward test on demo account and no trades opened. Experts tab in MT4 showed error 148. How can this be fixed so that one can forward test this? Is there anybody you can assist?
Really appreciate it and we can see how this trades going forward.
I have attached the EA and a screen shot of the error and back testing chart.![](https://c.mql5.com/forextsd/smiles/shades_smile.png)
...
Most probable cause fr that is line 140 that goes like this :That is probably one of the strangest way to calculate lot size I have ever seen (for example, on a 5000$ account it will try to open an order with 10 lots:)) Replace it with TLots=Lots; and it will use the Lots parameter value for lot size
Hi,
I found this EA and back tested it and unrealistic profits were produced. I tried to forward test on demo account and no trades opened. Experts tab in MT4 showed error 148. How can this be fixed so that one can forward test this? Is there anybody you can assist?
Really appreciate it and we can see how this trades going forward.
I have attached the EA and a screen shot of the error and back testing chart.My Back test EA without SL
I include a back test of EA I start from May 2, 2011 until 30 November 2011. Is there someone who is willing to improve this EA so that more take entry and reduced floating and increased profits earned ? Back test this EA with initial capital of $ 100 and the final $ 2,515.44 which you can change its own capital and its multiplication 0.02 as needed. I'm waiting for PM from you friends who are willing and I expect feedbacknya to me. Sorry not my friend did not want PM to master coding but I am a junior member so I'm not allowed to PM before sending 15 posts. Send me your email please.Thank you
Best Regards
Help with Trend Magic indicator!
I am a FULL dummy in MQL programming. Therefore, I am asking for help from an expert in the latter. There is an indicator called Trend Magic. It draws a line of different colour depending on whether up- or downtrend is taking place. It uses CCI(50) and ATR(5) to calculate a value for line drawing. I need to compare the value of this indicator on bar(-1) (i.e., preceding to the current one) with that of bar(-2). This should be value (price), which is shown under Trend Magic in the Data Window when pointing to the respective bar on the graph.
profitable EA till yet but not taking live trades plz Help
this is good profitable ea but not running on making live trades plz help, here is the link , Multiupload.com - upload your files to multiple file hosting sites!
Fix this EA by codebase
i found an ea that giving good backtest but not making trades on live charts , can you fix this , Thanks in Advance
mtf_rsi_sar.mq4
Breakout EA, exit in several steps
Can anybody help to code the exit?
The rules are:
stop loss is a fixed number of pips (is realised)
take profit:
take profit 1 should be a fixed number of pips and close the half of the open lots. When TP1 ist reached, the stop loss should be set to break even.
take profit 2 should be either a fixed number of pips or should close the trade at a given time (for example at 19:00)
Thanks.