Files
MT5-EA-Sniper-Strategy/Experts/Nkanven/HighTension.mq5
T

96 lines
3.3 KiB
Plaintext
Raw Normal View History

2022-03-31 23:30:44 +01:00
//+------------------------------------------------------------------+
//| HighTension.mq5 |
//| Copyright 2022, Nkondog Anselme Venceslas. |
//| https://www.linkedin/in/nkondog.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Nkondog Anselme Venceslas."
#property link "https://www.linkedin/in/nkondog.com"
#property version "1.00"
#include <Trade\Trade.mqh>
#include <Nkanven\HighTension\Parameters.mqh> //EA paramters
#include <Nkanven\HighTension\Prechecks.mqh> //Trading conditions checks
#include <Nkanven\HighTension\ScanPositions.mqh> //Trading conditions checks
#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
2022-04-15 07:39:35 +01:00
#include <Nkanven\HighTension\Notifications.mqh> //Handle notification
2022-03-31 23:30:44 +01:00
int handle;
const int indexMA = 0;
const int indexColor = 1;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
2022-04-01 02:08:33 +01:00
handle = iCustom(gSymbol, PERIOD_CURRENT, "Nkanven\MA-Slope", InpPeriods, InpMethod, InpAppliedPrice);
2022-03-31 23:30:44 +01:00
if(handle == INVALID_HANDLE)
{
PrintFormat("Error %i ", GetLastError());
return(INIT_FAILED);
}
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
IndicatorRelease(handle);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
2022-04-01 02:08:33 +01:00
TimeCurrent(dt);
SymbolInfoTick(_Symbol,last_tick);
2022-04-15 07:39:35 +01:00
2022-04-01 02:08:33 +01:00
CheckPreChecks();
2022-04-15 07:39:35 +01:00
Comment("Spread ", DoubleToString(Spread,0));
2022-04-01 02:08:33 +01:00
if(!gIsPreChecksOk)
return;
2022-04-15 07:39:35 +01:00
//Print("TF", PERIOD_CURRENT, " 1min ", PERIOD_M1, " 5min ", PERIOD_M5, " Period ", Period());
2022-05-12 16:02:50 +01:00
/*ScanPositions();*/
2022-03-31 23:30:44 +01:00
if(!newBar())
2022-05-12 16:02:50 +01:00
return;
2022-03-31 23:30:44 +01:00
int cnt = CopyBuffer(handle, indexMA, 0, 3, bufferMA);
if(cnt<3)
return;
cnt = CopyBuffer(handle, indexColor, 0, 3, bufferColor);
currentMA = bufferMA[1];
currentColor = bufferColor[1];
2022-04-01 02:08:33 +01:00
CloseTransactions();
ExecuteEntry();
2022-03-31 23:30:44 +01:00
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool newBar()
{
static datetime prevTime = 0;
datetime currentTime = iTime(gSymbol, PERIOD_CURRENT, 0);
if(currentTime != prevTime)
{
prevTime = currentTime;
return(true);
}
return(false);
}
//+------------------------------------------------------------------+