diff --git a/Experts/Nkanven/HighTension.ex5 b/Experts/Nkanven/HighTension.ex5 index 2786363..e99a184 100644 Binary files a/Experts/Nkanven/HighTension.ex5 and b/Experts/Nkanven/HighTension.ex5 differ diff --git a/Experts/Nkanven/HighTension.mq5 b/Experts/Nkanven/HighTension.mq5 index 262c038..1b89c00 100644 --- a/Experts/Nkanven/HighTension.mq5 +++ b/Experts/Nkanven/HighTension.mq5 @@ -14,6 +14,7 @@ #include //Lot size calculator #include //Lot size calculator #include //Emergency close of transaction +#include //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(); } diff --git a/Include/Nkanven/HighTension/EntriesManager.mqh b/Include/Nkanven/HighTension/EntriesManager.mqh index 535a2c1..580549f 100644 Binary files a/Include/Nkanven/HighTension/EntriesManager.mqh and b/Include/Nkanven/HighTension/EntriesManager.mqh differ diff --git a/Include/Nkanven/HighTension/Notifications.mqh b/Include/Nkanven/HighTension/Notifications.mqh new file mode 100644 index 0000000..b0f8214 --- /dev/null +++ b/Include/Nkanven/HighTension/Notifications.mqh @@ -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."); + } + } + } +//+------------------------------------------------------------------+ diff --git a/Include/Nkanven/HighTension/Parameters.mqh b/Include/Nkanven/HighTension/Parameters.mqh index 645d328..c76d941 100644 --- a/Include/Nkanven/HighTension/Parameters.mqh +++ b/Include/Nkanven/HighTension/Parameters.mqh @@ -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; diff --git a/Include/Nkanven/HighTension/Prechecks.mqh b/Include/Nkanven/HighTension/Prechecks.mqh index 82ff17b..e32ed83 100644 --- a/Include/Nkanven/HighTension/Prechecks.mqh +++ b/Include/Nkanven/HighTension/Prechecks.mqh @@ -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");