From 5327473eaffc338adbf860ce9866dea8d0f75684 Mon Sep 17 00:00:00 2001 From: Artur Date: Tue, 17 Mar 2020 23:34:45 +0100 Subject: [PATCH] Updated for RangeBars ver. 3.04 --- Experts/RangeBars_ExampleEA.mq5 | 14 ++++++-- Experts/RangeBars_ExampleEA2.mq5 | 30 +++++++++++++++--- Include/AZ-INVEST/SDK/CustomChartInputs.mqh | Bin 29120 -> 29176 bytes .../AZ-INVEST/SDK/CustomChartSettingsBase.mqh | Bin 23292 -> 22948 bytes 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Experts/RangeBars_ExampleEA.mq5 b/Experts/RangeBars_ExampleEA.mq5 index 731432d..03cf7b9 100644 --- a/Experts/RangeBars_ExampleEA.mq5 +++ b/Experts/RangeBars_ExampleEA.mq5 @@ -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); @@ -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... diff --git a/Experts/RangeBars_ExampleEA2.mq5 b/Experts/RangeBars_ExampleEA2.mq5 index 4e2e734..8c40817 100644 --- a/Experts/RangeBars_ExampleEA2.mq5 +++ b/Experts/RangeBars_ExampleEA2.mq5 @@ -8,6 +8,7 @@ // Helper functions for placing market orders. // +#define DEVELOPER_VERSION #include // @@ -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); @@ -79,8 +85,12 @@ 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); } //+------------------------------------------------------------------+ @@ -88,7 +98,16 @@ int OnInit() //+------------------------------------------------------------------+ void OnDeinit(const int reason) { - rangeBars.Deinit(); + // + // delete RanegBars class + // + + if(rangeBars != NULL) + { + rangeBars.Deinit(); + delete rangeBars; + rangeBars = NULL; + } // // delete MarketOrder class @@ -97,6 +116,7 @@ void OnDeinit(const int reason) if(marketOrder != NULL) { delete marketOrder; + marketOrder = NULL; } } diff --git a/Include/AZ-INVEST/SDK/CustomChartInputs.mqh b/Include/AZ-INVEST/SDK/CustomChartInputs.mqh index 7b2e6cca65b0b066fa2a5a1d978fb59be22acef9..a62e9f60e9f71457b1c8e96bc967b6f74ff7ef6b 100644 GIT binary patch delta 248 zcmX@`nDNJB#tnZMCqH0hn=HT_GI;|J+vEb~q{;i3g3!bs0r@mIYo4f;Zxdu(>F0vQ66!<-IG-ryp#Sn3Cg-sGOrF3gGr2*y3M?d|G5Lg|&}4(SfXU}19U!VSCfi8ugD?XoCrGnQ=3y1s StQ9Z8IN2dlW^+->$mAOCh{?COXH2f(IR+GGo4iIKMKfC4iIH=R$wS#C}K!uC_Wu2q!h^knd3@MH)9+LI_HJvl&< zjai978_4#ZJV{b%@&hTM$#T*@{Iv|c3|v4L=>v5G;pTWrZf2-^xi+`STw|P^plUOD Uo*Wy{cVd%IsmN@8A-Bg00OKrIi~s-t