MetaTrader4
AK-47 स्केल्पर ईए: मेटाट्रेडर 4 के लिए बेहतरीन ट्रेडिंग टूल
1. इनपुट पैरामीटर #define ExtBotName "AK-47 स्केल्पर ईए" //बॉट का नाम
#define Version "1.00"
//--- इनपुट पैरामीटर ---
extern string EASettings = "---------------------------------------------"; //-------- <ईए सेटिंग्स> --------
input int InpMagicNumber = 124656; //मैजिक नंबर
extern string TradingSettings = "---------------------------------------------"; //-------- <ट्रेडिंग सेटिंग्स> --------
input double Inpuser_lot = 0.01; //लॉट्स
input double InpSL_Pips = 3.5; //स्टॉपलॉस (पिप्स में)
input double InpMax_spread = 0.5; //अधिकतम अनुमति स्प्रेड (पिप्स में) (0 = फ्लोटिंग)
extern string MoneySettings = "---------------------------------------------"; //-------- <पैसों की सेटिंग्स> --------
input bool isVolume_Percent = true; //वॉल्यूम प्रतिशत की अनुमति दें
input double InpRisk = 3; //बैलेंस का रिस्क प्रतिशत (%)
input string TimeSettings = "---------------------------------------------"; //-------- <ट्रेडिंग टाइम सेटिंग्स> --------
input bool InpTimeFilter = true; //ट्रेडिंग टाइम फ़िल्टर
input int InpStartHour = 2; //शुरुआत का घंटा
input int InpStartMinute = 30; //शुरुआत का मिनट
input int InpEndHour = 21; //समापन का घंटा
input int InpEndMinute = 0 //समापन का मिनट 2. स्थानीय वेरिएबल्स की प्रारंभिककरण //--- वेरिएबल्स
int Pips2Points; // स्लिपेज 3 पिप्स 3=पॉइंट्स 30=पॉइंट्स
double Pips2Double; // स्टॉपलॉस 15 पिप्स 0.015 0.0150
int InpMax_slippage = 3; // अधिकतम स्लिपेज अनुमति_Pips।
bool isOrder = false; // केवल 1 ऑर्डर खोलें
int slippage;
string strComment = ""; 3. मुख्य कोड a/ एक्सपर्ट इनिशियलाइजेशन फंक्शन int OnInit()
{
//---
//3 या 5 अंकों की पहचान
//पिप और पॉइंट
if (Digits % 2 == 1)
{
Pips2Double = _Point*10;
Pips2Points = 10;
slippage = 10* InpMax_slippage;
}
else
{
Pips2Double = _Point;
Pips2Points = 1;
slippage = InpMax_slippage;
}
//---
return(INIT_SUCCEEDED);
} b/ एक्सपर्ट टिक फंक्शन void OnTick()
{
//---
if(IsTradeAllowed() == false)
{
Comment("AK-47 ईए\nट्रेड अनुमति नहीं है।");
return;
}
MqlDateTime structTime;
TimeCurrent(structTime);
structTime.sec = 0;
//शुरुआत का समय सेट करें
structTime.hour = InpStartHour;
structTime.min = InpStartMinute;
datetime timeStart = StructToTime(structTime);
//समापन का समय सेट करें
structTime.hour = InpEndHour;
structTime.min = InpEndMinute;
datetime timeEnd = StructToTime(structTime);
double acSpread = MarketInfo(Symbol(), MODE_SPREAD);
StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL);
strComment = "\n" + ExtBotName + " - v." + (string)Version;
strComment += "\nGMT समय = " + TimeToString(TimeGMT(),TIME_DATE|TIME_SECONDS);
strComment += "\nट्रेडिंग समय = [" + (string)InpStartHour + "घंटा" + (string)InpStartMinute + " --> " + (string)InpEndHour + "घंटा" + (string)InpEndMinute + "]";
strComment += "\nवर्तमान स्प्रेड = " + (string)acSpread + " पॉइंट्स";
strComment += "\nवर्तमान स्टॉपलेवल = " + (string)StopLevel + " पॉइंट्स";
Comment(strComment);
//अपडेट वैल्यूज
UpdateOrders();
TrailingStop();
//ट्रेडिंग समय की जांच करें
if(InpTimeFilter)
{
if(TimeCurrent() >= timeStart && TimeCurrent() < timeEnd)
{
if(!isOrder) OpenOrder();
}
}
else
{
if(!isOrder) OpenOrder();
}
} 3.1 ऑर्डर भेजने के लिए सिग्नल की गणना करें void OpenOrder(){
//int OrdType = OP_SELL;//-1;
double TP = 0;
double SL = 0;
string comment = ExtBotName;
//लॉट्स की गणना करें
double lot1 = CalculateVolume();
//if(OrdType == OP_SELL){
double OpenPrice = NormalizeDouble(Bid - (StopLevel * _Point) - (InpSL_Pips/2) * Pips2Double, Digits);
SL = NormalizeDouble(Ask + StopLevel * _Point + InpSL_Pips/2 * Pips2Double, Digits);
if(CheckSpreadAllow()) //स्प्रेड की जांच करें
{
if(!OrderSend(_Symbol, OP_SELLSTOP, lot1, OpenPrice, slippage, SL, TP, comment, InpMagicNumber, 0, clrRed))
Print(__FUNCTION__,"--> ऑर्डर भेजने में त्रुटि ",GetLastError());
}
//}
} 3.2 वॉल्यूम की गणना करें double CalculateVolume()
{
double LotSize = 0;
if(isVolume_Percent == false)
{
LotSize = Inpuser_lot;
}
else
{
LotSize = (InpRisk) * AccountFreeMargin();
LotSize = LotSize /100000;
double n = MathFloor(LotSize/Inpuser_lot);
//Comment((string)n);
LotSize = n * Inpuser_lot;
if(LotSize < Inpuser_lot)
LotSize = Inpuser_lot;
if(LotSize > MarketInfo(Symbol(),MODE_MAXLOT))
LotSize = MarketInfo(Symbol(),MODE_MAXLOT);
if(LotSize < MarketInfo(Symbol(),MODE_MINLOT))
LotSize = MarketInfo(Symbol(),MODE_MINLOT);
}
return(LotSize);
} 3.3 ईए में "ट्रेलिंग स्टॉप" फ़ंक्शन है, SL हर बार मूल्य परिवर्तन होने पर बदल जाएगा (नीचे) void TrailingStop()
{
for(int i = OrdersTotal() - 1; i >= 0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if((OrderMagicNumber() == InpMagicNumber) && (OrderSymbol() == Symbol())) //_Symbol))
{
//सेल ऑर्डर के लिए
if(OrderType() == OP_SELL)
{
//--जब मूल्य बदलता है तो SL की गणना करें
double SL_in_Pip = NormalizeDouble(OrderStopLoss() - (StopLevel * _Point) - Ask, Digits) / Pips2Double;
if(SL_in_Pip > InpSL_Pips){
double newSL = NormalizeDouble(Ask + (StopLevel * _Point) + InpSL_Pips * Pips2Double, Digits);
if(!OrderModify(OrderTicket(), OrderOpenPrice(), newSL, OrderTakeProfit(), 0, clrRed))
{
Print(__FUNCTION__,"--> ऑर्डर संशोधन में त्रुटि ",GetLastError());
{
continue;
}
}
}
//सेलस्टॉप ऑर्डर के लिए
else if(OrderType() == OP_SELLSTOP)
{
double SL_in_Pip = NormalizeDouble(OrderStopLoss() - (StopLevel * _Point) - Ask, Digits) / Pips2Double;
if(SL_in_Pip < InpSL_Pips/2){
double newOP = NormalizeDouble(Bid - (StopLevel * _Point) - (InpSL_Pips/2) * Pips2Double, Digits);
double newSL = NormalizeDouble(Ask + (StopLevel * _Point) + (InpSL_Pips/2) * Pips2Double, Digits);
if(!OrderModify(OrderTicket(), newOP, newSL, OrderTakeProfit(), 0, clrRed))
{
Print(__FUNCTION__,"--> पेंडिंगऑर्डर संशोधन में त्रुटि!", GetLastError());
continue;
}
}
}
}
}
}
}
2023.01.14