#define SYMBOL_NAME Symbol()
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- declaramos las variables en las que se anotarán los coeficentes
double initial_margin_rate = 0; // coeficiente del cobro de margen inicial
double maintenance_margin_rate = 0; // coeficiente del cobro de margen de mantenimiento
//--- obtenemos y mostramos en el diario de registro los coeficientes del símbolo SYMBOL_NAME para la orden de mercado Buy
SymbolInfoMarginRatePrint(SYMBOL_NAME, ORDER_TYPE_BUY, initial_margin_rate, maintenance_margin_rate);
//--- obtenemos y mostramos en el diario de registro los coeficientes del símbolo SYMBOL_NAME para la orden de mercado Sell
SymbolInfoMarginRatePrint(SYMBOL_NAME, ORDER_TYPE_SELL, initial_margin_rate, maintenance_margin_rate);
/*
resultado:
Initial margin rate for symbol AFKS for the Buy market order: 0.225600
Maintenance margin rate for symbol AFKS for the Buy market order: 0.112800
Initial margin rate for symbol AFKS for the Sell market order: 0.254400
Maintenance margin rate for symbol AFKS for the Sell market order: 0.127200
*/
}
//+------------------------------------------------------------------+
//| Mostramos en el registro los coeficientes de cobro de margen |
//+------------------------------------------------------------------+
void SymbolInfoMarginRatePrint(const string symbol, const ENUM_ORDER_TYPE order_type, double &initial_margin_rate, double &maintenance_margin_rate)
{
//--- obtenemos los coeficientes del símbolo symbol para la orden de mercado order_type
ResetLastError();
if(!SymbolInfoMarginRate(symbol, order_type, initial_margin_rate, maintenance_margin_rate))
{
Print("SymbolInfoMarginRate() failed. Error ", GetLastError());
return;
}
//--- imprimimos los valores obtenidos de los coeficientes
string type=(order_type==ORDER_TYPE_BUY ? "Buy" : order_type==ORDER_TYPE_SELL ? "Sell" : "Unknown");
PrintFormat("Initial margin rate for symbol %s for the %s market order: %f\n"+
"Maintenance margin rate for symbol %s for the %s market order: %f",
SYMBOL_NAME, type, initial_margin_rate,
SYMBOL_NAME, type, maintenance_margin_rate);
}
|