mathmarketmodels/Scripts/instantstoploss2/instantstoploss2_1.mq5

46 строки
4,1 КиБ
MQL5
Исходный Постоянная ссылка Обычный вид История

2025-09-10 12:14:50 +01:00
<EFBFBD><EFBFBD>/*// Include the Trade.mqh file to use CTrade class
#include <Trade\Trade.mqh>
#include <Trade\AccountInfo.mqh>
#include <ChartObjects\ChartObjectsTxtControls.mqh>
//+------------------------------------------------------------------+
//| StopsLevel.mq5 |
//| Copyright 2023, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
void OnStart()
{
// Define the symbol you are interested in
string symbol = _Symbol;
// Variable to store the stops level
int stops_level;
// Retrieve the stops level for the specified symbol
stops_level = (int)SymbolInfoInteger(symbol, SYMBOL_TRADE_STOPS_LEVEL);
// Check if the retrieval was successful
if(stops_level != -1)
{
// Print the stops level in points
Print("The stops level for ", symbol, " is ", stops_level + SymbolInfoDouble(symbol, SYMBOL_BID) - (_Point*10));
}
else
{
// Print an error message if the retrieval failed
Print("Failed to retrieve the stops level for ", symbol);
}
}
//
// ### Explanation:
//
// - **SymbolInfoInteger**: This function is used to get various properties of a trading symbol. When you pass `SYMBOL_TRADE_STOPS_LEVEL` as the second argument, it returns the stops level in points.
//
// - **stops_level**: This variable stores the result of the `SymbolInfoInteger` function call. If the function call is successful, `stops_level` will contain the minimum distance in points for stop orders.
//
// - **Error Handling**: The script checks if `stops_level` is not equal to `-1`, which would indicate a successful retrieval. If it equals `-1`, it means the retrieval failed, and an error message is printed.
//
// This script can be used in an MQL5 environment to check the stops level for any symbol you are interested in. Always ensure that the symbol you are querying is available in your trading platform.
//
*/