2022-03-10 20:06:09 +01:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| TheChallenger.mq5 |
|
|
|
|
|
//| Copyright 2022, MetaQuotes Ltd. |
|
|
|
|
|
//| https://www.mql5.com |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#property copyright "Copyright 2022, MetaQuotes Ltd."
|
|
|
|
|
#property link "https://www.mql5.com"
|
|
|
|
|
#property version "1.00"
|
|
|
|
|
|
2022-03-13 00:00:52 +01:00
|
|
|
#include <Trade\Trade.mqh>
|
2022-03-10 20:06:09 +01:00
|
|
|
#include <Nkanven\TheChallenger\Parameters.mqh> //EA paramters
|
|
|
|
|
#include <Nkanven\TheChallenger\TradingHour.mqh> //Trading hours checks
|
|
|
|
|
#include <Nkanven\TheChallenger\Prechecks.mqh> //Trading conditions checks
|
|
|
|
|
#include <Nkanven\TheChallenger\ScanPositions.mqh> //Trading conditions checks
|
|
|
|
|
#include <Nkanven\TheChallenger\LotSizeCal.mqh> //Lot size calculator
|
|
|
|
|
#include <Nkanven\TheChallenger\EntriesManager.mqh> //Lot size calculator
|
2022-03-13 00:00:52 +01:00
|
|
|
#include <Nkanven\TheChallenger\CloseTransactions.mqh> //Emergency close of transaction
|
2022-03-10 20:06:09 +01:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| Expert initialization function |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
|
#include <Indicators/Oscilators.mqh>
|
|
|
|
|
CiATR* atr;
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
int OnInit()
|
|
|
|
|
{
|
|
|
|
|
//---
|
|
|
|
|
atr = new CiATR();
|
2022-03-12 19:02:59 +01:00
|
|
|
atr.Create(gSymbol, InpTimeFrame, InpAtrPeriod);
|
2022-03-10 20:06:09 +01:00
|
|
|
//---
|
|
|
|
|
return(INIT_SUCCEEDED);
|
|
|
|
|
}
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| Expert deinitialization function |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
void OnDeinit(const int reason)
|
|
|
|
|
{
|
|
|
|
|
//---
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| Expert tick function |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
void OnTick()
|
|
|
|
|
{
|
|
|
|
|
//---
|
|
|
|
|
TimeCurrent(dt);
|
|
|
|
|
|
|
|
|
|
SymbolInfoTick(_Symbol,last_tick);
|
2022-03-13 00:00:52 +01:00
|
|
|
|
2022-03-10 20:06:09 +01:00
|
|
|
CheckOperationHours();
|
|
|
|
|
CheckPreChecks();
|
|
|
|
|
ScanPositions();
|
|
|
|
|
|
2022-03-13 17:33:48 +01:00
|
|
|
//Get ATR values
|
2022-03-10 20:06:09 +01:00
|
|
|
atr.Refresh(-1);
|
|
|
|
|
gAtr = atr.Main(1);
|
2022-03-13 00:00:52 +01:00
|
|
|
|
2022-03-10 20:06:09 +01:00
|
|
|
if(!gIsPreChecksOk)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-03-13 16:43:14 +01:00
|
|
|
if(InpActivateRiskWatcher)
|
|
|
|
|
{
|
|
|
|
|
drawdownWatcher();
|
|
|
|
|
CloseTransactions();
|
|
|
|
|
}
|
2022-03-10 20:06:09 +01:00
|
|
|
ExecuteEntry();
|
|
|
|
|
}
|
|
|
|
|
//+------------------------------------------------------------------+
|