├── Experts ├── ButtonDemo.mq4 ├── PriceBreakChart.mq4 ├── TimeFrameChart.mq4 └── UIApp.mqh ├── Indicators ├── DeMarker.mq4 └── DeMarker.mqh ├── LICENSE ├── README.md └── Scripts └── CsvFile.mq4 /Experts/ButtonDemo.mq4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingmaotu/mql4-lib-examples/0e7fdbe181de9c357f5e1ebb82319d030d0f0e80/Experts/ButtonDemo.mq4 -------------------------------------------------------------------------------- /Experts/PriceBreakChart.mq4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingmaotu/mql4-lib-examples/0e7fdbe181de9c357f5e1ebb82319d030d0f0e80/Experts/PriceBreakChart.mq4 -------------------------------------------------------------------------------- /Experts/TimeFrameChart.mq4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingmaotu/mql4-lib-examples/0e7fdbe181de9c357f5e1ebb82319d030d0f0e80/Experts/TimeFrameChart.mq4 -------------------------------------------------------------------------------- /Experts/UIApp.mqh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingmaotu/mql4-lib-examples/0e7fdbe181de9c357f5e1ebb82319d030d0f0e80/Experts/UIApp.mqh -------------------------------------------------------------------------------- /Indicators/DeMarker.mq4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dingmaotu/mql4-lib-examples/0e7fdbe181de9c357f5e1ebb82319d030d0f0e80/Indicators/DeMarker.mq4 -------------------------------------------------------------------------------- /Indicators/DeMarker.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Module: Indicators/DeMarker.mqh | 3 | //| This file is part of the mql4-lib-examples project: | 4 | //| https://github.com/dingmaotu/mql4-lib-examples | 5 | //| | 6 | //| Copyright 2017 Li Ding | 7 | //| | 8 | //| Licensed under the Apache License, Version 2.0 (the "License"); | 9 | //| you may not use this file except in compliance with the License. | 10 | //| You may obtain a copy of the License at | 11 | //| | 12 | //| http://www.apache.org/licenses/LICENSE-2.0 | 13 | //| | 14 | //| Unless required by applicable law or agreed to in writing, | 15 | //| software distributed under the License is distributed on an | 16 | //| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | 17 | //| either express or implied. | 18 | //| See the License for the specific language governing permissions | 19 | //| and limitations under the License. | 20 | //+------------------------------------------------------------------+ 21 | #property strict 22 | 23 | #include 24 | #include 25 | #include 26 | //+------------------------------------------------------------------+ 27 | //| Indicator parameters | 28 | //+------------------------------------------------------------------+ 29 | class DeMarkerParam: public AppParam 30 | { 31 | ObjectAttr(int,AvgPeriod,AvgPeriod); // SMA Period 32 | }; 33 | //+------------------------------------------------------------------+ 34 | //| DeMarker implementation | 35 | //| You can use this indicator in your EA without running it as a | 36 | //| standalone program | 37 | //+------------------------------------------------------------------+ 38 | class DeMarker: public Indicator 39 | { 40 | private: 41 | int m_period; 42 | protected: 43 | double ExtMainBuffer[]; 44 | double ExtMaxBuffer[]; 45 | double ExtMinBuffer[]; 46 | public: 47 | //--- time series like access when used in an EA 48 | double operator[](const int index) {return ExtMainBuffer[ArraySize(ExtMainBuffer)-index-1];} 49 | 50 | DeMarker(DeMarkerParam *param) 51 | :m_period(param.getAvgPeriod()) 52 | { 53 | if(isRuntimeControlled()) 54 | { 55 | string short_name; 56 | //--- indicator lines 57 | SetIndexStyle(0,DRAW_LINE); 58 | SetIndexBuffer(0,ExtMainBuffer); 59 | //--- name for DataWindow and indicator subwindow label 60 | short_name="DeM("+IntegerToString(m_period)+")"; 61 | IndicatorShortName(short_name); 62 | SetIndexLabel(0,short_name); 63 | //--- 64 | SetIndexDrawBegin(0,m_period); 65 | } 66 | } 67 | 68 | int main(const int total, 69 | const int prev, 70 | const datetime &time[], 71 | const double &open[], 72 | const double &high[], 73 | const double &low[], 74 | const double &close[], 75 | const long &tickVolume[], 76 | const long &volume[], 77 | const int &spread[]) 78 | { 79 | //--- check for bars count 80 | if(totalhigh[i-1]) ExtMaxBuffer[i]=high[i]-high[i-1]; 107 | else ExtMaxBuffer[i]=0.0; 108 | 109 | if(low[i] | 7 | //| | 8 | //| Licensed under the Apache License, Version 2.0 (the "License"); | 9 | //| you may not use this file except in compliance with the License. | 10 | //| You may obtain a copy of the License at | 11 | //| | 12 | //| http://www.apache.org/licenses/LICENSE-2.0 | 13 | //| | 14 | //| Unless required by applicable law or agreed to in writing, | 15 | //| software distributed under the License is distributed on an | 16 | //| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | 17 | //| either express or implied. | 18 | //| See the License for the specific language governing permissions | 19 | //| and limitations under the License. | 20 | //+------------------------------------------------------------------+ 21 | #property copyright "Copyright 2017, Li Ding" 22 | #property link "dingmaotu@hotmail.com" 23 | #property version "1.00" 24 | #property description "Illustration of the use of Utils/CsvFile class" 25 | #property strict 26 | #include 27 | //+------------------------------------------------------------------+ 28 | //| A simplified quote struct | 29 | //+------------------------------------------------------------------+ 30 | struct MyStruct 31 | { 32 | string symbol; 33 | double close; 34 | datetime time; 35 | }; 36 | //+------------------------------------------------------------------+ 37 | //| Write simplified `numberOfQutoes` quotes to a csv file | 38 | //+------------------------------------------------------------------+ 39 | void WriteCsv(string path,int numberOfQuotes) 40 | { 41 | MqlRates rates[]; 42 | CopyRates(_Symbol,_Period,0,numberOfQuotes,rates); 43 | CsvFile csv(path,FILE_WRITE); // check csv.valid() to see if the file opens correctly 44 | for(int i=0; i