mirror of
https://github.com/rithsila/MT5-EA-Sniper-Strategy.git
synced 2026-08-19 05:38:15 +00:00
Initial commit. Working on DCA Manager
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,78 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| GeminiHedge.mq5 |
|
||||
//| 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"
|
||||
#property version "1.00"
|
||||
#include <Trade\Trade.mqh>
|
||||
#include <Nkanven\GeminiHedge\Parameters.mqh> //EA paramters
|
||||
#include <Nkanven\GeminiHedge\TradingHour.mqh> //Trading hours checks
|
||||
#include <Nkanven\GeminiHedge\Prechecks.mqh> //Trading conditions checks
|
||||
#include <Nkanven\GeminiHedge\ScanPositions.mqh> //Trading conditions checks
|
||||
#include <Nkanven\GeminiHedge\LotSizeCal.mqh> //Lot size calculator
|
||||
#include <Nkanven\GeminiHedge\EntriesManager.mqh> //Lot size calculator
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
//---
|
||||
//---
|
||||
return(INIT_SUCCEEDED);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert deinitialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//---
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert tick function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
//---
|
||||
TimeCurrent(dt);
|
||||
string instruments[];
|
||||
|
||||
if(InpActivateDCAHedging)
|
||||
{
|
||||
string instruments[] = {InpInstrument1, InpInstrument2};
|
||||
}
|
||||
else
|
||||
{
|
||||
string instruments[] = {InpInstrument1};
|
||||
}
|
||||
|
||||
for(int i=0; i<ArraySize(instruments); i++)
|
||||
{
|
||||
Spread = SymbolInfoInteger(instruments[i], SYMBOL_SPREAD);
|
||||
SymbolInfoTick(instruments[i],last_tick);
|
||||
gSymbol = instruments[i];
|
||||
|
||||
|
||||
CheckOperationHours();
|
||||
CheckPreChecks();
|
||||
ScanPositions();
|
||||
|
||||
if(!gIsPreChecksOk)
|
||||
return;
|
||||
|
||||
//Check if positions not exist
|
||||
|
||||
|
||||
//Check pending orders
|
||||
|
||||
Print("Good for trading...");
|
||||
ExecuteEntry();
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,27 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| CheckHistory.mqh |
|
||||
//| Copyright 2021, Nkondog Anselme Venceslas |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
|
||||
#property link "https://www.mql5.com"
|
||||
//+------------------------------------------------------------------+
|
||||
//| defines |
|
||||
//+------------------------------------------------------------------+
|
||||
// #define MacrosHello "Hello, world!"
|
||||
// #define MacrosYear 2010
|
||||
//+------------------------------------------------------------------+
|
||||
//| DLL imports |
|
||||
//+------------------------------------------------------------------+
|
||||
// #import "user32.dll"
|
||||
// int SendMessageA(int hWnd,int Msg,int wParam,int lParam);
|
||||
// #import "my_expert.dll"
|
||||
// int ExpertRecalculate(int wParam,int lParam);
|
||||
// #import
|
||||
//+------------------------------------------------------------------+
|
||||
//| EX5 imports |
|
||||
//+------------------------------------------------------------------+
|
||||
// #import "stdlib.ex5"
|
||||
// string ErrorDescription(int error_code);
|
||||
// #import
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,29 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| DCAManager.mqh |
|
||||
//| Copyright 2022, MetaQuotes Ltd. |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2022, MetaQuotes Ltd."
|
||||
#property link "https://www.mql5.com"
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
void DcaManager()
|
||||
{
|
||||
//Compute pending orders levels
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
void DcaWatcher()
|
||||
{
|
||||
if(gTotalBuyPositions > 0)
|
||||
{
|
||||
//return position exists
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
@@ -0,0 +1,62 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| LotSizeCal.mqh |
|
||||
//| Copyright 2021, Nkondog Anselme Venceslas |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
|
||||
#property link "https://www.mql5.com"
|
||||
|
||||
|
||||
//Lot Size Calculator
|
||||
void LotSizeCalculate(double SL=0)
|
||||
{
|
||||
//If the position size is dynamic
|
||||
if(InpRiskDefaultSize==RISK_DEFAULT_AUTO)
|
||||
{
|
||||
//If the stop loss is not zero then calculate the lot size
|
||||
if(SL!=0)
|
||||
{
|
||||
double RiskBaseAmount=0;
|
||||
Print("Compute lot size");
|
||||
|
||||
//TickValue is the value of the individual price increment for 1 lot of the instrument, expressed in the account currenty
|
||||
double TickValue=SymbolInfoDouble(gSymbol,SYMBOL_TRADE_TICK_VALUE);
|
||||
//Define the base for the risk calculation depending on the parameter chosen
|
||||
if(InpRiskBase==RISK_BASE_BALANCE)
|
||||
RiskBaseAmount=AccountInfoDouble(ACCOUNT_BALANCE);
|
||||
if(InpRiskBase==RISK_BASE_EQUITY)
|
||||
RiskBaseAmount=AccountInfoDouble(ACCOUNT_EQUITY);
|
||||
if(InpRiskBase==RISK_BASE_FREEMARGIN)
|
||||
RiskBaseAmount=AccountInfoDouble(ACCOUNT_FREEMARGIN);
|
||||
|
||||
//Calculate the Position Size
|
||||
gLotSize=((RiskBaseAmount*InpMaxRiskPerTrade/100)/(SL*TickValue));
|
||||
|
||||
Print("(RiskBaseAmount ", RiskBaseAmount, " InpMaxRiskPerTrade ", InpMaxRiskPerTrade, " SL ", SL, " TickValue ", TickValue);
|
||||
}
|
||||
|
||||
//If the stop loss is zero then the lot size is the default one
|
||||
if(SL==0)
|
||||
{
|
||||
gLotSize=InpDefaultLotSize;
|
||||
}
|
||||
}
|
||||
//Normalize the Lot Size to satisfy the allowed lot increment and minimum and maximum position size
|
||||
gLotSize=MathFloor(gLotSize/SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_STEP);
|
||||
|
||||
Print("LotSize ", gLotSize);
|
||||
//Limit the lot size in case it is greater than the maximum allowed by the broker
|
||||
if(gLotSize>SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX))
|
||||
gLotSize=SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX);
|
||||
Print("Lot ", gLotSize, " Max lot ", SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX));
|
||||
|
||||
Print("LotSize2 ", gLotSize);
|
||||
//If the lot size is too small then set it to 0 and don't trade
|
||||
if(gLotSize<InpMinLotSize || gLotSize < SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MIN))
|
||||
{
|
||||
gLotSize=0;
|
||||
Print("Lot size too small : ", gLotSize);
|
||||
}
|
||||
Print("LotSize3 ", gLotSize);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,140 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Parameters.mqh |
|
||||
//| Copyright 2021, Nkondog Anselme Venceslas |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
|
||||
#property link "https://www.mql5.com"
|
||||
|
||||
//Enumerative for the base used for risk calculation
|
||||
enum ENUM_RISK_BASE
|
||||
{
|
||||
RISK_BASE_EQUITY=1, //EQUITY
|
||||
RISK_BASE_BALANCE=2, //BALANCE
|
||||
RISK_BASE_FREEMARGIN=3, //FREE MARGIN
|
||||
};
|
||||
|
||||
//Enumerative for the default risk size
|
||||
enum ENUM_RISK_DEFAULT_SIZE
|
||||
{
|
||||
RISK_DEFAULT_FIXED=1, //FIXED SIZE
|
||||
RISK_DEFAULT_AUTO=2, //AUTOMATIC SIZE BASED ON RISK
|
||||
};
|
||||
|
||||
//Enumerative for the Stop Loss mode
|
||||
enum ENUM_MODE_SL
|
||||
{
|
||||
SL_FIXED=0, //FIXED STOP LOSS
|
||||
SL_AUTO=1, //AUTOMATIC STOP LOSS
|
||||
};
|
||||
|
||||
//Enumerative for the Take Profit Mode
|
||||
enum ENUM_MODE_TP
|
||||
{
|
||||
TP_FIXED=0, //FIXED TAKE PROFIT
|
||||
TP_AUTO=1, //AUTOMATIC TAKE PROFIT
|
||||
};
|
||||
|
||||
//Enumerative for the stop loss calculation
|
||||
enum ENUM_MODE_SL_BY
|
||||
{
|
||||
SL_BY_POINTS=0, //STOP LOSS PASSED IN POINTS
|
||||
SL_BY_PRICE=1, //STOP LOSS PASSED BY PRICE
|
||||
};
|
||||
|
||||
//Enumerative for trading time
|
||||
enum ENUM_MODE_TRADING_TIME
|
||||
{
|
||||
DAY_TRADING=0, //Day trade
|
||||
NIGHT_TRADING=1, //Night trade
|
||||
DAY_NIGHT_TRADING=2, //Both day & night trade
|
||||
ALL_DAY_TRADING=3, //Round the clock
|
||||
};
|
||||
|
||||
//Enumerative for trading time
|
||||
enum ENUM_MODE_TRADE_SIGNAL
|
||||
{
|
||||
BUY_SIGNAL=0, //Buy trade
|
||||
SELL_SIGNAL=1, //Sell trade
|
||||
NO_SIGNAL=2, //No trade
|
||||
};
|
||||
|
||||
//Enumerative for the Take Profit Mode
|
||||
enum ENUM_DCA_STATUS
|
||||
{
|
||||
NO_DEALS=0,
|
||||
NO_BUY_POSITIONS=1, //FIXED TAKE PROFIT
|
||||
NO_UPPER_BUY_ORDERS=2, //AUTOMATIC TAKE PROFIT
|
||||
NO_LOWER_BUY_ORDERS=3,
|
||||
};
|
||||
v
|
||||
//
|
||||
// Input Section
|
||||
//
|
||||
|
||||
input string Comment_0="=========="; //Risk Management Settings
|
||||
|
||||
input ENUM_RISK_DEFAULT_SIZE InpRiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
|
||||
input double InpDefaultLotSize=0.01; //Position Size (if fixed or if no stop loss defined)
|
||||
input ENUM_RISK_BASE InpRiskBase=RISK_BASE_BALANCE; //Risk Base
|
||||
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 InpSlippage=1; //Maximum Slippage Allowed in points
|
||||
input string Comment_01="----------------------"; //Stop loss settings
|
||||
input int InpDefaultStopLoss=200; //Default Stop Loss In Points (0=No Stop Loss)
|
||||
input int InpMinStopLoss=0; //Minimum Allowed Stop Loss In Points
|
||||
input int InpMaxStopLoss=5000; //Maximum Allowed Stop Loss In Points
|
||||
input string Comment_02="----------------------"; //Take profit settings
|
||||
input int InpDefaultTakeProfit=60; //Default Take Profit In Points (0=No Take Profit)
|
||||
input int InpMinTakeProfit=0; //Minimum Allowed Take Profit In Points
|
||||
input int InpMaxTakeProfit=5000; //Maximum Allowed Take Profit In Points
|
||||
input double InpTakeProfitPercent=1.0; //Take Profit percent on risk base
|
||||
|
||||
input string Comment_03="----------------------"; //Trading Hours Settings
|
||||
input bool InpUseTradingHours=false; //Limit Trading Hours
|
||||
input ENUM_MODE_TRADING_TIME InpTradingPeriods=ALL_DAY_TRADING; //Select trading periods
|
||||
input int InpDayTradingHourStart=7; //Day Trading Start Hour (Broker Server Hour)
|
||||
input int InpDayTradingHourEnd=21; //Day Trading End Hour (Broker Server Hour)
|
||||
input int InpNightTradingHourStart=1; //Night Trading Start Hour (Broker Server Hour)
|
||||
input int InpNightTradingHourEnd=5; //Night Trading End Hour (Broker Server Hour)
|
||||
|
||||
input string Comment_04="----------------------"; //DCA settings
|
||||
input bool InpActivateDCAHedging=false; //Active DCA Hedging
|
||||
input string InpInstrument1="EURUSD.i"; //Instrument 1
|
||||
input string InpInstrument2="USDCHF.i"; //Instrument 2
|
||||
|
||||
input string Comment_05="----------------------"; //Stop loss settings
|
||||
// Fast moving average
|
||||
input int InpPeriods = 21; // Fast periods
|
||||
input ENUM_MA_METHOD InpMethod = MODE_SMA; // Fast method
|
||||
input ENUM_APPLIED_PRICE InpAppliedPrice = PRICE_CLOSE; // Fast price
|
||||
input string InpComment = __FILE__; //Default trade comment
|
||||
input int InpMagicNumber = 198901; //Magic Number
|
||||
input ENUM_TIMEFRAMES InpTimeFrame = PERIOD_CURRENT;
|
||||
input int InpSameCandleCount= 2; //Same Candle in a row
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
string gSymbol;
|
||||
|
||||
int gTotalBuyOrders, gTotalBuyPositions, gTotalOrders, gTotalPositions;
|
||||
bool gIsOperatingHours=false;
|
||||
bool gIsPreChecksOk=false; //Indicates if the pre checks are satisfied
|
||||
bool gIsSpreadOK=false; //Indicates if the spread is low enough to trade
|
||||
bool IsSpreadOK=false;
|
||||
bool gEmergencyClose=false; //Urgently close losing trade
|
||||
|
||||
|
||||
double gLotSize=InpDefaultLotSize;
|
||||
|
||||
int gTickValue=0;
|
||||
long Spread;// = SymbolInfoInteger(gSymbol,SYMBOL_SPREAD) / 100; //Check the impact. It's originally a double
|
||||
|
||||
int gOrderOpRetry = 10;
|
||||
|
||||
MqlTick last_tick, blast_tick;
|
||||
MqlDateTime dt;
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,79 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Prechecks.mqh |
|
||||
//| Copyright 2021, Nkondog Anselme Venceslas |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
|
||||
#property link "https://www.mql5.com"
|
||||
|
||||
//Perform integrity checks when the EA is loaded
|
||||
void CheckPreChecks()
|
||||
{
|
||||
gIsPreChecksOk=true;
|
||||
//Check if Live Trading is enabled
|
||||
if(!MQLInfoInteger(MQL_TRADE_ALLOWED))
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Live Trading is not enabled, please enable it in Metatrader and chart settings");
|
||||
return;
|
||||
}
|
||||
//Trading period verification
|
||||
if(!gIsOperatingHours)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Out of trading hours");
|
||||
return;
|
||||
}
|
||||
//Check if the default stop loss you are setting in above the minimum and below the maximum
|
||||
if(InpDefaultStopLoss<InpMinStopLoss || InpDefaultStopLoss>InpMaxStopLoss)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Default Stop Loss must be between Minimum and Maximum Stop Loss Allowed");
|
||||
return;
|
||||
}
|
||||
//Check if the default take profit you are setting in above the minimum and below the maximum
|
||||
if(InpDefaultTakeProfit<InpMinTakeProfit || InpDefaultTakeProfit>InpMaxTakeProfit)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Default Take Profit must be between Minimum and Maximum Take Profit Allowed");
|
||||
return;
|
||||
}
|
||||
//Check if the Lot Size is between the minimum and maximum
|
||||
if(InpDefaultLotSize<InpMinLotSize || InpDefaultLotSize>InpMaxLotSize)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Default Lot Size must be between Minimum and Maximum Lot Size Allowed");
|
||||
return;
|
||||
}
|
||||
//Slippage must be >= 0
|
||||
if(InpSlippage<0)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Slippage must be a positive value");
|
||||
return;
|
||||
}
|
||||
//MaxSpread must be >= 0
|
||||
if(InpMaxSpread<0)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Maximum Spread must be a positive value");
|
||||
return;
|
||||
}
|
||||
//MaxRiskPerTrade is a % between 0 and 100
|
||||
if(InpMaxRiskPerTrade<0 || InpMaxRiskPerTrade>100)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Maximum Risk Per Trade must be a percentage between 0 and 100");
|
||||
return;
|
||||
}
|
||||
//Spread is acceptable
|
||||
long SpreadCurr=(int)Spread;
|
||||
Print("Spread ", Spread);
|
||||
if(SpreadCurr>InpMaxSpread)
|
||||
{
|
||||
gIsPreChecksOk=false;
|
||||
Print("Spread is higher than Max acceptable spread");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,76 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ScanPositions.mqh |
|
||||
//| Copyright 2021, Nkondog Anselme Venceslas |
|
||||
//| https://www.linkedin.com/in/nkondog |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
|
||||
#property link "https://www.linkedin.com/in/nkondog"
|
||||
|
||||
//Scan all positions to find the ones submitted by the EA
|
||||
//NOTE This function is defined as bool because we want to return true if it is successful and false if it fails
|
||||
void ScanPositions()
|
||||
{
|
||||
|
||||
//Scan all the orders, retrieving some of the details
|
||||
gTotalPositions = PositionsTotal();
|
||||
gTotalOrders = OrdersTotal();
|
||||
gTotalBuyPositions = 0;
|
||||
gTotalBuyOrders = 0;
|
||||
|
||||
for(int i=0; i<gTotalPositions; i++)
|
||||
{
|
||||
//If there is a problem reading the order print the error, exit the function and return false
|
||||
if(PositionGetTicket(i) == 0)
|
||||
{
|
||||
int Error=GetLastError();
|
||||
//string ErrorText=GetLastErrorText(Error);
|
||||
//Print("ERROR - Unable to select the order - ",Error," - ",ErrorText);
|
||||
Print("ERROR - Unable to select the order - ",Error," - ",Error);
|
||||
return;
|
||||
}
|
||||
//If the order is not for the instrument on chart we can ignore it
|
||||
if(PositionGetSymbol(i)!=gSymbol)
|
||||
continue;
|
||||
//If the order has Magic Number different from the Magic Number of the EA then we can ignore it
|
||||
if(PositionGetInteger(POSITION_MAGIC)!=InpMagicNumber)
|
||||
continue;
|
||||
//If it is a buy order then increment the total count of buy orders
|
||||
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
|
||||
gTotalBuyPositions++;
|
||||
|
||||
Print("POSITION_TYPE_BUY ", POSITION_TYPE_BUY, " PositionGetInteger(POSITION_TYPE) ", PositionGetInteger(POSITION_TYPE));
|
||||
}
|
||||
Print("Total positions ", gTotalPositions, " - Total buys ", gTotalBuyPositions);
|
||||
|
||||
|
||||
|
||||
for(int i=0; i<gTotalOrders; i++)
|
||||
{
|
||||
//If there is a problem reading the order print the error, exit the function and return false
|
||||
if(OrderGetTicket(i) == 0)
|
||||
{
|
||||
int Error=GetLastError();
|
||||
//string ErrorText=GetLastErrorText(Error);
|
||||
//Print("ERROR - Unable to select the order - ",Error," - ",ErrorText);
|
||||
Print("ERROR - Unable to select the order - ",Error," - ",Error);
|
||||
return;
|
||||
}
|
||||
//If the order is not for the instrument on chart we can ignore it
|
||||
if(OrderGetString(ORDER_SYMBOL)!=gSymbol)
|
||||
continue;
|
||||
//If the order has Magic Number different from the Magic Number of the EA then we can ignore it
|
||||
if(OrderGetInteger(ORDER_MAGIC)!=InpMagicNumber)
|
||||
continue;
|
||||
//If it is a buy order then increment the total count of buy orders
|
||||
if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY)
|
||||
gTotalBuyPositions++;
|
||||
|
||||
Print("ORDER_TYPE_BUY ", ORDER_TYPE_BUY, " PositionGetInteger(ORDER_TYPE) ", OrderGetInteger(ORDER_TYPE));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
Print("Total Orders ", gTotalOrders, " - Total buys ", gTotalBuyOrders);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| TradingHour.mqh |
|
||||
//| Copyright 2021, Nkondog Anselme Venceslas |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
|
||||
#property link "https://www.mql5.com"
|
||||
|
||||
//Check and return if it is operation hours or not
|
||||
void CheckOperationHours()
|
||||
{
|
||||
bool day_trading = false, night_trading = false;
|
||||
gIsOperatingHours=false;
|
||||
|
||||
//If we are not using operating hours then IsOperatingHours is true and I skip the other checks
|
||||
if(!InpUseTradingHours || InpTradingPeriods == ALL_DAY_TRADING)
|
||||
{
|
||||
gIsOperatingHours=true;
|
||||
Print("Round clock trading");
|
||||
return;
|
||||
}
|
||||
|
||||
if(InpTradingPeriods == DAY_TRADING)
|
||||
{
|
||||
Print("dt.hour ", dt.hour," >= InpDayTradingHourStart ", InpDayTradingHourStart ," ", dt.hour >= InpDayTradingHourStart);
|
||||
Print("dt.hour ", dt.hour," <= InpDayTradingHourEnd ", InpDayTradingHourEnd ," ", dt.hour <= InpDayTradingHourEnd);
|
||||
|
||||
//Check day trading hours
|
||||
if(dt.hour >= InpDayTradingHourStart && dt.hour <= InpDayTradingHourEnd)
|
||||
{
|
||||
day_trading = true;
|
||||
gIsOperatingHours=true;
|
||||
Print("Day period trading");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
Print("InpTradingPeriods == NIGHT_TRADING ", InpTradingPeriods == NIGHT_TRADING);
|
||||
if(InpTradingPeriods == NIGHT_TRADING)
|
||||
{
|
||||
//Check night trading hours
|
||||
if(dt.hour >= InpNightTradingHourStart && dt.hour <= InpNightTradingHourEnd)
|
||||
{
|
||||
night_trading = true;
|
||||
gIsOperatingHours=true;
|
||||
Print("Night period trading");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(InpTradingPeriods == DAY_NIGHT_TRADING)
|
||||
{
|
||||
//Check night trading hours
|
||||
if(day_trading || night_trading)
|
||||
{
|
||||
gIsOperatingHours=true;
|
||||
Print("Day and night periods trading");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1 @@
|
||||
<mxfile host="app.diagrams.net" modified="2022-03-16T13:21:47.927Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36 Edg/89.0.774.68" etag="E0apx0Uk7C3yas40CVFH" version="17.1.3" type="device"><diagram id="U2lFxktPaEXklclutEbk" name="Page-1">1Vpbb6s4EP41kXYfWgHmlsekTXtW291Wp5V6+uiAQ7wlODKmTc6vX1PM1YSQBEjahwqPx8bMfPMxM2EEblabewrXy3+Ii/yRpribEbgdaZqtjvn/WLBNBLqtJQKPYjcRqbngGf9GQqgIaYRdFJYUGSE+w+uy0CFBgBxWkkFKyWdZbUH88l3X0EOS4NmBvix9xS5bisfSrFz+A2Fvmd5ZNcUDr2CqLJ4kXEKXfBZEYDYCN5QQllytNjfIj22X2iVZd7djNjsYRQFrs8CYPv6GLxq+ZxDTt49JdLX6uFLNZJsP6EfiicVp2TY1AXK5RcSQULYkHgmgP8ulU0qiwEXxfRQ+ynUeCFlzocqF/yHGtsK9MGKEi5Zs5YvZBfb9G+IT+nVH4BrIdnUuDxkl76gwY2tzYJp8JjllfLSd5hCikETUQU020AWuIPUQa1I0MrdxuCOyQoxu+UKKfMjwR/kkUADPy/Ry3/AL4Z5DXKVLrpo4jBum6i8OtHV8Ga38RAFMPxBlmIP6Ac6R/0RCzDAJuMqcMEZWBYWJj714gsWOK3qIRMzHAXdFGmZK5oR4Ldo0u0E2mlgARHQIelAtMf7Mgy1VWRbizFR6srJmXERAdAlvoyW8d3lqIHjXGd70+YGnc45x04uvHmAUOEuuNZtIXvlcYoae1/DLGJ/8ZVS2aD3CjyWekzA/NvZiXtUGBb0q2f6JImeJnPdQsjNdktU84keY7rF4xbYL/ucodbZdLBT+141tNaNCKLZsXLvGtnpvttUk295BP0RHsErBtlCg2EcLVgPujNdR4E7iLCjec42CRCJYx270RZnCuPXp9hcfXCnXijZOJW/x9LVu26ngdlNccLstjp4QxdymiJbeHhLH7SW0BjLcz3FmI3quxD6tKU/s9EQwP0m2ja6UQagpFXQl5xSrcoBxV8FtQW0dK4S776ONy/cRuWcO12TDHLzZE5+AZyDh+YVG/cI54erOsayUYWzsAfFZ8GoPgdcqjjKG7BmvoFyy9ATY8UVkdGctcTTzRLwNkwNqcjW6Ow/h++F1GPumUPDw+oTb0z88ObEd5Dh17pjbhm50VexU8S/nJlZNblKNxs7sDWQuP0dodAl0uyXQgVLvqcOY9FACNJRGAtyrnyYS/RKmLUehaBmEsZ82OGQSTHIQqAcHnwuRvagNPtOx0XzRUfCZ9rVVrryy91Gx8lK1a0OOwd5qr5QDCtbmJOYmHZrvVXsZ+oXVXkCua79z7TVQvpoi8ph8FeiNCOkoXzUrRb7VT7pq2LW36ZV8gdwuuNTyKktUu4HrrgT5LDAepE1QxReoEmFPOB6k7ALWEZg9OZXMwZfj7a0Et8PAN0h1Btr+ALULlsNUZ0D+AerJjxMQ/tScKnDg8StCXURrmsYXnx6aleRFr0sNh2zK68ZZAmiDWRI/liGGb4WpPHziQam9e0TUdRlDbTscYHxiDB1FwZZWrjyA3Vz4WabVpN8TZcvtl5u49xK7JC8A775viIMW5d+gP7zp4IJiXGkX4+rolLSudaOtG1YYt2WFHXXLQG9WuUU9i7ssySvVg+s/wj8b4k250HanpZRJLPtZ7HzxJjdbJl+rQtTU0jrcwMN8SGCY1Zzl7AZu8z1ZXmg6PgxDnAARUiaLCxbeVWVea6WcQ93DR+3Z5eh0vGB9o8b4qezUJoi2w/npFgk7StWjXB6qlY20fsrQ6oH35UDVjHyvvtmYY/WTM+mWBPgfs9v7v/6958KXn5Pb5Gr6+ML/vz7+/Pvu4fH1NKrxKHQxB2tKKgEJ4rTAj7/tm0Ln3fvarXb2K3WrzCxIwNKEQ03HSeqgWRVmE0vKpCaEHfBZ5WNAYMp0llFXMaLUKvRb8Bkf5t/eJmjIP2AGs/8B</diagram></mxfile>
|
||||
Reference in New Issue
Block a user