StrToDouble or StringToDouble does not work

 

I can not figure out why it does not work, anybody can help? Pls see the following code:

 double Sig[1][1];   // magic|type|target----magic|type|target
      
      bool no_Sig = false;
      string Sig_str = Signal_Get("Sig");
      string res[];
      if (StringFind(Sig_str, "|", 0) != -1){
               int end_find = StringFind(Sig_str,"----", 0);
               if (end_find == -1){
                          sep="|";                // A separator as a character
                        //--- Get the separator code
                        u_sep=StringGetCharacter(sep,0);
                        //--- Split the string to substrings
                        k=StringSplit(Sig_str,u_sep,result);
                        
                        if(k>0){
                           for(i=0;i<k;i++) {
                                  Sig[0][i] = StrToDouble(result[i]);
                             }
                          }
                        ArrayFree(result);
                } else {
                          sep="----";                // A separator as a character
                         //--- Get the separator code
                         u_sep=StringGetCharacter(sep,0);
                        //--- Split the string to substrings
                         k=StringSplit(Sig_str,u_sep,result);
                         ArrayResize(Sig, k);
                         if(k>0){
                           for(i=0;i<k;i++) {
                                   sep="|";                // A separator as a character
                                  //--- Get the separator code
                                  u_sep=StringGetCharacter(sep,0);
                                 //--- Split the string to substrings
                                  int m=StringSplit(result[i],u_sep,res);
                                  for(j=0;j<m;j++) {
                                       Sig[i][j] = StringToDouble(res[j]); PrintFormat("res[%d]: %s -- Sig[%d][%d] -- %f", j, res[j], i, j, Sig[i][j]);
                                  }
                                }
                             }
                       }
                        ArrayFree(result);
        } 

the magic number is converted successfully. but the type (either 1 or 0) and the target can not be converted, I get zeros, why?

see the log:

14:40:26 DFLY_M8 GBPJPY,M15: res[0]: 1901 -- Sig[12][0] -- 1901.00

14:40:26 DFLY_M8 GBPJPY,M15: res[1]: 1 -- Sig[12][1] -- 0.00

14:40:26 DFLY_M8 GBPJPY,M15: res[2]: 169.9138 -- Sig[12][2] -- 0.00

14:40:32 DFLY_M8 AUDCAD,M15: res[0]: 2800 -- Sig[0][0] -- 2800.0000

14:40:32 DFLY_M8 AUDCAD,M15: res[1]: 1 -- Sig[0][1] -- 0.0000

14:40:32 DFLY_M8 AUDCAD,M15: res[2]: 1.0127 -- Sig[0][2] -- 0.0000

 
marshall318:

I can not figure out why it does not work, anybody can help? Pls see the following code:

the magic number is converted successfully. but the type (either 1 or 0) and the target can not be converted, I get zeros, why?

What size are your arrays ? Print(ArraySize(res)) and Print(ArraySize(result)) . . . I suspect they are size 0 elements
 
the code cant be compiled and there 17 errors
 

please see the log, arraysize of res is not zero, size is 3, res[0] is ok, but res[1] and res[2] can not be converted

15:32:10 DFLY_M8 GBPUSD,M15: size of result[] is: 5

15:32:10 DFLY_M8 GBPUSD,M15: size of res[] is: 3

15:32:10 DFLY_M8 GBPUSD,M15: res[0]: 1900 -- Sig[0][0] -- 1900.000000

15:32:10 DFLY_M8 GBPUSD,M15: res[1]: 1 -- Sig[0][1] -- 0.000000

15:32:10 DFLY_M8 GBPUSD,M15: res[2]: 1.6585 -- Sig[0][2] -- 0.000000

15:32:10 DFLY_M8 GBPUSD,M15: size of res[] is: 3

15:32:10 DFLY_M8 GBPUSD,M15: res[0]: 1900 -- Sig[4][0] -- 1900.000000

15:32:10 DFLY_M8 GBPUSD,M15: res[1]: 1 -- Sig[4][1] -- 0.000000

