Getting All Available Symbols - page 2

 
BenLinus:

. . . I'm curious, how did you find the offset? . . .

I didn't. AllMarketData said the record length was 1936 characters (or bytes). Once you read the first twelve characters (which contains the symbol's name as defined by the broker) of the first record, you needed to advance 1924 characters (or bytes) to the next record.

. . . When I looked at symbols.raw in notepad I didn't see the symbols the way it comes out in the output. I did see for example "EURCHF" in symbols.raw but my output when I write all the symbols array to a file appears as "EURCHF." -- which is how my broker writes it.

So long as what you see in the output is what your broker has defined as the symbol name. Did you confirm that "EURCHF." is the proper symbol name? Do you see the period in the symbol name in MT4's Market Watch window or when you open a chart for that symbol?
 
Thirteen:

I didn't. AllMarketData said the record length was 1936 characters (or bytes). Once you read the first twelve characters (which contains the symbol's name as defined by the broker) of the first record, you needed to advance 1924 characters (or bytes) to the next record.

That makes sense, but how did AllMarketData know the record length?

  TotalRecords=FileSize(handle) / 1936;


Thirteen:

So long as what you see in the output is what your broker has defined as the symbol name. Did you confirm that "EURCHF." is the proper symbol name? Do you see the period in the symbol name in MT4's Market Watch window or when you open a chart for that symbol?

Yes, "EURCHF." is the proper symbol name. My broker adds a period for nano accounts.
 

I finished a draft of the code. I can't test it since the markets are closed but the init() seems to work fine.


I think there is a slight problem with my approach. Since I'm going to use the custom indicator on only one chart, then the files will update only when a new tick comes in to that chart. This is really not an issue for my analysis purposes, but I would feel much better if I could get a more real-time experience. Would it be possible to make start() run at fixed intervals instead of at the arrival of a new tick? What if I use some sort of timing system and an infinit loop inside start()?


Btw, my other charting software updates its charts (that it draws from my data) no faster than every second -- so this is the bottle neck.

Files:
 
BenLinus:


I finished a draft of the code. I can't test it since the markets are closed but the init() seems to work fine.

Can't you make it into an EA and test in the Strategy Tester ?
 
RaptorUK:
Can't you make it into an EA and test in the Strategy Tester ?


Good idea!
 
RaptorUK:
Can't you make it into an EA and test in the Strategy Tester ?


No...

It won't work in the tester because I've used the iClose(), iHigh(), etc., functions that work on the real-time charts -- which are frozen atm.

 

There is a problem with my start(). In the output it looks like FileSeek() is not seeking properly:


EURUSD5m.csv
...
...
...
...
20130906,22:05,1.3178,1.3180,1.3176,1.3179,38
20130906,22:10,1.3178,1.3185,1.3176,1.3176,45
20130906,22:15,1.3177,1.3178,1.3176,1.3177,13
20130906,22:20,1.3179,1.3180,1.3178,1.3179,10
20130906,22:25,1.3178,1.3178,1.3176,1.3177,12
20130906,22:30,1.3178,1.3179,1.3178,1.3179,2
20130906,22:35,1.3180,1.3180,1.3178,1.3179,8
20130906,22:40,1.3178,1.3180,1.3177,1.3177,16
20130906,22:45,1.3176,1.3178,1.3176,1.20130906,22:55,1.3177,1.3177,1.3175,1.3175,7
.3178,4


int start()
{



        for(int i =0; i< TotalSymbols; i++){


                for(int j=0; j<5 ; j++ ){

                        FileName[j] = StringSubstr(SymbolArray[i],0,6) + FileNameEnd[j] ;      //We are interested in 5 periods for each symbol
                        
                        Handles[j]  = FileOpen(FileName[j] , FILE_CSV|FILE_READ|FILE_WRITE, "\t");

                        if (Handles[j]<1){
                                Print("cannot open file error_",GetLastError());
                                return(0);
                        }
                }



                static string LastTickStrings[5];
                static double ClosePrices[5];   
                static datetime CurrentTimeStamps[5];

                //----------Check for new bar -----------\\
                for( j=0; j<5 ; j++ ){
                        if(CurrentTimeStamps[j] != iTime(SymbolArray[i],Periods[j], 0) ){    //this condition should be met on the first start() iteration

                                CurrentTimeStamps[j] = iTime(SymbolArray[i],Periods[j], 0);

                                //print a new line
                                LastTickStrings[j] = MakeInfoString(SymbolArray[i],Periods[j] ,0);
                                FileWrite(Handles[j], LastTickStrings[j]);
                                ClosePrices[j] = iClose(SymbolArray[i],Periods[j] ,0);
                        }       

                        else if(ClosePrices[j] != iClose(SymbolArray[i],Periods[j] ,0) ){   //if not a newbar, but a new tick, we should delete the last line and rewrite               

                                int ByteCount = StringLen(LastTickStrings[j]) + 2 ; //count number of bytes to go back

                                LastTickStrings[j] = MakeInfoString(SymbolArray[i],Periods[j] ,0);
                                FileSeek(Handles[j],-1*ByteCount, SEEK_END);
                                FileWrite(Handles[j], LastTickStrings[j] );
                        }
                }


                for( j=0; j<5 ; j++ )
                        FileClose(Handles[j]);


        }  //next symbol



        return(0);

}


I don't get what went wrong. I used the same logic of my code that handles only the current chart:

        if(CurrentTimeStamp != Time[0]) 
        {
                CurrentTimeStamp = Time[0];

                //print a new line
                LastTickStr = MakeInfoString(0);
                FileWrite(Handle, LastTickStr);
                ClosePrice = Close[0];
        }


        if(ClosePrice != Close[0]){//delete the last line and rewrite           

                int ByteCount = StringLen(LastTickStr) + 2 ; //count number of bytes to go back

                LastTickStr = MakeInfoString(0);
                FileSeek(Handle,-1*ByteCount, SEEK_END);
                FileWrite(Handle, LastTickStr);

        }


Please, any advise?

Files:
 

Now, I'm 90% sure the problem is in keeping track of the values of each file. Erroneously, I managed the timestamps, prices, and strings for only 5 files. Probably I will need to keep track of all the files. I'm thinking of either using FileSeek() or Making my arrays (much) larger.

Maybe it was not a good idea to write code before bedtime.

 
BenLinus:


I finished a draft of the code. I can't test it since the markets are closed but the init() seems to work fine.


Would it be possible to make start() run at fixed intervals instead of at the arrival of a new tick?


https://www.fx1.net/wiki/pmwiki.php/MT4Ticker/MT4Ticker


It is also good to simulate ticks on weekends.

 
szgy74:

https://www.fx1.net/wiki/pmwiki.php/MT4Ticker/MT4Ticker


It is also good to simulate ticks on weekends.


Thanks. I have a lot of code fixing to do first.
Reason: