Author: Copyright Big Mouth Software Studio
Price Data Components
Series array that contains open time of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open prices of each barSeries array that contains close prices for each bar
Miscellaneous
It sends emailsUses files from the file systemIt issuies visual alerts to the screenIt writes information to file
0 Views
0 Downloads
0 Favorites
BaseData
ÿþ//+------------------------------------------------------------------+

//|                                                     BaseData.mq4 |

//|                              Copyright Big Mouth Software Studio |

//|                                             https://www.mql5.com |

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

#property copyright "Copyright Big Mouth Software Studio"

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict

//# API #

extern int cycletime = 60;       //öeô•hTgÿÒy	ÿ

extern int fileMaxRow = 1000;    //US‡eöNg'YLˆpe 

extern int remindNum = 100;      //®öNÐc’‘‡eöNpe 

//# öeô•3b #

int outFileFlg = 0;

//# ‡eöNúQ›R #

string outFileList[];

int arrayIndex = 1;

//# ‡eöNúQ›RFLG #

int fileCnt = 0;

int fileErrCnt = 0;

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

//| Expert initialization function                                   |

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

int OnInit()

  {

//--- create timer

   EventSetTimer(cycletime);

//---

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

//--- destroy timer

   EventKillTimer();

   

  }

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

//| Timer function                                                   |

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

void OnTimer()

  {

//---

   outFileFlg = outFileFlg + 1;

   string dateStr = StringSubstr(TimeToStr(iTime(Symbol(),0,0)),0,10);

   string timeStr = StringSubstr(TimeToStr(iTime(Symbol(),0,0)),11,8);

   string currencyType = Symbol();

   if(currencyType == "SPT_GLD")

      {

         currencyType = "XAUUSD";

      }

   string tickMsg = StringConcatenate("INSERT INTO ",currencyType,"_DAILY VALUES ('",dateStr,"','",timeStr,"','",iHigh(NULL,0,1),"','",iOpen(NULL,0,1),"','",iClose(NULL,0,1),"','",iLow(NULL,0,1),"');");

   

   

   Print("outFileFlg:",outFileFlg," tickMsg:",tickMsg);

   ArrayResize(outFileList,arrayIndex);

   outFileList[arrayIndex - 1] = tickMsg;

   arrayIndex = arrayIndex + 1;

   if(outFileFlg == fileMaxRow)

      {

         OutputFile();

         string outFileList[];

         arrayIndex = 1;

         outFileFlg = 0;

      }

   if(fileCnt == remindNum)

      {

         string msg = StringConcatenate("ò]Ï~ޏí~ub‡eöNÿ",fileCnt, "*Nÿ÷‹èla
g¡RhV…QX[0");

         SendMail("‡eöNúQ›Råw",msg);

         fileCnt = 0;

      }

   if(fileErrCnt == 3)

      {

         SendMail("‡eöN_8^åw","ò]Ï~ޏí~ÑSu_8^3!kÿ÷‹ÊSöeågw");

         fileErrCnt = 0;

      }  

  }

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

//|  ‡eöNúQ›R                                                        |

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

void OutputFile()

   {

      Print("***** ‡eöNúQ›R *****");

      string currencyType = Symbol();

      if(currencyType == "SPT_GLD")

         {

            currencyType = "XAUUSD";

         }

      string filename = StringConcatenate(Year(),"-",Month(),"-",Day(),"(",DayOfWeek(),")#",Hour(),"-",Minute(),"-",Seconds(),'_',currencyType,".sql");

      Print("filename:",filename);

      int h = FileOpen(filename, FILE_WRITE|FILE_ANSI|FILE_TXT);

      if(h == INVALID_HANDLE){

         Alert("Sb_‡eöN•ï‹");

         fileErrCnt = fileErrCnt + 1;

         return;

      }

      Print("ArrayMax:",ArraySize(outFileList));

      int max = ArraySize(outFileList);

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

         FileWrite(h,outFileList[i]);

      }

      FileClose(h);

      Alert("‡eöNò]Rú^");

      fileCnt = fileCnt + 1;

   }

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---