The following is a description of the MQL source code items checking conducted at GogoJungle.
Please use this as a checklist when you register your EA for sale.
—.
The EA check process is as follows:
Please note that this check does not guarantee the performance of the EA.
The source code (mq4):
This section describes specific source code checks (mq4).
[Example
extern int MagicNumber = 123456;
input int MAGIC = 123456;
extern
or input
to check)OrdersTotal
)[Example.
//-------- entering a new position --------
// Count the number of positions
for(i=OrdersTotal()-1; i>=0; i--)
{
// Select orders (if an error occurs, break out of the loop)
if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false)
{
Print("OrderSelect returned the error of ", GetLastError() );
break; }
}
// Order confirmation (if the currency pair does not match, return to the beginning of the for statement)
if (OrderSymbol() ! = Symbol()) continue; }
//Confirm magic number (if the magic number does not match, return to the top of the for statement)
if (OrderMagicNumber() ! = MagicNumber) continue; if (OrderMagicNumber() !
if (OrderType() == OP_BUY)
{
CountBuy = CountBuy + 1; }
}
if (OrderType() == OP_SELL)
{
CountSell = CountSell + 1; }
}
}
OrderSend
).[Example
if (countbuy<MaxPos) {
int ticket = -1;
ticket=OrderSend(NULL,OP_BUY,lot,Ask,Slippage,0,0,Com,MagicNumber,0,Blue);
[Example.
OrderSend(NULL,OP_BUY,lot,Ask,Slippage,0,0,Com,MagicNumber",0,Blue);
[Example.
OrderSend(NULL,OP_BUY,lot,Ask,Slippage,0,0,Com,MagicNumber",0,Blue);
Symbol()
or NULL
.USDJPYm
, USDJPY_
or other characters depending on the broker are taken into account)[Example
OrderSend("Symbol()",OP_BUY,lot,Ask,Slippage,0,0,Com,MagicNumber,0,Blue);
OrderClose
to confirm)The following is an invalid example because if OrderModify fails, SL and TP will never be set again
[NG Example.
if( EntryPosition == 1 ) //Entry condition for buy.
{
res=OrderSend(Symbol(),OP_BUY,Lots ,Ask,SLP,0,0, "TrendLogic",MAGIC,0,Red);
if (OrderSelect(res,SELECT_BY_TICKET)==true)
{
if (Buy_stoploss!=0) SL=OrderOpenPrice()-Buy_stoploss*AdjustPoint(Symbol());
if (Buy_takeprofit!=0) TP=OrderOpenPrice()+Buy_takeprofit*AdjustPoint(Symbol());
}
Modified=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,0,Red); }
}
else if(EntryPosition == -1 ) //---- SellEntry
{
res=OrderSend(Symbol(),OP_SELL,Lots,Bid,SLP,0,0, "TrendLogic",MAGIC,0,White); }
if(OrderSelect(res,SELECT_BY_TICKET)==true)
{
if(Sell_stoploss!=0) SL=OrderOpenPrice()+Sell_stoploss*AdjustPoint(Symbol());
if(Sell_takeprofit!=0) TP=OrderOpenPrice()-Sell_takeprofit*AdjustPoint(Symbol());
}
Modified=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,0,White); }
}
The following is a way to force sl,tp to be set at the time of order
[Before modification
ticket=OrderSend(symbol,OP_BUY,Lots,Ask,Slippage,0,0,NULL,MagicNumber,0,Blue);
if(ticket>=0)
if(OrderModify(ticket,OrderOpenPrice(),sl,tp,0))
{
lastTime=now;
entry_cnt++;
}
[After modification
ticket=OrderSend(symbol,OP_BUY,Lots,Ask,Slippage,sl,tp,NULL,MagicNumber,0,Blue);
if(ticket>=0)
{
lastTime=now;
entry_cnt++;
}
[Example.
for( i=OrdersTotal()-1; i>=0; i-- ){
if( OrderSelect(i, SELECT_BY_POS) == true ){
if( OrderType() == OP_BUY && OrderMagicNumber() == Magic && OrderSymbol() == Symbol() ){
if( ! (OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),Slippage,Green)){
The following is invalid because of the pattern of ticket change at the time of settlement
for( i=OrdersTotal()-1; i>=0; i-- ){
if( OrderSelect(i, SELECT_BY_POS) == true ){
if( OrderType() == OP_BUY && OrderMagicNumber() == Magic && OrderSymbol() == Symbol() ){
OrderTicketChange();.
if( ! (OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),Slippage,Green)){
void OrderTicketChange()
{
OrderSelect(3, SELECT_BY_POS); }
}
If infinite loop processing is used, it is NG.
[Example.
bool closePosition(int magic, int type = -1) //function to process settlement.
{
int result_count = 0; //number of attempts
int close_signal = 0; //0 means success, non-zero means failure
if(IsTradeAllowed() == true) {
for(int i = OrdersTotal() - 1; i >= 0; i--) {
if(OrderSelect(i, SELECT_BY_POS) == false) continue;
if(OrderSymbol() ! = Symbol() || OrderMagicNumber() ! = magic) continue; if(type >= 0 &&
if(type >= 0 && OrderType() ! = type) continue; if(OrderType() !
RefreshRates(); if(OrderClose(OrderType() !
if(OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, ArrowColor[OrderType()]) == true) {
continue; //first close process (usually succeeds here)
}else{ //processing in case of settlement failure from here
result_count = 0; for(int j = 0; j = 0; j = 0; j = 0; j = 0
for(int j = 0; j < RETRY_COUNT; j++) { //repeat processing until retry count is reached
Sleep(200);
if(OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, ArrowColor[OrderType()]) == true) {
break; //exit from the loop if successful
}else{ //in case of failure
int err = GetLastError();
if(err > 0){
result_count++; //increase the counter for the number of failures
Print("[OrderClose Error] : ", err, " ", ErrorDescription(err)); }
}
}
if(result_count == RETRY_COUNT) { //when the counter reaches the specified number of attempts
close_signal++; //signal settlement failure
}
}
}
}
if(close_signal == 0) return(true); //exit the function because of success
Alert("[OrderClose Error] : Close timeout. Check the experts log."); //Timeout error on failure
}
return(false); //Alert and exit the function.
}
It is invalid if variables used for settlement conditions are initialized upon restart.
while
must not result in an infinite loop (error handling patterns must be covered).[Good example: Timeout handling is described.
while(true)
{
int hoge; //variable that becomes 1 when processing is successful
//**** where processing such as settlement***//
if(hoge) return(true);
// timeout processing
if (GetTickCount() - StartTime > 10 * 1000)
{
Alert("OrderSend timeout. Check the experts log."); { return(-1); }
return(-1); }
}
[Bad example: timeout processing is not described.
while(true)
{
int hoge; //variable that becomes 1 if processing is successful
//**** where processing such as settlement***//
if(hoge) return(true); }
}
[Other examples of loop escaping
// If the error is not resolved by retrying, escape the loop
if(err == ERR_INVALID_PRICE) break; }
if(err == ERR_INVALID_STOPS) break;
if(err == ERR_LONGS_NOT_ALLOWED) break; break
if(err == ERR_SHORTS_NOT_ALLOWED) break; if(err == ERR_SHORTS_NOT_ALLOWED) break;
if(err == ERR_NOT_ENOUGH_MONEY) break; break
if(err == ERR_TRADE_TOO_MANY_ORDERS) break; if(err == ERR_TRADE_TOO_MANY_ORDERS)
[invalid Example: Specifying a brokerage firm (Gaitame)
int OnInit()
{
if(IsTradeAllowed() == false) {
Alert("Enable the setting 'Allow live trading' in the Expert Properties!"); }
}
if(StringFind(TerminalInfoString(TERMINAL_COMPANY), "Gaitame") == -1) return(INIT_FAILED); //If the brokerage is not "Gaitame", initialization will fail
magic_array[0] = Magic1;
bars1 = getBars(Magic1);
return(INIT_SUCCEEDED); }
}
http
to check)hst
,dll
)GlobalVariableSet
, GlobalVariableGet
) are not used.Example: In the case of product ID 12345, product name GogoJungleEA
int ticket = OrderSend( ①, ②, ③, ④, ⑤, ⑥, ⑦, "12345:GogoJungle_EA", ⑨, ⑩, ⑪);
[Example
double Gda_280[30];
int G_digits_192=0;
double G_point_196=0.0;
int Gi_204;
double Gd_208;
double Gd_216; double
double Gd_224; double Gd_224;.
[Example
int 2516972921474835825095 ;
int 919926175214748358129332 ;
int OnInit()
{
158651616521474836452710 = 945331452214748360523750 (); int
1821361779214748361111350 ( 158651616521474836452710 );
[Example.
//#include <MT4params.mqh>
//#include <MT4License_1.mqh>
//int group_no = 11,group,a1=1; //group number 0:not used
//bool PC_Check = true; // true: do PC binding false: don't do it
//datetime PrevTime;
//string ServerURL0 = "http://reapseven.xsrv.jp/license";
//string ServerURL = "http://fxea.xsrv.jp/license"; //server URL
//string ServerURL2 = "http://fxea.xsrv.jp/license"; //string
//int stp=-1;
//#import "shell32.dll"
//int ShellExecuteW(int hWnd, int lpVerb, string lpFile, string lpParameters, string lpDirectory, int nCmdShow);
//#import
//string DataPath = TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\Libraries";
If 1: ORDER_FILLING_FOK * Default
If 2: ORDER_FILLING_IOC
[Example
int FillingMode=(int)SymbolInfoInteger(_Symbol,SYMBOL_FILLING_MODE);
if(FillingMode == 2){
request.type_filling = ORDER_FILLING_IOC;
}
PositionsTotal
).[Example
int pos = 0;.
int posTotal=PositionsTotal();
for( int posIndex=0; posIndex<posTotal; posIndex++ )
{
const ulong ticket=PositionGetTicket(posIndex);
if(PositionSelectByTicket(ticket) &&
PositionGetString(POSITION_SYMBOL)==_Symbol &&
PositionGetInteger(POSITION_MAGIC)==Magic_Number)
{
pos++; }
}
}
}
[Example
input int Magic_Number;
MqlTradeRequest request;
MqlTradeResult result;
request.action = TRADE_ACTION_DEAL;
request.magic = Magic_Number;
request.symbol = _Symbol;
request.volume = 0.1;
request.sl = stoploss;
request.tp = takeprofit;
request.position = 0;
OrderSend(request,result);
[Example
int posTotal=PositionsTotal();
for( int posIndex=0; posIndex<posTotal; posIndex++ )
{
const ulong ticket=PositionGetTicket(posIndex);
if(PositionSelectByTicket(ticket) &&
PositionGetString(POSITION_SYMBOL)==_Symbol &&
PositionGetInteger(POSITION_MAGIC)==Magic_Number)
{
MqlTradeRequest request request; MqlTradeResult result
MqlTradeResult result;
request.action = TRADE_ACTION_DEAL;
request.magic = Magic_Number;
request.symbol = _Symbol;
request.volume = 0.1;
request.sl = 0;
request.tp = 0;
request.position = ticket;
OrderSend(request,result);
}
}
}
GogoJungle performs the above source checks on all EAs.
Please report any operational problems or new information to us.
We will update the checked items as needed based on your reports.
We look forward to receiving your EAs.
検索結果がありません。 |
検索結果がありません。 |