//+-------------- ФУНКЦИЯ ОБРАБОТКИ ОШИБОК ---------------------------------+ int Fun_Error(int Error) { switch(Error) { case 0: return (0); case 1: Print("Trying to change already set values with the same values.");return(1); case 2: Print("Common mistake. Stop all trading attempts until the circumstances are clarified.");return(0); case 3: Print("Wrong parameters passed to the trading function.");return(1); case 4: Print("The trading server is busy. Let's try again ..");Sleep(3000);return(1); case 5: Print("Old version of the client terminal.");return(0); case 6: Print("No connection to the trading server.");return(1); case 7: Print("Not enough rights.");return(1); case 8: Print("Too frequent requests.");return(1); case 9: Print("Invalid operation disrupting server operation.");return(1); case 64: Print("The account is blocked. It is necessary to stop all attempts at trading operations.");return(0); case 65: Print("Invalid account number.");return(1); case 128: Print("The transaction has expired.");return(1); case 129: Print("Wrong bid or ask price, possibly not normalized price.");return(1); case 130: Print("Stops that are too close or incorrectly calculated or abnormal prices in stops (or in the opening price of a pending order).");return(1); case 131: Print("Wrong volume, error in granulation of volume.");return(1); case 132: Print("The market is closed.");return(1); case 133: Print("Trade is prohibited.");return(0); case 134: Print("Not enough money to complete the operation.");return(0); case 135: Print("The price has changed. We try again ..");RefreshRates();return(1); case 136: Print("No price. We are waiting for a new tick .."); while(RefreshRates()==false)// До нового тика Sleep(1); return(1); case 137: Print("The broker is busy. Let's try again ..");Sleep(3000);return(1); case 138: Print("The requested price is out of date, or bid and ask are confused.");return(1); case 139: Print("The order is blocked and is already being processed.");return(1); case 140: Print("Only purchase allowed. You cannot repeat the SELL operation.");return(1); case 141: Print("Too many requests.");return(1); case 142: Print("The order is queued.");return(1); case 143: Print("The order has been accepted by the dealer for execution.");return(1); case 144: Print("The order is canceled by the client upon manual confirmation of the transaction.");return(1); case 145: Print("Modification is prohibited, because the order is too close to the market and is blocked due to possible early execution.");return(1); case 146: Print("The trading subsystem is busy. Let's try again ..");Sleep(500);return(1); case 147: Print("Using the expiration date of the order is prohibited by the broker.");return(1); case 148: Print("The number of open and pending orders has reached the limit set by the broker.");return(1); case 149: Print("An attempt to open an opposite position to an existing one if hedging is prohibited.");return(1); case 4000: return (0); case 4001: Print("Invalid function pointer.");return(1); case 4002: Print("Array index is out of range.");return(1); case 4003: Print("No memory for function stack.");return(1); case 4004: Print("Stack overflow after recursive call.");return(1); case 4005: Print("There is no memory on the stack for passing parameters.");return(1); case 4006: Print("There is no memory for the string parameter.");return(1); case 4007: Print("There is no memory for the time line.");return(1); case 4008: Print("Uninitialized string.");return(1); case 4009: Print("An uninitialized string in an array.");return(1); case 4010: Print("There is no memory for the string array.");return(1); case 4011: Print("Line is too long.");return(1); case 4012: Print("The remainder of division by zero.");return(1); case 4013: Print("Division by zero.");return(1); case 4014: Print("Unknown team.");return(1); case 4015: Print("Wrong transition.");return(1); case 4016: Print("Uninitialized array.");return(1); case 4017: Print("DLL calls are not allowed.");return(1); case 4018: Print("Unable to load library.");return(1); case 4019: Print("Unable to call function.");return(1); case 4020: Print("Calls to external library functions are not allowed.");return(1); case 4021: Print("There is not enough memory for the string returned from the function.");return(1); case 4022: Print("The system is busy.");return(1); case 4050: Print("Incorrect number of function parameters.");return(1); case 4051: Print("Invalid function parameter value.");return(1); case 4052: Print("Internal error of string function.");return(1); case 4053: Print("Array error.");return(1); case 4054: Print("Misuse of timeseries array.");return(1); case 4055: Print("Custom indicator error.");return(1); case 4056: Print("Arrays are incompatible.");return(1); case 4057: Print("Error processing global variables.");return(1); case 4058: Print("Global variable not detected.");return(1); case 4059: Print("Function not allowed in test mode.");return(1); case 4060: Print("Enter the HTTP address !!!.");return(1); case 4061: Print("Error sending mail.");return(1); case 4062: Print("A parameter of type string is expected.");return(1); case 4063: Print("A parameter of type integer is expected.");return(1); case 4064: Print("A parameter of type double is expected.");return(1); case 4065: Print("An array is expected as a parameter.");return(1); case 4066: Print("The requested historical data is in an update state.");return(1); case 4067: Print("An error occurred while performing a trading operation.");return(1); case 4099: Print("End of file.");return(1); case 4100: Print("An error occurred while working with the file.");return(1); case 4101: Print("Invalid file name.");return(1); case 4102: Print("Too many open files.");return(1); case 4103: Print("Unable to open file.");return(1); case 4104: Print("Incompatible file access mode.");return(1); case 4105: Print("No order has been selected.");return(1); case 4106: Print("Unknown character.");return(1); case 4107: Print("Incorrect price parameter for the trading function.");return(1); case 4108: Print("Invalid ticket number.");return(1); case 4109: Print("Trading is not permitted. You must enable the option Allow Expert Advisor to trade in the expert properties.");return(1); case 4110: Print("Long positions are not allowed. It is necessary to check the properties of the expert.");return(1); case 4111: Print("Short positions are not allowed. It is necessary to check the properties of the expert.");return(1); case 4200: Print("The object already exists.");return(1); case 4201: Print("An unknown property of the object was requested.");return(1); case 4202: Print("The object does not exist.");return(1); case 4203: Print("Unknown object type.");return(1); case 4204: Print("No object name.");return(1); case 4205: Print("Error coordinates of the object.");return(1); case 4206: Print("The specified subwindow was not found.");return(1); case 4207: Print("An error occurred while working with the object.");return(1); return(0); } return(0); }
バリデータは、パラメータを通過していきます。最初の組み合わせでトレードが 成立しなかった場合、Expert Advisorをアンロードします。以上です。これ以上の検査は意味がない。
要は、Expert Advisorでバリデーターを動作させないということです。
一部のシンボルで取引がない場合でもテストはパスします。主な内容は、取引操作ができない場合、Expert Advisorはその旨のログを発行し、作業を継続するというものです。
あなたが作っているのは、バリデーターではなく、人々のためのプログラムなのです。なぜ、エラーを処理せず、単にチャートから削除するプログラムがマーケットに必要なのでしょうか?そんな奇跡を、あなたは自分で買いますか?
Artemさん、これはテストEA(検証を確認中、販売するつもりはない)ですが、やはりアンロード条件がうまくいかないとトレードになりませんね。 取引開始が不可能な最小ロットでは、ログファイルをプリントで埋め尽くすだけです。こ れ以上、いいことはないでしょう。
アンロードを外すが何も変わらない。アンロードせずにEAをテストした結果は、以前の投稿をご覧ください。
何が言いたいんだ、レナト。まあ、そうなんですけどね。
これ、市場向けに作ったんですよ。
//+-------------- ФУНКЦИЯ ОБРАБОТКИ ОШИБОК ---------------------------------+
int Fun_Error(int Error)
{
switch(Error)
{
case 0: return (0);
case 1: Print("Trying to change already set values with the same values.");return(1);
case 2: Print("Common mistake. Stop all trading attempts until the circumstances are clarified.");return(0);
case 3: Print("Wrong parameters passed to the trading function.");return(1);
case 4: Print("The trading server is busy. Let's try again ..");Sleep(3000);return(1);
case 5: Print("Old version of the client terminal.");return(0);
case 6: Print("No connection to the trading server.");return(1);
case 7: Print("Not enough rights.");return(1);
case 8: Print("Too frequent requests.");return(1);
case 9: Print("Invalid operation disrupting server operation.");return(1);
case 64: Print("The account is blocked. It is necessary to stop all attempts at trading operations.");return(0);
case 65: Print("Invalid account number.");return(1);
case 128: Print("The transaction has expired.");return(1);
case 129: Print("Wrong bid or ask price, possibly not normalized price.");return(1);
case 130: Print("Stops that are too close or incorrectly calculated or abnormal prices in stops (or in the opening price of a pending order).");return(1);
case 131: Print("Wrong volume, error in granulation of volume.");return(1);
case 132: Print("The market is closed.");return(1);
case 133: Print("Trade is prohibited.");return(0);
case 134: Print("Not enough money to complete the operation.");return(0);
case 135: Print("The price has changed. We try again ..");RefreshRates();return(1);
case 136: Print("No price. We are waiting for a new tick ..");
while(RefreshRates()==false)// До нового тика
Sleep(1);
return(1);
case 137: Print("The broker is busy. Let's try again ..");Sleep(3000);return(1);
case 138: Print("The requested price is out of date, or bid and ask are confused.");return(1);
case 139: Print("The order is blocked and is already being processed.");return(1);
case 140: Print("Only purchase allowed. You cannot repeat the SELL operation.");return(1);
case 141: Print("Too many requests.");return(1);
case 142: Print("The order is queued.");return(1);
case 143: Print("The order has been accepted by the dealer for execution.");return(1);
case 144: Print("The order is canceled by the client upon manual confirmation of the transaction.");return(1);
case 145: Print("Modification is prohibited, because the order is too close to the market and is blocked due to possible early execution.");return(1);
case 146: Print("The trading subsystem is busy. Let's try again ..");Sleep(500);return(1);
case 147: Print("Using the expiration date of the order is prohibited by the broker.");return(1);
case 148: Print("The number of open and pending orders has reached the limit set by the broker.");return(1);
case 149: Print("An attempt to open an opposite position to an existing one if hedging is prohibited.");return(1);
case 4000: return (0);
case 4001: Print("Invalid function pointer.");return(1);
case 4002: Print("Array index is out of range.");return(1);
case 4003: Print("No memory for function stack.");return(1);
case 4004: Print("Stack overflow after recursive call.");return(1);
case 4005: Print("There is no memory on the stack for passing parameters.");return(1);
case 4006: Print("There is no memory for the string parameter.");return(1);
case 4007: Print("There is no memory for the time line.");return(1);
case 4008: Print("Uninitialized string.");return(1);
case 4009: Print("An uninitialized string in an array.");return(1);
case 4010: Print("There is no memory for the string array.");return(1);
case 4011: Print("Line is too long.");return(1);
case 4012: Print("The remainder of division by zero.");return(1);
case 4013: Print("Division by zero.");return(1);
case 4014: Print("Unknown team.");return(1);
case 4015: Print("Wrong transition.");return(1);
case 4016: Print("Uninitialized array.");return(1);
case 4017: Print("DLL calls are not allowed.");return(1);
case 4018: Print("Unable to load library.");return(1);
case 4019: Print("Unable to call function.");return(1);
case 4020: Print("Calls to external library functions are not allowed.");return(1);
case 4021: Print("There is not enough memory for the string returned from the function.");return(1);
case 4022: Print("The system is busy.");return(1);
case 4050: Print("Incorrect number of function parameters.");return(1);
case 4051: Print("Invalid function parameter value.");return(1);
case 4052: Print("Internal error of string function.");return(1);
case 4053: Print("Array error.");return(1);
case 4054: Print("Misuse of timeseries array.");return(1);
case 4055: Print("Custom indicator error.");return(1);
case 4056: Print("Arrays are incompatible.");return(1);
case 4057: Print("Error processing global variables.");return(1);
case 4058: Print("Global variable not detected.");return(1);
case 4059: Print("Function not allowed in test mode.");return(1);
case 4060: Print("Enter the HTTP address !!!.");return(1);
case 4061: Print("Error sending mail.");return(1);
case 4062: Print("A parameter of type string is expected.");return(1);
case 4063: Print("A parameter of type integer is expected.");return(1);
case 4064: Print("A parameter of type double is expected.");return(1);
case 4065: Print("An array is expected as a parameter.");return(1);
case 4066: Print("The requested historical data is in an update state.");return(1);
case 4067: Print("An error occurred while performing a trading operation.");return(1);
case 4099: Print("End of file.");return(1);
case 4100: Print("An error occurred while working with the file.");return(1);
case 4101: Print("Invalid file name.");return(1);
case 4102: Print("Too many open files.");return(1);
case 4103: Print("Unable to open file.");return(1);
case 4104: Print("Incompatible file access mode.");return(1);
case 4105: Print("No order has been selected.");return(1);
case 4106: Print("Unknown character.");return(1);
case 4107: Print("Incorrect price parameter for the trading function.");return(1);
case 4108: Print("Invalid ticket number.");return(1);
case 4109: Print("Trading is not permitted. You must enable the option Allow Expert Advisor to trade in the expert properties.");return(1);
case 4110: Print("Long positions are not allowed. It is necessary to check the properties of the expert.");return(1);
case 4111: Print("Short positions are not allowed. It is necessary to check the properties of the expert.");return(1);
case 4200: Print("The object already exists.");return(1);
case 4201: Print("An unknown property of the object was requested.");return(1);
case 4202: Print("The object does not exist.");return(1);
case 4203: Print("Unknown object type.");return(1);
case 4204: Print("No object name.");return(1);
case 4205: Print("Error coordinates of the object.");return(1);
case 4206: Print("The specified subwindow was not found.");return(1);
case 4207: Print("An error occurred while working with the object.");return(1);
return(0);
}
return(0);
}
こんな風に引っ掛けるんです。
ticket=OrderSend(Symbol(),OP_SELL,Lot,BID,0,0,0,"",0,0,clrNONE);
if(ticket<0 && Fun_Error(GetLastError())==1){return;}
//---
ticket=OrderSend(Symbol(),OP_BUY,Lot,ASK,0,0,0,"",0,0,clrNONE);
if(ticket<0 && Fun_Error(GetLastError())==1){return;}
試してみてください、エラーが出るかもしれません
Artyom これはテスト用のExpert Advisorで、とにかくアンロード条件がうまくいくと取引してくれないんだ。 取引を開くことが不可能な最小ロットでは、単にログファイルをプリントで埋め尽くします。こ れ以上やっても意味がない。
アンロードを外すが何も変わらない。DumpingなしのEAをテストした結果は、私の過去の投稿を参照してください。
えーと......誤発注の たびに一回ずつエントリーできないんですか?
はい、エラーなしで動作します
ここで、市場のために。
//+-------------- ФУНКЦИЯ ОБРАБОТКИ ОШИБОК ---------------------------------+
これはエラー処理ではありません。エラーコードの 説明をプリントアウトしているところです。
処理とは、エラーが発生したときにアルゴリズムを実行することです。アルゴリズムは、エラーを修正してリクエストを再送信するための条件を作成しようとするはずです。これが全くできない場合は、元のパラメータを記録し、それをまあまあの値に修正してみて、最終的に「パラメータを修正してもリクエストを送信することはできない」という判断を下すことになるはずです。
レナートさん、ありがとうございます。便利なんです。いただきます )))
やめて...
これはエラー処理ではありません。エラーコードの 説明をプリントアウトしているに過ぎない。
処理とは、エラーが発生したときにアルゴリズムを実行することです。アルゴリズムは、エラーを修正し、2回目のリクエストを送信するための条件を作成しようとするはずです。もし、それが全くできないのであれば、オリジナルのパラメータを記録し、それを「こんな風に修正しよう」と試み、最終的に「パラメータを修正してもリクエストを送信することはできない」と判断するはずです。
これと10年
ノークレーム
ちなみに、最初のモデレーターの一人はそうでした。
ヴァインだ、覚えてるか?