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 7b2e6cc..a62e9f6 100644 Binary files a/Include/AZ-INVEST/SDK/CustomChartInputs.mqh and b/Include/AZ-INVEST/SDK/CustomChartInputs.mqh differ diff --git a/Include/AZ-INVEST/SDK/CustomChartSettingsBase.mqh b/Include/AZ-INVEST/SDK/CustomChartSettingsBase.mqh index e0348a5..ac03852 100644 Binary files a/Include/AZ-INVEST/SDK/CustomChartSettingsBase.mqh and b/Include/AZ-INVEST/SDK/CustomChartSettingsBase.mqh differ