├── MQL4 ├── Export Data to CSV.mq4 └── FSB Data Source.mq4 ├── MQL5 ├── Export Data to CSV.mq5 └── FSB Data Source.mq5 └── README.md /MQL4/Export Data to CSV.mq4: -------------------------------------------------------------------------------- 1 | //| Copyright: (C) 2015 Forex Software Ltd. | 2 | //| Website: http://forexsb.com/ | 3 | //| Support: http://forexsb.com/forum/ | 4 | //| License: Proprietary under the following circumstances: | 5 | //| | 6 | //| This code is a part of Forex Strategy Builder. It is free for | 7 | //| use as an integral part of Forex Strategy Builder. | 8 | //| One can modify it in order to improve the code or to fit it for | 9 | //| personal use. This code or any part of it cannot be used in | 10 | //| other applications without a permission. | 11 | //| The contact information cannot be changed. | 12 | //| | 13 | //| NO LIABILITY FOR CONSEQUENTIAL DAMAGES | 14 | //| | 15 | //| In no event shall the author be liable for any damages whatsoever | 16 | //| (including, without limitation, incidental, direct, indirect and | 17 | //| consequential damages, damages for loss of business profits, | 18 | //| business interruption, loss of business information, or other | 19 | //| pecuniary loss) arising out of the use or inability to use this | 20 | //| product, even if advised of the possibility of such damages. | 21 | //+--------------------------------------------------------------------+ 22 | 23 | #property copyright "Copyright 2015, Forex Software Ltd." 24 | #property link "http://forexsb.com" 25 | #property version "2.00" 26 | 27 | void OnStart() 28 | { 29 | Comment("Loading..."); 30 | int maxBars= MathMin(TerminalInfoInteger(TERMINAL_MAXBARS),100000); 31 | string comment=""; 32 | ENUM_TIMEFRAMES periods[] = {PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1}; 33 | for(int p=0;p1) 50 | { 51 | int filehandle=FileOpen(fileName,FILE_WRITE|FILE_CSV); 52 | for(int i=bars-1; i>=0; i--) 53 | { 54 | FileWrite(filehandle, 55 | TimeToString(rates_array[i].time,TIME_DATE), 56 | TimeToString(rates_array[i].time,TIME_MINUTES), 57 | rates_array[i].open, 58 | rates_array[i].high, 59 | rates_array[i].low, 60 | rates_array[i].close, 61 | rates_array[i].tick_volume); 62 | } 63 | FileFlush(filehandle); 64 | FileClose(filehandle); 65 | comment="File exported: "+fileName+", "+IntegerToString(bars)+" bars"; 66 | } 67 | else 68 | { 69 | comment="Error with exporting: "+fileName; 70 | } 71 | return (comment); 72 | } 73 | 74 | string PeriodToStr(ENUM_TIMEFRAMES period) 75 | { 76 | string strper; 77 | switch(period) 78 | { 79 | case PERIOD_M1 : strper="1"; break; 80 | case PERIOD_M5 : strper="5"; break; 81 | case PERIOD_M15 : strper="15"; break; 82 | case PERIOD_M30 : strper="30"; break; 83 | case PERIOD_H1 : strper="60"; break; 84 | case PERIOD_H4 : strper="240"; break; 85 | case PERIOD_D1 : strper="1440"; break; 86 | case PERIOD_W1 : strper="10080"; break; 87 | case PERIOD_MN1 : strper="302400"; break; 88 | default : strper=""; 89 | } 90 | return (strper); 91 | } 92 | //+------------------------------------------------------------------+ 93 | -------------------------------------------------------------------------------- /MQL4/FSB Data Source.mq4: -------------------------------------------------------------------------------- 1 | //| Copyright: (C) 2015 Forex Software Ltd. | 2 | //| Website: http://forexsb.com/ | 3 | //| Support: http://forexsb.com/forum/ | 4 | //| License: Proprietary under the following circumstances: | 5 | //| | 6 | //| This code is a part of Forex Strategy Builder. It is free for | 7 | //| use as an integral part of Forex Strategy Builder. | 8 | //| One can modify it in order to improve the code or to fit it for | 9 | //| personal use. This code or any part of it cannot be used in | 10 | //| other applications without a permission. | 11 | //| The contact information cannot be changed. | 12 | //| | 13 | //| NO LIABILITY FOR CONSEQUENTIAL DAMAGES | 14 | //| | 15 | //| In no event shall the author be liable for any damages whatsoever | 16 | //| (including, without limitation, incidental, direct, indirect and | 17 | //| consequential damages, damages for loss of business profits, | 18 | //| business interruption, loss of business information, or other | 19 | //| pecuniary loss) arising out of the use or inability to use this | 20 | //| product, even if advised of the possibility of such damages. | 21 | //+--------------------------------------------------------------------+ 22 | 23 | #property copyright "Forex Software Ltd." 24 | #property link "http://forexsb.com" 25 | #property version "1.00" 26 | #property strict 27 | 28 | class InstrumentProperties; 29 | //+------------------------------------------------------------------+ 30 | //| Script program start function | 31 | //+------------------------------------------------------------------+ 32 | void OnStart() 33 | { 34 | string dataSourceName=TerminalInfoString(TERMINAL_NAME); 35 | string path=TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\\Files"; 36 | StringReplace(path,"\\","\\\\"); 37 | string dataDirectory=path; 38 | string description="Data Source exported from "+ 39 | TerminalInfoString(TERMINAL_NAME)+", "+ 40 | TerminalInfoString(TERMINAL_COMPANY); 41 | 42 | string symbolsList[]; 43 | int symbols=GetSymbolsList(symbolsList); 44 | InstrumentProperties *properties[]; 45 | ArrayResize(properties,symbols); 46 | for(int i=0;i3) 73 | symbolsList[symbolIndex++]=symbol; 74 | } 75 | ArrayResize(symbolsList,symbolIndex); 76 | return (symbolIndex); 77 | } 78 | //+------------------------------------------------------------------+ 79 | void SaveStringToFile(string filename,string text) 80 | { 81 | int handle= FileOpen(filename,FILE_TXT|FILE_WRITE|FILE_ANSI); 82 | if(handle == INVALID_HANDLE) 83 | return; 84 | 85 | FileWriteString(handle,text); 86 | FileClose(handle); 87 | } 88 | //+------------------------------------------------------------------+ 89 | //| | 90 | //+------------------------------------------------------------------+ 91 | string ComposeDataSourceContent(string dataSourceName, 92 | string dataDirectory, 93 | string description, 94 | InstrumentProperties *&properties[]) 95 | { 96 | string content=""; 97 | content += "{\n"; 98 | content += " \"DataSourceName\" : \"" + dataSourceName + "\",\n"; 99 | content += " \"DataDirectory\" : \"" + dataDirectory + "\",\n"; 100 | content += " \"Description\" : \"" + description + "\",\n"; 101 | content += " \"InstrumentProperties\": {\n"; 102 | int propCount=ArraySize(properties); 103 | for(int i=0;i100000.0) 197 | { 198 | if(currProfit=="JPY") 199 | rate=0.01; 200 | else if(currAccount=="JPY") 201 | rate=100; 202 | else 203 | rate=1.0; 204 | } 205 | 206 | return (rate); 207 | } 208 | //+------------------------------------------------------------------+ 209 | string InstrumentProperties::GetPropertyJson(void) 210 | { 211 | string content=""; 212 | content += " \""+this.Symbol+"\" : {\n"; 213 | content += " \"Symbol\" : \""+this.Symbol+"\",\n"; 214 | content += " \"InstrType\" : "+IntegerToString(this.InstrType)+",\n"; 215 | content += " \"Comment\" : \""+this.Comment+"\",\n"; 216 | content += " \"PriceIn\" : \""+this.PriceIn+"\",\n"; 217 | content += " \"BaseFileName\" : \""+this.BaseFileName+"\",\n"; 218 | content += " \"LotSize\" : "+IntegerToString(this.LotSize)+",\n"; 219 | content += " \"Slippage\" : "+IntegerToString(this.Slippage)+",\n"; 220 | content += " \"Spread\" : "+DoubleToString(this.Spread,2)+",\n"; 221 | content += " \"SwapLong\" : "+DoubleToString(this.SwapLong,2)+",\n"; 222 | content += " \"SwapShort\" : "+DoubleToString(this.SwapShort,2)+",\n"; 223 | content += " \"Commission\" : "+DoubleToString(this.Commission,2)+",\n"; 224 | content += " \"RateToUSD\" : "+DoubleToString(this.RateToUSD,this.Digits)+",\n"; 225 | content += " \"RateToEUR\" : "+DoubleToString(this.RateToEUR,this.Digits)+",\n"; 226 | content += " \"RateToGBP\" : "+DoubleToString(this.RateToGBP,this.Digits)+",\n"; 227 | content += " \"RateToJPY\" : "+DoubleToString(this.RateToJPY,this.Digits)+",\n"; 228 | content += " \"SwapType\" : "+IntegerToString(this.SwapType)+",\n"; 229 | content += " \"CommissionType\" : "+IntegerToString(this.CommissionType)+",\n"; 230 | content += " \"CommissionScope\" : "+IntegerToString(this.CommissionScope)+",\n"; 231 | content += " \"CommissionTime\" : "+IntegerToString(this.CommissionTime)+",\n"; 232 | content += " \"Digits\" : "+IntegerToString(this.Digits)+",\n"; 233 | content += " \"Point\" : "+DoubleToString(this.Point,this.Digits)+",\n"; 234 | content += " \"Pip\" : "+DoubleToString(this.Pip,this.Digits)+",\n"; 235 | content += " \"IsFiveDigits\" : "+(this.IsFiveDigits?"true":"false")+",\n"; 236 | content += " \"StopLevel\" : "+DoubleToString(this.StopLevel,2)+",\n"; 237 | content += " \"TickValue\" : "+DoubleToString(this.TickValue,2)+",\n"; 238 | content += " \"MinLot\" : "+DoubleToString(this.MinLot,2)+",\n"; 239 | content += " \"MaxLot\" : "+DoubleToString(this.MaxLot,2)+",\n"; 240 | content += " \"LotStep\" : "+DoubleToString(this.LotStep,2)+",\n"; 241 | content += " \"MarginRequired\" : "+DoubleToString(this.MarginRequired,2)+"\n"; 242 | content += " }"; 243 | return (content); 244 | } 245 | //+------------------------------------------------------------------+ 246 | -------------------------------------------------------------------------------- /MQL5/Export Data to CSV.mq5: -------------------------------------------------------------------------------- 1 | //| Copyright: (C) 2015 Forex Software Ltd. | 2 | //| Website: http://forexsb.com/ | 3 | //| Support: http://forexsb.com/forum/ | 4 | //| License: Proprietary under the following circumstances: | 5 | //| | 6 | //| This code is a part of Forex Strategy Builder. It is free for | 7 | //| use as an integral part of Forex Strategy Builder. | 8 | //| One can modify it in order to improve the code or to fit it for | 9 | //| personal use. This code or any part of it cannot be used in | 10 | //| other applications without a permission. | 11 | //| The contact information cannot be changed. | 12 | //| | 13 | //| NO LIABILITY FOR CONSEQUENTIAL DAMAGES | 14 | //| | 15 | //| In no event shall the author be liable for any damages whatsoever | 16 | //| (including, without limitation, incidental, direct, indirect and | 17 | //| consequential damages, damages for loss of business profits, | 18 | //| business interruption, loss of business information, or other | 19 | //| pecuniary loss) arising out of the use or inability to use this | 20 | //| product, even if advised of the possibility of such damages. | 21 | //+--------------------------------------------------------------------+ 22 | 23 | #property copyright "Copyright 2015, Forex Software Ltd." 24 | #property link "http://forexsb.com" 25 | #property version "2.00" 26 | 27 | void OnStart() 28 | { 29 | Comment("Loading..."); 30 | int maxBars= MathMin(TerminalInfoInteger(TERMINAL_MAXBARS),100000); 31 | string comment=""; 32 | ENUM_TIMEFRAMES periods[] = {PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1}; 33 | for(int p=0;p1) 50 | { 51 | int filehandle=FileOpen(fileName,FILE_WRITE|FILE_CSV); 52 | for(int i=bars-1; i>=0; i--) 53 | { 54 | FileWrite(filehandle, 55 | TimeToString(rates_array[i].time,TIME_DATE), 56 | TimeToString(rates_array[i].time,TIME_MINUTES), 57 | rates_array[i].open, 58 | rates_array[i].high, 59 | rates_array[i].low, 60 | rates_array[i].close, 61 | rates_array[i].tick_volume); 62 | } 63 | FileFlush(filehandle); 64 | FileClose(filehandle); 65 | comment="File exported: "+fileName+", "+IntegerToString(bars)+" bars"; 66 | } 67 | else 68 | { 69 | comment="Error with exporting: "+fileName; 70 | } 71 | return (comment); 72 | } 73 | 74 | string PeriodToStr(ENUM_TIMEFRAMES period) 75 | { 76 | string strper; 77 | switch(period) 78 | { 79 | case PERIOD_M1 : strper="1"; break; 80 | case PERIOD_M5 : strper="5"; break; 81 | case PERIOD_M15 : strper="15"; break; 82 | case PERIOD_M30 : strper="30"; break; 83 | case PERIOD_H1 : strper="60"; break; 84 | case PERIOD_H4 : strper="240"; break; 85 | case PERIOD_D1 : strper="1440"; break; 86 | case PERIOD_W1 : strper="10080"; break; 87 | case PERIOD_MN1 : strper="302400"; break; 88 | default : strper=""; 89 | } 90 | return (strper); 91 | } 92 | //+------------------------------------------------------------------+ 93 | -------------------------------------------------------------------------------- /MQL5/FSB Data Source.mq5: -------------------------------------------------------------------------------- 1 | //| Copyright: (C) 2015 Forex Software Ltd. | 2 | //| Website: http://forexsb.com/ | 3 | //| Support: http://forexsb.com/forum/ | 4 | //| License: Proprietary under the following circumstances: | 5 | //| | 6 | //| This code is a part of Forex Strategy Builder. It is free for | 7 | //| use as an integral part of Forex Strategy Builder. | 8 | //| One can modify it in order to improve the code or to fit it for | 9 | //| personal use. This code or any part of it cannot be used in | 10 | //| other applications without a permission. | 11 | //| The contact information cannot be changed. | 12 | //| | 13 | //| NO LIABILITY FOR CONSEQUENTIAL DAMAGES | 14 | //| | 15 | //| In no event shall the author be liable for any damages whatsoever | 16 | //| (including, without limitation, incidental, direct, indirect and | 17 | //| consequential damages, damages for loss of business profits, | 18 | //| business interruption, loss of business information, or other | 19 | //| pecuniary loss) arising out of the use or inability to use this | 20 | //| product, even if advised of the possibility of such damages. | 21 | //+--------------------------------------------------------------------+ 22 | 23 | #property copyright "Forex Software Ltd." 24 | #property link "http://forexsb.com" 25 | #property version "1.00" 26 | #property strict 27 | 28 | class InstrumentProperties; 29 | //+------------------------------------------------------------------+ 30 | //| Script program start function | 31 | //+------------------------------------------------------------------+ 32 | void OnStart() 33 | { 34 | string dataSourceName=TerminalInfoString(TERMINAL_NAME); 35 | string path=TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL5\\Files"; 36 | StringReplace(path,"\\","\\\\"); 37 | string dataDirectory=path; 38 | string description="Data Source exported from "+ 39 | TerminalInfoString(TERMINAL_NAME)+", "+ 40 | TerminalInfoString(TERMINAL_COMPANY); 41 | 42 | string symbolsList[]; 43 | int symbols=GetSymbolsList(symbolsList); 44 | InstrumentProperties *properties[]; 45 | ArrayResize(properties,symbols); 46 | for(int i=0;i3) 73 | symbolsList[symbolIndex++]=symbol; 74 | } 75 | ArrayResize(symbolsList,symbolIndex); 76 | return (symbolIndex); 77 | } 78 | //+------------------------------------------------------------------+ 79 | void SaveStringToFile(string filename,string text) 80 | { 81 | int handle= FileOpen(filename,FILE_TXT|FILE_WRITE|FILE_ANSI); 82 | if(handle == INVALID_HANDLE) 83 | return; 84 | 85 | FileWriteString(handle,text); 86 | FileClose(handle); 87 | } 88 | //+------------------------------------------------------------------+ 89 | //| | 90 | //+------------------------------------------------------------------+ 91 | string ComposeDataSourceContent(string dataSourceName, 92 | string dataDirectory, 93 | string description, 94 | InstrumentProperties *&properties[]) 95 | { 96 | string content=""; 97 | content += "{\n"; 98 | content += " \"DataSourceName\" : \"" + dataSourceName + "\",\n"; 99 | content += " \"DataDirectory\" : \"" + dataDirectory + "\",\n"; 100 | content += " \"Description\" : \"" + description + "\",\n"; 101 | content += " \"InstrumentProperties\": {\n"; 102 | int propCount=ArraySize(properties); 103 | for(int i=0;i100000.0) 200 | { 201 | if(currProfit=="JPY") 202 | rate=0.01; 203 | else if(currAccount=="JPY") 204 | rate=100; 205 | else 206 | rate=1.0; 207 | } 208 | 209 | return (rate); 210 | } 211 | //+------------------------------------------------------------------+ 212 | string InstrumentProperties::GetPropertyJson(void) 213 | { 214 | string content=""; 215 | content += " \""+this.Symbol+"\" : {\n"; 216 | content += " \"Symbol\" : \""+this.Symbol+"\",\n"; 217 | content += " \"InstrType\" : "+IntegerToString(this.InstrType)+",\n"; 218 | content += " \"Comment\" : \""+this.Comment+"\",\n"; 219 | content += " \"PriceIn\" : \""+this.PriceIn+"\",\n"; 220 | content += " \"BaseFileName\" : \""+this.BaseFileName+"\",\n"; 221 | content += " \"LotSize\" : "+IntegerToString(this.LotSize)+",\n"; 222 | content += " \"Slippage\" : "+IntegerToString(this.Slippage)+",\n"; 223 | content += " \"Spread\" : "+DoubleToString(this.Spread,2)+",\n"; 224 | content += " \"SwapLong\" : "+DoubleToString(this.SwapLong,2)+",\n"; 225 | content += " \"SwapShort\" : "+DoubleToString(this.SwapShort,2)+",\n"; 226 | content += " \"Commission\" : "+DoubleToString(this.Commission,2)+",\n"; 227 | content += " \"RateToUSD\" : "+DoubleToString(this.RateToUSD,this.Digits)+",\n"; 228 | content += " \"RateToEUR\" : "+DoubleToString(this.RateToEUR,this.Digits)+",\n"; 229 | content += " \"RateToGBP\" : "+DoubleToString(this.RateToGBP,this.Digits)+",\n"; 230 | content += " \"RateToJPY\" : "+DoubleToString(this.RateToJPY,this.Digits)+",\n"; 231 | content += " \"SwapType\" : "+IntegerToString(this.SwapType)+",\n"; 232 | content += " \"CommissionType\" : "+IntegerToString(this.CommissionType)+",\n"; 233 | content += " \"CommissionScope\" : "+IntegerToString(this.CommissionScope)+",\n"; 234 | content += " \"CommissionTime\" : "+IntegerToString(this.CommissionTime)+",\n"; 235 | content += " \"Digits\" : "+IntegerToString(this.Digits)+",\n"; 236 | content += " \"Point\" : "+DoubleToString(this.Point,this.Digits)+",\n"; 237 | content += " \"Pip\" : "+DoubleToString(this.Pip,this.Digits)+",\n"; 238 | content += " \"IsFiveDigits\" : "+(this.IsFiveDigits?"true":"false")+",\n"; 239 | content += " \"StopLevel\" : "+DoubleToString(this.StopLevel,2)+",\n"; 240 | content += " \"TickValue\" : "+DoubleToString(this.TickValue,2)+",\n"; 241 | content += " \"MinLot\" : "+DoubleToString(this.MinLot,2)+",\n"; 242 | content += " \"MaxLot\" : "+DoubleToString(this.MaxLot,2)+",\n"; 243 | content += " \"LotStep\" : "+DoubleToString(this.LotStep,2)+",\n"; 244 | content += " \"MarginRequired\" : "+DoubleToString(this.MarginRequired,2)+"\n"; 245 | content += " }"; 246 | return (content); 247 | } 248 | //+------------------------------------------------------------------+ 249 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FSB MQ Code 2 | 3 | MQL helper scripts for Forex Strategy Builder. 4 | 5 | Website: http://forexsb.com 6 | Suport forum: http://forexsb.com/forum/ 7 | --------------------------------------------------------------------------------