71 lines
2.9 KiB
MQL5
71 lines
2.9 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Apollo-One.mq5 |
|
|
//| Copyright 2022, MetaQuotes Ltd. |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
//| Expert initialization function |
|
|
//+------------------------------------------------------------------+
|
|
#include "Utils.mqh"
|
|
Utils Helper;
|
|
|
|
// --other parameters
|
|
input int Input_TargetProfitPips = 20; // Target price offset in pips
|
|
input double Input_MartingaleHours = 3; // Martingale start time in hours
|
|
input int Input_MartingaleMaxDoublings = 5; // Amount of martingale doublings
|
|
|
|
double MartingaleMultiplier = 1.6;
|
|
int MartinGaleTimeInSeconds = (int) Input_MartingaleHours * 3600;
|
|
|
|
// indicator magic
|
|
ENUM_ORDER_TYPE CurrentTrend = ORDER_TYPE_SELL;
|
|
input ENUM_TIMEFRAMES TrendPeriod = PERIOD_D1;
|
|
|
|
int EA_Magic=12345; // EA Magic Number
|
|
//+----------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
int OnInit()
|
|
{
|
|
//InitSuperTrend();
|
|
EventSetTimer(10); // check every 30 seconds if we should martingale existing buy and sell trades
|
|
return(INIT_SUCCEEDED);
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Expert deinitialization function |
|
|
//+------------------------------------------------------------------+
|
|
void OnDeinit(const int reason)
|
|
{
|
|
//--- destroy timer
|
|
EventKillTimer();
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Expert tick function |
|
|
//+------------------------------------------------------------------+
|
|
void OnTick()
|
|
{
|
|
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Timer function |
|
|
//+------------------------------------------------------------------+
|
|
void OnTimer()
|
|
{
|
|
|
|
if(Helper.OpenPositionsCount(CurrentTrend) == 0)
|
|
{
|
|
Helper.OpenNewPosition(CurrentTrend, Input_MartingaleMaxDoublings, MartingaleMultiplier, Input_TargetProfitPips);
|
|
}
|
|
|
|
if(Helper.ShouldMartingale(ORDER_TYPE_BUY, MartinGaleTimeInSeconds))
|
|
{
|
|
Helper.Martingale(ORDER_TYPE_BUY, MartingaleMultiplier, Input_TargetProfitPips);
|
|
}
|
|
|
|
if(Helper.ShouldMartingale(ORDER_TYPE_SELL, MartinGaleTimeInSeconds))
|
|
{
|
|
Helper.Martingale(ORDER_TYPE_SELL, MartingaleMultiplier, Input_TargetProfitPips);
|
|
}
|
|
}
|
|
//+------------------------------------------------------------------+
|