एमटी2ट्रेडिंग पुस्तकालय आपको एमक्यूएल कोड से सीधे ट्रेडिंग सिग्नल भेजने की अनुमति देता है (या तो तकनीकी संकेतक या विशेषज्ञ सलाहकार से)।
एमटी2ट्रेडिंग लाइब्रेरी का उपयोग करने के लिए सुनिश्चित करें कि लाइब्रेरी (एमटी४ / ५ के लिए एमटी2ट्रेडिंग _पुस्तकालय) को आपके मेटाट्रेडर टर्मिनल के लाइब्रेरी फ़ोल्डर (एमक्यूएल४ / लाइब्रेरीज़ या एमक्यूएल५ / लाइब्रेरीज़) में कॉपी किया गया है।
अपने संकेतक या ई.ए के साथ अपने कोड के शीर्ष पर कार्यों को घोषित करें आयात
enum broker {
All = 0,
IQOption = 1,
Binary = 2,
Spectre = 3,
Alpari = 4,
InstaBinary = 5,
OptionField = 6,
CLMForex = 7,
DukasCopy = 8,
GCOption = 9,
StrategyTester = 10,
CapitalCore = 11,
PocketOption = 12,
Bitness = 13
};
enum martingale {
NoMartingale = 0,
OnNextExpiry = 1,
OnNextSignal = 2,
Anti_OnNextExpiry = 3,
Anti_OnNextSignal = 4,
OnNextSignal_Global= 5,
Anti_OnNextSignal_Global = 6
};
enum result {
TIE = 0,
WIN = 1,
LOSS = 2
};
#import "mt2trading_library.ex4"
bool mt2trading (string symbol, string direction, double amount, int expiryMinutes);
bool mt2trading (string symbol, string direction, double amount, int expiryMinutes, string signalname);
bool mt2trading (string symbol, string direction, double amount, int expiryMinutes,
martingale martingaleType, int martingaleSteps, double martingaleCoef,
broker myBroker, string signalName, string signalid);
int traderesult (string signalid);
double tradeprofit (string signalid);
#import
#import "mt2trading_library.ex5"
bool mt2trading (string symbol, string direction, double amount, int expiryMinutes);
bool mt2trading (string symbol, string direction, double amount, int expiryMinutes, string signalname);
bool mt2trading (string symbol, string direction, double amount, int expiryMinutes,
martingale martingaleType, int martingaleSteps, double martingaleCoef,
broker myBroker, string signalName, string signalid);
int traderesult (string signalid);
double tradeprofit (string signalid);
#import
extern broker Broker = All;
extern string SignalName = "My Signal"; // Signal Name (optional)
extern double TradeAmount = 1; // Trade Amount
extern int ExpiryMinutes = 5; // Expiry Time [minutes]
extern martingale MartingaleType = NoMartingale; // Martingale
extern int MartingaleSteps = 2; // Martingale Steps
extern double MartingaleCoef = 2.0; // Martingale Coefficient
int OnInit()
{
// Initialize the time flag
sendOnce = TimeCurrent();
// Generate a unique signal id for signals management (based on timestamp, chart id and some random number)
MathSrand(GetTickCount());
if (MartingaleType == OnNextSignal || MartingaleType == Anti_OnNextSignal)
signalID = IntegerToString(GetTickCount()) + IntegerToString(MathRand()); // indicator-wide id
else if (MartingaleType = OnNextSignal_Global || MartingaleType == Anti_OnNextSignal_Global)
signalID = IntegerToString(AccountInfoInteger(ACCOUNT_LOGIN))
+ IntegerToString(TerminalInfoInteger(TERMINAL_BUILD))
+ AccountInfoString(ACCOUNT_NAME); // terminal-wide id
if (StringLen(Symbol()) >= 6)
asset = StringSubstr(Symbol(),0,6);
else
asset = Symbol();
}
ऊपर_तीर_शर्त और डाउन_एरो_कंडीशन पर अप / डाउन ट्रेड रखने के लिए उदाहरण:
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
// Reinitialization of signalID if no martingale is used or martingale type is OnNextExpiry
if (MartingaleType == NoMartingale || MartingaleType == OnNextExpiry || MartingaleType == Anti_OnNextExpiry)
signalID = IntegerToString(GetTickCount()) + IntegerToString(MathRand()); // candle-wide unique id
//...
bool Up_Arrow_Condition = ...
bool Down_Arrow_Condition = ...
if (UP_Arrow_Condition && signaltime != time[0])
{
mt2trading (asset, "CALL", TradeAmount, ExpiryMinutes, MartingaleType, MartingaleSteps,
MartingaleCoef, Broker, SignalName, signalID);
signaltime = time[0];
}
if (DOWN_Arrow_Condition && signaltime != time[0])
{
mt2trading (asset, "PUT", TradeAmount, ExpiryMinutes, MartingaleType, MartingaleSteps,
MartingaleCoef, Broker, SignalName, signalID);
signaltime = time[0];
}
//...
return(rates_total);
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
// Reinitialization of signalID if no martingale is used or martingale type is OnNextExpiry
if (MartingaleType == NoMartingale || MartingaleType == OnNextExpiry || MartingaleType == Anti_OnNextExpiry)
signalID = IntegerToString(GetTickCount()) + IntegerToString(MathRand()); // candle-wide unique id
//...
ArraySetAsSeries(time,true); // ---> only in MQL5
bool Up_Arrow_Condition = ...
bool Down_Arrow_Condition = ...
if (UP_Arrow_Condition && signaltime != time[0])
{
mt2trading (asset, "CALL", TradeAmount, ExpiryMinutes, MartingaleType, MartingaleSteps,
MartingaleCoef, Broker, SignalName, signalID);
signaltime = time[0];
}
if (DOWN_Arrow_Condition && signaltime != time[0])
{
mt2trading (asset, "PUT", TradeAmount, ExpiryMinutes, MartingaleType, MartingaleSteps,
MartingaleCoef, Broker, SignalName, signalID);
signaltime = time[0];
}
//...
return(rates_total);
}