Reorganize files, symbolic link to MT5 folder

This commit is contained in:
Nkondog Anselme
2022-01-03 05:26:31 +01:00
parent 2bb0816712
commit b9bdccdd2a
41 changed files with 0 additions and 0 deletions
Binary file not shown.
+268
View File
@@ -0,0 +1,268 @@
//+------------------------------------------------------------------+
//| 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.
+224
View File
@@ -0,0 +1,224 @@
/*
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
@@ -0,0 +1,134 @@
//+------------------------------------------------------------------+
//| 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;
}
}
//+------------------------------------------------------------------+
Binary file not shown.
+148
View File
@@ -0,0 +1,148 @@
//+------------------------------------------------------------------+
//| 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.
Binary file not shown.
Binary file not shown.