ReferenzArray verändert sich nicht: Solved

Einloggen oder registrieren, um einen Kommentar zu schreiben
Bayne
1009
Bayne  

Hey habe eine Funktion die Daten in ein File schreiben soll. Das würde auch klappen, wenn die ArrayReferenz funktionieren würde...

seit ich einen Loop (in Switch_Input_Types())integriert habe der im voraus die nächsten X Zeilen füllen soll ( für die Wochentag daten z.b. die nächsten 7 arrayeinträge), funktioniert das ganze nicht, mittels Print auch im for j loop und auch ausserhalb die jeweiligen arrayeinträge abgerufen, bekomme jedoch immer 0 zurück.

Innerhalb der DatenabrufFunktion(Switch_Input_Types()), bekomme ich auch die richtigen daten. Nur leider ändert sich im array nichts.


     for(int i=bars-LatestBarBack -1 /*-1 weil array*/;i>LatestBarForward;i--)
          {
          datetime time=iTime(my_symbol,my_timeframe,i);
          
          Y_Close[i] = iClose(my_symbol,my_timeframe,i); // hieraus wird später unser Y Label
          Y_Lows[i]=iLow(my_symbol,my_timeframe,i);
          Y_Highs[i]=iHigh(my_symbol,my_timeframe,i);
          Time[i] = iTime(my_symbol,my_timeframe,i);
          int InputIndex=0;
          for (int j = 0; j<ArraySize(Input_Types);j++)
               {
                     
               /*x_data[i][InputIndex] = */Switch_Input_Types(Input_Types,j,i,x_data,InputIndex); // FeatureValue
               //Print("x_data[i][j] = ",x_data[i][j]);

                Print("x_data[",i,"][",InputIndex,"] = ",x_data[i][InputIndex]); //leider immer null
                }


            //checken ob sich in x_data was geändert hat
            for (int p =0; p<ArraySize(x_data)/191;p++)    
               {
               for (int o =0; o<ArraySize(x_data)/(bars-LatestBarBack);o++)
                  {
                  if(x_data[p][o] !=0)
                     {Print("x_data[",p,"][",o,"] = ",x_data[p][o]);} //wird nie abgerufen
                  }
               }   
            FileWrite(FileHandle,x_data[i][0],x_data[i][1],x_data[i][2],x_data[i][3],x_data[i][4],x_data[i][5],x_data[i][6],x_data[i][7],x_data[i][8],x_data[i][9],x_data[i][10],x_data[i][11],x_data[i][12],x_data[i][13],x_data[i][14],x_data[i][15],x_data[i][16],x_data[i][17],x_data[i][18],x_data[i][19],x_data[i][20],
                           x_data[i][21],x_data[i][22],x_data[i][23],x_data[i][24],x_data[i][25],x_data[i][26],x_data[i][27],x_data[i][28],x_data[i][29],x_data[i][30],x_data[i][31],x_data[i][32],x_data[i][33],x_data[i][34],x_data[i][35],x_data[i][36],x_data[i][37],x_data[i][38],x_data[i][39],x_data[i][40],
                           x_data[i][41],x_data[i][42],x_data[i][43],x_data[i][44],x_data[i][45],x_data[i][46],x_data[i][47],x_data[i][48],x_data[i][49],x_data[i][50],x_data[i][51],x_data[i][52],x_data[i][53],x_data[i][54],x_data[i][55],x_data[i][56],x_data[i][57],x_data[i][58],x_data[i][59],x_data[i][50],
                           x_data[i][61],/*iTime(my_symbol,my_timeframe,i));//*/x_data[i][62]); // sind mittlerweile mehr als 62 Daten
                                         
                               
            }

In Input_Types[] ist der case , also die art des gewünschten Inputs angegeben: (hier die Initialisierungsfunktion)

//Input_Types=Array das art des Inputs enthällt ; CaseI= gesuchter Index in Input_Types (=Art des Inputs ; Sample = Datenposition in History ; Input_X = InputArray ; int &Input = Referenz auf Index im "Input_X" array

