mirror of
https://github.com/rithsila/MT5-EA-Sniper-Strategy.git
synced 2026-08-16 04:08:13 +00:00
Working on DCA Manager
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| CloseTransactions.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;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
void CloseTransactions()
|
||||
{
|
||||
bool result = true;
|
||||
int cts = PositionsTotal();
|
||||
ulong theTicket;
|
||||
double positionProfit = 0.0;
|
||||
|
||||
if(cts > 0)
|
||||
{
|
||||
for(int i = cts-1; i>=0; i--)
|
||||
{
|
||||
ulong ticket = PositionGetTicket(i);
|
||||
if(PositionSelectByTicket(ticket))
|
||||
{
|
||||
if(PositionGetInteger(POSITION_MAGIC)==InpMagicNumber)
|
||||
{
|
||||
if(positionProfit > PositionGetDouble(POSITION_PROFIT))
|
||||
{
|
||||
positionProfit = PositionGetDouble(POSITION_PROFIT);
|
||||
theTicket = ticket;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Print("Error (", GetLastError(), ") while selecting position by ticket");
|
||||
}
|
||||
}
|
||||
if(gEmergencyClose)
|
||||
{
|
||||
if(!trade.PositionClose(theTicket))
|
||||
Print("Error (", GetLastError(), ") while deleting all buy positions");
|
||||
}
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
void drawdownWatcher()
|
||||
{
|
||||
double amountDiff, equity, balance, percentDiff;
|
||||
balance=AccountInfoDouble(ACCOUNT_BALANCE);
|
||||
equity=AccountInfoDouble(ACCOUNT_EQUITY);
|
||||
gEmergencyClose = false;
|
||||
|
||||
if(equity < balance)
|
||||
{
|
||||
amountDiff = balance - equity;
|
||||
percentDiff = (amountDiff*100)/balance;
|
||||
|
||||
Print("amountDiff ", amountDiff, " percentDiff ", percentDiff, " InpMaxDrawdown ", InpMaxDrawdown);
|
||||
|
||||
if(InpMaxDrawdown < percentDiff)
|
||||
{
|
||||
gEmergencyClose = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
Binary file not shown.
@@ -73,26 +73,17 @@ input double InpMinLotSize=0.01; //Minimu
|
||||
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 bool InpActivateRiskWatcher=false; //Active risk watcher
|
||||
input string Comment_00="----------------------"; //Stop loss settings
|
||||
input ENUM_MODE_SL InpStopLossMode=SL_FIXED; //Stop Loss Mode
|
||||
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 double InpMaxDrawdown=2.5; //Max DD level
|
||||
input string Comment_01="----------------------"; //Take profit settings
|
||||
input ENUM_MODE_TP InpTakeProfitMode=TP_FIXED; //Take Profit Mode
|
||||
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_1="========="; //ATR settings
|
||||
// Average True Range
|
||||
input int InpAtrPeriod = 14; //ATR period
|
||||
input int InpAtrMultiplier = 3; //ATR multiplier
|
||||
|
||||
input string Comment_2="=========="; //Trading Hours Settings
|
||||
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)
|
||||
@@ -100,18 +91,26 @@ input int InpDayTradingHourEnd=21; //Day Tr
|
||||
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_02="----------------------"; //Stop loss settings
|
||||
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 double InpMinCandleLenght = 25.0; //Min candle length
|
||||
input int InpCandleWickPercent = 75; //Candle wick percent
|
||||
input int InpSameCandleCount= 2; //Same Candle in a row
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
string gSymbol = Symbol();
|
||||
double gAtr;
|
||||
double gSma;
|
||||
|
||||
int gTotalSellPositions, gTotalBuyPositions, gTotalPositions;
|
||||
bool gIsOperatingHours=false;
|
||||
@@ -128,6 +127,6 @@ long Spread = SymbolInfoInteger(gSymbol,SYMBOL_SPREAD) / 100; //Check t
|
||||
|
||||
int gOrderOpRetry = 10;
|
||||
|
||||
MqlTick last_tick;
|
||||
MqlTick last_tick, blast_tick;
|
||||
MqlDateTime dt;
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user