Updated for ver.3.16
This commit is contained in:
Binary file not shown.
+91
-32
@@ -1,17 +1,20 @@
|
||||
#property copyright "Copyright 2017-2021, Artur Zas"
|
||||
// GNU General Public License v3.0 -> https://github.com/9nix6/Median-and-Turbo-Renko-indicator-bundle/blob/master/LICENSE
|
||||
#property link "https://www.az-invest.eu"
|
||||
#property version "1.17"
|
||||
#define VERSION "1.20"
|
||||
#property version VERSION
|
||||
#property description "Example EA: Trading based on 2 moving average crossover."
|
||||
#property description "MA1 & MA2 need to be enabled on the inicator creating the chart."
|
||||
#property description "MA1 && MA2 need to be enabled on the inicator creating the chart."
|
||||
#property description "MA1 - Fast moving average"
|
||||
#property description "MA2 - Slow moving average"
|
||||
#property description " "
|
||||
#property description "GNU General Public License v3.0"
|
||||
|
||||
//#define RANGEBAR_LICENSE // uncomment when used on a Tick & Volume bar chart from https://www.az-invest.eu/rangebars-for-metatrader-5
|
||||
//#define ULTIMATE_RENKO_LICENSE // uncomment when used on Ultimate Renko chart from https://www.az-invest.eu/ultimate-renko-indicator-generator-for-metatrader-5
|
||||
//#define VOLUMECHART_LICENSE // uncomment when used on a Tick & Volume bar chart from https://www.az-invest.eu/Tick-chart-and-volume-chart-for-mt5
|
||||
//#define RANGEBAR_LICENSE // uncomment when used on a Tick & Volume bar chart from https://www.az-invest.eu/rangebars-for-metatrader-5
|
||||
//#define SECONDSCHART_LICENSE // uncomment when used on a Seconds TF bar chart from https://www.az-invest.eu/seconds-timeframe-chart-for-metatrader-5
|
||||
//#define LINEBREAKCHART_LICENSE // uncomment when used on a Line Break chart from https://www.az-invest.eu
|
||||
//#define LINEBREAKCHART_LICENSE // uncomment when used on a Line Break chart from https://www.az-invest.eu/linebreak-chart-for-metatrader-5
|
||||
//
|
||||
// Uncomment only ONE of the 5 directives listed below and recompile
|
||||
// -----------------------------------------------------------------
|
||||
@@ -21,14 +24,14 @@
|
||||
//#define EA_ON_XTICK_CHART // Use EA on XTick Chart (obsolete)
|
||||
//#define EA_ON_TICK_VOLUME_CHART // Use EA on Tick & Volume Bar Chart
|
||||
//#define EA_ON_SECONDS_CHART // Use EA on Seconds Interval chart
|
||||
//#define EA_ON_LINEBREAK_CHART // Use EA on LineBreak charts
|
||||
//#define EA_ON_LINEBREAK_CHART // Use EA on LineBreak charts
|
||||
|
||||
//#define DEVELOPER_VERSION // used when I develop ;) should always be commented out
|
||||
|
||||
// Uncomment the directive below and recompile if EA is used with P-Renko BR Ultimate
|
||||
// ----------------------------------------------------------------------------------
|
||||
//
|
||||
// #define P_RENKO_BR_PRO // Use in P-Renko BR Ultimate version
|
||||
//#define P_RENKO_BR_PRO // Use in P-Renko BR Ultimate version
|
||||
|
||||
//
|
||||
// Uncomment the directive below and recompile for use in a backtest only
|
||||
@@ -65,6 +68,7 @@
|
||||
|
||||
#include <AZ-INVEST/SDK/TimeControl.mqh>
|
||||
#include <AZ-INVEST/SDK/TradeFunctions.mqh>
|
||||
#include <AZ-INVEST/SDK/TradeManager.mqh>
|
||||
|
||||
enum ENUM_TRADE_DIRECTION
|
||||
{
|
||||
@@ -74,22 +78,30 @@ enum ENUM_TRADE_DIRECTION
|
||||
};
|
||||
|
||||
#ifdef SHOW_INDICATOR_INPUTS
|
||||
input group "EA parameters"
|
||||
input group "### EA parameters"
|
||||
#endif
|
||||
input double Lots = 0.1; // Traded lots
|
||||
input uint StopLoss = 100; // Stop Loss (in points)
|
||||
input uint TakeProfit = 250; // Take profit (in points)
|
||||
input uint TakeProfit = 300; // Take profit (in points)
|
||||
input ENUM_TRADE_DIRECTION ValidTradeDirection = TRADE_DIRECTION_ALL; // Valid trading type
|
||||
input bool ForceSR = false; // Force Stop & Reverse
|
||||
input bool ReverseOnMACrossInsideGap = true; // Reverse trade if MA cross inside a gap
|
||||
input bool CloseTradeAfterTradingHours = true; // Close trade after trading hours
|
||||
input ulong DeviationPoints = 0; // Maximum defiation (in points)
|
||||
input double ManualTickSize = 0.000; // Tick Size (0 = auto detect)
|
||||
input group "### Trading schedule (Non stop if start = 0 & end = 0)"
|
||||
input string Start="9:00"; // Start trading at
|
||||
input string End="17:55"; // End trading at
|
||||
input bool CloseTradeAfterTradingHours = false; // Close trade after trading hours
|
||||
input group "### Trade management";
|
||||
input int InpBEPoints = 0; // BreakEven (Points) [ 0 = OFF ]
|
||||
input int InpTrailByPoints = 0; // Trail by (Points) [ 0 = OFF ]
|
||||
input int InpTrailStartPoints = 150; // Start trailing after (Points)
|
||||
input int InpPartialCloseAtProfitPoints = 0; // Partial close at (Points) [ 0 = OFF ]
|
||||
input int InpPartialClosePercentage = 50; // Partial close %
|
||||
input group "### Misc";
|
||||
input ulong MagicNumber=5150; // Assign trade ID
|
||||
input ulong DeviationPoints = 0; // Maximum deviation (in points)
|
||||
input double ManualTickSize = 0.000; // Tick Size (0 = auto detect)
|
||||
input int NumberOfRetries = 50; // Maximum number of retries
|
||||
input int BusyTimeout_ms = 1000; // Wait [ms] before retry on bussy errors
|
||||
input int BusyTimeout_ms = 1000; // Wait [ms] before retry on busy errors
|
||||
input int RequoteTimeout_ms = 250; // Wait [ms] before retry on requotes
|
||||
|
||||
// Global data buffers
|
||||
@@ -106,8 +118,10 @@ int numberOfBars = 3;
|
||||
|
||||
CMarketOrder *marketOrder = NULL;
|
||||
CTimeControl *timeControl = NULL;
|
||||
CTradeManager *tradeManager = NULL;
|
||||
|
||||
ulong currentTicket;
|
||||
CTradeManagerState tradeManagerState;
|
||||
ENUM_POSITION_TYPE currentPositionType;
|
||||
ENUM_POSITION_TYPE signal;
|
||||
ENUM_POSITION_TYPE validation;
|
||||
@@ -191,7 +205,25 @@ int OnInit()
|
||||
|
||||
timeControl.SetValidTraingHours(Start,End);
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
//
|
||||
// Init TradeManager
|
||||
//
|
||||
|
||||
CTradeManagerParameters params2;
|
||||
{
|
||||
params2.BEPoints = InpBEPoints;
|
||||
params2.TrailByPoints = InpTrailByPoints;
|
||||
params2.TrailStartPoints = InpTrailStartPoints;
|
||||
params2.PartialCloseAtProfitPoints = InpPartialCloseAtProfitPoints;
|
||||
params2.PartialClosePercentage = InpPartialClosePercentage;
|
||||
}
|
||||
|
||||
if(tradeManager == NULL)
|
||||
{
|
||||
tradeManager = new CTradeManager(params2, marketOrder);
|
||||
}
|
||||
|
||||
return INIT_SUCCEEDED;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert deinitialization function |
|
||||
@@ -223,7 +255,13 @@ void OnDeinit(const int reason)
|
||||
delete customBars;
|
||||
customBars = NULL;
|
||||
}
|
||||
|
||||
|
||||
if(tradeManager != NULL)
|
||||
{
|
||||
delete tradeManager;
|
||||
tradeManager = NULL;
|
||||
}
|
||||
|
||||
Comment("");
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -231,20 +269,15 @@ void OnDeinit(const int reason)
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
if(marketOrder == NULL || customBars == NULL || timeControl == NULL)
|
||||
if(marketOrder == NULL || customBars == NULL || timeControl == NULL || tradeManager == NULL)
|
||||
return;
|
||||
|
||||
if(customBars.IsNewBar())
|
||||
// trade management
|
||||
|
||||
if(marketOrder.IsOpen(currentTicket, _Symbol, MagicNumber))
|
||||
{
|
||||
if(timeControl.IsScheduleEnabled())
|
||||
{
|
||||
Comment("EA trading schedule ON ("+Start+" to "+End+") | trading enabled = "+(string)timeControl.IsTradingTimeValid());
|
||||
}
|
||||
else
|
||||
{
|
||||
Comment("EA trading schedule OFF");
|
||||
}
|
||||
|
||||
// checks done on every tick
|
||||
|
||||
if(!timeControl.IsTradingTimeValid())
|
||||
{
|
||||
if(marketOrder.IsOpen(currentTicket,_Symbol,MagicNumber))
|
||||
@@ -258,6 +291,22 @@ void OnTick()
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tradeManager.Manage(currentTicket, tradeManagerState);
|
||||
}
|
||||
|
||||
// Signal handler
|
||||
|
||||
if(customBars.IsNewBar())
|
||||
{
|
||||
if(timeControl.IsScheduleEnabled())
|
||||
{
|
||||
Comment("EA trading schedule ON ("+Start+" to "+End+") | trading enabled = "+(string)timeControl.IsTradingTimeValid());
|
||||
}
|
||||
else
|
||||
{
|
||||
Comment("EA trading schedule OFF");
|
||||
}
|
||||
|
||||
//
|
||||
// Get moving average values for current, last completed bar and the bar before that...
|
||||
@@ -280,19 +329,21 @@ void OnTick()
|
||||
if(timeControl.IsScheduleEnabled())
|
||||
{
|
||||
Comment("EA trading schedule ("+Start+" to "+End+") | trading enabled = "+(string)timeControl.IsTradingTimeValid()+
|
||||
"\n MA1 [2]: "+DoubleToString(MA1[2],_Digits)+" [1]: "+DoubleToString(MA1[1],_Digits)+
|
||||
"\n MA2 [2]: "+DoubleToString(MA2[2],_Digits)+" [1]: "+DoubleToString(MA2[1],_Digits)+
|
||||
// "\n MA1 [2]: "+DoubleToString(MA1[2],_Digits)+" [1]: "+DoubleToString(MA1[1],_Digits)+
|
||||
// "\n MA2 [2]: "+DoubleToString(MA2[2],_Digits)+" [1]: "+DoubleToString(MA2[1],_Digits)+
|
||||
"\n MA cross signal = "+marketOrder.PositionTypeToString(signal)+
|
||||
"\n MA validation = "+marketOrder.PositionTypeToString(validation)+
|
||||
"\n Trade manager: "+tradeManager.ToString()+
|
||||
"\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Comment("EA trading schedule not used. Trading is enabled."+
|
||||
"\n MA1 [2]: "+DoubleToString(MA1[2],_Digits)+" [1]: "+DoubleToString(MA1[1],_Digits)+
|
||||
"\n MA2 [2]: "+DoubleToString(MA2[2],_Digits)+" [1]: "+DoubleToString(MA2[1],_Digits)+
|
||||
// "\n MA1 [2]: "+DoubleToString(MA1[2],_Digits)+" [1]: "+DoubleToString(MA1[1],_Digits)+
|
||||
// "\n MA2 [2]: "+DoubleToString(MA2[2],_Digits)+" [1]: "+DoubleToString(MA2[1],_Digits)+
|
||||
"\n MA cross signal = "+marketOrder.PositionTypeToString(signal)+
|
||||
"\n MA validation = "+marketOrder.PositionTypeToString(validation)+
|
||||
"\n Trade manager: "+tradeManager.ToString()+
|
||||
"\n");
|
||||
}
|
||||
|
||||
@@ -306,6 +357,7 @@ void OnTick()
|
||||
{
|
||||
PrintFormat("Reversing %s position on Stop&Reverse condition (ticket:%d)", _Symbol, currentTicket);
|
||||
marketOrder.Reverse(currentTicket,Lots,StopLoss,TakeProfit);
|
||||
tradeManagerState.Clear();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -313,8 +365,10 @@ void OnTick()
|
||||
else if(!marketOrder.IsOpen(_Symbol,POSITION_TYPE_BUY,MagicNumber))
|
||||
{
|
||||
if(IsTradeDirectionValid(POSITION_TYPE_BUY))
|
||||
{
|
||||
marketOrder.Long(_Symbol,Lots,StopLoss,TakeProfit);
|
||||
|
||||
tradeManagerState.Clear();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -328,6 +382,7 @@ void OnTick()
|
||||
{
|
||||
PrintFormat("Reversing %s position on Stop&Reverse condition (ticket:%d)", _Symbol, currentTicket);
|
||||
marketOrder.Reverse(currentTicket,Lots,StopLoss,TakeProfit);
|
||||
tradeManagerState.Clear();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -335,8 +390,10 @@ void OnTick()
|
||||
else if(!marketOrder.IsOpen(_Symbol,POSITION_TYPE_SELL,MagicNumber))
|
||||
{
|
||||
if(IsTradeDirectionValid(POSITION_TYPE_SELL))
|
||||
{
|
||||
tradeManagerState.Clear();
|
||||
marketOrder.Short(_Symbol,Lots,StopLoss,TakeProfit);
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -357,18 +414,20 @@ void OnTick()
|
||||
// reverse position on signal change inside gap.
|
||||
PrintFormat("Reversing %s position on signal change inside gap (ticket:%d)", _Symbol, currentTicket);
|
||||
marketOrder.Reverse(currentTicket,Lots,StopLoss,TakeProfit);
|
||||
tradeManagerState.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
// close position on signal change inside gap.
|
||||
PrintFormat("Closing %s position on signal change inside gap (ticket:%d)", _Symbol, currentTicket);
|
||||
marketOrder.Close(currentTicket);
|
||||
tradeManagerState.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Binary file not shown.
+83
-30
@@ -1,15 +1,18 @@
|
||||
#property copyright "Copyright 2017-2021, Artur Zas"
|
||||
// GNU General Public License v3.0 -> https://github.com/9nix6/Median-and-Turbo-Renko-indicator-bundle/blob/master/LICENSE
|
||||
#property link "https://www.az-invest.eu"
|
||||
#property version "1.09"
|
||||
#property description "Example EA: Trading based on moving average & price crossover."
|
||||
#define VERSION "1.10"
|
||||
#property version VERSION
|
||||
#property description "Example EA: Trading based on moving average && price crossover."
|
||||
#property description "MA1 needs to be enabled on the inicator creating the chart."
|
||||
#property description " "
|
||||
#property description "GNU General Public License v3.0"
|
||||
|
||||
//#define RANGEBAR_LICENSE // uncomment when used on a Tick & Volume bar chart from https://www.az-invest.eu/rangebars-for-metatrader-5
|
||||
//#define ULTIMATE_RENKO_LICENSE // uncomment when used on Ultimate Renko chart from https://www.az-invest.eu/ultimate-renko-indicator-generator-for-metatrader-5
|
||||
//#define VOLUMECHART_LICENSE // uncomment when used on a Tick & Volume bar chart from https://www.az-invest.eu/Tick-chart-and-volume-chart-for-mt5
|
||||
//#define RANGEBAR_LICENSE // uncomment when used on a Tick & Volume bar chart from https://www.az-invest.eu/rangebars-for-metatrader-5
|
||||
//#define SECONDSCHART_LICENSE // uncomment when used on a Seconds TF bar chart from https://www.az-invest.eu/seconds-timeframe-chart-for-metatrader-5
|
||||
//#define LINEBREAKCHART_LICENSE // uncomment when used on a Line Break chart from https://www.az-invest.eu
|
||||
//#define LINEBREAKCHART_LICENSE // uncomment when used on a Line Break chart from https://www.az-invest.eu/linebreak-chart-for-metatrader-5
|
||||
|
||||
//
|
||||
// Uncomment only ONE of the 5 directives listed below and recompile
|
||||
@@ -20,14 +23,14 @@
|
||||
//#define EA_ON_XTICK_CHART // Use EA on XTick Chart (obsolete)
|
||||
//#define EA_ON_TICK_VOLUME_CHART // Use EA on Tick & Volume Bar Chart
|
||||
//#define EA_ON_SECONDS_CHART // Use EA on Seconds Interval chart
|
||||
//#define EA_ON_LINEBREAK_CHART // Use EA on LineBreak charts
|
||||
//#define EA_ON_LINEBREAK_CHART // Use EA on LineBreak charts
|
||||
|
||||
//#define DEVELOPER_VERSION // used when I develop ;) should always be commented out
|
||||
|
||||
// Uncomment the directive below and recompile if EA is used with P-Renko BR Ultimate
|
||||
// ----------------------------------------------------------------------------------
|
||||
//
|
||||
// #define P_RENKO_BR_PRO // Use in P-Renko BR Ultimate version
|
||||
//#define P_RENKO_BR_PRO // Use in P-Renko BR Ultimate version
|
||||
|
||||
//
|
||||
// Uncomment the directive below and recompile for use in a backtest only
|
||||
@@ -64,6 +67,7 @@
|
||||
|
||||
#include <AZ-INVEST/SDK/TimeControl.mqh>
|
||||
#include <AZ-INVEST/SDK/TradeFunctions.mqh>
|
||||
#include <AZ-INVEST/SDK/TradeManager.mqh>
|
||||
|
||||
enum ENUM_TRADE_DIRECTION
|
||||
{
|
||||
@@ -79,18 +83,26 @@ input double Lots = 0.1; // Trade
|
||||
input uint StopLoss = 0; // Stop Loss
|
||||
input uint TakeProfit = 0; // Take profit
|
||||
input int ConfirmationBars = 1; // Signal confirmation bars
|
||||
input int PrevSignalBars = 1; // Prev signal confirmation bars
|
||||
input int PrevSignalBars = 1; // Prev. signal confirmation bars
|
||||
input ENUM_TRADE_DIRECTION ValidTradeDirection = TRADE_DIRECTION_ALL; // Valid trading type
|
||||
input bool CloseTradeOnSignalChange = true; // Close trade on signal change
|
||||
input bool ForceSR = false; // Force Stop & Reverse
|
||||
input bool CloseTradeAfterTradingHours = true; // Close trade after trading hours
|
||||
input ulong DeviationPoints = 0; // Maximum defiation (in points)
|
||||
input double ManualTickSize = 0.000; // Tick Size (0 = auto detect)
|
||||
input group "### Trading schedule (Non stop if start = 0 & end = 0)"
|
||||
input string Start="9:00"; // Start trading at
|
||||
input string End="17:55"; // End trading at
|
||||
input bool CloseTradeAfterTradingHours = true; // Close trade after trading hours
|
||||
input group "### Trade management";
|
||||
input int InpBEPoints = 0; // BreakEven (Points) [ 0 = OFF ]
|
||||
input int InpTrailByPoints = 0; // Trail by (Points) [ 0 = OFF ]
|
||||
input int InpTrailStartPoints = 150; // Start trailing after (Points)
|
||||
input int InpPartialCloseAtProfitPoints = 0; // Partial close at (Points) [ 0 = OFF ]
|
||||
input int InpPartialClosePercentage = 50; // Partial close %
|
||||
input group "### Misc";
|
||||
input ulong MagicNumber=8888; // Assign trade ID
|
||||
input ulong DeviationPoints = 0; // Maximum defiation (in points)
|
||||
input double ManualTickSize = 0.000; // Tick Size (0 = auto detect)
|
||||
input int NumberOfRetries = 50; // Maximum number of retries
|
||||
input int BusyTimeout_ms = 1000; // Wait [ms] before retry on bussy errors
|
||||
input int BusyTimeout_ms = 1000; // Wait [ms] before retry on busy errors
|
||||
input int RequoteTimeout_ms = 250; // Wait [ms] before retry on requotes
|
||||
|
||||
// Global data buffers
|
||||
@@ -107,10 +119,12 @@ int _prevSignalBars;
|
||||
|
||||
// EA variables
|
||||
|
||||
CMarketOrder *marketOrder;
|
||||
CTimeControl *timeControl;
|
||||
CMarketOrder *marketOrder = NULL;
|
||||
CTimeControl *timeControl = NULL;
|
||||
CTradeManager *tradeManager = NULL;
|
||||
|
||||
ulong currentTicket;
|
||||
CTradeManagerState tradeManagerState;
|
||||
ENUM_POSITION_TYPE currentPositionType;
|
||||
ENUM_POSITION_TYPE signal;
|
||||
ENUM_POSITION_TYPE validation;
|
||||
@@ -168,6 +182,8 @@ int OnInit()
|
||||
}
|
||||
|
||||
customBars.Init();
|
||||
if(customBars.GetHandle() == INVALID_HANDLE)
|
||||
return(INIT_FAILED);
|
||||
|
||||
signal = POSITION_TYPE_NONE;
|
||||
_confirmationBars = (ConfirmationBars < 1) ? 1 : ConfirmationBars;
|
||||
@@ -195,6 +211,24 @@ int OnInit()
|
||||
|
||||
timeControl.SetValidTraingHours(Start,End);
|
||||
|
||||
//
|
||||
// Init TradeManager
|
||||
//
|
||||
|
||||
CTradeManagerParameters params2;
|
||||
{
|
||||
params2.BEPoints = InpBEPoints;
|
||||
params2.TrailByPoints = InpTrailByPoints;
|
||||
params2.TrailStartPoints = InpTrailStartPoints;
|
||||
params2.PartialCloseAtProfitPoints = InpPartialCloseAtProfitPoints;
|
||||
params2.PartialClosePercentage = InpPartialClosePercentage;
|
||||
}
|
||||
|
||||
if(tradeManager == NULL)
|
||||
{
|
||||
tradeManager = new CTradeManager(params2, marketOrder);
|
||||
}
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -228,6 +262,12 @@ void OnDeinit(const int reason)
|
||||
customBars = NULL;
|
||||
}
|
||||
|
||||
if(tradeManager != NULL)
|
||||
{
|
||||
delete tradeManager;
|
||||
tradeManager = NULL;
|
||||
}
|
||||
|
||||
Comment("");
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -235,20 +275,15 @@ void OnDeinit(const int reason)
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
if(marketOrder == NULL)
|
||||
if(marketOrder == NULL || customBars == NULL || timeControl == NULL || tradeManager == NULL)
|
||||
return;
|
||||
|
||||
if(customBars.IsNewBar())
|
||||
|
||||
// trade management
|
||||
|
||||
if(marketOrder.IsOpen(currentTicket, _Symbol, MagicNumber))
|
||||
{
|
||||
if(timeControl.IsScheduleEnabled())
|
||||
{
|
||||
Comment("EA trading schedule ON ("+Start+" to "+End+") | trading enabled = "+(string)timeControl.IsTradingTimeValid());
|
||||
}
|
||||
else
|
||||
{
|
||||
Comment("EA trading schedule OFF");
|
||||
}
|
||||
|
||||
// checks done on every tick
|
||||
|
||||
if(!timeControl.IsTradingTimeValid())
|
||||
{
|
||||
if(marketOrder.IsOpen(currentTicket,_Symbol,MagicNumber))
|
||||
@@ -262,7 +297,23 @@ void OnTick()
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tradeManager.Manage(currentTicket, tradeManagerState);
|
||||
}
|
||||
|
||||
// Signal handler
|
||||
|
||||
if(customBars.IsNewBar())
|
||||
{
|
||||
if(timeControl.IsScheduleEnabled())
|
||||
{
|
||||
Comment("EA trading schedule ON ("+Start+" to "+End+") | trading enabled = "+(string)timeControl.IsTradingTimeValid());
|
||||
}
|
||||
else
|
||||
{
|
||||
Comment("EA trading schedule OFF");
|
||||
}
|
||||
|
||||
//
|
||||
// Get MqlRateInfo & moving average values for current, last completed bar and the bar before that...
|
||||
//
|
||||
@@ -283,17 +334,19 @@ void OnTick()
|
||||
if(timeControl.IsScheduleEnabled())
|
||||
{
|
||||
Comment("EA trading schedule ("+Start+" to "+End+") | trading enabled = "+(string)timeControl.IsTradingTimeValid()+
|
||||
"\n MA_1 [2]: "+DoubleToString(MA1[2],_Digits)+" [1]: "+DoubleToString(MA1[1],_Digits)+
|
||||
"\n Close[2]: "+DoubleToString(RateInfo[2].close,_Digits)+" [1]: "+DoubleToString(RateInfo[1].close,_Digits)+
|
||||
//"\n MA_1 [2]: "+DoubleToString(MA1[2],_Digits)+" [1]: "+DoubleToString(MA1[1],_Digits)+
|
||||
//"\n Close[2]: "+DoubleToString(RateInfo[2].close,_Digits)+" [1]: "+DoubleToString(RateInfo[1].close,_Digits)+
|
||||
"\n Price & MA cross signal = "+marketOrder.PositionTypeToString(signal)+
|
||||
"\n Trade manager: "+tradeManager.ToString()+
|
||||
"\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Comment("EA trading schedule not used. Trading is enabled."+
|
||||
"\n MA_1 [2]: "+DoubleToString(MA1[2],_Digits)+" [1]: "+DoubleToString(MA1[1],_Digits)+
|
||||
"\n Close[2]: "+DoubleToString(RateInfo[2].close,_Digits)+" [1]: "+DoubleToString(RateInfo[1].close,_Digits)+
|
||||
//"\n MA_1 [2]: "+DoubleToString(MA1[2],_Digits)+" [1]: "+DoubleToString(MA1[1],_Digits)+
|
||||
//"\n Close[2]: "+DoubleToString(RateInfo[2].close,_Digits)+" [1]: "+DoubleToString(RateInfo[1].close,_Digits)+
|
||||
"\n Price & MA cross signal = "+marketOrder.PositionTypeToString(signal)+
|
||||
"\n Trade manager: "+tradeManager.ToString()+
|
||||
"\n");
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user