Skip to content

Commit

Permalink
Updated EA files for latest SDK version
Browse files Browse the repository at this point in the history
  • Loading branch information
9nix6 committed Mar 15, 2020
1 parent 3660031 commit d914e7a
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 24 deletions.
55 changes: 47 additions & 8 deletions Experts/2MA_Cross.mq5
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#property copyright "Copyright 2017-2019, Artur Zas"
#property copyright "Copyright 2017-2020, Artur Zas"
#property link "https://www.az-invest.eu"
#property version "1.10"
#property version "1.11"

//
// Uncomment only ONE of the 3 directives listed below and recompile
Expand All @@ -22,15 +22,15 @@

#ifdef EA_ON_RANGE_BARS
#include <AZ-INVEST/SDK/RangeBars.mqh>
RangeBars customBars = RangeBars(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
RangeBars *customBars = NULL;
#endif
#ifdef EA_ON_RENKO
#include <AZ-INVEST/SDK/MedianRenko.mqh>
MedianRenko customBars = MedianRenko(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
MedianRenko *customBars = NULL;
#endif
#ifdef EA_ON_XTICK_CHART
#include <AZ-INVEST/SDK/TickChart.mqh>
TickChart customBars = TickChart(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
TickChart *customBars = NULL;
#endif

#include <AZ-INVEST/SDK/TimeControl.mqh>
Expand Down Expand Up @@ -65,8 +65,8 @@ int numberOfBars = 3;

// EA variables

CMarketOrder *marketOrder;
CTimeControl timeControl;
CMarketOrder *marketOrder = NULL;
CTimeControl *timeControl = NULL;

ulong currentTicket;
ENUM_POSITION_TYPE currentPositionType;
Expand All @@ -91,6 +91,19 @@ ENUM_POSITION_TYPE validation;
//+------------------------------------------------------------------+
int OnInit()
{
if(customBars == NULL)
{
#ifdef EA_ON_RANGE_BARS
customBars = new RangeBars(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
#endif
#ifdef EA_ON_RENKO
customBars = new MedianRenko(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
#endif
#ifdef EA_ON_XTICK_CHART
customBars = new TickChart(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
#endif
}

customBars.Init();
if(customBars.GetHandle() == INVALID_HANDLE)
return(INIT_FAILED);
Expand All @@ -111,6 +124,11 @@ int OnInit()

marketOrder = new CMarketOrder(params);

if(timeControl == NULL)
{
timeControl = new CTimeControl();
}

timeControl.SetValidTraingHours(Start,End);

return(INIT_SUCCEEDED);
Expand All @@ -121,9 +139,30 @@ int OnInit()
void OnDeinit(const int reason)
{
customBars.Deinit();

// delete TimeControl class

if(timeControl != NULL)
{
delete timeControl;
timeControl = NULL;
}

// delete MarketOrder class

if(marketOrder != NULL)
{
delete marketOrder;
marketOrder = NULL;
}

// delete MedianRenko class

if(customBars != NULL)
{
delete customBars;
customBars = NULL;
}

Comment("");
}
Expand All @@ -132,7 +171,7 @@ void OnDeinit(const int reason)
//+------------------------------------------------------------------+
void OnTick()
{
if(marketOrder == NULL)
if(marketOrder == NULL || customBars == NULL || timeControl == NULL)
return;

if(customBars.IsNewBar())
Expand Down
21 changes: 17 additions & 4 deletions Experts/ExampleEA.mq5
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// Copyright 2017-2019, Artur Zas
// Copyright 2017-2020, Artur Zas
// https://www.az-invest.eu
// https://www.mql5.com/en/users/arturz
//

#property copyright "Copyright 2017-2019, Artur Zas"
#property copyright "Copyright 2017-2020, Artur Zas"
#property link "https://www.mql5.com/en/users/arturz"
#property version "3.00"
#property version "3.01"
#property description "Example EA showing the way to use the MedianRenko class defined in MedianRenko.mqh"

//
Expand All @@ -31,13 +31,16 @@
// Example shown in OnInit & OnDeinit functions below:
//

MedianRenko medianRenko = MedianRenko(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
MedianRenko *medianRenko = NULL;

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
if(medianRenko == NULL)
medianRenko = new MedianRenko(MQLInfoInteger((int)MQL5_TESTING) ? false : true);

medianRenko.Init();
if(medianRenko.GetHandle() == INVALID_HANDLE)
return(INIT_FAILED);
Expand All @@ -54,6 +57,16 @@ int OnInit()
void OnDeinit(const int reason)
{
medianRenko.Deinit();

//
// delete MedianRenko class
//

if(medianRenko != NULL)
{
delete medianRenko;
medianRenko = NULL;
}

//
// your custom code goes here...
Expand Down
29 changes: 21 additions & 8 deletions Experts/ExampleEA3.mq5
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// Copyright 2017-2019, Artur Zas
// Copyright 2017-2020, Artur Zas
// https://www.az-invest.eu
// https://www.mql5.com/en/users/arturz
//

#property copyright "Copyright 2017-2019, AZ-iNVEST"
#property link "http://www.az-invest.eu"
#property version "1.10"
#property copyright "Copyright 2017-2020, Artur Zas"
#property link "https://www.az-invest.eu"
#property version "1.11"
#property description "Example EA showing the way to use the MedianRenko class defined in MedianRenko.mqh"
#property description "as well as external indicators attached to the RenkoCharts"

Expand Down Expand Up @@ -34,17 +34,20 @@ input int InpRSIPeriod=14; // RSI Period
// Example shown in OnInit & OnDeinit functions below:
//

MedianRenko medianRenko = MedianRenko(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
int RsiHandle = -1;
MedianRenko *medianRenko = NULL;
int RsiHandle = -1;

double RsiBuffer[]; // This array will store the RSI values for the renko chart
MqlRates RenkoRatesInfoArray[]; // This array will store the MqlRates data for renkos
double RsiBuffer[]; // This array will store the RSI values for the renko chart
MqlRates RenkoRatesInfoArray[]; // This array will store the MqlRates data for renkos

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
if(medianRenko == NULL)
medianRenko = new MedianRenko(MQLInfoInteger((int)MQL5_TESTING) ? false : true);

medianRenko.Init();
if(medianRenko.GetHandle() == INVALID_HANDLE)
return(INIT_FAILED);
Expand All @@ -58,6 +61,16 @@ void OnDeinit(const int reason)
{
medianRenko.Deinit();

//
// delete MedianRenko class
//

if(medianRenko != NULL)
{
delete medianRenko;
medianRenko = NULL;
}

//
// your custom code goes here...
//
Expand Down
47 changes: 43 additions & 4 deletions Experts/PriceMA_Cross.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

#ifdef EA_ON_RANGE_BARS
#include <AZ-INVEST/SDK/RangeBars.mqh>
RangeBars customBars = RangeBars(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
RangeBars *customBars = NULL;
#endif
#ifdef EA_ON_RENKO
#include <AZ-INVEST/SDK/MedianRenko.mqh>
MedianRenko customBars = MedianRenko(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
MedianRenko *customBars = NULL;
#endif
#ifdef EA_ON_XTICK_CHART
#include <AZ-INVEST/SDK/TickChart.mqh>
TickChart customBars = TickChart(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
TickChart *customBars = NULL;
#endif

#include <AZ-INVEST/SDK/TimeControl.mqh>
Expand Down Expand Up @@ -64,7 +64,7 @@ int numberOfBars = 4;
// EA variables

CMarketOrder *marketOrder;
CTimeControl timeControl;
CTimeControl *timeControl;

ulong currentTicket;
ENUM_POSITION_TYPE currentPositionType;
Expand All @@ -89,6 +89,19 @@ ENUM_POSITION_TYPE validation;
//+------------------------------------------------------------------+
int OnInit()
{
if(customBars == NULL)
{
#ifdef EA_ON_RANGE_BARS
customBars = new RangeBars(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
#endif
#ifdef EA_ON_RENKO
customBars = new MedianRenko(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
#endif
#ifdef EA_ON_XTICK_CHART
customBars = new TickChart(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
#endif
}

customBars.Init();

signal = POSITION_TYPE_NONE;
Expand All @@ -107,6 +120,11 @@ int OnInit()

marketOrder = new CMarketOrder(params);

if(timeControl == NULL)
{
timeControl = new CTimeControl();
}

timeControl.SetValidTraingHours(Start,End);

return(INIT_SUCCEEDED);
Expand All @@ -117,9 +135,30 @@ int OnInit()
void OnDeinit(const int reason)
{
customBars.Deinit();

// delete TimeControl class

if(timeControl != NULL)
{
delete timeControl;
timeControl = NULL;
}

// delete MarketOrder class

if(marketOrder != NULL)
{
delete marketOrder;
marketOrder = NULL;
}

// delete MedianRenko class

if(customBars != NULL)
{
delete customBars;
customBars = NULL;
}

Comment("");
}
Expand Down

0 comments on commit d914e7a

Please sign in to comment.