diff --git a/Experts/Nkanven/Lotcal.ex5 b/Experts/Nkanven/Lotcal.ex5 index 6569467..422b8c4 100644 Binary files a/Experts/Nkanven/Lotcal.ex5 and b/Experts/Nkanven/Lotcal.ex5 differ diff --git a/Experts/Nkanven/Lotcal.mq5 b/Experts/Nkanven/Lotcal.mq5 index 42a4496..b9b29a4 100644 Binary files a/Experts/Nkanven/Lotcal.mq5 and b/Experts/Nkanven/Lotcal.mq5 differ diff --git a/Experts/Nkanven/NYMidnightBreak.ex5 b/Experts/Nkanven/NYMidnightBreak.ex5 new file mode 100644 index 0000000..b77fac1 Binary files /dev/null and b/Experts/Nkanven/NYMidnightBreak.ex5 differ diff --git a/Experts/Nkanven/NYMidnightBreak.mq5 b/Experts/Nkanven/NYMidnightBreak.mq5 new file mode 100644 index 0000000..81f58a8 --- /dev/null +++ b/Experts/Nkanven/NYMidnightBreak.mq5 @@ -0,0 +1,53 @@ +//+------------------------------------------------------------------+ +//| NYMidnightBreak.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" + +#include // EA paramters +#include // Lot size calculator + +#define SECONDSINADAY 86400 +//+------------------------------------------------------------------+ +//| Expert initialization function | +//+------------------------------------------------------------------+ +int OnInit() + { +//--- + +//--- + return(INIT_SUCCEEDED); + } +//+------------------------------------------------------------------+ +//| Expert deinitialization function | +//+------------------------------------------------------------------+ +void OnDeinit(const int reason) + { +//--- + + } +//+------------------------------------------------------------------+ +//| Expert tick function | +//+------------------------------------------------------------------+ +void OnTick() + { +//--- +//--- The date is on Sunday + datetime time=D'2002.04.25 12:00'; + string symbol="GBPUSD"; + ENUM_TIMEFRAMES tf=PERIOD_H1; + bool exact=false; +//--- If there is no bar at the specified time, iBarShift will return the index of the nearest bar + int bar_index=iBarShift(symbol,tf,time,exact); +//--- Check the error code after the call of iBarShift() + +datetime Midnight, StartOfNewYear; + + + Midnight = TimeCurrent() - ( TimeCurrent()%SECONDSINADAY ); // midnight today as a datetime + Print(" Hour ", dt.hour, " midnight " , Midnight); + } +//+------------------------------------------------------------------+ diff --git a/Include/Nkanven/NYMidnightBreak/Functions.mqh b/Include/Nkanven/NYMidnightBreak/Functions.mqh new file mode 100644 index 0000000..30ec714 --- /dev/null +++ b/Include/Nkanven/NYMidnightBreak/Functions.mqh @@ -0,0 +1,30 @@ +//+------------------------------------------------------------------+ +//| Functions.mqh | +//| Copyright 2022, MetaQuotes Ltd. | +//| https://www.mql5.com | +//+------------------------------------------------------------------+ +#property copyright "Copyright 2022, MetaQuotes Ltd." +#property link "https://www.mql5.com" + + +//Check and return if the spread is not too high +void CheckSpread() + { +//Get the current spread in points, the (int) transforms the double coming from MarketInfo into an integer to avoid a warning when compiling + long SpreadCurr=(int)Spread; + Print("Spread ", Spread); + if(SpreadCurr<=InpMaxSpread) + { + IsSpreadOK=true; + } + else + { + IsSpreadOK=false; + } + } + +double GetSignalBoundries() +{ + //Get midnight high and low + iHigh() +} \ No newline at end of file diff --git a/Include/Nkanven/NYMidnightBreak/LotSizeCal.mqh b/Include/Nkanven/NYMidnightBreak/LotSizeCal.mqh new file mode 100644 index 0000000..5ff8fc3 --- /dev/null +++ b/Include/Nkanven/NYMidnightBreak/LotSizeCal.mqh @@ -0,0 +1,56 @@ +//+------------------------------------------------------------------+ +//| 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; + + //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 + LotSize=((RiskBaseAmount*InpMaxRiskPerTrade/100)/(SL*TickValue)); + } + //If the stop loss is zero then the lot size is the default one + if(SL==0) + { + LotSize=InpDefaultLotSize; + } + } +//Normalize the Lot Size to satisfy the allowed lot increment and minimum and maximum position size + LotSize=MathFloor(LotSize/SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_STEP); + +//Limit the lot size in case it is greater than the maximum allowed by the user + if(LotSize>InpMaxLotSize) + LotSize=InpMaxLotSize; +//Limit the lot size in case it is greater than the maximum allowed by the broker + if(LotSize>SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX)) + LotSize=SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX); + Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(gSymbol,SYMBOL_VOLUME_MAX)); +//If the lot size is too small then set it to 0 and don't trade + if(LotSize