My EA returns an error when registering a new product:
test on EURUSD,H1 (netting) 2020.04.15 15:47:05 failed modify #44 sell 0.2 EURUSD sl: 1.08929, tp: 1.08599 -> sl: 1.08919, tp: 1.08599 [Modification failed due to order or position being close to market]
But my EA is meant to run on WIN$, not forex. Why doesn't the tester let you know which asset to run?
Now how can I correct something that has no error, because the EA is running perfectly, I just can't register the product for sale.
My EA returns an error when registering a new product:
test on EURUSD,H1 (netting) 2020.04.15 15:47:05 failed modify #44 sell 0.2 EURUSD sl: 1.08929, tp: 1.08599 -> sl: 1.08919, tp: 1.08599 [Modification failed due to order or position being close to market]
But my EA is meant to run on WIN$, not forex. Why doesn't the tester let you know which asset to run?
Now how can I correct something that has no error, because the EA is running perfectly, I just can't register the product for sale.
The robot must be prepared to work on any asset....
To correct the error mentioned above, you must carry out the check below before modifying the position:
//+--------------------------------------------------------------------------------------------------------------------+//| Checks if the distance between the TakeProfit/StopLoss and the closing price is greater than SYMBOL_TRADE_STOPS_LEVEL |//+--------------------------------------------------------------------------------------------------------------------+bool Check_SL_TP(ENUM_ORDER_TYPE type, double SL, double TP)
{
//--- Local variablesbool SL_check = false, TP_check = false;
//--- Determines last price for current symboldouble BID = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double ASK = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
//--- get the SYMBOL_TRADE_STOPS_LEVEL levelint stops_level = (int)SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL);
if(stops_level != 0)
{
PrintFormat("SYMBOL_TRADE_STOPS_LEVEL=%d: StopLoss and TakeProfit must not be nearer than %d points from the closing price", stops_level, stops_level);
}
//--- check only two order typesswitch(type)
{
//--- Buy operationcaseORDER_TYPE_BUY:
{
//--- check the StopLoss
SL_check = (BID - SL > stops_level * _Point);
if(!SL_check)
{
ERRMSG = StringFormat("For order %s StopLoss=%.5f must be less than %.5f (Bid=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)", EnumToString(type), SL, BID - stops_level * _Point, BID, stops_level);
}
//--- check the TakeProfit
TP_check = (TP - BID > stops_level * _Point);
if(!TP_check)
{
ERRMSG = StringFormat("For order %s TakeProfit=%.5f must be greater than %.5f (Bid=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)", EnumToString(type), TP, BID + stops_level * _Point, BID, stops_level);
}
//--- return the result of checkingreturn(SL_check && TP_check);
}
//--- Sell operationcaseORDER_TYPE_SELL:
{
//--- check the StopLoss
SL_check = (SL - ASK > stops_level * _Point);
if(!SL_check)
{
ERRMSG = StringFormat("For order %s StopLoss=%.5f must be greater than %.5f (Ask=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)", EnumToString(type), SL, ASK + stops_level * _Point, ASK, stops_level);
}
//--- check the TakeProfit
TP_check = (ASK - TP > stops_level * _Point);
if(!TP_check)
{
ERRMSG = StringFormat("For order %s TakeProfit=%.5f must be less than %.5f (Ask=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)", EnumToString(type), TP, ASK - stops_level * _Point, ASK, stops_level);
}
//--- return the result of checkingreturn(TP_check && SL_check);
}
break;
}
//--- Verification succeededreturn(false);
}
See other checks that should be carried out by the robot in the article below:
Followed the instructions on the various forums including writing the description afresh, hiding it from the market so on and so forth but the description still reverts to the original version.
Now I can no longer restore the product on the market neither can I edit it. I have requested assistance on the forums related to this issue but no assistance as of yet.
How do I resolve this issue of "Not being able to edit product description?" Please assist
Before sending trade orders, it is also necessary to check if the volumes specified in the order are correct. The number of lots that the Expert Advisor is going to specify in the order should be checked before calling the OrderSend() function. For financial instruments, theSpecification specifies the minimum and maximum allowed volumes for trading, as well as the volume gradation. You can get these values in MQL5from the ENUM_SYMBOL_INFO_DOUBLE enumeration using theSymbolInfoDouble() function.
//+------------------------------------------------------------------+//| Checks the order volume for correctness ||//+------------------------------------------------------------------+bool CheckVolumeValue(double volume,string &description)
{
//--- minimum permissible volume for trading operationsdouble min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
if(volume<min_volume)
{
description=StringFormat("Volume less than the minimum allowed SYMBOL_VOLUME_MIN=%.2f",min_volume);
return(false);
}
//--- maximum allowable volume for trading operationsdouble max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
if(volume>max_volume)
{
description=StringFormat("Volume greater than maximum allowed SYMBOL_VOLUME_MAX=%.2f",max_volume);
return(false);
}
//--- get the minimum volume gradationdouble volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);
int ratio=(int)MathRound(volume/volume_step);
if(MathAbs(ratio*volume_step-volume)>0.0000001)
{
description=StringFormat("Volume is not a multiple of the minimum grading SYMBOL_VOLUME_STEP=%.2f, nearest correct volume is %.2f",
volume_step,ratio*volume_step);
return(false);
}
description="Correct volume value";
return(true);
}
Before sending trade orders, it is also necessary to check if the volumes specified in the order are correct. The number of lots that the Expert Advisor is going to specify in the order should be checked before calling the OrderSend() function. For financial instruments, theSpecification specifies the minimum and maximum allowed volumes for trading, as well as the volume gradation. These values can be obtained in MQL5from the ENUM_SYMBOL_INFO_DOUBLE enumeration using theSymbolInfoDouble() function
Didn't help, can I fix some other code?
Can you tell me how to refine the script?
Read the article completely, 'CheckVolumeValue' is a check of correctness of input parameters.
And there is also a check of correct lot rounding ...
Taking into account the volume of the open position and the volume in pending orders, the final check will look like this:
//+------------------------------------------------------------------+//| Returns the maximum allowable volume for the order by symbol |//+------------------------------------------------------------------+double NewOrderAllowedVolume(string symbol)
{
double allowed_volume=0;
//--- get the maximum volume limit in the orderdouble symbol_max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
//--- get the character limit on volumedouble max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT);
//--- get the volume of the open position by symboldouble opened_volume=PositionVolume(symbol);
if(opened_volume>=0)
{
//--- if we have already exhausted the volumeif(max_volume-opened_volume<=0)
return(0);
//--- open position volume does not exceed max_volumedouble orders_volume_on_symbol=PendingsVolume(symbol);
allowed_volume=max_volume-opened_volume-orders_volume_on_symbol;
if(allowed_volume>symbol_max_volume) allowed_volume=symbol_max_volume;
}
return(allowed_volume);
}
//+------------------------------------------------------------------+//| Script programme start function|//+------------------------------------------------------------------+voidOnStart()
{
//---double step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP)/2.0;
double volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN)-step;
double finish=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX)+step;
//--- find out how many decimal places are contained in the volume gradationint digits=(int)MathLog10(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP));
if(digits<0) digits=-digits;
else digits=0;
//--- check many different volume values in the loopwhile(volume<finish+4*step)
{
string descr;
if(!CheckVolumeValue(volume,descr))
{
Print("Inspection Result ",volume,": ",descr);
}
elsePrintFormat("The %G volume is correct.",volume);
volume+=3*step;
volume=NormalizeDouble(volume,digits+1);
}
//---
}
//+------------------------------------------------------------------+//| Checks the order volume for correctness ||//+------------------------------------------------------------------+bool CheckVolumeValue(double volume,string &description)
{
//--- minimum permissible volume for trading operationsdouble min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
if(volume<min_volume)
{
description=StringFormat("Volume less than the minimum allowed SYMBOL_VOLUME_MIN=%.2f",min_volume);
return(false);
}
//--- maximum allowable volume for trading operationsdouble max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
if(volume>max_volume)
{
description=StringFormat("Volume greater than maximum allowed SYMBOL_VOLUME_MAX=%.2f",max_volume);
return(false);
}
//--- get the minimum volume gradationdouble volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);
int ratio=(int)MathRound(volume/volume_step);
if(MathAbs(ratio*volume_step-volume)>0.0000001)
{
description=StringFormat("Volume is not a multiple of the minimum grading SYMBOL_VOLUME_STEP=%.2f, nearest correct volume is %.2f",
volume_step,ratio*volume_step);
return(false);
}
description="Correct volume value";
return(true);
}
//+------------------------------------------------------------------+
Предлагаю свой набор торговых функций в виде готового советника. Представленный способ позволяет получать множество торговых стратегий простым добавлением индикаторов и изменением входных параметров.
My EA returns an error when registering a new product:
test on EURUSD,H1 (netting) 2020.04.15 15:47:05 failed modify #44 sell 0.2 EURUSD sl: 1.08929, tp: 1.08599 -> sl: 1.08919, tp: 1.08599 [Modification failed due to order or position being close to market]
But my EA is meant to run on WIN$, not forex. Why doesn't the tester let you know which asset to run?
Now how can I correct something that has no error, because the EA is running perfectly, I just can't register the product for sale.
My EA returns an error when registering a new product:
test on EURUSD,H1 (netting) 2020.04.15 15:47:05 failed modify #44 sell 0.2 EURUSD sl: 1.08929, tp: 1.08599 -> sl: 1.08919, tp: 1.08599 [Modification failed due to order or position being close to market]
But my EA is meant to run on WIN$, not forex. Why doesn't the tester let you know which asset to run?
Now how can I correct something that has no error, because the EA is running perfectly, I just can't register the product for sale.
The robot must be prepared to work on any asset....
To correct the error mentioned above, you must carry out the check below before modifying the position:
See other checks that should be carried out by the robot in the article below:
What tests should a trading robot pass before being published on the Market - MQL5 Articles
Hi, I am unable to edit the product description on one of my old products.
Followed the instructions on the various forums including writing the description afresh, hiding it from the market so on and so forth but the description still reverts to the original version.
Now I can no longer restore the product on the market neither can I edit it. I have requested assistance on the forums related to this issue but no assistance as of yet.
How do I resolve this issue of "Not being able to edit product description?" Please assist
When loading the Expert Advisor and testing it writes an error, I don't understand how to correct it.
test on EURUSD,H1 (netting)
2020.04.14 00:24:42 failed instant buy 0.01 EURUSD at 1.09044 [Invalid volume]
2020.04.14 00:24:45 failed instant buy 0.01 EURUSD at 1.09044 [Invalid volume]
2020.04.14 00:24:48 failed instant buy 0.01 EURUSD at 1.09037 [Invalid volume]
2020.04.21 00:01:34 failed instant buy 0.01 EURUSD at 1.08626 [Invalid volume]
2020.04.21 00:01:37 failed instant buy 0.01 EURUSD at 1.08626 [Invalid volume]
2020.04.21 00:01:40 failed instant buy 0.01 EURUSD at 1.08626 [Invalid volume]
2020.04.27 16:08:24 failed instant sell 0.01 EURUSD at 1.08546 [Invalid volume]
2020.04.27 16:08:27 failed instant sell 0.01 EURUSD at 1.08548 [Invalid volume]
2020.04.27 16:08:30 failed instant sell 0.01 EURUSD at 1.08547 [Invalid volume]
2020.04.29 20:15:52 failed instant sell 0.01 EURUSD at 1.08565 [Invalid volume]
2020.04.29 20:15:55 failed instant sell 0.01 EURUSD at 1.08566 [Invalid volume]
2020.04.29 20:15:58 failed instant sell 0.01 EURUSD at 1.08566 [Invalid volume]
2020.05.18 00:12:09 failed instant buy 0.01 EURUSD at 1.08134 [Invalid volume]
2020.05.18 00:12:12 failed instant buy 0.01 EURUSD at 1.08134 [Invalid volume]
2020.05.18 00:12:15 failed instant buy 0.01 EURUSD at 1.08143 [Invalid volume]
2020.05.21 15:50:25 failed instant sell 0.01 EURUSD at 1.10031 [Invalid volume]
2020.05.21 15:50:28 failed instant sell 0.01 EURUSD at 1.10034 [Invalid volume]
2020.05.21 15:50:31 failed instant sell 0.01 EURUSD at 1.10036 [Invalid volume]
2020.05.25 19:00:05 failed instant buy 0.01 EURUSD at 1.08950 [Invalid volume]
2020.05.25 19:00:08 failed instant buy 0.01 EURUSD at 1.08951 [Invalid volume]
2020.05.25 19:00:11 failed instant buy 0.01 EURUSD at 1.08952 [Invalid volume]
there are no trading operations
When loading the Expert Advisor and testing it writes an error, it is not clear how to correct it.
test on EURUSD,H1 (netting)
2020.04.14 00:24:42 failed instant buy 0.01 EURUSD at 1.09044 [Invalid volume]
***
Read it, put it in the code
Incorrect volumes in trade operations
Before sending trade orders, it is also necessary to check if the volumes specified in the order are correct. The number of lots that the Expert Advisor is going to specify in the order should be checked before calling the OrderSend() function. For financial instruments, theSpecification specifies the minimum and maximum allowed volumes for trading, as well as the volume gradation. You can get these values in MQL5from the ENUM_SYMBOL_INFO_DOUBLE enumeration using theSymbolInfoDouble() function.
Didn't help, can I fix some other code?
Can you tell me how to refine the script?
Read it, put it in the code
Incorrect volumes in trade operations
Before sending trade orders, it is also necessary to check if the volumes specified in the order are correct. The number of lots that the Expert Advisor is going to specify in the order should be checked before calling the OrderSend() function. For financial instruments, theSpecification specifies the minimum and maximum allowed volumes for trading, as well as the volume gradation. These values can be obtained in MQL5from the ENUM_SYMBOL_INFO_DOUBLE enumeration using theSymbolInfoDouble() function
Didn't help, can I fix some other code?
Can you tell me how to refine the script?
Read the article completely, 'CheckVolumeValue' is a check of correctness of input parameters.
And there is also a check of correct lot rounding ...
Taking into account the volume of the open position and the volume in pending orders, the final check will look like this:
add?
checkvolumevalue.mq5 as it is written here
add?
checkvolumevalue.mq5 as it is written here
All the necessary checks are in the article Almost a constructor for creating an EA
Is the code asked about earlier suitable?
You could write the necessary lines from the article.