Anything wrong with this: Symbol in Market Watch
Results 1 to 4 of 34

Thread: Anything wrong with this: Symbol in Market Watch

  1. #1
    Hello,

    I have searched a bit how to check if a Symbol is in the Market View window.

    Most of the code follow something along this approach:

    Inserted Code hFile = FileOpenHistory(symbols.sel, FILE_BIN|FILE_READ); if(hFile lt; 0) return(-1); SymbolsTotal = (FileSize(hFile) - 4) / 128; FileSeek(hFile, 4, SEEK_SET); for(int I = 0; I lt; SymbolsTotal; I ) if(FileReadString(hFile, 12) == SymbolName) FileClose(hFile); //corrected return(true); //OK FileSeek(hFile, 116, SEEK_CUR); FileClose(hFile); return(false); //Not found Anything wrong with this: easy check the error code: seems simpler and probably quicker
    Inserted Code #include lt;stderror.mqhgt; GetLastError(); //clean last err int iL.Digits = MarketInfo(Symbol, MODE_DIGITS); if (GetLastError() == ERR_UNKNOWN_SYMBOL) //Not found return(false); else //OK return(true); } Thanks for any information

    R

  2. #2
    Quote Originally Posted by ;
    hello,

    I've searched a little how to assess if a Symbol is in the Market Watch window.

    The majority of the code follow something along this approach:

    Inserted Code hFile = FileOpenHistory(symbols.sel, FILE_BIN|FILE_READ); if(hFile lt; 0) return(-1); SymbolsTotal = (FileSize(hFile) - 4) / 128; FileSeek(hFile, 4, SEEK_SET); for(int I = 0; I lt; SymbolsTotal; I ) if(FileReadString(hFile, 12) == SymbolName) return(true); //OK FileSeek(hFile, 116, SEEK_CUR); FileClose(hFile); return(false); //Not found [b]Anything wrong with...
    looks good on paper, however I think the first code example is meant to be a jumping-off tip for further reading of information in the file and isn't meant to only see if a symbol exists or not. Else it is missing a fileclose before coming accurate.

  3. #3
    Quote Originally Posted by ;
    else it is missing a fileclose before returning true.
    My poor: THANKS. Corrected it in the article. Was speaking to this code snipped of: http://forum.mql4.com/24948 ChartWindow
    and wondered whether it would be not simpler only checking the error code. .

    But I am not sure if the other egy: looping throughout the symbols.sel file has some benefits like I mostly saw this egy on the net

  4. #4
    Quote Originally Posted by ;
    My bad: THANKS. Adjusted it. Was speaking to the code snipped of: http://forum.mql4.com/24948 ChartWindow
    and wondered whether it would be not easier just checking the error code. .

    But I am not sure whether another egy: looping throughout the symbols.sel document has some advantages as I mostly watched this approach on the net
    did you come to some conclusion. I am still curious about this as far as I could tell the file scanning variant was likely just the first idea of how to go about doing it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.