void Switch_Input_Types  (int &InputTypes[], int CaseI, int Sample, double &Input_X[][191], int &Input) 
{    
      datetime time = iTime(my_symbol,my_timeframe,Sample);
      switch(InputTypes[CaseI]) 
                  {
                  case 1 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+2) - iClose(my_symbol,my_timeframe,Sample+1);Input++;break;
                  case 2 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+3) - iClose(my_symbol,my_timeframe,Sample+2);Input++;break;
                  case 3 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+4) - iClose(my_symbol,my_timeframe,Sample+3);Input++;break;
                  case 4 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+5) - iClose(my_symbol,my_timeframe,Sample+4);Input++;break;
                  case 5 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+6) - iClose(my_symbol,my_timeframe,Sample+5);Input++;break;
                  case 6 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+7) - iClose(my_symbol,my_timeframe,Sample+6);Input++;break;
                  case 7 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+8) - iClose(my_symbol,my_timeframe,Sample+7);Input++;break;
                  case 8 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+9) - iClose(my_symbol,my_timeframe,Sample+8);Input++;break;
                  case 9 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+10) - iClose(my_symbol,my_timeframe,Sample+9);Input++;break;
                  case 10 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+11) - iClose(my_symbol,my_timeframe,Sample+10);Input++;break;
                  case 11 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+12) - iClose(my_symbol,my_timeframe,Sample+11);Input++;break;
                  case 12 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+13) - iClose(my_symbol,my_timeframe,Sample+12);Input++;break;
                  case 13 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+14) - iClose(my_symbol,my_timeframe,Sample+13);Input++;break;
                  case 14 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+15) - iClose(my_symbol,my_timeframe,Sample+14);Input++;break;
                  case 15 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+16) - iClose(my_symbol,my_timeframe,Sample+15);Input++;break;
                  case 16 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+17) - iClose(my_symbol,my_timeframe,Sample+16);Input++;break;
                  case 17 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+18) - iClose(my_symbol,my_timeframe,Sample+17);Input++;break;
                  case 18 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+19) - iClose(my_symbol,my_timeframe,Sample+18);Input++;break;
                  case 19 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+20) - iClose(my_symbol,my_timeframe,Sample+19);Input++;break;
                  case 20 : Input_X[Sample][Input]=  iClose(my_symbol,my_timeframe,Sample+21) - iClose(my_symbol,my_timeframe,Sample+20);Input++;break;
                  
                  case 21 : for (int wd =0; wd<7;wd++){                       if(wd!=TimeDayOfWeek(time)){
                                                                              Input_X[Sample][Input+wd]=0;}
                                                                              else{
                                                                              Input_X[Sample][Input+wd] =1;}
                                                                              Input++;} 
                                                                              break; 
                  case 22 : for (int md =0; md<31;md++){ 
                                                                              int month = TimeDayOfMonth(time);
                                                                              if(md!=month)
                                                                              {Input_X[Sample][Input+md]=0;}
                                                                              else if (md== month)
                                                                              {Input_X[Sample][Input+md] =1;}
                                                                              Input++;} 
                                                                              break;
                  case 23 : for (int m =0; m<12;m++){     if(m!=TimeMonth(time)){Input_X[Sample][Input+m]=0;}    else{  Input_X[Sample][Input+m] =TimeDayOfWeek(time);}     Input++;}break;

                  case 24 : for (int h =0; h<24;h++){     if(h!=TimeHour(time)){Input_X[Sample][Input+h]=0;}     else{Input_X[Sample][Input+h] =TimeDayOfWeek(time);}     Input++;} break;
                  case 25 :               int rsi_buf=CopyBuffer(RSI_Handle,0,Sample,3,RSI);
                                          if (rsi_buf<0){Print("CopyBufferMA1 error =",GetLastError());}
                                          Input_X[Sample][Input] =RSI[2]-RSI[1]; }
                                          Input++;break;
                  
                  }
Bayne
1009
Bayne  
EDIT: ein simples leerzeichen hat das problem gelöst...
double &Input_X[][191]

lösung:

double & Input_X[][191]
Christian
3202
Christian  
Bayne:
EDIT: ein simples leerzeichen hat das problem gelöst...

lösung:

Das möchte ich so nicht stehen lassen.

Der Compiler ließt immer von links nach rechts. Ob da ein Leerzeichen mehr ist stört ihn nicht.


Als Beweis hier ein Testskript:

//+------------------------------------------------------------------+
//|                                         Forum_Bayne_Referenz.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+



void OnStart()
  {
  double x = 5;
  double y = 10;
  double z = 15;
  
  F1(x);
  F2(y);
  F1_bayne(z);
  Print(x);
  Print(y); 
  Print(z);
  }
//+------------------------------------------------------------------+


void F1(double &x)
{
  x = x +1;
}
void F1_bayne(double & z)
{
  z = z +1;
}
void F2(double y)
{
  y = y +1;
}

Ausgabe:

LD      0       12:44:47.375    Forum_Bayne_Referenz (EURUSD,H1)        6.0
PL      0       12:44:47.376    Forum_Bayne_Referenz (EURUSD,H1)        10.0
HE      0       12:44:47.376    Forum_Bayne_Referenz (EURUSD,H1)        16.0

Das kann nicht dein Problem gelöst haben.

Einloggen oder registrieren, um einen Kommentar zu schreiben