Skip to content

Commit

Permalink
Updated for RangeBars ver. 3.04
Browse files Browse the repository at this point in the history
  • Loading branch information
9nix6 committed Mar 17, 2020
1 parent 8035947 commit 5327473
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
14 changes: 12 additions & 2 deletions Experts/RangeBars_ExampleEA.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ input int InpRSIPeriod = 14; // RSI period
// Example shown below
//

RangeBars rangeBars(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
RangeBars *rangeBars = NULL;

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

rangeBars.Init();
if(rangeBars.GetHandle() == INVALID_HANDLE)
return(INIT_FAILED);
Expand All @@ -48,7 +53,12 @@ int OnInit()
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
rangeBars.Deinit();
if(rangeBars != NULL)
{
rangeBars.Deinit();
delete rangeBars;
rangeBars = NULL;
}

//
// your custom code goes here...
Expand Down
30 changes: 25 additions & 5 deletions Experts/RangeBars_ExampleEA2.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// Helper functions for placing market orders.
//

#define DEVELOPER_VERSION
#include <AZ-INVEST/SDK/TradeFunctions.mqh>

//
Expand Down Expand Up @@ -52,14 +53,19 @@ ulong currentTicket;
// Example shown below
//

RangeBars rangeBars(MQLInfoInteger((int)MQL5_TESTING) ? false : true);
CMarketOrder * marketOrder;
RangeBars *rangeBars = NULL;
CMarketOrder *marketOrder = NULL;

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

rangeBars.Init();
if(rangeBars.GetHandle() == INVALID_HANDLE)
return(INIT_FAILED);
Expand All @@ -79,16 +85,29 @@ int OnInit()
params.busyTimeout_ms = InpBusyTimeout_ms;
params.requoteTimeout_ms = InpRequoteTimeout_ms;
}
marketOrder = new CMarketOrder(params);


if(marketOrder == NULL)
{
marketOrder = new CMarketOrder(params);
}

return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
rangeBars.Deinit();
//
// delete RanegBars class
//

if(rangeBars != NULL)
{
rangeBars.Deinit();
delete rangeBars;
rangeBars = NULL;
}

//
// delete MarketOrder class
Expand All @@ -97,6 +116,7 @@ void OnDeinit(const int reason)
if(marketOrder != NULL)
{
delete marketOrder;
marketOrder = NULL;
}
}

Expand Down
Binary file modified Include/AZ-INVEST/SDK/CustomChartInputs.mqh
Binary file not shown.
Binary file modified Include/AZ-INVEST/SDK/CustomChartSettingsBase.mqh
Binary file not shown.

0 comments on commit 5327473

Please sign in to comment.