Strategy Tester crashed when using Indicator with FX Blue Trading Simulator New comment

To add comments, please log in or register
Behdad Ahmadi
47
Behdad Ahmadi  

I coded an Indicator which use a DLL file (I coded this DLL file to call Python function from C++). The Indicator works well on charts when trading without any bugs, but If I want it to use in FX Blue Simluator Visual chart to backtest it manually, MT4 crashes with this error:

Fault bucket , type 0
Event Name: AppHangB1
Response: Not available
Cab Id: 0

Problem signature:
P1: terminal.exe
P2: 4.0.0.1170
P3: 00d42400
P4: c6ec
P5: 134217729
P6: 
P7: 
P8: 
P9: 
P10: 

Attached files:
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERA69.tmp.WERInternalMetadata.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERA7A.tmp.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERA79.tmp.csv
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERA89.tmp.txt
\\?\C:\Users\Behdad\AppData\Local\Temp\WER8FE7.tmp.appcompat.txt

These files may be available here:
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppHang_terminal.exe_eda3427189d02477d267a6977027f4653d57d929_df4afc6b_08b09227

Analysis symbol: 
Rechecking for solution: 0
Report Id: 5bb6966e-1557-4e96-a968-16413bf1a7c9
Report Status: 97
Hashed bucket: 
Cab Guid: 0


Indicator Code:

#import "PythonNumpyMean.dll"
int CalculateZones(double &data[], double quantile, int arraySize,char&[]);

#import

//+------------------------------------------------------------------+

//|                                               SuppResistance.mq4 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+




#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
        double data[];
        char response[];
         int status = 0;

input color M5color = clrTurquoise;
char buffer[4096];
input int WINDOW = 5;
input double PARAM_SHIFT = 0.25;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//ArrayResize(data,4096);
 ArrayResize(data,WINDOW);
   DeleteAllCreatedObjects();
//---
   return(INIT_SUCCEEDED);
  }
  
  int deinit()
  {
//----
DeleteAllCreatedObjects();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

int start()
  {


    if (IsNewBar()){
    
    
        
         Rate(data,WINDOW);
        status=  CalculateZones(data,PARAM_SHIFT ,ArraySize(data),buffer);
        Print(status);
         string zones = CharArrayToString(buffer);
         DeleteAllCreatedObjects();
         CreateObjects("MARKET",zones,M5color,1);
  }

 
   return(0);
}





void Rate(double &out[],int len){
        for(int i=(len - 1);i>-1;i--){
         //double close = ;
         out[i] = iClose(NULL,0,i+1);
      }   
 }
   
bool IsNewBar()
{
   static datetime lastbar;
   datetime curbar = (datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
   if(lastbar != curbar)
   {
      lastbar = curbar;
      return true;
   }
   return false;
}


 void CreateObjects(string suffixName,string zones,color colorCode, int width){
   string sep=",";
   ushort u_sep;  
   string result[]; 
   u_sep=StringGetCharacter(sep,0);
   int k=StringSplit(zones,u_sep,result);
   
      if(k>0)
        {
         for(int i=0;i<k;i++)
           {
              // string name = "ZONE-" + result[i];
                string name = "LINE-" + i;
               //ObjectCreate(name,OBJ_HLINE,0,D'2004.02.20 12:30', result[i]);
               
                //ObjectCreate(name,OBJ_HLINE,0,0, result[i]);
               ObjectCreate(ChartID(),name,OBJ_HLINE,0,0,result[i]);
               ObjectSetInteger(0,name,OBJPROP_COLOR,colorCode);
               //ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
               ObjectSetInteger(0,name,OBJPROP_STYLE,1);
               
           }
        }
 }
   
 void DeleteAllCreatedObjects(){
 for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--){
       // string on = ObjectName(iObj);
        if(ObjectType(ObjectName(iObj)==OBJ_HLINE)) ObjectDelete(ObjectName(iObj));
       // if (StringFind(on, "ZONE") == 0)  ObjectDelete(on);
 
      }
 
  }

What's the problem with Indicator?

Thank you

To add comments, please log in or register