SCAMMER -
Here is the code sent to me by the originator of this thread:
//±-----------------------------------------------------------------+
//| MT4 Version |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |
//±-----------------------------------------------------------------+
extern double TakeProfit = 50;
extern double Lots = 1;
extern double TrailingStop = 30;
extern double MACDOpenLevel=3;
extern double MACDCloseLevel=2;
extern double MATrendPeriod=26;
//±-----------------------------------------------------------------+
//| |
//±-----------------------------------------------------------------+
int start()
{
double MacdCurrent, MacdPrevious, SignalCurrent;
double SignalPrevious, MaCurrent, MaPrevious;
int cnt, ticket, total;
// initial data checks
// it is important to make sure that the expert works with a normal
// chart and the user did not make any mistakes setting external
// variables (Lots, StopLoss, TakeProfit,
// TrailingStop) in our case, we check TakeProfit
// on a chart of less than 100 bars
if(Bars<100)
{
Print(“bars less than 100”);
return(0);
}
if(TakeProfit<10)
{
Print(“TakeProfit less than 10”);
return(0); // check TakeProfit
}
// to simplify the coding and speed up access
// data are put into internal variables
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1);
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1000Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
MathAbs(MacdCurrent)>(MACDOpenLevelPoint) && MaCurrent>MaPrevious)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfitPoint,“macd sample”,16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
// check for short position (SELL) possibility
if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
MacdCurrent>(MACDOpenLevelPoint) && MaCurrent<MaPrevious)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfitPoint,“macd sample”,16384,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
// it is important to enter the market correctly,
// but it is more important to exit it correctly…
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
MacdCurrent>(MACDCloseLevelPoint))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
return(0); // exit
}
// check for trailing stop
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>PointTrailingStop)
{
if(OrderStopLoss()<Bid-PointTrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-PointTrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
}
else // go to short position
{
// should it be closed?
if(MacdCurrent<0 && MacdCurrent>SignalCurrent &&
MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevelPoint))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
return(0); // exit
}
// check for trailing stop
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(PointTrailingStop))
{
if((OrderStopLoss()>(Ask+PointTrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
return(0);
}
// the end.
Here is the code found on docs.mql4dotcom - - and this person is trying to pass it off as his/her own and is simply stating when you make some money from it send some to me!
//±-----------------------------------------------------------------+
//| MACD Sample.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |
//±-----------------------------------------------------------------+
extern double TakeProfit = 50;
extern double Lots = 0.1;
extern double TrailingStop = 30;
extern double MACDOpenLevel=3;
extern double MACDCloseLevel=2;
extern double MATrendPeriod=26;
double Points;
//±-----------------------------------------------------------------+
//| |
//±-----------------------------------------------------------------+
int init ()
{
Points = MarketInfo (Symbol(), MODE_POINT);
//----
return(0);
}
//±-----------------------------------------------------------------+
//| |
//±-----------------------------------------------------------------+
int deinit()
{
return(0);
}
//±-----------------------------------------------------------------+
//| |
//±-----------------------------------------------------------------+
int start()
{
double MacdCurrent=0, MacdPrevious=0, SignalCurrent=0;
double SignalPrevious=0, MaCurrent=0, MaPrevious=0;
int cnt=0, total;
// ïåðâè÷íûå ïðîâåðêè äàííûõ
// âàæíî óäîñòîâåðèòüñÿ ÷òî ýêñïåðò ðàáîòàåò íà íîðìàëüíîì ãðàôèêå è
// ïîëüçîâàòåëü ïðàâèëüíî âûñòàâèë âíåøíèå ïåðåìåííûå (Lots, StopLoss,
// TakeProfit, TrailingStop)
// â íàøåì ñëó÷àå ïðîâåðÿåì òîëüêî TakeProfit
if(Bars<100)
{
Print(“bars less than 100”);
return(0); // íà ãðàôèêå ìåíåå 100 áàðîâ
}
if(TakeProfit<10)
{
Print(“TakeProfit less than 10”);
return(0); // ïðîâåðÿåì TakeProfit
}
// ðàäè óïðîùåíèÿ è óñêîðåíèÿ êîäà, ñîõðàíèì íåîáõîäèìûå
// äàííûå èíäèêàòîðîâ âî âðåìåííûõ ïåðåìåííûõ
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,MODE_EMA,0,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,MODE_EMA,0,PRICE_CLOSE,1);
// òåïåðü íàäî îïðåäåëèòüñÿ - â êàêîì ñîñòîÿíèè òîðãîâûé òåðìèíàë?
// ïðîâåðèì, åñòü ëè ðàíåå îòêðûòûå ïîçèöèè èëè îðäåðû?
if(OrdersTotal()<1)
{
// íåò íè îäíîãî îòêðûòîãî îðäåðà
// íà âñÿêèé ñëó÷àé ïðîâåðèì, åñëè ó íàñ ñâîáîäíûå äåíüãè íà ñ÷åòó?
// çíà÷åíèå 1000 âçÿòî äëÿ ïðèìåðà, îáû÷íî ìîæíî îòêðûòü 1 ëîò
if(AccountFreeMargin()<(1000Lots))
{
Print(“We have no money”);
return(0); // äåíåã íåò - âûõîäèì
}
// ïðîâåðèì, íå ñëèøêîì ëè ÷àñòî ïûòàåìñÿ îòêðûòüñÿ?
// åñëè ïîñëåäíèé ðàç òîðãîâàëè ìåíåå ÷åì 5 ìèíóò(560=300 ñåê)
// íàçàä, òî âûõîäèì
// If((CurTime-LastTradeTime)<300) { Exit }
// ïðîâåðÿåì íà âîçìîæíîñòü âñòàòü â äëèííóþ ïîçèöèþ (BUY)
if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
MathAbs(MacdCurrent)>(MACDOpenLevelPoints) && MaCurrent>MaPrevious)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfitPoints,“macd sample”,16384,0,Red); // èñïîëíÿåì
if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
return(0); // âûõîäèì, òàê êàê âñå ðàâíî ïîñëå ñîâåðøåíèÿ òîðãîâîé îïåðàöèè
// íàñòóïèë 10-òè ñåêóíäíûé òàéìàóò íà ñîâåðøåíèå òîðãîâûõ îïåðàöèé
}
// ïðîâåðÿåì íà âîçìîæíîñòü âñòàòü â êîðîòêóþ ïîçèöèþ (SELL)
if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
MacdCurrent>(MACDOpenLevelPoints) && MaCurrent<MaPrevious)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfitPoints,“macd sample”,16384,0,Red); // èñïîëíÿåì
if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
return(0); // âûõîäèì
};
// çäåñü ìû çàâåðøèëè ïðîâåðêó íà âîçìîæíîñòü îòêðûòèÿ íîâûõ ïîçèöèé.
// íîâûå ïîçèöèè îòêðûòû íå áûëè è ïðîñòî âûõîäèì ïî Exit, òàê êàê
// âñå ðàâíî àíàëèçèðîâàòü íå÷åãî
return(0);
};
// ïåðåõîäèì ê âàæíîé ÷àñòè ýêñïåðòà - êîíòðîëþ îòêðûòûõ ïîçèöèé
// 'âàæíî ïðàâèëüíî âîéòè â ðûíîê, íî âûéòè - åùå âàæíåå…'
total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // ýòî îòêðûòàÿ ïîçèöèÿ? OP_BUY èëè OP_SELL
OrderSymbol()==Symbol()) // èíñòðóìåíò ñîâïàäàåò?
{
if(OrderType()==OP_BUY) // îòêðûòà äëèííàÿ ïîçèöèÿ
{
// ïðîâåðèì, ìîæåò óæå ïîðà çàêðûâàòüñÿ?
if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
MacdCurrent>(MACDCloseLevelPoints))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // çàêðûâàåì ïîçèöèþ
return(0); // âûõîäèì
};
// ïðîâåðèì - ìîæåò ìîæíî/íóæíî óæå òðåéëèíã ñòîï ñòàâèòü?
if(TrailingStop>0) // ïîëüçîâàòåëü âûñòàâèë â íàñòðîéêàõ òðåéëèíãñòîï
{ // çíà÷èò ìû èäåì åãî ïðîâåðÿòü
if(Bid-OrderOpenPrice()>PointsTrailingStop)
{
if(OrderStopLoss()<Bid-PointsTrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-PointsTrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
else // èíà÷å ýòî êîðîòêàÿ ïîçèöèÿ
{
// ïðîâåðèì, ìîæåò óæå ïîðà çàêðûâàòüñÿ?
if(MacdCurrent<0 && MacdCurrent>SignalCurrent &&
MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevelPoints))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // çàêðûâàåì ïîçèöèþ
return(0); // âûõîäèì
}
// ïðîâåðèì - ìîæåò ìîæíî/íóæíî óæå òðåéëèíã ñòîï ñòàâèòü?
if(TrailingStop>0) // ïîëüçîâàòåëü âûñòàâèë â íàñòðîéêàõ òðåéëèíãñòîï
{ // çíà÷èò ìû èäåì åãî ïðîâåðÿòü
if((OrderOpenPrice()-Ask)>(PointsTrailingStop))
{
if(OrderStopLoss()==0.0 ||
OrderStopLoss()>(Ask+PointsTrailingStop))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+PointsTrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
return(0);
}
// the end.
I did email this person in private - but I cannot let this go out to the public without at least informing you of what is going on.
Just compare the code - the first lines alone will tell you this is pirated code –
Babypips please close this thread. and take appropriate action on the originator.