feat: Complete MT5 EA Sniper Strategy implementation with comprehensive documentation

- Add complete MT5 Expert Advisor with institutional trading concepts
- Implement Order Blocks (OB), Break of Structure (BOS), Liquidity Sweeps, and Fair Value Gaps (FVG)
- Include AI integration with GrokAI for enhanced market analysis
- Add comprehensive risk management and session management systems
- Implement advanced optimization and backtesting frameworks
- Include complete test suite with integration, performance, and validation tests
- Add professional documentation with API docs, deployment guide, and user manual
- Update README.md with industry-standard documentation and Mermaid architecture diagram
- Add comprehensive .gitignore for MT5 development environment
- Include system validation and test results reports

Features:
 Multi-timeframe analysis (1M, 15M, H4)
 Institutional trading concepts implementation
 AI-powered market structure analysis
 Advanced risk management with Monte Carlo simulation
 Real-time news filtering and fundamental analysis
 Adaptive parameter optimization
 Comprehensive testing and validation framework
 Professional documentation and deployment guides
This commit is contained in:
sila
2025-09-20 15:25:18 +07:00
parent 352ff26fc7
commit b6166d4246
289 changed files with 29606 additions and 17098 deletions
Vendored
BIN
View File
Binary file not shown.
-83
View File
@@ -1,83 +0,0 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
# Node artifact files
node_modules/
dist/
# Compiled Java class files
*.class
# Compiled Python bytecode
*.py[cod]
# Log files
*.log
# Package files
*.jar
# Maven
target/
dist/
# JetBrains IDE
.idea/
# Unit test reports
TEST*.xml
# Generated by MacOS
.DS_Store
# Generated by Windows
Thumbs.db
# Applications
*.app
*.exe
*.war
# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv
# VS folder
.vscode/
# MT4/MT5 files
MT4/MT5 files
Files/
Images/
Indicators/
Libraries/
Logs/
Presets/
Profiles/
Scripts/
Services/
Shared Projets/
*.dat
Experts/Advisors/
Experts/Examples/
Include/Arrays/
Include/C*
Include/Expert/
Include/Files/
Include/G*
Include/I
Include/M*
Include/O*
Include/S*
Include/T*
Include/W*
Include/V*
Shared Projects/
-5
View File
@@ -1,5 +0,0 @@
{
"files.associations": {
"*.mqh": "cpp"
}
}
-172
View File
@@ -1,172 +0,0 @@
//+------------------------------------------------------------------+
//| LotCal.mq4 |
//| 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"
#property strict
//Parameters
//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
RISK_BASE_INPUT=4, //INPUT BASE
};
//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
};
input ENUM_RISK_DEFAULT_SIZE InpRiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
input double InpBalance=10000.0; //Balance
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 Allowedv
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string Symb = Symbol();
double LotSize=InpDefaultLotSize;
double price=0.0;
double risk=0.0;
double StoplossPips=0.0;
//TickValue is the value of the individual price increment for 1 lot of the instrument, expressed in the account currenty
double TickValue=SymbolInfoDouble(Symb,SYMBOL_TRADE_TICK_VALUE);
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Print("The Expert Advisor with name ",MQLInfoString(MQL_PROGRAM_NAME)," is running");
//--- enable object create events
ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_CREATE,true);
//--- enable object delete events
ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_DELETE,true);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
LotSizeCalculate(price);
//Comment("Lot size : ", LotSize);
double StopAmount = StoplossPips * LotSize * TickValue;
string text ="Lot size for "+ InpMaxRiskPerTrade +"% = " + DoubleToString(LotSize,2) + " lot (" + DoubleToString(StopAmount, 2) + " " + AccountInfoString(ACCOUNT_CURRENCY) + ")";
string name = "Lot";
ObjectCreate(name, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name,text, 14, "Corbel Bold", YellowGreen);
ObjectSet(name, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
ObjectSet(name, OBJPROP_XDISTANCE, 350);
ObjectSet(name, OBJPROP_YDISTANCE, 10);
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, // Event identifier
const long& lparam, // Event parameter of long type
const double& dparam, // Event parameter of double type
const string& sparam) // Event parameter of string type
{
//--- the object has been deleted
if(id==CHARTEVENT_OBJECT_DELETE)
{
Print("The object with name ",sparam," has been deleted");
}
//--- the object has been created
if(id==CHARTEVENT_OBJECT_CREATE)
{
Print("The object with name ",sparam," has been created");
}
//--- the object has been moved or its anchor point coordinates has been changed
if(id==CHARTEVENT_OBJECT_DRAG)
{
price = ObjectGetDouble(0, sparam, OBJPROP_PRICE, 0);
Print("The anchor point coordinates of the object with name ",sparam," has been changed. Price ", price);
}
}
//Lot Size Calculator
void LotSizeCalculate(double stopLoss)
{
double SL=0;
double PriceAsk=MarketInfo(0,MODE_ASK);
double PriceBid=MarketInfo(0,MODE_BID);
if(stopLoss < PriceAsk)
{
SL = (PriceAsk-stopLoss)/_Point;
}
if(stopLoss > PriceAsk)
{
SL = (stopLoss-PriceBid)/_Point;
}
Print("Stop loss distance ", SL);
//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;
//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);
if(InpRiskBase==RISK_BASE_INPUT)
RiskBaseAmount=InpBalance;
//Calculate the Position Size
Print("RiskBaseAmount ", RiskBaseAmount, " MaxRiskPerTrade ", InpMaxRiskPerTrade, "Stop loss ", SL, " TickValue ", TickValue);
LotSize=((RiskBaseAmount*InpMaxRiskPerTrade/100)/(SL*TickValue));
StoplossPips = SL;
}
//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(Symb,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(Symb,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(Symb,SYMBOL_VOLUME_MAX))
LotSize=SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX);
Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX));
//If the lot size is too small then set it to 0 and don't trade
if(LotSize < SymbolInfoDouble(Symb,SYMBOL_VOLUME_MIN))
{
LotSize=0;
Print("Lot size too small");
}
}
//+------------------------------------------------------------------+
View File
Binary file not shown.
-253
View File
@@ -1,253 +0,0 @@
//+------------------------------------------------------------------+
//| LotCal.mq4 |
//| 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 "2.00" //Handle take profit ant dymanic horizontal line price detection
#property strict
#define KEY_B 66
#define KEY_S 83
//Parameters
//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
RISK_BASE_INPUT=4, //INPUT BASE
};
//Enumerative for the default risk type
enum ENUM_RISK_DEFAULT_TYPE
{
FIXED=1, //FIXED
Percent=2, //AMOUNT BASE
};
//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
};
input ENUM_RISK_DEFAULT_SIZE InpRiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
input double InpDefaultLotSize=0.01; //Lot Size if fixed Position Size Mode = FIXED
input ENUM_RISK_BASE InpRiskBase=RISK_BASE_BALANCE; //Risk Base
input ENUM_RISK_DEFAULT_TYPE InpRiskDefaultType=FIXED; //Risk Type
input double InpFixRiskAmount=10; //Max Account Risk ($) if risk type = FIXED
input double InpMaxLossPercent=1.0; //Max Account Risk (%)
input double InpTPMultiple=1; //TP multiple %
input double InpMinLotSize=0.01; //Minimum lot Size Allowed
input double InpMaxLotSize=100; //Maximum lot Size Allowed
input int InpSlippage=1; //Slippage
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string Symb = Symbol();
double RiskBaseAmount=InpFixRiskAmount;
double MaxRiskPerTrade=InpFixRiskAmount; //Percentage To Risk Each Trade
double LotSize=InpDefaultLotSize;
double stopLoss=0.0;
double TakeProfit=0.0;
double risk=0.0;
double StoplossPips=0.0;
//TickValue is the value of the individual price increment for 1 lot of the instrument, expressed in the account currenty
double TickValue=SymbolInfoDouble(Symb,SYMBOL_TRADE_TICK_VALUE);
int ticket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Print("The Expert Advisor with name ",MQLInfoString(MQL_PROGRAM_NAME)," is running");
//--- enable object create events
ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_CREATE,true);
//--- enable object delete events
ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_DELETE,true);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
stopLoss = NormalizeDouble(ObjectGetDouble(0, "sl", OBJPROP_PRICE), _Digits);
//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);
displayOnChart();
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, // Event identifier
const long& lparam, // Event parameter of long type
const double& dparam, // Event parameter of double type
const string& sparam) // Event parameter of string type
{
//--- the object has been deleted
if(id==CHARTEVENT_OBJECT_DELETE)
{
Print("The object with name ",sparam," has been deleted");
}
//--- the object has been created
if(id==CHARTEVENT_OBJECT_CREATE)
{
Print("The object with name ",sparam," has been created");
}
/*--- the object has been moved or its anchor point coordinates has been changed
if(id==CHARTEVENT_OBJECT_DRAG)
{
price = ObjectGetDouble(0, sparam, OBJPROP_PRICE, 0);
//Print("The anchor point coordinates of the object with name ",sparam," has been changed. Price ", price);
displayOnChart();
}*/
if(id==CHARTEVENT_KEYDOWN)
{
switch(lparam)
{
case KEY_B:
///SendOrder(TRADE_ACTION_DEAL, ORDER_TYPE_BUY,Symb,last_tick.ask,price,LotSize);
ticket = OrderSend(Symb, OP_BUY, LotSize, Ask, 1, stopLoss, TakeProfit);
Alert("Buy " + (string)LotSize + " lot " + Symb + " at " + (string)Ask + " SL at " + (string)stopLoss);
break;
case KEY_S:
ticket = OrderSend(Symb, OP_SELL, LotSize, Bid, 1, stopLoss,TakeProfit);
Alert("Sell " + (string)LotSize + " lot " + Symb + " at " + (string)Bid + " SL at " + (string)stopLoss);
break;
default:
//Print("Do nothing");
break;
}
if(ticket<=0)
{
int error=GetLastError();
//---- not enough money
//if(error==134);
//---- 10 seconds wait
Sleep(10000);
//---- refresh price data
RefreshRates();
}
else
{
OrderSelect(ticket,SELECT_BY_TICKET);
OrderPrint();
}
}
}
//Lot Size Calculator
void LotSizeCalculate(double sLoss)
{
double SL=0;
double PriceAsk=MarketInfo(0,MODE_ASK);
double PriceBid=MarketInfo(0,MODE_BID);
double spread = MarketInfo(0,MODE_SPREAD) * _Point;
double pipDiff = 0.0;
if(sLoss < PriceAsk)
{
pipDiff = PriceAsk-sLoss;
SL = pipDiff /_Point;
//Print("TakeProfit ", TakeProfit, " PriceAsk ", PriceAsk, " pipDiff ", pipDiff, " InpTPMultiple ", InpTPMultiple, " spread ", spread);
TakeProfit = PriceAsk + (pipDiff * InpTPMultiple) + (spread*2);
}
if(sLoss > PriceAsk)
{
pipDiff = sLoss-PriceBid;
SL = pipDiff /_Point;
//Print("TakeProfit ", TakeProfit, " PriceAsk ", PriceBid, " pipDiff ", pipDiff, " InpTPMultiple ", InpTPMultiple, " spread ", spread);
TakeProfit = PriceBid - (pipDiff * InpTPMultiple) - (spread*2);
}
TakeProfit = NormalizeDouble(TakeProfit, _Digits);
//Print("Stop loss distance ", SL);
StoplossPips = SL;
//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)
{
//Calculate the Position Size
LotSize=((RiskBaseAmount*MaxRiskPerTrade/100)/(SL*TickValue));
}
}
//Normalize the Lot Size to satisfy the allowed lot increment and minimum and maximum position size
LotSize=MathFloor(LotSize/SymbolInfoDouble(Symb,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(Symb,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(Symb,SYMBOL_VOLUME_MAX))
LotSize=SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX);
//Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX));
//If the lot size is too small then set it to 0 and don't trade
if(LotSize < SymbolInfoDouble(Symb,SYMBOL_VOLUME_MIN))
{
LotSize=0;
//Print("Lot size too small");
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void displayOnChart()
{
double initialLoss = (RiskBaseAmount * InpMaxLossPercent) / 100;
if(InpRiskDefaultType == FIXED)
{
initialLoss = InpFixRiskAmount;
}
initialLoss = NormalizeDouble(initialLoss, 2);
MaxRiskPerTrade = NormalizeDouble((initialLoss * 100) / RiskBaseAmount, 2);
LotSizeCalculate(stopLoss);
//Comment("Lot size : ", LotSize);
double StopAmount = StoplossPips * LotSize * TickValue;
if(InpRiskDefaultSize == RISK_DEFAULT_FIXED)
{
MaxRiskPerTrade = NormalizeDouble((StopAmount * 100) / RiskBaseAmount, 2);
}
string text ="Lot size for "+ (string)DoubleToString(MaxRiskPerTrade,2) +"% = " + DoubleToString(LotSize,2) + " lot (" + DoubleToString(StopAmount, 2) + " " + AccountInfoString(ACCOUNT_CURRENCY) + ")";
string name = "Lot";
ObjectCreate(name, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name,text, 14, "Corbel Bold", YellowGreen);
ObjectSet(name, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
ObjectSet(name, OBJPROP_XDISTANCE, 350);
ObjectSet(name, OBJPROP_YDISTANCE, 10);
}
//+------------------------------------------------------------------+
Binary file not shown.
Binary file not shown.
@@ -1,128 +0,0 @@
//+------------------------------------------------------------------+
//| MuzzlingAlligatorWatcher.mq4 |
//| Copyright 2022, Nkondog Anselme Venceslas. |
//| https://www.linkedin.com/in/nkondog |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Nkondog Anselme Venceslas."
#property link "ttps://www.linkedin.com/in/nkondog"
#property version "1.00"
#property strict
#include <Nkanven/Lib/Navlib.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
input string Comment_0="=========="; //Alligator parameters
input ENUM_TIMEFRAMES inpTimeframe = PERIOD_CURRENT; //Timeframe
input int inpJawsPeriod = 13; //Jaws period
input int inpJawsShift = 8; //Jaws shift
input int inpTeethPeriod = 8; //Teeth period
input int inpTeethShift = 5; //Teeth shift
input int inpLipsPeriod = 5; //Lips period
input int inpLipsShift = 3; //Lips shift
input ENUM_MA_METHOD inpMethod = MODE_SMMA; //Method
input ENUM_APPLIED_PRICE inpApplyedTo = PRICE_MEDIAN; //Applied to
input string Comment_1="=========="; //Moving average parameters
input ENUM_MA_METHOD inpMAMethod = MODE_SMA; //MA method
input int inpMAPeriod = 200; //MA period
input int inpMASHift = 0; //MA shift
input ENUM_APPLIED_PRICE inpMAApplyedTo = PRICE_CLOSE; //MA applied to
double jaws, teeth, lips, sma, prevCandleHigh, prevCandleLow, currentPrice, prevClosePrice;
string comm = "";
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
if(!newCandle())
return;
jaws=iAlligator(NULL,0,inpJawsPeriod,inpJawsShift,inpTeethPeriod,inpTeethShift,inpLipsPeriod,inpLipsShift,MODE_SMMA,PRICE_MEDIAN,MODE_GATORJAW,0);
teeth=iAlligator(NULL,0,inpJawsPeriod,inpJawsShift,inpTeethPeriod,inpTeethShift,inpLipsPeriod,inpLipsShift,MODE_SMMA,PRICE_MEDIAN,MODE_GATORTEETH,0);
lips=iAlligator(NULL,0,inpJawsPeriod,inpJawsShift,inpTeethPeriod,inpTeethShift,inpLipsPeriod,inpLipsShift,MODE_SMMA,PRICE_MEDIAN,MODE_GATORLIPS,0);
sma = iMA(NULL,0,inpMAPeriod,inpMASHift,inpMAMethod,inpMAApplyedTo,1);
Print(" Jaws ", jaws, " teeth ", teeth, " lips ", lips, " sma ", sma);
//Get previous candle
prevCandleHigh = iHigh(NULL, PERIOD_CURRENT, 1);
prevCandleLow = iLow(NULL, PERIOD_CURRENT, 1);
currentPrice = iClose(NULL, PERIOD_CURRENT, 0);
prevClosePrice = iClose(NULL, PERIOD_CURRENT, 1);
//comm = "jaws " + (string)jaws + " teeth " + (string)teeth + " lips " + (string)lips + " sma " + (string)sma;
comm = "Trade alert on " + Symbol();
comm += "\n";
comm += "";
if(sma < currentPrice)
{
//Alert for bullish continuation signal
if(prevClosePrice > jaws && prevClosePrice > teeth && prevClosePrice > lips)
{
if(prevCandleLow < jaws || prevCandleLow < teeth ||prevCandleLow < lips)
{
comm += " LONG CONTINUATION SIGNAL: Price above SMA just moves above Alligator. \n";
Notify(comm);
}
}
//Alert for bearish counter trend signal
if(lips > teeth && teeth > jaws)
{
if(prevClosePrice < jaws && prevClosePrice < teeth && prevClosePrice < lips)
{
comm += " SHORT COUNTER TREND SIGNAL: Price above SMA moves below Alligator in a trending market \n";
Notify(comm);
}
}
}
if(sma > currentPrice)
{
//Alert for bearish continuation signal
if(prevClosePrice < jaws && prevClosePrice < teeth && prevClosePrice < lips)
{
if(prevCandleHigh > jaws || prevCandleHigh > teeth ||prevCandleHigh > lips)
{
comm += " SHORT CONTINUATION SIGNAL: Price below SMA just moves below Alligator. \n";
Notify(comm);
}
}
//Alert for bullish counter trend signal
if(lips < teeth && teeth < jaws)
{
if(prevClosePrice > jaws && prevClosePrice > teeth && prevClosePrice > lips)
{
comm += " LONG COUNTER TREND SIGNAL: Price below SMA just closes above Alligator in a down trending market \n";
Notify(comm);
}
}
}
}
//+------------------------------------------------------------------+
Binary file not shown.
-51
View File
@@ -1,51 +0,0 @@
//+------------------------------------------------------------------+
//| NewCandleAlert.mq4 |
//| 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"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
newBar();
}
//+------------------------------------------------------------------+
bool newBar()
{
static datetime prevTime = 0;
datetime currentTime = iTime(Symbol(), PERIOD_CURRENT, 0);
if(currentTime != prevTime)
{
prevTime = currentTime;
Alert("New candle");
return(true);
}
return(false);
}
Binary file not shown.
-236
View File
@@ -1,236 +0,0 @@
//+------------------------------------------------------------------+
//| Telegram2MT4.mq4 |
//| 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"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
enum ENUM_RISK_DEFAULT
{
RISK_DEFAULT_FIXED = 1,
RISK_DEFAULT_AUTO = 2,
};
input ENUM_RISK_DEFAULT inpRiskDefault = RISK_DEFAULT_FIXED; //Lot sizing mode
input double inpDefaultLotSize = 0.01; //Default lot
input double inpRiskPercent = 0.1; //Risk percentage
input double inpMaxLotSize = 10; //Max lot
input int inpMaxSlippage = 3; //Max slippage
input int inpMagicNumber = 1987; //Magic number
input string inpSymbolPrefix = ""; //Symbol prefix
input string inpSymbolSuffix = ""; //Symbol suffix
double vbid,vask,vpoint;
int vdigits, vspread;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//---
checkForPermissions();
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
//read file writen by TelegramReader
readTelegramFile();
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void readTelegramFile()
{
//--- open the file
string fileName = "order.bin";
ResetLastError();
string table[];
int file_handle=FileOpen("Telegramreader"+"//"+fileName,FILE_READ|FILE_ANSI, " ");
if(file_handle!=INVALID_HANDLE)
{
PrintFormat("%s file is available for reading",fileName);
PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH));
//--- additional variables
int str_size;
string str;
int i = 0;
//--- read data from the file
while(!FileIsEnding(file_handle))
{
//--- find out how many symbols are used for writing the time
str_size=FileReadInteger(file_handle,INT_VALUE);
//--- read the string
str=FileReadString(file_handle,str_size);
//--- print the string
Print("i" + i + " " + str);
ArrayResize(table, ArraySize(table) + 1);
table[i] = str;
i += 1;
}
//--- close the file
FileClose(file_handle);
//PrintFormat("Data is read, %s file is closed",fileName);
FileDelete("Telegramreader"+"//"+fileName);
sendOrder(table[2], table[0], table[1], NormalizeDouble(table[3], Digits), NormalizeDouble(table[4], Digits), NormalizeDouble(table[5], Digits));
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void sendOrder(string type, string direction, string symbol, double entryPrice, double takeProfit, double stopLoss)
{
int ticket = 0;
symbol = inpSymbolPrefix+symbol+inpSymbolSuffix;
double lotSize;
vbid = MarketInfo(symbol,MODE_BID);
vask = MarketInfo(symbol,MODE_ASK);
vpoint = MarketInfo(symbol,MODE_POINT);
vdigits = (int)MarketInfo(symbol,MODE_DIGITS);
vspread = (int)MarketInfo(symbol,MODE_SPREAD);
Print(type, direction, symbol, entryPrice, takeProfit, stopLoss);
if(type == "NOW")
{
if(direction == "BUY")
{
lotSize = LotSizeCalculate(OP_BUY, stopLoss, symbol, vpoint);
Print("Lot size ", lotSize);
ticket=OrderSend(symbol,OP_BUY,lotSize,vask,inpMaxSlippage, stopLoss,takeProfit,"Trade from eInvestors",inpMagicNumber,0,Green);
}
if(direction == "SELL")
{
lotSize = LotSizeCalculate(OP_SELL, stopLoss, symbol, vpoint);
Print("Lot size ", lotSize);
ticket=OrderSend(symbol,OP_SELL,lotSize,vbid,inpMaxSlippage, stopLoss,takeProfit,"Trade from eInvestors",inpMagicNumber,0,Green);
}
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
else
Print("Error opening BUY order : ",GetLastError());
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Compute lot size function |
//+------------------------------------------------------------------+
double LotSizeCalculate(int ordertype, double stoploss, string symbol, double vpoint)
{
double tickValue = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE);
double riskBaseAmount;
double lotSize = 0;
double SL = 0;
if(stoploss > 0)
{
if(ordertype == OP_BUY)
{
SL = (vask-stoploss)/vpoint;
}
else
if(ordertype == OP_SELL)
{
SL = (stoploss-vbid)/vpoint;
}
}
//Print("SL ", SL, " risk base ", AccountInfoDouble(ACCOUNT_BALANCE), "tick value ", tickValue);
Print("if statement ", SL != 0 && inpRiskDefault == RISK_DEFAULT_AUTO);
if(SL != 0 && inpRiskDefault == RISK_DEFAULT_AUTO)
{
riskBaseAmount = AccountInfoDouble(ACCOUNT_BALANCE);
lotSize = ((riskBaseAmount*inpRiskPercent/100)/(SL*tickValue));
}
else
{
lotSize = inpDefaultLotSize;
}
lotSize = MathFloor(lotSize/SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP))*SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP);
if(lotSize > inpMaxLotSize)
{
lotSize = inpMaxLotSize;
}
if(lotSize > SymbolInfoDouble(symbol, SYMBOL_VOLUME_MAX))
{
lotSize = SymbolInfoDouble(symbol, SYMBOL_VOLUME_MAX);
}
if(lotSize < SymbolInfoDouble(symbol, SYMBOL_VOLUME_MIN))
{
lotSize = SymbolInfoDouble(symbol, SYMBOL_VOLUME_MIN);
}
return lotSize;
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void checkForPermissions()
{
if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
Alert("Check if automated trading is allowed in the terminal settings!");
if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
Alert("Check if automated trading is allowed in the terminal settings!");
else
{
if(!MQLInfoInteger(MQL_TRADE_ALLOWED))
Alert("Automated trading is forbidden in the program settings for ",__FILE__);
}
if(!AccountInfoInteger(ACCOUNT_TRADE_EXPERT))
Alert("Automated trading is forbidden for the account ",AccountInfoInteger(ACCOUNT_LOGIN),
" at the trade server side");
if(!AccountInfoInteger(ACCOUNT_TRADE_ALLOWED))
Comment("Trading is forbidden for the account ",AccountInfoInteger(ACCOUNT_LOGIN),
".\n Perhaps an investor password has been used to connect to the trading account.",
"\n Check the terminal journal for the following entry:",
"\n\'",AccountInfoInteger(ACCOUNT_LOGIN),"\': trading has been disabled - investor mode.");
}
//+------------------------------------------------------------------+
-71
View File
@@ -1,71 +0,0 @@
//+------------------------------------------------------------------+
//| Navlib.mqh |
//| Copyright 2022, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property strict
void Notify(string message)
{
Print("Message sent ", message);
if(!IsTesting())
{
//SendNotification(message);
string headers;
string url = "https://api.telegram.org/bot5854676759:AAEGN1a1HQ-3uiVtv7FxEf7IXKrMATBzkQg/sendMessage?chat_id=-1001821417162&text="+message;
char data[],result[];
int res = WebRequest("GET",
url,
NULL,
NULL,
3000,
data,
0,
result,
headers
);
Print(CharArrayToString(result), " Res ", res, headers); // 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.");
}
}
} else
{
Comment(message);
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool newCandle()
{
static datetime prevTime = 0;
datetime currentTime = iTime(Symbol(), PERIOD_CURRENT, 0);
if(currentTime != prevTime)
{
prevTime = currentTime;
return(true);
}
return(false);
}
//+------------------------------------------------------------------+
-1
View File
@@ -1 +0,0 @@
New-Item -ItemType Junction -Path "C:\Users\Nkondog\AppData\Roaming\MetaQuotes\Terminal\E3E3B02889D32F38295D39BF94B6AD4A\MQL5\Include\Nkanven" -Target "D:\ITprojects\sat_bot\Include\Nkanven"
Binary file not shown.
-267
View File
@@ -1,267 +0,0 @@
//+------------------------------------------------------------------+
//| AreaBreaker.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
#property version "1.00"
#include <A_Parameters.mqh> // Description of variables
#include <DL_ErrorHandling.mqh> // Error library
#include <DL_PreChecks.mqh> // Prechecks
#include <DL_CheckOperationHours.mqh> //
#include <Trade\Trade.mqh>
#include <A_PositionsManager.mqh> // Scan for opened positions
#include <A_HistoryChecker.mqh> //Check transaction history
#include <A_TradeManager.mqh> //Manage trade dynamic open and close conditions
#include <A_EntriesManagement.mqh> // Check buy and sell entries signals and execute them
#include <A_LotSizeCal.mqh> // Lot size calculate
//#include <DL_TradingBoundaries.mqh> //Draw trading range boundaries on chart
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
//Zigzag drawing inputs
string prefix = "SRLevel_"; //Object name prefix
color lineColor = clrYellow;
int lineWeight = 2;
double SRLevels[];
double Buffer[];
int Handle;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Handle = iCustom(Symb, PERIOD_CURRENT, "Examples\\ZigZag", Depth, Deviation, Backstep);
if(Handle==INVALID_HANDLE)
{
Print("Could not create a handle to ZigZag indicator");
return(INIT_FAILED);
}
//Clean up any SR levels left from earlier indicators
ObjectsDeleteAll(0, prefix, 0, OBJ_HLINE);
ChartRedraw(0);
ArrayResize(SRLevels, LookBack);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
IndicatorRelease(Handle);
ObjectsDeleteAll(0, prefix, 0, OBJ_HLINE);
ChartRedraw(0);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
ArraySetAsSeries(Buffer,true);
CopyBuffer(Handle, 0, 0, 3, Buffer);
if(candleChanged())
if(Buffer[0]>0)
Print("Zigzag level ", Buffer[0]);
//DrawLevels();
SymbolInfoTick(_Symbol,last_tick);
if(!ScanPositions())
return;
CheckHistory();
CheckSpread();
EvaluateEntry();
ProfitRunner();
CloseOpenPositions();
ExecuteEntry();
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
/*
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//One time convert points to a price gap
static double levelGap = GapPoint*SymbolInfoDouble(Symb, SYMBOL_POINT);
if(rates_total ==prev_calculated)
return(rates_total);
//Get most recent lookback peaks
double zz =0;
double zzPeaks[];
int zzCount = 0;
ArrayResize(zzPeaks, LookBack);
ArrayInitialize(zzPeaks, 0.0);
int count = CopyBuffer(Handle, 0, 0, rates_total, Buffer);
if(count < 0)
{
int err = GetLastError();
return(0);
}
for(int i=1; i<rates_total && zzCount<LookBack; i++)
{
zz = Buffer[i];
Print(Buffer[i]);
if(zz != 0 && zz != EMPTY_VALUE)
{
zzPeaks[zzCount] = zz;
zzCount++;
}
}
ArraySort(zzPeaks);
//Search for grouping and set levels
int srCounter =0; //Number of support and resistance found
double price =0; //Average peaks price
int priceCount =0; //How many peaks are found
ArrayInitialize(SRLevels, 0.0);
for(int i=LookBack-1; i>=0; i--)
{
price += zzPeaks[i];
priceCount++;
if(i=0 || (zzPeaks[i]-zzPeaks[i-1]) > GapPoint)
{
if(priceCount >= Sensitivity)
{
price = price/priceCount;
SRLevels[srCounter] = price;
srCounter++;
}
price =0;
priceCount=0;
}
}
DrawLevels();
//--- return value of prev_calculated for next call
return(rates_total);
}
*/
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DrawLevels()
{
for(int i=0; i<LookBack; i++)
{
string name = "prefix_" + IntegerToString(i);
Print("Drawing SR Lookback ", LookBack, " Find object ", ObjectFind(0, name), " SRLevel ", i, " ", SRLevels[i]);
if(SRLevels[i] == 0)
{
ObjectDelete(0, name);
continue;
}
Print("Peak ", SRLevels[i], " numero ", i);
if(ObjectFind(0, name) < 0)
{
ObjectCreate(0,name, OBJ_HLINE, 0, 0, SRLevels[i]);
ObjectSetInteger(0, name, OBJPROP_COLOR, lineColor);
ObjectSetInteger(0, name, OBJPROP_WIDTH, lineWeight);
ObjectSetInteger(0, name, OBJPROP_SELECTABLE, true);
ObjectMove(0, name, 0, iTime(Symb,_Period,0), SRLevels[i]);
}
else
{
ObjectSetDouble(0, name, OBJPROP_PRICE, SRLevels[1]);
}
}
ChartRedraw(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool candleChanged()
{
MqlRates priceData[];
ArraySetAsSeries(priceData, true);
CopyRates(Symb, PERIOD_CURRENT, 0, 3, priceData);
static datetime timeStampLastCheck;
static int candleCounter;
datetime timeStampCurrentCandle;
timeStampCurrentCandle = priceData[0].time;
if(timeStampCurrentCandle != timeStampLastCheck)
{
timeStampLastCheck = timeStampCurrentCandle;
candleCounter = candleCounter+1;
return true;
}
return false;
}
//+------------------------------------------------------------------+
//Initialize variables
void InitializeVariables()
{
IsNewCandle=false;
IsTradedThisBar=false;
IsOperatingHours=false;
IsSpreadOK=false;
LotSize=DefaultLotSize;
TickValue=0;
TotalOpenBuy=0;
TotalOpenSell=0;
TotalOpenOrders=0;
SignalEntry=SIGNAL_ENTRY_NEUTRAL;
SignalExit=SIGNAL_EXIT_NEUTRAL;
Print("Variables intialized");
}
//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
double SpreadCurr=SymbolInfoInteger(Symb, SYMBOL_SPREAD);
Print("Spread ", SpreadCurr);
if(SpreadCurr<=MaxSpread)
{
IsSpreadOK=true;
}
else
{
IsSpreadOK=false;
}
}
//+------------------------------------------------------------------+
Binary file not shown.
Binary file not shown.
Binary file not shown.
-66
View File
@@ -1,66 +0,0 @@
//+------------------------------------------------------------------+
//| CandleCount.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 <Trade\Trade.mqh>
#include <Nkanven\CandleCount\Parameters.mqh> //EA paramters
#include <Nkanven\CandleCount\TradingHour.mqh> //Trading hours checks
#include <Nkanven\CandleCount\Prechecks.mqh> //Trading conditions checks
#include <Nkanven\CandleCount\ScanPositions.mqh> //Trading conditions checks
#include <Nkanven\CandleCount\LotSizeCal.mqh> //Lot size calculator
#include <Nkanven\CandleCount\EntriesManager.mqh> //Lot size calculator
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
#include <Indicators/Trend.mqh>
CiMA* sma;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//---
sma = new CiMA();
sma.Create(gSymbol, InpTimeFrame, InpPeriods, InpAppliedPrice, InpMethod, PRICE_CLOSE);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
TimeCurrent(dt);
SymbolInfoTick(InpInstrument1,last_tick);
SymbolInfoTick(InpInstrument2, blast_tick);
sma.Refresh(-1);
gSma = sma.Main(1);
CheckOperationHours();
CheckPreChecks();
ScanPositions();
if(!gIsPreChecksOk)
return;
Print("Good for trading...");
ExecuteEntry();
}
//+------------------------------------------------------------------+
Binary file not shown.
@@ -1,155 +0,0 @@
//+------------------------------------------------------------------+
//| EA_Template_1.0.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
#include <Expert\ExpertBase.mqh>
//Input section
//Some standard inputs
input double inpVolume = 0.01; //Default order size
input string inpComment = __FILE__; //Default trade comment
input int inpMagicNumber = 12345; //Magic number
//Declare the Expert
#define CExpert CExpertBase
CExpert *Expert;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//Assign the default values to the expert
Expert = new CExpert();
Expert.SetVolume(inpVolume);
Expert.SetTradeComment(__FILE__);
Expert.SetMagic(inpMagicNumber);
//--- create timer
EventSetTimer(60);
int result = Expert.OnInit();
//---
return(result);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
delete Expert;
return;
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
Expert.OnTick();
return;
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
Expert.OnTimer();
return;
}
//+------------------------------------------------------------------+
//| Trade function |
//+------------------------------------------------------------------+
void OnTrade()
{
//---
Expert.OnTrade();
return;
}
//+------------------------------------------------------------------+
//| TradeTransaction function |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result)
{
//---
Expert.OnTradeTransaction(trans, request, result);
return;
}
//+------------------------------------------------------------------+
//| Tester function |
//+------------------------------------------------------------------+
double OnTester()
{
//---
//double ret=0.0;
//---
//---
//return(ret);
return(Expert.OnTester());
}
//+------------------------------------------------------------------+
//| TesterInit function |
//+------------------------------------------------------------------+
void OnTesterInit()
{
//---
Expert.OnTesterInit();
return;
}
//+------------------------------------------------------------------+
//| TesterPass function |
//+------------------------------------------------------------------+
void OnTesterPass()
{
//---
Expert.OnTesterPass();
return;
}
//+------------------------------------------------------------------+
//| TesterDeinit function |
//+------------------------------------------------------------------+
void OnTesterDeinit()
{
//---
Expert.OnTesterDeinit();
return;
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
//+------------------------------------------------------------------+
//| BookEvent function |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{
//---
Expert.OnBookEvent();
return;
}
//+------------------------------------------------------------------+
-224
View File
@@ -1,224 +0,0 @@
/*
EA_Template.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2012-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
// Use the following line for the current framework
#include <Orchard/Frameworks/Framework.mqh>
// Use the following line for a specific framework (replace x.x)
//#include <Orchard/Frameworks/Framework_x.x/Framework.mqh>
//
// Input Section
//
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Indicators
//
CIndicatorBase *Indicator1;
//
// Signals
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
//
CTPSLBase *TPObject;
CTPSLBase *SLObject;
//
// Indicators for TPSL - use child class names instead of CIndicatorBase
//
CIndicatorBase *IndicatorTPSL1;
CIndicatorBase *IndicatorTPSL2;
int OnInit() {
//
// Instantiate the expert, use the child class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Set up the indicators
//
Indicator1 = new CIndicatorBase();
//
// Set up the signals
//
EntrySignal = new CSignalBase();
EntrySignal.AddIndicator(Indicator1, 0);
ExitSignal = new CSignalBase();
ExitSignal.AddIndicator(Indicator1, 0);
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new CTPSLBase(); // Create the object
IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new CTPSLBase();
IndicatorTPSL2 = new CIndicatorBase();
SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete Indicator1;
delete TPObject;
delete SLObject;
delete IndicatorTPSL1;
delete IndicatorTPSL2;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
Binary file not shown.
-134
View File
@@ -1,134 +0,0 @@
//+------------------------------------------------------------------+
//| Equilibrium.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
#property version "1.00"
#include <Indicators/Trend.mqh>
#include <Indicators\Oscilators.mqh>
CiIchimoku* ichimoku;
CiADX* adx;
CiATR* atr;
#include <E_Parameters.mqh> // Description of variables
#include <DL_ErrorHandling.mqh> // Error library
#include <DL_PreChecks.mqh> // Prechecks
#include <DL_CheckOperationHours.mqh> //
#include <Trade\Trade.mqh>
#include <DL_ScanPositions.mqh> // Scan for opened positions
#include <E_CheckHistory.mqh> //Check transaction history
#include <E_TradeManagement.mqh> //Manage trade dynamic open and close conditions
#include <E_EntriesManagement.mqh> // Check buy and sell entries signals and execute them
#include <DL_LotSizeCal.mqh> // Lot size calculate
//#include <DL_TradingBoundaries.mqh> //Draw trading range boundaries on chart
#include <E_ClosePositions.mqh> // Close opened positions
//TODO: Add ADX to filter ranging market
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//---
ichimoku = new CiIchimoku();
ichimoku.Create(Symb, PERIOD_CURRENT, tenkan_sen, kijun_sen, senkou_span_b);
atr = new CiATR();
atr.Create(Symb, PERIOD_CURRENT, atr_period);
// adx = new CiADX();
// adx.Create(Symb, PERIOD_CURRENT, adx_period);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
ichimoku.Refresh(-1);
Tenkansen = ichimoku.TenkanSen(0);
Kijunsen = ichimoku.KijunSen(0);
Senkouspana = ichimoku.SenkouSpanA(-26);
Senkouspanb = ichimoku.SenkouSpanB(-26);
BwSenkouspana = ichimoku.SenkouSpanA(26);
BwSenkouspanb = ichimoku.SenkouSpanB(26);
Chinkouspan = ichimoku.ChinkouSpan(26);
atr.Refresh(-1);
Atr = atr.Main(1);
/*adx.Refresh(-1);
AdxMain = adx.Main(1);
AdxPlus = adx.Plus(1);
AdxMinus = adx.Minus(1);*/
SymbolInfoTick(_Symbol,last_tick);
//ScanPositions scans all the opened positions and collect statistics, if an error occurs it skips to the next price change
if(!ScanPositions())
return;
CloseOpenPositions();
CheckHistory();
CheckSpread();
EvaluateEntry();
ProfitRunner();
ExecuteEntry();
Comment(
"Expert Advisor by Anselme Nkondog (c) 2021\n");
return;
}
//+------------------------------------------------------------------+
//Initialize variables
void InitializeVariables()
{
IsNewCandle=false;
IsTradedThisBar=false;
IsOperatingHours=false;
IsSpreadOK=false;
LotSize=DefaultLotSize;
TickValue=0;
TotalOpenBuy=0;
TotalOpenSell=0;
TotalOpenOrders=0;
SignalEntry=SIGNAL_ENTRY_NEUTRAL;
SignalExit=SIGNAL_EXIT_NEUTRAL;
Print("Variables intialized");
}
//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=Spread;
Print("Spread ", SpreadCurr);
if(SpreadCurr<=MaxSpread)
{
IsSpreadOK=true;
}
else
{
IsSpreadOK=false;
}
}
//+------------------------------------------------------------------+
@@ -1,21 +0,0 @@
/*
EA_Template.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description: Basic template for framework based MQ4 expert
Uses: framework_2.02 minimum
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// Load the common code
//
#include "EA_Template.mqh" // Remember to change this
@@ -1,64 +0,0 @@
/*
EA_Template.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description: Basic template for framework based MQ4 expert
Uses: framework_2.02 minimum
*/
#property copyright "Copyright 2012-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// Load the common code
//
#include "EA_Template.mqh" // Remember to change this
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
int OnTesterInit() {
return(Expert.OnTesterInit());
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
@@ -1,182 +0,0 @@
/*
EA_Template.mqh
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description: Holds common template code between MQ4 and MQ5
Uses: framework_2.02 minimum
*/
//
// This is where we pull in the framework
//
#include <Nkanven/Frameworks/Framework.mqh>
//
// Input Section
//
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20202020; // Magic Number
//
// Declare the expert, use the child class name
// If the base class does everything needed then it's OK to
// just use CExpertBase
// Declare the name CExpert as the actual class name.
// This allows other files to just refer to CExpert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Indicators - use the child class name instead of CIndicatorBase
// Remove if not needed
//
CIndicatorBase *Indicator1;
//
// Signals - use the child class name instead of CSignalBase
// Remove if not needed
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
// Remove if not needed
//
CTPSLBase *TPObject;
CTPSLBase *SLObject;
//
// Indicators for TPSL - use child class names instead of CIndicatorBase
// Remove if not needed
//
CIndicatorBase *IndicatorTPSL1;
CIndicatorBase *IndicatorTPSL2;
int OnInit() {
//
// Instantiate the expert
// Uses the declared class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators - using your child class name
//
Indicator1 = new CIndicatorBase();
//
// Set up the signals - using your child class names
//
EntrySignal = new CSignalBase();
EntrySignal.AddIndicator(Indicator1, 0); // Add as many indicators as you need
ExitSignal = new CSignalBase();
ExitSignal.AddIndicator(Indicator1, 0); // Add as many indicators as you need
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal); // repeat for more signals
Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new CTPSLBase(); // Create the object
IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new CTPSLBase();
IndicatorTPSL2 = new CIndicatorBase();
SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
// Delete all objects created
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete Indicator1;
delete TPObject;
delete SLObject;
delete IndicatorTPSL1;
delete IndicatorTPSL2;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
@@ -1,181 +0,0 @@
/*
EA_Template.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
// Use the following line for the current framework
#include <Orchard/Frameworks/Framework.mqh>
// Use the following line for a specific framework (replace x.x)
//#include <Orchard/Frameworks/Framework_x.x/Framework.mqh>
//
// Input Section
//
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Indicators
//
CIndicatorBase *Indicator1;
//
// Signals
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
//
CTPSLBase *TPObject;
CTPSLBase *SLObject;
//
// Indicators for TPSL - use child class names instead of CIndicatorBase
//
CIndicatorBase *IndicatorTPSL1;
CIndicatorBase *IndicatorTPSL2;
int OnInit() {
//
// Instantiate the expert, use the child class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Set up the indicators
//
Indicator1 = new CIndicatorBase();
//
// Set up the signals
//
EntrySignal = new CSignalBase();
EntrySignal.AddIndicator(Indicator1, 0);
ExitSignal = new CSignalBase();
ExitSignal.AddIndicator(Indicator1, 0);
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new CTPSLBase(); // Create the object
IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new CTPSLBase();
IndicatorTPSL2 = new CIndicatorBase();
SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete Indicator1;
delete TPObject;
delete SLObject;
delete IndicatorTPSL1;
delete IndicatorTPSL2;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
@@ -1,224 +0,0 @@
/*
EA_Template.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2012-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
// Use the following line for the current framework
#include <Nkanven/Frameworks/Framework.mqh>
// Use the following line for a specific framework (replace x.x)
//#include <Orchard/Frameworks/Framework_x.x/Framework.mqh>
//
// Input Section
//
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Indicators
//
CIndicatorBase *Indicator1;
//
// Signals
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
//
CTPSLBase *TPObject;
CTPSLBase *SLObject;
//
// Indicators for TPSL - use child class names instead of CIndicatorBase
//
CIndicatorBase *IndicatorTPSL1;
CIndicatorBase *IndicatorTPSL2;
int OnInit() {
//
// Instantiate the expert, use the child class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Set up the indicators
//
Indicator1 = new CIndicatorBase();
//
// Set up the signals
//
EntrySignal = new CSignalBase();
EntrySignal.AddIndicator(Indicator1, 0);
ExitSignal = new CSignalBase();
ExitSignal.AddIndicator(Indicator1, 0);
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new CTPSLBase(); // Create the object
IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new CTPSLBase();
IndicatorTPSL2 = new CIndicatorBase();
SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete Indicator1;
delete TPObject;
delete SLObject;
delete IndicatorTPSL1;
delete IndicatorTPSL2;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
@@ -1,197 +0,0 @@
/*
MA Crossover.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Nkanven/Frameworks/GervisFrame.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
// Bar numbers for comparison
//input int InpBar2 = 2; // Base bar number
//input int InpBar1 = 1; // Crossover bar number
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
//delete ExitSignal;
delete EntrySignal;
delete FastIndicator;
delete SlowIndicator;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
@@ -1,153 +0,0 @@
/*
MA Crossover.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Orchard/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
// Bar numbers for comparison
//input int InpBar2 = 2; // Base bar number
//input int InpBar1 = 1; // Crossover bar number
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
//delete ExitSignal;
delete EntrySignal;
delete FastIndicator;
delete SlowIndicator;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
@@ -1,197 +0,0 @@
/*
MA Crossover.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Nkanven/Frameworks/GDeaFramework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
// Bar numbers for comparison
//input int InpBar2 = 2; // Base bar number
//input int InpBar1 = 1; // Crossover bar number
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new iMA(Symbol(), PERIOD_CURRENT, InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new iMA(Symbol(), PERIOD_CURRENT, InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
//delete ExitSignal;
delete EntrySignal;
delete FastIndicator;
delete SlowIndicator;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
Binary file not shown.
Binary file not shown.
@@ -1,284 +0,0 @@
//+------------------------------------------------------------------+
//| SnT Bot.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.salixnigra.com"
#property version "1.0"
#include <Nkanven/Frameworks/GridFramework.mqh>
//
// Input Section
//
//This is where you should include the input parameters for your entry and exit signals
input string Comment_strategy="=========="; //Entry And Exit Settings
//Add in this section the parameters for the indicators used in your entry and exit
//General input parameters
input string Comment_0="=========="; //Risk Management Settings
input ENUM_RISK_DEFAULT_SIZE InpRiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
input double InpDefaultLotSize=1; //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 InpProfitPercent=1;
input double InpMinLotSize=0.01; //Min Lot Size
input double InpMaxLotSize=100; //Max Lot Size
input string Comment_1="=========="; //Trading Hours Settings
input bool InpUseTradingHours=false; //Activate Trading Hours
input string InpTradingHourStart="01"; //Trading Start Hour (Broker Server Hour)
input string InpTradingStartMin="30"; //Trading Start minute
input string InpTradingHourEnd="23"; //Trading End Hour (Broker Server Hour)
input string InpTradingEndMin="00"; //Trading End minute
input bool InpUseTradingSession=true;
input ENUM_TRADING_SESSION InpTradingSession = LONDON_SESSION; //Trading session
input string Comment_2="=========="; //Trading Hours Settings
input int InpGridGap = 1000;
input double InpVolume = 0.01; //Default order size
input string InpComment = __FILE__; //Default trade comment
input int InpMagicNumber = 20200701; //Magic Number
input int InpBrokerTimeZoneGMT = 2; //Broker timezone from GMT
input int InpSlippage = 2; //Slippage
input int not_used;
int londonSession[] = {7, 17};
int newyorkSession[] = {13, 23};
int tokyoSession[] = {0, 6};
//
// Declare the expert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals
//
CSignalGrid *EntrySignal;
CSignalGrid *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
//
GridTPSL *TPObject;
GridTPSL *SLObject;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//
// Instantiate the expert, use the child class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
Expert.SetDefaultLotSize(InpDefaultLotSize);
Expert.SetGridGap(InpGridGap);
Expert.SetGridNumber(10);
Expert.SetMaxLotSize(InpMaxLotSize);
Expert.SetMaxRiskPerTrade(InpMaxRiskPerTrade);
Expert.SetMinLotSize(InpMinLotSize);
Expert.SetRiskBase(InpRiskBase);
Expert.SetRiskDefaultSize(InpRiskDefaultSize);
Expert.SetUseTradingSession(InpTradingSession);
Expert.SetSlippage(InpSlippage);
Expert.SetProfitPercent(InpProfitPercent);
//
// Set up the signals
//
//EntrySignal = new CSignalGrid();
//EntrySignal.SetMaxRiskPerTrade(InpMaxRiskPerTrade);
//EntrySignal.setMmagic(InpMagicNumber);
//EntrySignal.AddIndicator(Indicator1, 0);
//ExitSignal = new CSignalGrid();
//ExitSignal.SetMaxRiskPerTrade(InpMaxRiskPerTrade);
//ExitSignal.setMmagic(InpMagicNumber);
//ExitSignal.AddIndicator(Indicator1, 0);
//
// Add the signals to the expert
//
//Expert.AddEntrySignal(EntrySignal);
//Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new GridTPSL(); // Create the object
//IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
//TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new GridTPSL();
//IndicatorTPSL2 = new CIndicatorBase();
//SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
EventKillTimer();
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete TPObject;
delete SLObject;
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
Expert.OnTick();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTimer()
{
Expert.OnTimer();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTrade()
{
Expert.OnTrade();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result)
{
Expert.OnTradeTransaction(trans, request, result);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
/*double OnTester()
{
return(Expert.OnTester());
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTesterInit()
{
Expert.OnTesterInit();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTesterPass()
{
Expert.OnTesterPass();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTesterDeinit()
{
Expert.OnTesterDeinit();
return;
}
*/
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{
Expert.OnBookEvent();
return;
}
//+------------------------------------------------------------------+
@@ -1,176 +0,0 @@
/*
MA Crossover ATR TPSL.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Orchard/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
//
// For ATR based TPSL
//
input int InpATRPeriods = 14; // ATR Periods
input double InpATRMultiplier = 3.0; // ATR Multiplier
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200000; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
//
// TPSL - use child class name
//
CTPSLSimple *TPSL;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
// And for the TPSL
CIndicatorATR *IndicatorATR;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Set up the ATR TPSL
//
TPSL = new CTPSLSimple();
IndicatorATR = new CIndicatorATR(InpATRPeriods);
TPSL.AddIndicator(IndicatorATR, 0);
TPSL.SetIndex(1);
TPSL.SetMultiplier(InpATRMultiplier);
Expert.SetTakeProfitObj(TPSL);
Expert.SetStopLossObj(TPSL);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete EntrySignal;
delete TPSL;
delete FastIndicator;
delete SlowIndicator;
delete IndicatorATR;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
@@ -1,221 +0,0 @@
/*
MA Crossover ATR TPSL.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Orchard/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
//
// For ATR based TPSL
//
input int InpATRPeriods = 14; // ATR Periods
input double InpATRMultiplier = 3.0; // ATR Multiplier
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200000; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL
//
CTPSLSimple *TPSL;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
// And for the TPSL
CIndicatorATR *IndicatorATR;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Set up the ATR TPSL
//
TPSL = new CTPSLSimple();
IndicatorATR = new CIndicatorATR(InpATRPeriods);
TPSL.AddIndicator(IndicatorATR, 0);
TPSL.SetIndex(1);
TPSL.SetMultiplier(InpATRMultiplier);
Expert.SetTakeProfitObj(TPSL);
Expert.SetStopLossObj(TPSL);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete EntrySignal;
delete TPSL;
delete FastIndicator;
delete SlowIndicator;
delete IndicatorATR;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
@@ -1,153 +0,0 @@
/*
MA Crossover.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Orchard/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
// Bar numbers for comparison
//input int InpBar2 = 2; // Base bar number
//input int InpBar1 = 1; // Crossover bar number
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
//delete ExitSignal;
delete EntrySignal;
delete FastIndicator;
delete SlowIndicator;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
@@ -1,197 +0,0 @@
/*
MA Crossover.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Nkanven/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
// Bar numbers for comparison
//input int InpBar2 = 2; // Base bar number
//input int InpBar1 = 1; // Crossover bar number
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
//delete ExitSignal;
delete EntrySignal;
delete FastIndicator;
delete SlowIndicator;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
Binary file not shown.
-115
View File
@@ -1,115 +0,0 @@
//+------------------------------------------------------------------+
//| GDeaLite.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
#property version "1.00"
#include <Indicators/Trend.mqh>
#include <Indicators/Oscilators.mqh>
CiMA* fsma;
CiMA* ssma;
CiATR* atr;
#include <Nkanven\GDea\Parameters.mqh> // Description of variables
#include <DL_ErrorHandling.mqh> // Error library
#include <Nkanven\GDea\PreChecks.mqh> // Prechecks
#include <Nkanven\GDea\TradingHour.mqh> //
#include <Trade\Trade.mqh>
#include <Nkanven\GDea\ScanPositions.mqh> // Scan for opened positions
#include <Nkanven\GDea\CheckHistory.mqh> //Check transaction history
#include <Nkanven\GDea\TradeManager.mqh> //Manage trade dynamic open and close conditions
#include <Nkanven\GDea\EntriesManager.mqh> // Check buy and sell entries signals and execute them
#include <Nkanven\GDea\LotSizeCal.mqh> // Lot size calculate
#include <Nkanven\GDea\ClosePositions.mqh> // Close opened positions
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
fsma = new CiMA();
ssma = new CiMA();
fsma.Create(gSymbol, PERIOD_CURRENT, InpFastPeriods, InpFastAppliedPrice, InpFastMethod, PRICE_CLOSE);
ssma.Create(gSymbol, PERIOD_CURRENT, InpSlowPeriods, InpFastAppliedPrice, InpSlowMethod, PRICE_CLOSE);
atr = new CiATR();
atr.Create(gSymbol, PERIOD_CURRENT, InpAtrPeriod);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
fsma.Refresh(-1);
ssma.Refresh(-1);
gSsma = ssma.Main(1);
//isQualifiedCandle(0);
OrderClose();
if(!ScanPositions())
return;
if(OrdersTotal()>0)
return;
CheckSpread();
entryConditions();
EvaluateEntry();
ExecuteEntry();
Comment(
"Expert Advisor by Anselme Nkondog (c) 2021\n");
}
//+------------------------------------------------------------------+
//Initialize variables
void InitializeVariables()
{
gIsNewCandle=false;
gIsTradedThisBar=false;
gIsOperatingHours=false;
gIsSpreadOK=false;
gLotSize=InpDefaultLotSize;
gTickValue=0;
gTotalOpenBuy=0;
gTotalOpenSell=0;
gSignalEntry=SIGNAL_ENTRY_NEUTRAL;
gSignalExit=SIGNAL_EXIT_NEUTRAL;
Print("Variables intialized");
}
//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=SymbolInfoInteger(gSymbol, SYMBOL_SPREAD);
Print("Spread ", SpreadCurr);
if(SpreadCurr<=InpMaxSpread)
{
gIsSpreadOK=true;
}
else
{
gIsSpreadOK=false;
}
}
//+------------------------------------------------------------------+
Binary file not shown.
-81
View File
@@ -1,81 +0,0 @@
//+------------------------------------------------------------------+
//| 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\DCAManager.mqh> //DCA manager
#include <Nkanven\GeminiHedge\LotSizeCal.mqh> //Lot size calculator
#include <Nkanven\GeminiHedge\EntriesManager.mqh> //Trade entries manager
//+------------------------------------------------------------------+
//| 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)
{
Print("DCA Hedging is activated");
ArrayResize(instruments,2);
instruments[0] = InpInstrument1;
instruments[1] = InpInstrument2;
}
else
{
Print("DCA Hedging is not activated");
ArrayResize(instruments,1);
instruments[0] = InpInstrument1;
}
for(int i=0; i<ArraySize(instruments); i++)
{
Spread = SymbolInfoInteger(instruments[i], SYMBOL_SPREAD);
SymbolInfoTick(instruments[i],last_tick);
gSymbol = instruments[i];
point = SymbolInfoDouble(gSymbol, SYMBOL_POINT);
CheckOperationHours();
CheckPreChecks();
ScanPositions();
if(!gIsPreChecksOk)
return;
DcaManager();
Print("Good for trading...");
ExecuteEntry();
}
}
//+------------------------------------------------------------------+
Binary file not shown.
-115
View File
@@ -1,115 +0,0 @@
//+------------------------------------------------------------------+
//| Gervis.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
#property version "1.00"
#include <Indicators/Trend.mqh>
#include <Indicators/Oscilators.mqh>
CiMA* sma;
CiMA* ssma;
#include <Nkanven\Gervis\Parameters.mqh> // Description of variables
#include <Nkanven\DL_ErrorHandling.mqh> // Error library
#include <Nkanven\Gervis\PreChecks.mqh> // Prechecks
#include <Nkanven\Gervis\TradingHour.mqh> //
#include <Trade\Trade.mqh>
#include <Nkanven\Gervis\ScanPositions.mqh> // Scan for opened positions
#include <Nkanven\Gervis\CheckHistory.mqh> //Check transaction history
#include <Nkanven\Gervis\TradeManager.mqh> //Manage trade dynamic open and close conditions
#include <Nkanven\Gervis\EntriesManagerDCA.mqh> // Check buy and sell entries signals and execute them
#include <Nkanven\Gervis\LotSizeCal.mqh> // Lot size calculate
#include <Nkanven\Gervis\ClosePositions.mqh> // Close opened positions
#include <Nkanven\Gervis\HighestPriceLevel.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//sma = new CiMA();
//ssma = new CiMA();
//sma.Create(gSymbol, PERIOD_CURRENT, InpMAPeriods, InpMAAppliedPrice, InpMAMethod, PRICE_CLOSE);
//ssma.Create(gSymbol, PERIOD_CURRENT, 200, InpMAAppliedPrice, InpMAMethod, PRICE_CLOSE);
InitializeVariables();
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
SymbolInfoTick(_Symbol,last_tick);
TimeCurrent(dt);
CheckOperationHours();
//isQualifiedCandle(0);
OrderClose();
ScanPositions();
CheckSpread();
EvaluateEntry();
ExecuteEntry();
Comment(
"Expert Advisor by Anselme Nkondog (c) 2021\n "+
" Hour " + dt.hour + " Min "+ dt.min+"\n"
" Last Highest Price " + gLastHighestPrice + " Price %change "+ gPriceChange);
}
//+------------------------------------------------------------------+
//Initialize variables
void InitializeVariables()
{
gIsNewCandle=false;
gIsTradedThisBar=false;
gIsOperatingHours=false;
gIsSpreadOK=false;
gLotSize=InpDefaultLotSize;
gTickValue=0;
gTotalOpenBuy=0;
gTotalOpenSell=0;
gSignalEntry=SIGNAL_ENTRY_NEUTRAL;
gSignalExit=SIGNAL_EXIT_NEUTRAL;
Print("Variables intialized");
}
//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=SymbolInfoInteger(gSymbol, SYMBOL_SPREAD);
Print("Spread ", SpreadCurr);
if(SpreadCurr<=InpMaxSpread)
{
gIsSpreadOK=true;
}
else
{
gIsSpreadOK=false;
}
}
//+------------------------------------------------------------------+
Binary file not shown.
-95
View File
@@ -1,95 +0,0 @@
//+------------------------------------------------------------------+
//| 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
#include <Nkanven\HighTension\Notifications.mqh> //Handle notification
int handle;
const int indexMA = 0;
const int indexColor = 1;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
handle = iCustom(gSymbol, PERIOD_CURRENT, "Nkanven\MA-Slope", InpPeriods, InpMethod, InpAppliedPrice);
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()
{
//---
TimeCurrent(dt);
SymbolInfoTick(_Symbol,last_tick);
CheckPreChecks();
Comment("Spread ", DoubleToString(Spread,0));
if(!gIsPreChecksOk)
return;
//Print("TF", PERIOD_CURRENT, " 1min ", PERIOD_M1, " 5min ", PERIOD_M5, " Period ", Period());
/*ScanPositions();*/
if(!newBar())
return;
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];
CloseTransactions();
ExecuteEntry();
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool newBar()
{
static datetime prevTime = 0;
datetime currentTime = iTime(gSymbol, PERIOD_CURRENT, 0);
if(currentTime != prevTime)
{
prevTime = currentTime;
return(true);
}
return(false);
}
//+------------------------------------------------------------------+
Binary file not shown.
Binary file not shown.
Binary file not shown.
-148
View File
@@ -1,148 +0,0 @@
//+------------------------------------------------------------------+
//| MAGrid.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
#property version "1.00"
// Moving Average grid strategy
/*
Set pending orders x point above and below price.
If price above SMA, buy and set buy orders x time the ATR above and below price.
If price below SMA, sell and set sell orders x time the ATR above and below price.
Close all position at the close of the first candle crossing the moving average.
Open positions and set orders if there's nothing. At take profit, close all pending orders and reopen others
*/
#include <Indicators/Trend.mqh>
#include <Indicators/Oscilators.mqh>
CiMA* ma;
CiATR* atr;
#include <Nkanven\MAGrid\Parameters.mqh> // Description of variables
//#include <DL_ErrorHandling.mqh> // Error library
//#include <Nkanven\MAGrid\PreChecks.mqh> // Prechecks
//#include <Nkanven\MAGrid\TradingHour.mqh> //
#include <Trade\Trade.mqh>
#include <Nkanven\MAGrid\ScanPositions.mqh> // Scan for opened positions
//#include <Nkanven\MAGrid\CheckHistory.mqh> //Check transaction history
//#include <Nkanven\MAGrid\TradeManager.mqh> //Manage trade dynamic open and close conditions
#include <Nkanven\MAGrid\EntriesManager.mqh> // Check buy and sell entries signals and execute them
#include <Nkanven\MAGrid\LotSizeCal.mqh> // Lot size calculate
#include <Nkanven\MAGrid\CloseTransactions.mqh> // Close opened positions
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
ma = new CiMA();
ma.Create(gSymbol, PERIOD_CURRENT, InpFastPeriods, InpFastAppliedPrice, InpFastMethod, PRICE_CLOSE);
atr = new CiATR();
atr.Create(gSymbol, PERIOD_CURRENT, InpAtrPeriod);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
SymbolInfoTick(_Symbol,last_tick);
//Get technical indicators values
ma.Refresh(-1);
gMa = ma.Main(1);
atr.Refresh(-1);
gAtr = atr.Main(1);
//Initial position scanning
ScanPositions();
Print("Price is below SMA. Price = ", iClose(gSymbol, PERIOD_CURRENT, 1), " SMA = ", gMa, " Total buy ", gTotalBuyPositions);
//Check closing signal
//Close all buy position and orders if price is below MA
if(iClose(gSymbol, PERIOD_CURRENT, 1) < gMa && gTotalTransactions > 0)
{
Print("Price is below SMA. Price = ", iClose(gSymbol, PERIOD_CURRENT, 1), " SMA = ", gMa);
CloseTransactions(SIGNAL_EXIT_BUY);
}
else
{
//Close all sell positions and orders if price is above MA
if(iClose(gSymbol, PERIOD_CURRENT, 1) > gMa && gTotalTransactions > 0)
{
Print("Price is above SMA. Price = ", iClose(gSymbol, PERIOD_CURRENT, 1), " SMA = ", gMa);
CloseTransactions(SIGNAL_EXIT_SELL);
}
}
//Rescan positions
ScanPositions();
Print("Total transaction ", gTotalTransactions, " gTotalBuyPositions ", gTotalBuyPositions);
//Do not open positions if there are positions or orders pending
if(gTotalTransactions>0)
{
//If there's no position, close all pending orders
if(gTotalBuyPositions == 0 && gTotalTransactions > 0)
{
Print("Delete all");
CloseTransactions(SIGNAL_EXIT_ALL);
}
else
{
if(gTotalSellPositions==0 && gTotalTransactions >0)
{
CloseTransactions(SIGNAL_EXIT_ALL);
}
else
{
return;
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
CheckSpread();
EvaluateEntry();
ExecuteEntry();
}
//+------------------------------------------------------------------+
//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=SymbolInfoInteger(gSymbol, SYMBOL_SPREAD);
Print("Spread ", SpreadCurr);
if(SpreadCurr<=InpMaxSpread)
{
gIsSpreadOK=true;
}
else
{
gIsSpreadOK=false;
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
Binary file not shown.
Binary file not shown.
@@ -1,185 +0,0 @@
//+------------------------------------------------------------------+
//| MuzzlingAlligatorWatcher.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 <Indicators/BillWilliams.mqh>
#include <Indicators/Trend.mqh>
#include <Libraries/NavLib.mq5>
CiAlligator* alligator;
CiMA* ma;
input string Comment_0="=========="; //Alligator parameters
input ENUM_TIMEFRAMES inpTimeframe = PERIOD_CURRENT; //Timeframe
input int inpJawsPeriod = 13; //Jaws period
input int inpJawsShift = 8; //Jaws shift
input int inpTeethPeriod = 8; //Teeth period
input int inpTeethShift = 5; //Teeth shift
input int inpLipsPeriod = 5; //Lips period
input int inpLipsShift = 3; //Lips shift
input ENUM_MA_METHOD inpMethod = MODE_SMMA; //Method
input ENUM_APPLIED_PRICE inpApplyedTo = PRICE_MEDIAN; //Applied to
input string Comment_1="=========="; //Moving average parameters
input ENUM_MA_METHOD inpMAMethod = MODE_SMA; //MA method
input int inpMAPeriod = 200; //MA period
input int inpMASHift = 0; //MA shift
input ENUM_APPLIED_PRICE inpMAApplyedTo = PRICE_CLOSE; //MA applied to
double jaws, teeth, lips, sma, prevCandleHigh, prevCandleLow, currentPrice, openPrice, candleClose;
string symb = Symbol();
string comm = "";
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
alligator = new CiAlligator();
alligator.Create(symb, inpTimeframe, inpJawsPeriod, inpJawsShift, inpTeethPeriod, inpTeethShift, inpLipsPeriod, inpLipsShift, inpMethod, inpApplyedTo);
ma = new CiMA();
ma.Create(symb, inpTimeframe, inpMAPeriod, inpMASHift, inpMAMethod, inpMAApplyedTo);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
ObjectsDeleteAll(0);
Comment("");
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
//Alligator variables initialization
alligator.Refresh(-1);
jaws = NormalizeDouble(alligator.Jaw(0), _Digits);
teeth = NormalizeDouble(alligator.Teeth(0), _Digits);
lips = NormalizeDouble(alligator.Lips(0), _Digits);
//Moving Average variable initialization
ma.Refresh(-1);
sma = NormalizeDouble(ma.Main(1), _Digits);
//Get previous candle
prevCandleHigh = iHigh(symb, PERIOD_CURRENT, 1);
prevCandleLow = iLow(symb, PERIOD_CURRENT, 1);
currentPrice = iClose(symb, PERIOD_CURRENT, 0);
candleClose = iLow(symb, PERIOD_CURRENT, 0);
//comm = "jaws " + (string)jaws + " teeth " + (string)teeth + " lips " + (string)lips + " sma " + (string)sma;
comm = "Trade alert on " + symb;
comm += "\n";
comm += "";
Notify(comm);
if(sma < currentPrice)
{
//Alert for bullish continuation signal
if(prevCandleHigh > jaws && prevCandleHigh > teeth && prevCandleHigh > lips)
{
if(prevCandleLow < jaws || prevCandleLow < teeth ||prevCandleLow < lips)
{
comm += "LONG CONTINUATION SIGNAL: Price above SMA just moves above Alligator. \n";
}
}
//Alert for bearish counter trend signal
if(lips > teeth && teeth > jaws)
{
if(candleClose < lips && candleClose < teeth && candleClose < jaws)
{
comm += "SHORT COUNTER TREND SIGNAL: Price above SMA moves below Alligator in a trending market \n";
}
}
}
if(sma > currentPrice)
{
//Alert for bearish continuation signal
if(prevCandleLow < jaws && prevCandleLow < teeth && prevCandleLow < lips)
{
if(prevCandleHigh > jaws || prevCandleHigh > teeth ||prevCandleHigh > lips)
{
comm += "SHORT CONTINUATION SIGNAL: Price below SMA just moves below Alligator. \n";
}
}
//Alert for bearish counter trend signal
if(lips < teeth && teeth < jaws)
{
if(candleClose > lips && candleClose > teeth && candleClose > jaws)
{
comm += "LONG COUNTER TREND SIGNAL: Price below SMA just closes above Alligator in a down trending market \n";
}
}
}
if(MQLInfoInteger(MQL_TESTER))
{
Comment(comm);
}
else
{
Notify(comm);
}
}
//+------------------------------------------------------------------+
void Notify(string message)
{
Print("Message sent ", message);
//SendNotification(message);
string headers;
string url = "https://api.telegram.org/bot5854676759:AAEGN1a1HQ-3uiVtv7FxEf7IXKrMATBzkQg/sendMessage?chat_id=-1001821417162&text="+message;
char data[],result[];
int res = WebRequest("GET",
url,
NULL,
NULL,
3000,
data,
0,
result,
headers
);
Print(CharArrayToString(result), " Res ", res, headers); // 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.");
}
}
}
//+------------------------------------------------------------------+
Binary file not shown.
-53
View File
@@ -1,53 +0,0 @@
//+------------------------------------------------------------------+
//| 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 <Nkanven\NYMidnightBreak\Parameters.mqh> // EA paramters
#include <Nkanven\NYMidnightBreak\LotSizeCal.mqh> // 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);
}
//+------------------------------------------------------------------+
Binary file not shown.
-50
View File
@@ -1,50 +0,0 @@
//+------------------------------------------------------------------+
//| NewCandleAlert.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"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
newBar();
}
//+------------------------------------------------------------------+
bool newBar()
{
static datetime prevTime = 0;
datetime currentTime = iTime(Symbol(), PERIOD_CURRENT, 0);
if(currentTime != prevTime)
{
prevTime = currentTime;
Alert("New candle");
return(true);
}
return(false);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,408 +0,0 @@
//+------------------------------------------------------------------+
//| StarRiskCalculator.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.10"
//1.1 -> Add XAU lot computation and TP
#define KEY_B 66
#define KEY_S 83
//Parameters
MqlTick last_tick;
//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 type
enum ENUM_RISK_DEFAULT_TYPE
{
FIXED=1, //FIXED
Percent=2, //AMOUNT BASE
};
//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
};
input ENUM_RISK_DEFAULT_SIZE InpRiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
input double InpDefaultLotSize=0.01; //Lot Size if fixed Position Size Mode = FIXED
input ENUM_RISK_BASE InpRiskBase=RISK_BASE_BALANCE; //Risk Base
input ENUM_RISK_DEFAULT_TYPE InpRiskDefaultType=FIXED; //Risk Type
input double InpFixRiskAmount=10; //Max Account Risk ($) if risk type = FIXED
input double InpMaxLossPercent=1.0; //Max Account Risk (%)
input double InpTPMultiple=1; //TP multiple
input double InpMinLotSize=0.01; //Minimum Position Size Allowed
input double InpMaxLotSize=100; //Maximum Position Size Allowed
input int InpSlippage=1; //Slippage
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//input double InpMaxRiskPerTrade=0.5; //Percentage To Risk Each Trade
double RiskBaseAmount=InpFixRiskAmount;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string Symb = Symbol();
string AccountCurr = AccountInfoString(ACCOUNT_CURRENCY);
double MaxRiskPerTrade=0.0; //Percentage To Risk Each Trade
double LotSize=InpDefaultLotSize;
double StopLoss=0.0;
double TakeProfit=0.0;
double risk=0.0;
double StoplossPips=0.0;
double riskDiff=0.0;
double initialLoss=0.0;
double totalLoss=0.0;
double maxRiskPerLife=0.0;
//TickValue is the value of the individual price increment for 1 lot of the instrument, expressed in the account currenty
double TickValue=SymbolInfoDouble(Symb,SYMBOL_TRADE_TICK_VALUE);
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Print("The Expert Advisor with name ",MQLInfoString(MQL_PROGRAM_NAME)," is running");
//--- enable object create events
ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_CREATE,true);
//--- enable object delete events
ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_DELETE,true);
//--- create a horizontal line
if(!HLineCreate())
{
return(INIT_FAILED);
}
//--- redraw the chart and wait for 1 second
ChartRedraw();
Sleep(1000);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
ObjectsDeleteAll(0);
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
StopLoss = NormalizeDouble(ObjectGetDouble(0, "sl", OBJPROP_PRICE), _Digits);
//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);
displayOnChart();
}
//+------------------------------------------------------------------+
//| Create the horizontal line |
//+------------------------------------------------------------------+
bool HLineCreate(const long chart_ID=0, // chart's ID
const string name="sl", // line name
const int sub_window=0, // subwindow index
const color clr=clrRed, // line color
const ENUM_LINE_STYLE style=STYLE_SOLID, // line style
const int width=1, // line width
const bool back=false, // in the background
const bool selection=true, // highlight to move
const bool hidden=true, // hidden in the object list
const long z_order=0) // priority for mouse click
{
//--- if the price is not set, set it at 15 pips below the current Bid price level
double price=SymbolInfoDouble(Symbol(),SYMBOL_BID);
//--- reset the error value
ResetLastError();
//--- create a horizontal line
if(!ObjectCreate(chart_ID,name,OBJ_HLINE,sub_window,0,price))
{
Print(__FUNCTION__,
": failed to create a horizontal line! Error code = ",GetLastError());
return(false);
}
//--- set line color
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set line display style
ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- set line width
ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- display in the foreground (false) or background (true)
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the line by mouse
//--- when creating a graphical object using ObjectCreate function, the object cannot be
//--- highlighted and moved by default. Inside this method, selection parameter
//--- is true by default making it possible to highlight and move the object
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list
ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart
ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution
return(true);
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, // Event identifier
const long& lparam, // Event parameter of long type
const double& dparam, // Event parameter of double type
const string& sparam) // Event parameter of string type
{
//--- the object has been deleted
if(id==CHARTEVENT_OBJECT_DELETE)
{
Print("The object with name ",sparam," has been deleted");
}
//--- the object has been created
if(id==CHARTEVENT_OBJECT_CREATE)
{
Print("The object with name ",sparam," has been created");
}
/*--- the object has been moved or its anchor point coordinates has been changed
if(id==CHARTEVENT_OBJECT_DRAG)
{
StopLoss = ObjectGetDouble(0, sparam, OBJPROP_PRICE, 0);
Print("The anchor point coordinates of the object with name ",sparam," has been changed. Price ", StopLoss);
displayOnChart();
}*/
if(id==CHARTEVENT_KEYDOWN)
{
switch((int)lparam)
{
case KEY_B:
SendOrder(ORDER_TYPE_BUY,Symb,last_tick.ask,StopLoss,TakeProfit,LotSize);
Alert("Buy " + (string)LotSize + " lot " + Symb + " at " + (string)last_tick.ask + " SL at " + (string)StopLoss + " TP at " + (string)TakeProfit);
break;
case KEY_S:
SendOrder(ORDER_TYPE_SELL,Symb,last_tick.bid,StopLoss,TakeProfit,LotSize);
Alert("Sell " + (string)LotSize + " lot " + Symb + " at " + (string)last_tick.bid + " SL at " + (string)StopLoss + " TP at " + (string)TakeProfit);
break;
default:
//Print("Do nothing");
break;
}
}
}
//Lot Size Calculator
void LotSizeCalculate(double stopLoss)
{
SymbolInfoTick(_Symbol,last_tick);
double SL=0;
double PriceAsk=last_tick.ask;
double PriceBid=last_tick.bid;
double pipDiff = 0.0;
double spread = (SymbolInfoInteger(Symb, SYMBOL_SPREAD) * _Point);
if(stopLoss < PriceAsk)
{
pipDiff = PriceAsk-stopLoss;
SL = pipDiff/_Point;
//Print("PriceAsk ", PriceAsk, " pipDiff mult ", (pipDiff * InpTPMultiple), " point ", (SymbolInfoInteger(Symb, SYMBOL_SPREAD) * _Point));
TakeProfit = PriceAsk + (pipDiff * InpTPMultiple) + (spread*2);
}
if(stopLoss > PriceAsk)
{
pipDiff = stopLoss-PriceBid;
SL = pipDiff/_Point;
//Print("PriceAsk ", PriceAsk, " pipDiff mult ", (pipDiff * InpTPMultiple), " point ", (SymbolInfoInteger(Symb, SYMBOL_SPREAD) * _Point));
TakeProfit = PriceBid - (pipDiff * InpTPMultiple) - (spread*2);
}
//Print("Stop loss distance ", SL);
StoplossPips = SL;
//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)
{
tickDifferenceHandler();
//Print("tickvalue", TickValue);
//Calculate the Position Size
//Print("RiskBaseAmount ", RiskBaseAmount, " MaxRiskPerTrade ", MaxRiskPerTrade, "Stop loss ", SL, " TickValue ", TickValue);
LotSize=((RiskBaseAmount*MaxRiskPerTrade/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(Symb,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(Symb,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(Symb,SYMBOL_VOLUME_MAX))
LotSize=SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX);
//Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX));
//If the lot size is too small then set it to 0 and don't trade
if(LotSize < SymbolInfoDouble(Symb,SYMBOL_VOLUME_MIN))
{
LotSize=SymbolInfoDouble(Symb,SYMBOL_VOLUME_MIN);
//Print("Lot size too small");
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Delete a text label |
//+------------------------------------------------------------------+
bool LabelDelete(const long chart_ID=0, // chart's ID
const string name="Label") // label name
{
//--- reset the error value
ResetLastError();
//--- delete the label
if(!ObjectDelete(chart_ID,name))
{
Print(__FUNCTION__,
": failed to delete a text label! Error code = ",GetLastError());
return(false);
}
//--- successful execution
return(true);
}
//Send Order Function adjusted to handle errors and retry multiple times
void SendOrder(int Command, string Instrument, double OpenPrice, double SLPrice, double TPPrice, double lot, datetime Expiration=0)
{
MqlTradeRequest request= {};
MqlTradeResult result= {};
if(lot==0)
return;
request.action =TRADE_ACTION_DEAL; // type de l'opération de trading
request.symbol =Instrument; // symbole
request.volume =NormalizeDouble(lot,2); // volume de 0.1 lot
request.type =(ENUM_ORDER_TYPE)Command; // type de l'ordre
request.price =OpenPrice; // prix d'ouverture
request.sl =NormalizeDouble(SLPrice,Digits());
request.tp =NormalizeDouble(TPPrice, Digits());
request.deviation =InpSlippage;
request.expiration =Expiration; // déviation du prix autorisée
Print(request.sl + " - " + request.tp + " - " + request.volume + " - " + Digits());
if(!OrderSend(request,result))
{
PrintFormat("OrderSend erreur %d",GetLastError()); // en cas d'erreur d'envoi de la demande, affiche le code d'erreur
request.type_filling =SYMBOL_FILLING_FOK;
if(!OrderSend(request,result))
{
PrintFormat("OrderSend erreur %d",GetLastError()); // en cas d'erreur d'envoi de la demande, affiche le code d'erreur
if(GetLastError() == 4752)
{
Alert("Please enable EA trading");
}
}
}
//--- informations de l'opération
PrintFormat("retcode=%u transaction=%I64u ordre=%I64u",result.retcode,result.deal,result.order);
if(result.retcode == TRADE_RETCODE_DONE && result.order != 0)
{
Alert("Ordre placed successfully");
}
return;
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void displayOnChart()
{
//Print("Take profit ", TakeProfit);
initialLoss = (RiskBaseAmount * InpMaxLossPercent) / 100;
if(InpRiskDefaultType == FIXED)
{
initialLoss = InpFixRiskAmount;
}
initialLoss = NormalizeDouble(initialLoss, 2);
MaxRiskPerTrade = NormalizeDouble((initialLoss * 100) / RiskBaseAmount, 2);
LotSizeCalculate(StopLoss);
double StopAmount = (StoplossPips * LotSize * TickValue);
if(InpRiskDefaultSize == RISK_DEFAULT_FIXED)
{
MaxRiskPerTrade = NormalizeDouble((StopAmount * 100) / RiskBaseAmount, 2);
}
Comment("Star Risk Calculator \nLoss: " + (string)initialLoss + " " + AccountCurr + "\nMaxRiskPerTrade: " + (string)MaxRiskPerTrade +"%");
string text ="Lot size for "+ (string)MaxRiskPerTrade +"% = " + DoubleToString(LotSize,2) + " lot (" + (string)NormalizeDouble(StopAmount, 2) + " " + AccountCurr + ")";
string name = "Lot";
string name2 = "risk";
ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
//ObjectSetText(name,text, 36, "Corbel Bold", YellowGreen);
ObjectSetInteger(0,name, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
ObjectSetInteger(0,name, OBJPROP_XDISTANCE, 550);
ObjectSetInteger(0,name, OBJPROP_YDISTANCE, 10);
ObjectSetString(0,name,OBJPROP_TEXT,text);
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,14);
ObjectSetInteger(0,name,OBJPROP_COLOR,clrYellowGreen);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void tickDifferenceHandler()
{
if(StringFind(Symb, "XAU") != -1 && TickValue == 0.01)
{
TickValue = 1.0;
}
}
//TODO: Tickvalue is different. The problem might be there
//+------------------------------------------------------------------+
Binary file not shown.
-72
View File
@@ -1,72 +0,0 @@
//+------------------------------------------------------------------+
//| 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"
#include <Trade\Trade.mqh>
#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
#include <Nkanven\TheChallenger\CloseTransactions.mqh> //Emergency close of transaction
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
#include <Indicators/Oscilators.mqh>
CiATR* atr;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//---
atr = new CiATR();
atr.Create(gSymbol, InpTimeFrame, InpAtrPeriod);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
TimeCurrent(dt);
SymbolInfoTick(_Symbol,last_tick);
CheckOperationHours();
CheckPreChecks();
ScanPositions();
//Get ATR values
atr.Refresh(-1);
gAtr = atr.Main(1);
if(!gIsPreChecksOk)
return;
if(InpActivateRiskWatcher)
{
drawdownWatcher();
CloseTransactions();
}
ExecuteEntry();
}
//+------------------------------------------------------------------+
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-62
View File
@@ -1,62 +0,0 @@
//+------------------------------------------------------------------+
//| A_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(RiskDefaultSize==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
TickValue=SymbolInfoDouble(Symb,SYMBOL_TRADE_TICK_VALUE);
//Define the base for the risk calculation depending on the parameter chosen
if(RiskBase==RISK_BASE_BALANCE)
RiskBaseAmount=AccountInfoDouble(ACCOUNT_BALANCE);
if(RiskBase==RISK_BASE_EQUITY)
RiskBaseAmount=AccountInfoDouble(ACCOUNT_EQUITY);
if(RiskBase==RISK_BASE_FREEMARGIN)
RiskBaseAmount=AccountInfoDouble(ACCOUNT_FREEMARGIN);
//Calculate the Position Size
Print("Multiplier ", lotMultiplier, "Before lot multiplier ", (RiskBaseAmount*MaxRiskPerTrade/100)/(SL*TickValue));
Print("RiskBaseAmount ", RiskBaseAmount, " MaxRiskPerTrade ", MaxRiskPerTrade, "Stop loss ", SL, " TickValue ", TickValue);
LotSize=((RiskBaseAmount*MaxRiskPerTrade/100)/(SL*TickValue));
Print("After lot multiplier ", LotSize, " Lot multiplier ", lotMultiplier);
if(ActiveMartingale)
{
LotSize = LotSize * lotMultiplier;
}
}
//If the stop loss is zero then the lot size is the default one
if(SL==0)
{
LotSize=DefaultLotSize;
}
}
//Normalize the Lot Size to satisfy the allowed lot increment and minimum and maximum position size
LotSize=MathFloor(LotSize/SymbolInfoDouble(Symb,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(Symb,SYMBOL_VOLUME_STEP);
//Limit the lot size in case it is greater than the maximum allowed by the user
if(LotSize>MaxLotSize)
LotSize=MaxLotSize;
//Limit the lot size in case it is greater than the maximum allowed by the broker
if(LotSize>SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX))
LotSize=SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX);
Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX));
//If the lot size is too small then set it to 0 and don't trade
if(LotSize < SymbolInfoDouble(Symb,SYMBOL_VOLUME_MIN))
{
LotSize=0;
Print("Lot size too small");
}
}
-213
View File
@@ -1,213 +0,0 @@
//+------------------------------------------------------------------+
//| A_Parameters.mqh |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
//+------------------------------------------------------------------+
//| defines |
//+------------------------------------------------------------------+
//-ENUMERATIVE VARIABLES-//
//Enumerative variables are useful to associate numerical values to easy to remember strings
//It is similar to constants but also helps if the variable is set from the input page of the EA
//The text after the // is what you see in the input paramenters when the EA loads
//It is good practice to place all the enumberative at the start
//Enumerative for the entry signal value
enum ENUM_SIGNAL_ENTRY
{
SIGNAL_ENTRY_NEUTRAL=0, //SIGNAL ENTRY NEUTRAL
SIGNAL_ENTRY_BUY=1, //SIGNAL ENTRY BUY
SIGNAL_ENTRY_SELL=-1, //SIGNAL ENTRY SELL
};
//Enumerative for the exit signal value
enum ENUM_SIGNAL_EXIT
{
SIGNAL_EXIT_NEUTRAL=0, //SIGNAL EXIT NEUTRAL
SIGNAL_EXIT_BUY=1, //SIGNAL EXIT BUY
SIGNAL_EXIT_SELL=-1, //SIGNAL EXIT SELL
SIGNAL_EXIT_ALL=2, //SIGNAL EXIT ALL
};
//Enumerative for the allowed trading direction
enum ENUM_TRADING_ALLOW_DIRECTION
{
TRADING_ALLOW_BOTH=0, //ALLOW BOTH BUY AND SELL
TRADING_ALLOW_BUY=1, //ALLOW BUY ONLY
TRADING_ALLOW_SELL=-1, //ALLOW SELL ONLY
};
//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 candle type
enum ENUM_CANDLE_TYPE
{
NEUTRAL_CANDLE=0,
BEARISH_CANDLE=1,
BULLISH_CANDLE=2,
};
//Enumerative for price momentum
enum ENUM_PRICE_MOMENTUM
{
UP=2,
DOWN=1,
NEUTRAL=0,
};
struct LastTransaction
{
string time;
int type;
double profit;
} lt;
//-INPUT PARAMETERS-//
//The input parameters are the ones that can be set by the user when launching the EA
//If you place a comment following the input variable this will be shown as description of the field
//This is where you should include the input parameters for your entry and exit signals
input string Comment_strategy="=========="; //Entry And Exit Settings
//Add in this section the parameters for the indicators used in your entry and exit
//General input parameters
input string Comment_0="=========="; //Risk Management Settings
input ENUM_RISK_DEFAULT_SIZE RiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
input double DefaultLotSize=1; //Position Size (if fixed or if no stop loss defined)
input ENUM_RISK_BASE RiskBase=RISK_BASE_BALANCE; //Risk Base
input double MaxRiskPerTrade=0.5; //Percentage To Risk Each Trade
input double MinLotSize=0.01; //Minimum Position Size Allowed
input double MaxLotSize=100; //Maximum Position Size Allowed
input string Comment_1="=========="; //Trading Hours Settings
input bool UseTradingHours=false; //Limit Trading Hours
input string TradingHourStart="01"; //Trading Start Hour (Broker Server Hour)
input string TradingHourEnd="23"; //Trading End Hour (Broker Server Hour)
input string TradingStartMin="30"; //Trading Start minute (Broker Server Hour)
input string TradingEndMin="00"; //Trading End minute
input string Comment_2="=========="; //Stop Loss And Take Profit Settings
input ENUM_MODE_SL StopLossMode=SL_AUTO; //Stop Loss Mode
input int DefaultStopLoss=0; //Default Stop Loss In Points (0=No Stop Loss)
input int MinStopLoss=0; //Minimum Allowed Stop Loss In Points
input int MaxStopLoss=5000; //Maximum Allowed Stop Loss In Points
input bool AtrStopLoss=false; //Set Stop loss based on ATR
input int atr_sl_factor=3; //Multiplicator for ATR stop loss
input ENUM_MODE_TP TakeProfitMode=TP_AUTO; //Take Profit Mode
input int DefaultTakeProfit=0; //Default Take Profit In Points (0=No Take Profit)
input int MinTakeProfit=0; //Minimum Allowed Take Profit In Points
input int MaxTakeProfit=5000; //Maximum Allowed Take Profit In Points
input double TakeProfitPercent=1.0; //Take Profit percent on risk base
input double Breakevent=1.0; //Minimum Profit to breakeven
input bool ProfitRun=true;
input bool ActiveMartingale=false;
input string Comment_3="=========="; //Trailing Stop Settings
input bool UseTrailingStop=false; //Use Trailing Stop
input string Comment_4="=========="; //Additional Settings
input int MagicNumber=0; //Magic Number For The Orders Opened By This EA
input string OrderNote=""; //Comment For The Orders Opened By This EA
input int Slippage=5; //Slippage in points
input double MaxSpread=10.0; //Maximum Allowed Spread To Trade In Points
input string Comment_5="==========="; //Zigzag indicator setting
input int Depth=5;
input int Deviation=5;
input int Backstep=3;
input int GapPoint=100; //Minimum gap between peaks
input int Sensitivity=2; //Minimum peak at same level
input int LookBack=50; //Maximum peak to consider
input int NumberOfCandles=3;
//-GLOBAL VARIABLES-//
//The variables included in this section are global, hence they can be used in any part of the code
string Symb=Symbol(), server_time;
long current_chart_id = ChartID();
bool IsPreChecksOk=false; //Indicates if the pre checks are satisfied
bool IsNewCandle=false; //Indicates if this is a new candle formed
bool IsSpreadOK=false; //Indicates if the spread is low enough to trade
bool IsOperatingHours=false; //Indicates if it is possible to trade at the current time (server time)
bool IsTradedThisBar=false; //Indicates if an order was already executed in the current candle
bool In_Trade = true; //Indicates if trade range has been formed
bool CanBuy = true;
bool CanSell = true;
bool ClosePosition = false;
bool FollowProfit = false;
bool UpTrendingMarket = false;
bool DownTrendingMarket = false;
double TickValue=0; //Value of a tick in account currency at 1 lot
double LotSize=0; //Lot size for the position
double Tick_Size = SymbolInfoDouble(Symb,SYMBOL_TRADE_TICK_SIZE); //Tick size
double High[];
double Low[];
double PositionProfit;
//Indicators
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
long Spread = SymbolInfoInteger(Symb,SYMBOL_SPREAD) / 100; //Check the impact. It's originally a double
int OrderOpRetry=10; //Number of attempts to retry the order submission
int TotalOpenOrders=0; //Number of total open orders
int TotalOpenBuy=0; //Number of total open buy orders
int TotalOpenSell=0; //Number of total open sell orders
int StopLossBy=SL_BY_POINTS; //How the stop loss is passed for the lot size calculation
double lotMultiplier =1; //Adust lot size according to loosing trades
int candleCounter =0;
double firstCandleOpen =0;
double lastCandleClose=0;
double ProfitRunTargetPercent=10.0;
datetime LastBarTraded;
MqlDateTime dt;
MqlTick last_tick;
ENUM_SIGNAL_ENTRY SignalEntry=SIGNAL_ENTRY_NEUTRAL; //Entry signal variable
ENUM_SIGNAL_EXIT SignalExit=SIGNAL_EXIT_NEUTRAL;
ENUM_CANDLE_TYPE candleType=NEUTRAL_CANDLE;
ENUM_PRICE_MOMENTUM priceMomentum=NEUTRAL;
//+------------------------------------------------------------------+
-123
View File
@@ -1,123 +0,0 @@
//+------------------------------------------------------------------+
//| A_PositionsManager.mqh |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
CTrade trade;
//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
bool ScanPositions()
{
//Scan all the orders, retrieving some of the details
TotalOpenOrders = 0;
TotalOpenBuy = 0;
TotalOpenSell = 0;
for(int i=0; i<PositionsTotal(); 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);
return false;
}
//If the order is not for the instrument on chart we can ignore it
if(PositionGetSymbol(i)!=Symb)
continue;
//If the order has Magic Number different from the Magic Number of the EA then we can ignore it
if(PositionGetInteger(POSITION_MAGIC)!=MagicNumber)
continue;
//If it is a buy order then increment the total count of buy orders
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
TotalOpenBuy++;
//If it is a sell order then increment the total count of sell orders
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
TotalOpenSell++;
//Increment the total orders count
TotalOpenOrders++;
//Find what is the open time of the most recent trade and assign it to LastBarTraded
//this is necessary to check if we already traded in the current candle
if((datetime)PositionGetInteger(POSITION_TIME)>LastBarTraded || LastBarTraded==0)
LastBarTraded=(datetime)PositionGetInteger(POSITION_TIME);
}
Print("Total positions ", TotalOpenOrders, " - Total buys ", TotalOpenBuy, " - Total sells ", TotalOpenSell);
return true;
}
// We declare a function CloseOpenPositions of type int and we want to return
// the number of positions that are closed.
void CloseOpenPositions()
{
int TotalClose=0; // We want to count how many orders have been closed.
int c_slippage = Slippage;
Print("Close position status ", ClosePosition);
// Normalization of the slippage.
if(_Digits==3 || _Digits==5)
{
c_slippage=c_slippage*10;
}
// We scan all the orders backwards.
// This is required as if we start from the first order, we will have problems with the counters and the loop.
for(int i=PositionsTotal()-1; i>=0; i--)
{
ulong ticket = PositionGetTicket(i);
Print("Position profit is ", PositionGetDouble(POSITION_PROFIT));
PositionProfit = PositionGetDouble(POSITION_PROFIT);
/*if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && iClose(Symb, PERIOD_CURRENT, 1) < Senkouspanb && iClose(Symb, PERIOD_CURRENT, 1) < Senkouspana)
{
// We select the order of index i, selecting by position and from the pool of market/pending trades.
//If the selection is successful we try to close the order.
if(trade.PositionClose(ticket, c_slippage))
{
TotalClose++;
}
else
{
// If the order fails to be closed, we print the error.
Print("Order failed to close with error - ",GetLastError());
}
}
if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && iClose(Symb, PERIOD_CURRENT, 1) > Senkouspanb && iClose(Symb, PERIOD_CURRENT, 1) > Senkouspana)
{
// We select the order of index i, selecting by position and from the pool of market/pending trades.
//If the selection is successful we try to close the order.
if(trade.PositionClose(ticket, c_slippage))
{
TotalClose++;
}
else
{
// If the order fails to be closed, we print the error.
Print("Order failed to close with error - ",GetLastError());
}
}*/
if(ClosePosition)
{
if(trade.PositionClose(ticket, c_slippage))
{
TotalClose++;
ClosePosition = false;
}
else
{
// If the order fails to be closed, we print the error.
Print("Order failed to close with error - ",GetLastError());
}
}
// We can use a delay if the execution is too fast.
// Sleep() will wait X milliseconds before proceeding with the code.
// Sleep(300);
}
}
//+------------------------------------------------------------------+
-23
View File
@@ -1,23 +0,0 @@
//+------------------------------------------------------------------+
//| A_TradeManager.mqh |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
void ProfitRunner()
{
if(ProfitRun)
{
if(iClose(Symb, _Period, 1) < iClose(Symb, _Period, 2) && TotalOpenBuy > 0)
{
ClosePosition = true;
}
if(iClose(Symb, _Period, 1) > iClose(Symb, _Period, 2) && TotalOpenSell > 0)
{
ClosePosition = true;
}
}
Print("Looking to close this position ", ClosePosition);
}
-27
View File
@@ -1,27 +0,0 @@
//+------------------------------------------------------------------+
//| A_TradingHour.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
//+------------------------------------------------------------------+
@@ -1,27 +0,0 @@
//+------------------------------------------------------------------+
//| 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
//+------------------------------------------------------------------+
@@ -1,24 +0,0 @@
//+------------------------------------------------------------------+
//| DCAManager.mqh |
//| Copyright 2022, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link "https://www.mql5.com"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DcaManager(string instrument)
{
//Compute pending orders levels
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DcaWatcher(string intrument) {}
//+------------------------------------------------------------------+
Binary file not shown.
@@ -1,62 +0,0 @@
//+------------------------------------------------------------------+
//| 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);
}
//+------------------------------------------------------------------+
@@ -1,132 +0,0 @@
//+------------------------------------------------------------------+
//| 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
};
//
// 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 = Symbol();
double gSma;
int gTotalSellPositions, gTotalBuyPositions, 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;
//+------------------------------------------------------------------+
@@ -1,79 +0,0 @@
//+------------------------------------------------------------------+
//| 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;
}
}
//+------------------------------------------------------------------+
@@ -1,45 +0,0 @@
//+------------------------------------------------------------------+
//| ScanPositions.mqh |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
//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();
gTotalBuyPositions = 0;
gTotalSellPositions = 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++;
//If it is a sell order then increment the total count of sell orders
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
gTotalSellPositions++;
Print("POSITION_TYPE_BUY ", POSITION_TYPE_BUY, " POSITION_TYPE_SELL ", POSITION_TYPE_SELL, " PositionGetInteger(POSITION_TYPE) ", PositionGetInteger(POSITION_TYPE));
}
Print("Total positions ", gTotalPositions, " - Total buys ", gTotalBuyPositions, " - Total sells ", gTotalSellPositions);
}
@@ -1,62 +0,0 @@
//+------------------------------------------------------------------+
//| 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;
}
}
}
//+------------------------------------------------------------------+
Binary file not shown.
@@ -1,46 +0,0 @@
//+------------------------------------------------------------------+
//| DL_CheckOperationHours.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()
{
//If we are not using operating hours then IsOperatingHours is true and I skip the other checks
if(!UseTradingHours)
{
IsOperatingHours=true;
return;
}
//Check if the current hour is between the allowed hours of operations, if so IsOperatingHours is set true
Print("1 this is ", (TradingHourStart==TradingHourEnd && dt.hour==TradingHourStart && In_Trade));
if(TradingHourStart==TradingHourEnd && dt.hour==TradingHourStart && In_Trade)
IsOperatingHours=true;
if(TradingHourStart<TradingHourEnd && In_Trade)
{
if(TradingHourStart == dt.hour && dt.min >= TradingStartMin)
{
IsOperatingHours=true;
}
if(dt.hour > TradingHourStart)
{
IsOperatingHours=true;
}
}
if(TradingHourStart>TradingHourEnd && ((dt.hour>=TradingHourStart && dt.hour<=23) || (dt.hour<=TradingHourEnd && dt.hour>=0)) && In_Trade)
{
IsOperatingHours=true;
}
if(IsOperatingHours == false)
{
rangeUpdated = false;
}
}
//+------------------------------------------------------------------+
@@ -1,67 +0,0 @@
//+------------------------------------------------------------------+
//| DL_ClosePositions.mqh |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
CTrade trade;
// We declare a function CloseOpenPositions of type int and we want to return
// the number of positions that are closed.
void CloseOpenPositions()
{
int TotalClose=0; // We want to count how many orders have been closed.
int c_slippage = Slippage;
// Normalization of the slippage.
if(_Digits==3 || _Digits==5)
{
c_slippage=c_slippage*10;
}
if(TimeToString(LastBarTraded, TIME_DATE) == TimeToString(TimeCurrent(), TIME_DATE))
return;
// We scan all the orders backwards.
// This is required as if we start from the first order, we will have problems with the counters and the loop.
// We select the order of index i, selecting by position and from the pool of market/pending trades.
double accountProfit = AccountInfoDouble(ACCOUNT_EQUITY) - AccountInfoDouble(ACCOUNT_BALANCE);
double accountProfitPercent = (fabs(accountProfit)*100)/AccountInfoDouble(ACCOUNT_BALANCE);
if(accountProfit < 0 && accountProfitPercent >= 10)
{
for(int i=PositionsTotal()-1; i>=0; i--)
{
ulong ticket = PositionGetTicket(i);
//If the selection is successful we try to close the order.
if(trade.PositionClose(ticket, c_slippage))
{
TotalClose++;
}
else
{
// If the order fails to be closed, we print the error.
Print("Order failed to close with error - ",GetLastError());
}
/*Print("Position profit is ", PositionGetDouble(POSITION_PROFIT));
if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY && PositionGetDouble(POSITION_PRICE_CURRENT) < upper_boundary || PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL && PositionGetDouble(POSITION_PRICE_CURRENT) < upper_boundary)
{
}*/
// We can use a delay if the execution is too fast.
// Sleep() will wait X milliseconds before proceeding with the code.
// Sleep(300);
}
}
}
//+------------------------------------------------------------------+
Binary file not shown.
-97
View File
@@ -1,97 +0,0 @@
//+------------------------------------------------------------------+
//| DL_ErrorHandling.mqh |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
//+------------------------------------------------------------------+
//This functions returns a string corresponding to the description of an error
//Complete list of error available https://book.mql4.com/appendix/errors
string GetLastErrorText(int Error){
string Text="Error Not Defined";
if(Error==ERR_SUCCESS) Text="The operation completed successfully.";
if(Error==ERR_INTERNAL_ERROR) Text="Unexpected internal error.";
/*if(Error==ERR_COMMON_ERROR) Text="Common error.";
if(Error==ERR_INVALID_TRADE_PARAMETERS) Text="Invalid trade parameters.";
if(Error==ERR_SERVER_BUSY) Text="Trade server is busy.";
if(Error==ERR_OLD_VERSION) Text="Old version of the client terminal.";
if(Error==ERR_NO_CONNECTION) Text="No connection with trade server.";
if(Error==ERR_NOT_ENOUGH_RIGHTS) Text="Not enough rights.";
if(Error==ERR_TOO_FREQUENT_REQUESTS) Text="Too frequent requests.";
if(Error==ERR_MALFUNCTIONAL_TRADE) Text="Malfunctional trade operation.";
if(Error==ERR_ACCOUNT_DISABLED) Text="Account disabled.";
if(Error==ERR_INVALID_ACCOUNT) Text="Invalid account.";
if(Error==ERR_TRADE_TIMEOUT) Text="Trade timeout.";
if(Error==ERR_INVALID_PRICE) Text="Invalid price.";
if(Error==ERR_INVALID_STOPS) Text="Invalid stops.";
if(Error==ERR_INVALID_TRADE_VOLUME) Text="Invalid trade volume.";
if(Error==ERR_MARKET_CLOSED) Text="Market is closed.";
if(Error==ERR_TRADE_DISABLED) Text="Trade is disabled.";
if(Error==ERR_NOT_ENOUGH_MONEY) Text="Not enough money.";
if(Error==ERR_PRICE_CHANGED) Text="Price changed.";
if(Error==ERR_OFF_QUOTES) Text="Off quotes.";
if(Error==ERR_BROKER_BUSY) Text="Broker is busy.";
if(Error==ERR_REQUOTE) Text="Requote.";
if(Error==ERR_ORDER_LOCKED) Text="Order is locked.";
if(Error==ERR_LONG_POSITIONS_ONLY_ALLOWED) Text="Long positions only allowed.";
if(Error==ERR_TOO_MANY_REQUESTS) Text="Too many requests.";
if(Error==ERR_TRADE_MODIFY_DENIED) Text="Modification denied because an order is too close to market.";
if(Error==ERR_TRADE_CONTEXT_BUSY) Text="Trade context is busy.";
if(Error==ERR_TRADE_EXPIRATION_DENIED) Text="Expirations are denied by broker.";
if(Error==ERR_TRADE_TOO_MANY_ORDERS) Text="The amount of opened and pending orders has reached the limit set by a broker.";
if(Error==ERR_NO_MQLERROR) Text="No error.";
if(Error==ERR_WRONG_FUNCTION_POINTER) Text="Wrong function pointer.";
if(Error==ERR_ARRAY_INDEX_OUT_OF_RANGE) Text="Array index is out of range.";
if(Error==ERR_RECURSIVE_STACK_OVERFLOW) Text="Recursive stack overflow.";
if(Error==ERR_NO_MEMORY_FOR_TEMP_STRING) Text="No memory for temp string.";
if(Error==ERR_NOT_INITIALIZED_STRING) Text="Not initialized string.";
if(Error==ERR_NOT_INITIALIZED_ARRAYSTRING) Text="Not initialized string in an array.";
if(Error==ERR_NO_MEMORY_FOR_ARRAYSTRING) Text="No memory for an array string.";
if(Error==ERR_TOO_LONG_STRING) Text="Too long string.";
if(Error==ERR_REMAINDER_FROM_ZERO_DIVIDE) Text="Remainder from zero divide.";
if(Error==ERR_ZERO_DIVIDE) Text="Zero divide.";
if(Error==ERR_UNKNOWN_COMMAND) Text="Unknown command.";
if(Error==ERR_WRONG_JUMP) Text="Wrong jump.";
if(Error==ERR_NOT_INITIALIZED_ARRAY) Text="Not initialized array.";
if(Error==ERR_DLL_CALLS_NOT_ALLOWED) Text="DLL calls are not allowed.";
if(Error==ERR_CANNOT_LOAD_LIBRARY) Text="Cannot load library.";
if(Error==ERR_CANNOT_CALL_FUNCTION) Text="Cannot call function.";
if(Error==ERR_SYSTEM_BUSY) Text="System is busy.";
if(Error==ERR_SOME_ARRAY_ERROR) Text="Some array error.";
if(Error==ERR_CUSTOM_INDICATOR_ERROR) Text="Custom indicator error.";
if(Error==ERR_INCOMPATIBLE_ARRAYS) Text="Arrays are incompatible.";
if(Error==ERR_GLOBAL_VARIABLE_NOT_FOUND) Text="Global variable not found.";
if(Error==ERR_FUNCTION_NOT_CONFIRMED) Text="Function is not confirmed.";
if(Error==ERR_SEND_MAIL_ERROR) Text="Mail sending error.";
if(Error==ERR_STRING_PARAMETER_EXPECTED) Text="String parameter expected.";
if(Error==ERR_INTEGER_PARAMETER_EXPECTED) Text="Integer parameter expected.";
if(Error==ERR_DOUBLE_PARAMETER_EXPECTED) Text="Double parameter expected.";
if(Error==ERR_ARRAY_AS_PARAMETER_EXPECTED) Text="Array as parameter expected.";
if(Error==ERR_HISTORY_WILL_UPDATED) Text="Requested history data in updating state.";
if(Error==ERR_TRADE_ERROR) Text="Some error in trade operation execution.";
if(Error==ERR_END_OF_FILE) Text="End of a file.";
if(Error==ERR_SOME_FILE_ERROR) Text="Some file error.";
if(Error==ERR_WRONG_FILE_NAME) Text="Wrong file name.";
if(Error==ERR_TOO_MANY_OPENED_FILES) Text="Too many opened files.";
if(Error==ERR_CANNOT_OPEN_FILE) Text="Cannot open file.";
if(Error==ERR_NO_ORDER_SELECTED) Text="No order selected.";
if(Error==ERR_UNKNOWN_SYMBOL) Text="Unknown symbol.";
if(Error==ERR_INVALID_PRICE_PARAM) Text="Invalid price.";
if(Error==ERR_INVALID_TICKET) Text="Invalid ticket.";
if(Error==ERR_TRADE_NOT_ALLOWED) Text="Trade is not allowed.";
if(Error==ERR_LONGS_NOT_ALLOWED) Text="Longs are not allowed.";
if(Error==ERR_SHORTS_NOT_ALLOWED) Text="Shorts are not allowed.";
if(Error==ERR_OBJECT_ALREADY_EXISTS) Text="Object already exists.";
if(Error==ERR_UNKNOWN_OBJECT_PROPERTY) Text="Unknown object property.";
if(Error==ERR_OBJECT_DOES_NOT_EXIST) Text="Object does not exist.";
if(Error==ERR_UNKNOWN_OBJECT_TYPE) Text="Unknown object type.";
if(Error==ERR_NO_OBJECT_NAME) Text="No object name.";
if(Error==ERR_OBJECT_COORDINATES_ERROR) Text="Object coordinates error.";
if(Error==ERR_NO_SPECIFIED_SUBWINDOW) Text="No specified subwindow.";
if(Error==ERR_SOME_OBJECT_ERROR) Text="Some error in object operation.";*/
return Text;
}
-65
View File
@@ -1,65 +0,0 @@
//+------------------------------------------------------------------+
//| InitMQL4.mqh |
//| Copyright DC2008 |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "keiji"
#property copyright "DC2008"
#property link "https://www.mql5.com"
//--- Declaration of constants
#define OP_BUY 0 //Buy
#define OP_SELL 1 //Sell
#define OP_BUYLIMIT 2 //Pending order of BUY LIMIT type
#define OP_SELLLIMIT 3 //Pending order of SELL LIMIT type
#define OP_BUYSTOP 4 //Pending order of BUY STOP type
#define OP_SELLSTOP 5 //Pending order of SELL STOP type
//---
#define MODE_OPEN 0
#define MODE_CLOSE 3
#define MODE_VOLUME 4
#define MODE_REAL_VOLUME 5
#define MODE_TRADES 0
#define MODE_HISTORY 1
#define SELECT_BY_POS 0
#define SELECT_BY_TICKET 1
//---
#define DOUBLE_VALUE 0
#define FLOAT_VALUE 1
#define LONG_VALUE INT_VALUE
//---
#define CHART_BAR 0
#define CHART_CANDLE 1
//---
#define MODE_ASCEND 0
#define MODE_DESCEND 1
//---
#define MODE_LOW 1
#define MODE_HIGH 2
#define MODE_TIME 5
#define MODE_BID 9
#define MODE_ASK 10
#define MODE_POINT 11
#define MODE_DIGITS 12
#define MODE_SPREAD 13
#define MODE_STOPLEVEL 14
#define MODE_LOTSIZE 15
#define MODE_TICKVALUE 16
#define MODE_TICKSIZE 17
#define MODE_SWAPLONG 18
#define MODE_SWAPSHORT 19
#define MODE_STARTING 20
#define MODE_EXPIRATION 21
#define MODE_TRADEALLOWED 22
#define MODE_MINLOT 23
#define MODE_LOTSTEP 24
#define MODE_MAXLOT 25
#define MODE_SWAPTYPE 26
#define MODE_PROFITCALCMODE 27
#define MODE_MARGINCALCMODE 28
#define MODE_MARGININIT 29
#define MODE_MARGINMAINTENANCE 30
#define MODE_MARGINHEDGED 31
#define MODE_MARGINREQUIRED 32
#define MODE_FREEZELEVEL 33
//---
#define EMPTY -1
-54
View File
@@ -1,54 +0,0 @@
//+------------------------------------------------------------------+
//| DL_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(RiskDefaultSize==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
TickValue=SymbolInfoDouble(Symb,SYMBOL_TRADE_TICK_VALUE);
//Define the base for the risk calculation depending on the parameter chosen
if(RiskBase==RISK_BASE_BALANCE)
RiskBaseAmount=AccountInfoDouble(ACCOUNT_BALANCE);
if(RiskBase==RISK_BASE_EQUITY)
RiskBaseAmount=AccountInfoDouble(ACCOUNT_EQUITY);
if(RiskBase==RISK_BASE_FREEMARGIN)
RiskBaseAmount=AccountInfoDouble(ACCOUNT_FREEMARGIN);
//Calculate the Position Size
LotSize=((RiskBaseAmount*MaxRiskPerTrade/100)/(SL*TickValue));
}
//If the stop loss is zero then the lot size is the default one
if(SL==0)
{
LotSize=DefaultLotSize;
}
}
//Normalize the Lot Size to satisfy the allowed lot increment and minimum and maximum position size
LotSize=MathFloor(LotSize/SymbolInfoDouble(Symb,SYMBOL_VOLUME_STEP))*SymbolInfoDouble(Symb,SYMBOL_VOLUME_STEP);
//Limit the lot size in case it is greater than the maximum allowed by the user
if(LotSize>MaxLotSize)
LotSize=MaxLotSize;
//Limit the lot size in case it is greater than the maximum allowed by the broker
if(LotSize>SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX))
LotSize=SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX);
Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX));
//If the lot size is too small then set it to 0 and don't trade
if(LotSize<MinLotSize || LotSize < SymbolInfoDouble(Symb,SYMBOL_VOLUME_MIN))
{
LotSize=0;
Print("Lot size too small : ", LotSize);
}
}
-175
View File
@@ -1,175 +0,0 @@
//+------------------------------------------------------------------+
//| DL_Parameters.mqh |
//| Copyright 2021, Nkondog Anselme Venceslas. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas."
#property link "https://www.mql5.com"
//+------------------------------------------------------------------+
//| defines |
//+------------------------------------------------------------------+
#property strict
//+------------------------------------------------------------------+
//| defines |
//+------------------------------------------------------------------+
//--- input parameters
input bool rangedetection=true;
input double upperboundary;
input double lowerboundary;
input int stoploss;
input string taketype="fix";
input int takeprofitpercent=3;
input string timeframe="5min";
input double rangemargin=0.0;
//-ENUMERATIVE VARIABLES-//
//Enumerative variables are useful to associate numerical values to easy to remember strings
//It is similar to constants but also helps if the variable is set from the input page of the EA
//The text after the // is what you see in the input paramenters when the EA loads
//It is good practice to place all the enumberative at the start
//Enumerative for the entry signal value
enum ENUM_SIGNAL_ENTRY{
SIGNAL_ENTRY_NEUTRAL=0, //SIGNAL ENTRY NEUTRAL
SIGNAL_ENTRY_BUY=1, //SIGNAL ENTRY BUY
SIGNAL_ENTRY_SELL=-1, //SIGNAL ENTRY SELL
};
//Enumerative for the exit signal value
enum ENUM_SIGNAL_EXIT{
SIGNAL_EXIT_NEUTRAL=0, //SIGNAL EXIT NEUTRAL
SIGNAL_EXIT_BUY=1, //SIGNAL EXIT BUY
SIGNAL_EXIT_SELL=-1, //SIGNAL EXIT SELL
SIGNAL_EXIT_ALL=2, //SIGNAL EXIT ALL
};
//Enumerative for the allowed trading direction
enum ENUM_TRADING_ALLOW_DIRECTION{
TRADING_ALLOW_BOTH=0, //ALLOW BOTH BUY AND SELL
TRADING_ALLOW_BUY=1, //ALLOW BUY ONLY
TRADING_ALLOW_SELL=-1, //ALLOW SELL ONLY
};
//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
};
struct LastTransaction
{
string time;
int type;
double profit;
}lt;
//-INPUT PARAMETERS-//
//The input parameters are the ones that can be set by the user when launching the EA
//If you place a comment following the input variable this will be shown as description of the field
//This is where you should include the input parameters for your entry and exit signals
input string Comment_strategy="=========="; //Entry And Exit Settings
//Add in this section the parameters for the indicators used in your entry and exit
//General input parameters
input string Comment_0="=========="; //Risk Management Settings
input ENUM_RISK_DEFAULT_SIZE RiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
input double DefaultLotSize=1; //Position Size (if fixed or if no stop loss defined)
input ENUM_RISK_BASE RiskBase=RISK_BASE_BALANCE; //Risk Base
input double MaxRiskPerTrade=0.5; //Percentage To Risk Each Trade
input double MinLotSize=0.01; //Minimum Position Size Allowed
input double MaxLotSize=100; //Maximum Position Size Allowed
input string Comment_1="=========="; //Trading Hours Settings
input bool UseTradingHours=false; //Activate Trading Hours
input string TradingHourStart="01"; //Trading Start Hour (Broker Server Hour)
input string TradingHourEnd="23"; //Trading End Hour (Broker Server Hour)
input string TradingStartMin="30"; //Trading Start minute (Broker Server Hour)
input string TradingEndMin="00"; //Trading End minute
input string TradingBoundaryHour="01"; //Trading Boundary Hour
input string TradingBoundaryMin="25"; //Trading Boundary minute
input string Comment_2="=========="; //Stop Loss And Take Profit Settings
input ENUM_MODE_SL StopLossMode=SL_AUTO; //Stop Loss Mode
input int DefaultStopLoss=0; //Default Stop Loss In Points (0=No Stop Loss)
input int MinStopLoss=0; //Minimum Allowed Stop Loss In Points
input int MaxStopLoss=5000; //Maximum Allowed Stop Loss In Points
input ENUM_MODE_TP TakeProfitMode=TP_AUTO; //Take Profit Mode
input int DefaultTakeProfit=0; //Default Take Profit In Points (0=No Take Profit)
input int MinTakeProfit=0; //Minimum Allowed Take Profit In Points
input int MaxTakeProfit=5000; //Maximum Allowed Take Profit In Points
input string Comment_3="=========="; //Trailing Stop Settings
input bool UseTrailingStop=false; //Use Trailing Stop
input string Comment_4="=========="; //Additional Settings
input int MagicNumber=0; //Magic Number For The Orders Opened By This EA
input string OrderNote=""; //Comment For The Orders Opened By This EA
input int Slippage=5; //Slippage in points
input int MaxSpread=100; //Maximum Allowed Spread To Trade In Points
input int MaxCandleIteration=100; //Max candles to check for trading range boundaries
//-GLOBAL VARIABLES-//
//The variables included in this section are global, hence they can be used in any part of the code
string Symb=Symbol(), server_time;
long current_chart_id = ChartID();
bool IsPreChecksOk=false; //Indicates if the pre checks are satisfied
bool IsNewCandle=false; //Indicates if this is a new candle formed
bool IsSpreadOK=false; //Indicates if the spread is low enough to trade
bool IsOperatingHours=false; //Indicates if it is possible to trade at the current time (server time)
bool IsTradedThisBar=false; //Indicates if an order was already executed in the current candle
bool In_Trade = false; //Indicates if trade range has been formed
double TickValue=0; //Value of a tick in account currency at 1 lot
double LotSize=0; //Lot size for the position
double upper_boundary, lower_boundary; //Trading range boundaries
double rangeScope;
double Tick_Size = SymbolInfoDouble(Symb,SYMBOL_TRADE_TICK_SIZE); //Tick size
double High[];
double Low[];
long Spread = SymbolInfoInteger(Symb,SYMBOL_SPREAD) / 100; //Check the impact. It's originally a double
int OrderOpRetry=10; //Number of attempts to retry the order submission
int TotalOpenOrders=0; //Number of total open orders
int TotalOpenBuy=0; //Number of total open buy orders
int TotalOpenSell=0; //Number of total open sell orders
int StopLossBy=SL_BY_POINTS; //How the stop loss is passed for the lot size calculation
int Mas_Tip[6]; // Order type array
int lotMultiplier =1; //Adust lot size according to loosing trades
datetime LastBarTraded;
MqlDateTime dt;
MqlTick last_tick;
ENUM_SIGNAL_ENTRY SignalEntry=SIGNAL_ENTRY_NEUTRAL; //Entry signal variable
ENUM_SIGNAL_EXIT SignalExit=SIGNAL_EXIT_NEUTRAL; //Exit signal variable
-62
View File
@@ -1,62 +0,0 @@
//+------------------------------------------------------------------+
//| DL_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()
{
IsPreChecksOk=true;
//Check if Live Trading is enabled in MT4
if(!MQLInfoInteger(MQL_TRADE_ALLOWED))
{
IsPreChecksOk=false;
Print("Live Trading is not enabled, please enable it in MT4 and chart settings");
return;
}
//Check if the default stop loss you are setting in above the minimum and below the maximum
if(DefaultStopLoss<MinStopLoss || DefaultStopLoss>MaxStopLoss)
{
IsPreChecksOk=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(DefaultTakeProfit<MinTakeProfit || DefaultTakeProfit>MaxTakeProfit)
{
IsPreChecksOk=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(DefaultLotSize<MinLotSize || DefaultLotSize>MaxLotSize)
{
IsPreChecksOk=false;
Print("Default Lot Size must be between Minimum and Maximum Lot Size Allowed");
return;
}
//Slippage must be >= 0
if(Slippage<0)
{
IsPreChecksOk=false;
Print("Slippage must be a positive value");
return;
}
//MaxSpread must be >= 0
if(MaxSpread<0)
{
IsPreChecksOk=false;
Print("Maximum Spread must be a positive value");
return;
}
//MaxRiskPerTrade is a % between 0 and 100
if(MaxRiskPerTrade<0 || MaxRiskPerTrade>100)
{
IsPreChecksOk=false;
Print("Maximum Risk Per Trade must be a percentage between 0 and 100");
return;
}
}

Some files were not shown because too many files have changed in this diff Show More