mirror of
https://github.com/rithsila/MT5-EA-Sniper-Strategy.git
synced 2026-08-24 08:08:22 +00:00
Add spread check
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,48 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Notifications.mqh |
|
||||
//| Copyright 2022, Nkondog Anselme Venceslas. |
|
||||
//| https://www.linkedin.com/in/nkondog |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2022, Nkondog Anselme Venceslas."
|
||||
#property link "https://www.linkedin.com/in/nkondog"
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
void Notify(string message)
|
||||
{
|
||||
|
||||
SendNotification(message);
|
||||
|
||||
string headers;
|
||||
string url = "https://api.telegram.org/bot1203586996:AAF3GTCy2yVyvXsCjd9pODhJncTUG7NcOKw/sendMessage?chat_id=-457969372&text="+message;
|
||||
char data[],result[];
|
||||
|
||||
int res = WebRequest("GET",
|
||||
url,
|
||||
NULL,
|
||||
NULL,
|
||||
3000,
|
||||
data,
|
||||
0,
|
||||
result,
|
||||
headers
|
||||
);
|
||||
//Print(CharArrayToString(result)); // see the results
|
||||
|
||||
if(res==-1)
|
||||
{
|
||||
Print("Error in WebRequest. Error code =",GetLastError());
|
||||
//--- Perhaps the URL is not listed, display a message about the necessity to add the address
|
||||
MessageBox("Add the address '"+url+"' to the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(res==200)
|
||||
{
|
||||
//--- Successful download
|
||||
Print("Telegran notification sent.");
|
||||
}
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -57,7 +57,7 @@ input ENUM_RISK_BASE InpRiskBase=RISK_BASE_BALANCE; //Risk B
|
||||
input double InpMaxRiskPerTrade=0.5; //Percentage To Risk Each Trade
|
||||
input double InpMinLotSize=0.01; //Minimum Position Size Allowed
|
||||
input double InpMaxLotSize=100; //Maximum Position Size Allowed
|
||||
input int InpMaxSpread=10; //Maximum Spread Allowed
|
||||
input int InpMaxSpread=15; //Maximum Spread Allowed
|
||||
input int InpSlippage=1; //Maximum Slippage Allowed in points
|
||||
input string Comment_01="----------------------"; //Stop loss settings
|
||||
input ENUM_MODE_SL InpStopLossMode=SL_FIXED; //Stop Loss Mode
|
||||
@@ -101,7 +101,7 @@ bool IsSpreadOK=false; //Urgently close
|
||||
double gLotSize=InpDefaultLotSize;
|
||||
|
||||
int gTickValue=0;
|
||||
long Spread = SymbolInfoInteger(gSymbol,SYMBOL_SPREAD) / 100; //Check the impact. It's originally a double
|
||||
double Spread = 0.0; //Check the impact. It's originally a double
|
||||
|
||||
int gOrderOpRetry = 10;
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ void CheckPreChecks()
|
||||
return;
|
||||
}
|
||||
//Spread is acceptable
|
||||
long SpreadCurr=(int)Spread;
|
||||
if(SpreadCurr>InpMaxSpread)
|
||||
Spread = (last_tick.ask-last_tick.bid)/Point();
|
||||
if(Spread>InpMaxSpread)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Spread is higher than Max acceptable spread");
|
||||
|
||||
Reference in New Issue
Block a user