15:32:10 DFLY_M8 GBPUSD,M15: res[2]: 1.6585 -- Sig[4][2] -- 0.000000

15:32:17 DFLY_M8 AUDCAD,M15: size of result[] is: 9

15:32:17 DFLY_M8 AUDCAD,M15: size of res[] is: 3

15:32:17 DFLY_M8 AUDCAD,M15: res[0]: 2800 -- Sig[0][0] -- 2800.000000

15:32:17 DFLY_M8 AUDCAD,M15: res[1]: 1 -- Sig[0][1] -- 0.000000

15:32:17 DFLY_M8 AUDCAD,M15: res[2]: 1.0127 -- Sig[0][2] -- 0.000000

15:32:17 DFLY_M8 AUDCAD,M15: size of res[] is: 3

15:32:17 DFLY_M8 AUDCAD,M15: res[0]: 2800 -- Sig[4][0] -- 2800.000000

15:32:17 DFLY_M8 AUDCAD,M15: res[1]: 1 -- Sig[4][1] -- 0.000000

15:32:17 DFLY_M8 AUDCAD,M15: res[2]: 1.0127 -- Sig[4][2] -- 0.000000

15:32:17 DFLY_M8 AUDCAD,M15: size of res[] is: 3

15:32:17 DFLY_M8 AUDCAD,M15: res[0]: 2900 -- Sig[8][0] -- 2900.000000

15:32:17 DFLY_M8 AUDCAD,M15: res[1]: 1 -- Sig[8][1] -- 0.000000

15:32:17 DFLY_M8 AUDCAD,M15: res[2]: 1.017 -- Sig[8][2] -- 0.000000

15:32:20 DFLY_M8 USDCHF,M15: size of result[] is: 5

15:32:20 DFLY_M8 USDCHF,M15: size of res[] is: 3

15:32:20 DFLY_M8 USDCHF,M15: res[0]: 1900 -- Sig[0][0] -- 1900.000000

15:32:20 DFLY_M8 USDCHF,M15: res[1]: 0 -- Sig[0][1] -- 0.000000

15:32:20 DFLY_M8 USDCHF,M15: res[2]: 0.89636 -- Sig[0][2] -- 0.000000

15:32:20 DFLY_M8 USDCHF,M15: size of res[] is: 3

15:32:20 DFLY_M8 USDCHF,M15: res[0]: 1900 -- Sig[4][0] -- 1900.000000

15:32:20 DFLY_M8 USDCHF,M15: res[1]: 0 -- Sig[4][1] -- 0.000000

15:32:20 DFLY_M8 USDCHF,M15: res[2]: 0.89636 -- Sig[4][2] -- 0.000000

 
marshall318:

I can not figure out why it does not work, anybody can help? Pls see the following code:

the magic number is converted successfully. but the type (either 1 or 0) and the target can not be converted, I get zeros, why?

see the log:

14:40:26 DFLY_M8 GBPJPY,M15: res[0]: 1901 -- Sig[12][0] -- 1901.00

14:40:26 DFLY_M8 GBPJPY,M15: res[1]: 1 -- Sig[12][1] -- 0.00

14:40:26 DFLY_M8 GBPJPY,M15: res[2]: 169.9138 -- Sig[12][2] -- 0.00

14:40:32 DFLY_M8 AUDCAD,M15: res[0]: 2800 -- Sig[0][0] -- 2800.0000

14:40:32 DFLY_M8 AUDCAD,M15: res[1]: 1 -- Sig[0][1] -- 0.0000

14:40:32 DFLY_M8 AUDCAD,M15: res[2]: 1.0127 -- Sig[0][2] -- 0.0000

Your Sig array is defined by :

 double Sig[1][1]; 

Then you are using ArrayResize, which can only resize the first dimension. You only have items with index 0, not Sig[x][1] or Sig[x][2]

 
Thanks, it works. I thought this code Sig[i][j] = StringToDouble(res[j]); could increase the size
Reason: