Add spread check

This commit is contained in:
Nkondog Anselme
2022-04-15 07:39:35 +01:00
parent 816c35632b
commit 1640247b61
6 changed files with 58 additions and 12 deletions
Binary file not shown.
+6 -8
View File
@@ -14,6 +14,7 @@
#include <Nkanven\HighTension\LotSizeCal.mqh> //Lot size calculator
#include <Nkanven\HighTension\EntriesManager.mqh> //Lot size calculator
#include <Nkanven\HighTension\CloseTransactions.mqh> //Emergency close of transaction
#include <Nkanven\HighTension\Notifications.mqh> //Handle notification
int handle;
const int indexMA = 0;
@@ -52,15 +53,16 @@ void OnTick()
TimeCurrent(dt);
SymbolInfoTick(_Symbol,last_tick);
CheckPreChecks();
Comment("Spread ", DoubleToString(Spread,0));
if(!gIsPreChecksOk)
return;
ScanPositions();
//Print("TF", PERIOD_CURRENT, " 1min ", PERIOD_M1, " 5min ", PERIOD_M5, " Period ", Period());
/*ScanPositions();
if(!newBar())
return;
return;*/
int cnt = CopyBuffer(handle, indexMA, 0, 3, bufferMA);
if(cnt<3)
@@ -70,10 +72,6 @@ void OnTick()
currentMA = bufferMA[1];
currentColor = bufferColor[1];
Print("Signal ", tradeSignal(), " Stop loss ", getAutoStopLoss(tradeSignal()));
Print("currentMA ", currentMA, " currentColor ", currentColor);
CloseTransactions();
ExecuteEntry();
}
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.");
}
}
}
//+------------------------------------------------------------------+
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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");