├── .gitignore
├── Experts
└── Orchard
│ └── Framework
│ └── Framework Example 3.00.1.mq5
├── Include
└── Orchard
│ └── Frameworks
│ ├── Framework.mqh
│ ├── Framework_3.00
│ ├── Common
│ │ ├── CommonBase.mqh
│ │ ├── Defines.mqh
│ │ └── Defines_mql4.mqh
│ ├── Expert
│ │ ├── Expert.mqh
│ │ ├── ExpertBase.mqh
│ │ └── LegBase.mqh
│ ├── Framework.mqh
│ ├── Framework_Version.mqh
│ └── Trade
│ │ ├── PositionInfo.mqh
│ │ ├── PositionInfo_mql4.mqh
│ │ ├── PositionInfo_mql5.mqh
│ │ ├── Trade.mqh
│ │ ├── Trade_mql4.mqh
│ │ └── Trade_mql5.mqh
│ ├── Framework_3.01
│ ├── Common
│ │ ├── CommonBase.mqh
│ │ ├── Defines.mqh
│ │ └── Defines_mql4.mqh
│ ├── Expert
│ │ ├── Expert.mqh
│ │ ├── ExpertBase.mqh
│ │ └── LegBase.mqh
│ ├── Framework.mqh
│ └── Trade
│ │ ├── PositionInfo.mqh
│ │ ├── PositionInfo_mql4.mqh
│ │ ├── PositionInfo_mql5.mqh
│ │ ├── Trade.mqh
│ │ ├── Trade_mql4.mqh
│ │ └── Trade_mql5.mqh
│ ├── Framework_3.02
│ ├── Common
│ │ ├── CommonBase.mqh
│ │ ├── Defines.mqh
│ │ └── Defines_mql4.mqh
│ ├── Expert
│ │ ├── Expert.mqh
│ │ ├── ExpertBase.mqh
│ │ └── LegBase.mqh
│ ├── Framework.mqh
│ └── Trade
│ │ ├── PositionInfo.mqh
│ │ ├── PositionInfo_mql4.mqh
│ │ ├── PositionInfo_mql5.mqh
│ │ ├── Trade.mqh
│ │ ├── Trade_mql4.mqh
│ │ └── Trade_mql5.mqh
│ ├── Framework_3.03
│ ├── Common
│ │ ├── CommonBase.mqh
│ │ ├── Defines.mqh
│ │ └── Defines_mql4.mqh
│ ├── Expert
│ │ ├── Expert.mqh
│ │ ├── ExpertBase.mqh
│ │ └── LegBase.mqh
│ ├── Framework.mqh
│ ├── Indicators
│ │ ├── IndicatorBase.mqh
│ │ ├── IndicatorHA.mqh
│ │ ├── IndicatorStochastic.mqh
│ │ └── Indicators.mqh
│ └── Trade
│ │ ├── PositionInfo.mqh
│ │ ├── PositionInfo_mql4.mqh
│ │ ├── PositionInfo_mql5.mqh
│ │ ├── Trade.mqh
│ │ ├── Trade_mql4.mqh
│ │ └── Trade_mql5.mqh
│ ├── Framework_3.04
│ ├── Common
│ │ ├── CommonBase.mqh
│ │ ├── Defines.mqh
│ │ └── Defines_mql4.mqh
│ ├── Expert
│ │ ├── Expert.mqh
│ │ ├── ExpertBase.mqh
│ │ └── LegBase.mqh
│ ├── Framework.mqh
│ ├── Indicators
│ │ ├── IndicatorBase.mqh
│ │ ├── IndicatorFractal.mqh
│ │ ├── IndicatorHA.mqh
│ │ ├── IndicatorMA.mqh
│ │ ├── IndicatorStochastic.mqh
│ │ └── Indicators.mqh
│ └── Trade
│ │ ├── PositionInfo.mqh
│ │ ├── PositionInfo_mql4.mqh
│ │ ├── PositionInfo_mql5.mqh
│ │ ├── Trade.mqh
│ │ ├── Trade_mql4.mqh
│ │ └── Trade_mql5.mqh
│ ├── Framework_3.05
│ ├── Common
│ │ ├── CommonBase.mqh
│ │ ├── Defines.mqh
│ │ └── Defines_mql4.mqh
│ ├── Expert
│ │ ├── Expert.mqh
│ │ ├── ExpertBase.mqh
│ │ └── LegBase.mqh
│ ├── Framework.mqh
│ ├── Indicators
│ │ ├── IndicatorBase.mqh
│ │ ├── IndicatorFractal.mqh
│ │ ├── IndicatorHA.mqh
│ │ ├── IndicatorMA.mqh
│ │ ├── IndicatorMACD.mqh
│ │ ├── IndicatorRSI.mqh
│ │ ├── IndicatorStochastic.mqh
│ │ └── Indicators.mqh
│ └── Trade
│ │ ├── PositionInfo.mqh
│ │ ├── PositionInfo_mql4.mqh
│ │ ├── PositionInfo_mql5.mqh
│ │ ├── Trade.mqh
│ │ ├── Trade_mql4.mqh
│ │ └── Trade_mql5.mqh
│ └── Framework_3.06
│ ├── Common
│ ├── CommonBase.mqh
│ ├── Defines.mqh
│ └── Defines_mql4.mqh
│ ├── Expert
│ ├── Expert.mqh
│ ├── ExpertBase.mqh
│ └── LegBase.mqh
│ ├── Extensions
│ └── TimeFilter.mqh
│ ├── Framework.mqh
│ ├── Indicators
│ ├── IndicatorBands.mqh
│ ├── IndicatorBase.mqh
│ ├── IndicatorFractal.mqh
│ ├── IndicatorHA.mqh
│ ├── IndicatorMA.mqh
│ ├── IndicatorMACD.mqh
│ ├── IndicatorRSI.mqh
│ ├── IndicatorStochastic.mqh
│ └── Indicators.mqh
│ └── Trade
│ ├── PositionInfo.mqh
│ ├── PositionInfo_mql4.mqh
│ ├── PositionInfo_mql5.mqh
│ ├── Trade.mqh
│ ├── Trade_mql4.mqh
│ └── Trade_mql5.mqh
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | mqlcache.dat
2 | *.ex4
3 | *.ex5
4 | *.lnk
5 | /*.bat
6 |
--------------------------------------------------------------------------------
/Experts/Orchard/Framework/Framework Example 3.00.1.mq5:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Framework Example 3.00.1.mq5
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2022, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.00"
36 |
37 | #include
38 |
39 | #define CExpert CExpertBase
40 | CExpert *Expert;
41 |
42 | int OnInit( void ) {
43 |
44 | Expert = new CExpert();
45 |
46 | return ( Expert.OnInit() );
47 | }
48 |
49 | void OnDeinit( const int reason ) {
50 |
51 | Expert.OnDeinit( reason );
52 |
53 | delete Expert;
54 | }
55 |
56 | void OnTick( void ) { Expert.OnTick(); }
57 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework.mqh
3 |
4 | Copyright 2013-2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | //
34 | // The only purpose of this mqh file is to provide a single
35 | // point to change the current framework version
36 | //
37 | // If you place an include to this file in your code you
38 | // will get the version framework defined in this file
39 | // unless your code has already included another
40 | // framework file
41 |
42 | // The following will load in the selected framework
43 | // beginning with the latest
44 | // If you have selected a framework with (need both lines in the beginning of your app)
45 | // #define FRAMEWORK_VERSION_3_XX_
46 | // #define FRAMEWORK_VERSION
47 | // then that version will be loaded. If not the most recent
48 | // is loaded
49 |
50 | // 3.06 CTradeCustom.ResultPrice() (for mql4)
51 | #include "Framework_3.06/Framework.mqh"
52 | // 3.05 RSI and MACD indicators
53 | #include "Framework_3.05/Framework.mqh"
54 | // 3.04 more indicators and common methods
55 | #include "Framework_3.04/Framework.mqh"
56 | // 3.03 introduced indicator classes
57 | #include "Framework_3.03/Framework.mqh"
58 | #include "Framework_3.02/Framework.mqh"
59 | #include "Framework_3.01/Framework.mqh"
60 | #include "Framework_3.00/Framework.mqh"
61 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Common/Defines.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "../Framework_Version.mqh"
34 |
35 | #ifdef __MQL4__
36 | #include "Defines_mql4.mqh"
37 | #endif
38 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Common/Defines_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines_mql4
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "../Framework_Version.mqh"
34 |
35 | enum ENUM_POSITION_TYPE
36 | {
37 | POSITION_TYPE_BUY,
38 | POSITION_TYPE_SELL
39 | };
40 |
41 | // Some return code definitions
42 | enum ENUM_TRADE_RETCODES
43 | {
44 | TRADE_RETCODE_INVALID = 10013, // Invalid request
45 | };
46 |
47 | struct MqlTradeRequest
48 | {
49 | int action; // Trade operation type (as int here)
50 | ulong magic; // Expert Advisor ID (magic number)
51 | ulong order; // Order ticket
52 | string symbol; // Trade symbol
53 | double volume; // Requested volume for a deal in lots
54 | double price; // Price
55 | double stoplimit; // StopLimit level of the order
56 | double sl; // Stop Loss level of the order
57 | double tp; // Take Profit level of the order
58 | ulong deviation; // Maximal possible deviation from the requested price
59 | ENUM_ORDER_TYPE type; // Order type
60 | int type_filling; // Order execution type (int here)
61 | int type_time; // Order expiration type (int here)
62 | datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
63 | string comment; // Order comment
64 | ulong position; // Position ticket
65 | ulong position_by; // The ticket of an opposite position
66 | };
67 |
68 | struct MqlTradeResult
69 | {
70 | uint retcode; // Operation return code
71 | ulong deal; // Deal ticket, if it is performed
72 | ulong order; // Order ticket, if it is placed
73 | double volume; // Deal volume, confirmed by broker
74 | double price; // Deal price, confirmed by broker
75 | double bid; // Current Bid price
76 | double ask; // Current Ask price
77 | string comment; // Broker comment to operation (by default it is filled by description of trade
78 | // server return code)
79 | uint request_id; // Request ID set by the terminal during the dispatch
80 | uint retcode_external; // Return code of an external trading system
81 | };
82 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Expert/Expert.mqh:
--------------------------------------------------------------------------------
1 | /** Disclaimer and Licence
2 |
3 | * This file is free software: you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation, either version 3 of the License, or
6 | * (at your option) any later version.
7 |
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 |
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program. If not, see .
15 |
16 | * All trading involves risk. You should have received the risk warnings
17 | * and terms of use in the README.MD file distributed with this software.
18 | * See the README.MD file for more information and before using this software.
19 |
20 | **/
21 | /**=
22 | *
23 | * Disclaimer and Licence
24 | *
25 | * This file is free software: you can redistribute it and/or modify
26 | * it under the terms of the GNU General Public License as published by
27 | * the Free Software Foundation, either version 3 of the License, or
28 | * (at your option) any later version.
29 | *
30 | * This program is distributed in the hope that it will be useful,
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 | * GNU General Public License for more details.
34 | *
35 | * You should have received a copy of the GNU General Public License
36 | * along with this program. If not, see .
37 | *
38 | * All trading involves risk. You should have received the risk warnings
39 | * and terms of use in the README.MD file distributed with this software.
40 | * See the README.MD file for more information and before using this software.
41 | *
42 | **/
43 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Expert/ExpertBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | ExpertBase.mqh
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "../Framework_Version.mqh"
34 |
35 | #include "../Common/CommonBase.mqh"
36 | #include "../Common/Defines.mqh"
37 |
38 | class CExpertBase : public CCommonBase {
39 |
40 | private:
41 | protected:
42 | public:
43 | CExpertBase() {}
44 | ~CExpertBase() {}
45 |
46 | virtual int OnInit() { return ( INIT_SUCCEEDED ); }
47 | virtual void OnDeinit( const int reason ) { return; }
48 | virtual void OnTick() { return; }
49 | };
50 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Expert/LegBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | ExpertBase.mqh
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "../Framework_Version.mqh"
34 |
35 | #include "../Common/CommonBase.mqh"
36 | #include "../Common/Defines.mqh"
37 |
38 | class CExpertBase : public CCommonBase {
39 |
40 | private:
41 | protected:
42 | public:
43 | CExpertBase() {}
44 | ~CExpertBase() {}
45 |
46 | virtual int OnInit() { return ( INIT_SUCCEEDED ); }
47 | virtual void OnDeinit( const int reason ) { return; }
48 | virtual void OnTick() { return; }
49 | };
50 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Framework.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework_3.00.mqh
3 |
4 | Copyright 2013-2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifndef FRAMEWORK_VERSION
34 | #define FRAMEWORK_VERSION
35 | #define FRAMEWORK_VERSION_3_00
36 | #endif
37 |
38 | #ifdef FRAMEWORK_VERSION_3_00
39 |
40 | #include "Common/CommonBase.mqh"
41 | #include "Expert/ExpertBase.mqh"
42 | #include "Trade/Trade.mqh"
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Framework_Version.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework_version.mqh
3 | Framework 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | all of thenumbers here are 3.nn or 3_nn
9 | just global replace nn with mm to update to a new version
10 |
11 | */
12 |
13 | /**=
14 | *
15 | * Disclaimer and Licence
16 | *
17 | * This file is free software: you can redistribute it and/or modify
18 | * it under the terms of the GNU General Public License as published by
19 | * the Free Software Foundation, either version 3 of the License, or
20 | * (at your option) any later version.
21 | *
22 | * This program is distributed in the hope that it will be useful,
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | * GNU General Public License for more details.
26 | *
27 | * You should have received a copy of the GNU General Public License
28 | * along with this program. If not, see .
29 | *
30 | * All trading involves risk. You should have received the risk warnings
31 | * and terms of use in the README.MD file distributed with this software.
32 | * See the README.MD file for more information and before using this software.
33 | *
34 | **/
35 |
36 | #ifdef _FRAMEWORK_VERSION_3_00
37 |
38 | #ifndef _FRAMEWORK_VERSION_
39 | #define _FRAMEWORK_VERSION_ "3.00"
40 | #endif
41 |
42 | #endif
43 |
44 | #ifndef _FRAMEWORK_VERSION_
45 |
46 | #define _FRAMEWORK_VERSION_ "3.00"
47 | // Make sure the define is correct for the selected version
48 | #ifndef _FRAMEWORK_VERSION_3_00
49 | #define _FRAMEWORK_VERSION_3_00
50 | #endif
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Trade/PositionInfo.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfoCustom.mqh
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2021, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.01"
36 | #property strict
37 |
38 | #include "../Framework_Version.mqh"
39 |
40 | #ifdef __MQL4__
41 | #include "PositionInfo_mql4.mqh"
42 | #endif
43 | #ifdef __MQL5__
44 | #include "PositionInfo_mql5.mqh"
45 | #endif
46 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Trade/PositionInfo_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo_mql4.mqh
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2021, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.01"
36 | #property strict
37 |
38 | #include "../Common/Defines.mqh"
39 | #include "../Framework_Version.mqh"
40 |
41 | class CPositionInfo {
42 |
43 | public:
44 | bool SelectByIndex( int index );
45 |
46 | int Magic() { return ( OrderMagicNumber() ); }
47 | ENUM_POSITION_TYPE PositionType() { return ( ( ENUM_POSITION_TYPE )OrderType() ); }
48 | double PriceOpen() { return ( OrderOpenPrice() ); }
49 | double StopLoss() { return ( OrderStopLoss() ); }
50 | string Symbol() { return ( OrderSymbol() ); }
51 | double TakeProfit() { return ( OrderTakeProfit() ); }
52 | int Ticket() { return ( OrderTicket() ); }
53 | };
54 |
55 | /*
56 | * CPositionInfoCustom::SelectByIndex
57 | * Select an order by indexed position
58 | * @param - index : index position of order to select
59 | * @return - ticket number : 0 if the order is not buy/sell or is closed or not found
60 | */
61 | bool CPositionInfo::SelectByIndex( int index ) {
62 |
63 | if ( !OrderSelect( index, SELECT_BY_POS, MODE_TRADES ) ) return ( false );
64 | if ( OrderType() != ORDER_TYPE_BUY && OrderType() != ORDER_TYPE_SELL ) return ( false );
65 | if ( OrderCloseTime() > 0 ) return ( false );
66 | return ( OrderTicket() > 0 );
67 | }
68 |
69 | class CPositionInfoCustom : public CPositionInfo {
70 |
71 | public:
72 | int Total() { return ( OrdersTotal() ); }
73 | };
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Trade/PositionInfo_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 | (For MQL5)
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CPositionInfoCustom : public CPositionInfo {
36 |
37 | public:
38 | int Total() { return ( PositionsTotal() ); }
39 | };
40 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Trade/Trade.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 |
4 | Copyright 2013-2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 |
32 | #include "../Framework_Version.mqh"
33 |
34 | #ifdef __MQL4__
35 | #include "Trade_mql4.mqh"
36 | #endif
37 | #ifdef __MQL5__
38 | #include "Trade_mql5.mqh"
39 | #endif
40 |
41 | #include "PositionInfo.mqh"
42 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.00/Trade/Trade_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 | (For MQL5)
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "../Framework_Version.mqh"
34 |
35 | #include
36 |
37 | class CTradeCustom : public CTrade {
38 |
39 | private:
40 | protected: // member variables
41 | public: // constructors
42 | public:
43 | bool PositionCloseByType( const string symbol, ENUM_POSITION_TYPE positionType,
44 | const ulong deviation = ULONG_MAX );
45 | void PositionCountByType( const string symbol, int &count[] );
46 | };
47 |
48 | bool CTradeCustom::PositionCloseByType( const string symbol, ENUM_POSITION_TYPE positionType,
49 | const ulong deviation = ULONG_MAX ) {
50 |
51 | bool result = true;
52 | int cnt = PositionsTotal();
53 | for ( int i = cnt - 1; i >= 0; i-- ) {
54 | ulong ticket = PositionGetTicket( i );
55 | if ( PositionSelectByTicket( ticket ) ) {
56 | if ( PositionGetString( POSITION_SYMBOL ) == symbol &&
57 | PositionGetInteger( POSITION_TYPE ) == positionType &&
58 | PositionGetInteger( POSITION_MAGIC ) == m_magic ) {
59 | result &= PositionClose( ticket, deviation );
60 | }
61 | }
62 | else {
63 | m_result.retcode = TRADE_RETCODE_REJECT;
64 | result = false;
65 | }
66 | }
67 |
68 | return ( result );
69 | }
70 |
71 | void CTradeCustom::PositionCountByType( const string symbol, int &count[] ) {
72 |
73 | ArrayResize( count, 6 );
74 | ArrayInitialize( count, 0 );
75 |
76 | int cnt = PositionsTotal();
77 | for ( int i = cnt - 1; i >= 0; i-- ) {
78 | ulong ticket = PositionGetTicket( i );
79 | if ( PositionSelectByTicket( ticket ) ) {
80 | if ( PositionGetString( POSITION_SYMBOL ) == symbol &&
81 | PositionGetInteger( POSITION_MAGIC ) == m_magic ) {
82 | count[( int )PositionGetInteger( POSITION_TYPE )]++;
83 | }
84 | }
85 | }
86 |
87 | return;
88 | }
89 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Common/CommonBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | CommonBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | #include "Defines.mqh"
36 |
37 | #define _INIT_CHECK_FAIL \
38 | if ( mInitResult != INIT_SUCCEEDED ) return ( mInitResult );
39 | #define _INIT_ERROR( msg ) return ( InitError( msg, INIT_PARAMETERS_INCORRECT ) );
40 | #define _INIT_ASSERT( condition, msg ) \
41 | if ( !condition ) return ( InitError( msg, INIT_FAILED ) );
42 |
43 | class CCommonBase : public CObject {
44 |
45 | private:
46 | protected: // Members
47 | int mDigits;
48 | string mSymbol;
49 | ENUM_TIMEFRAMES mTimeframe;
50 |
51 | string mInitMessage;
52 | int mInitResult;
53 |
54 | protected: // Constructors
55 | //
56 | // Constructors
57 | //
58 | CCommonBase() { Init( _Symbol, ( ENUM_TIMEFRAMES )_Period ); }
59 | CCommonBase( string symbol ) { Init( symbol, ( ENUM_TIMEFRAMES )_Period ); }
60 | CCommonBase( int timeframe ) { Init( _Symbol, ( ENUM_TIMEFRAMES )timeframe ); }
61 | CCommonBase( ENUM_TIMEFRAMES timeframe ) { Init( _Symbol, timeframe ); }
62 | CCommonBase( string symbol, int timeframe ) { Init( symbol, ( ENUM_TIMEFRAMES )timeframe ); }
63 | CCommonBase( string symbol, ENUM_TIMEFRAMES timeframe ) { Init( symbol, timeframe ); }
64 |
65 | //
66 | // Destructors
67 | //
68 | ~CCommonBase(){};
69 |
70 | int Init( string symbol, ENUM_TIMEFRAMES timeframe );
71 |
72 | protected: // Functions
73 | int InitError( string initMessage, int initResult ) {
74 | mInitMessage = initMessage;
75 | mInitResult = initResult;
76 | if ( initMessage != "" ) Print( initMessage );
77 | return ( initResult );
78 | }
79 |
80 | double PointsToDouble( int points ) {
81 | return ( points * SymbolInfoDouble( mSymbol, SYMBOL_POINT ) );
82 | }
83 |
84 | public: // Properties
85 | int InitResult() { return ( mInitResult ); }
86 | string InitMessage() { return ( mInitMessage ); }
87 |
88 | public: // Functions
89 | };
90 |
91 | int CCommonBase::Init( string symbol, ENUM_TIMEFRAMES timeframe ) {
92 |
93 | InitError( "", INIT_SUCCEEDED );
94 |
95 | mSymbol = symbol;
96 | mTimeframe = timeframe;
97 | mDigits = ( int )SymbolInfoInteger( symbol, SYMBOL_DIGITS );
98 |
99 | return ( INIT_SUCCEEDED );
100 | }
101 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Common/Defines.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Defines_mql4.mqh"
35 | #endif
36 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Common/Defines_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines_mql4
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | enum ENUM_POSITION_TYPE
34 | {
35 | POSITION_TYPE_BUY,
36 | POSITION_TYPE_SELL
37 | };
38 |
39 | // Some return code definitions
40 | enum ENUM_TRADE_RETCODES
41 | {
42 | TRADE_RETCODE_INVALID = 10013, // Invalid request
43 | };
44 |
45 | struct MqlTradeRequest
46 | {
47 | int action; // Trade operation type (as int here)
48 | ulong magic; // Expert Advisor ID (magic number)
49 | ulong order; // Order ticket
50 | string symbol; // Trade symbol
51 | double volume; // Requested volume for a deal in lots
52 | double price; // Price
53 | double stoplimit; // StopLimit level of the order
54 | double sl; // Stop Loss level of the order
55 | double tp; // Take Profit level of the order
56 | ulong deviation; // Maximal possible deviation from the requested price
57 | ENUM_ORDER_TYPE type; // Order type
58 | int type_filling; // Order execution type (int here)
59 | int type_time; // Order expiration type (int here)
60 | datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
61 | string comment; // Order comment
62 | ulong position; // Position ticket
63 | ulong position_by; // The ticket of an opposite position
64 | };
65 |
66 | struct MqlTradeResult
67 | {
68 | uint retcode; // Operation return code
69 | ulong deal; // Deal ticket, if it is performed
70 | ulong order; // Order ticket, if it is placed
71 | double volume; // Deal volume, confirmed by broker
72 | double price; // Deal price, confirmed by broker
73 | double bid; // Current Bid price
74 | double ask; // Current Ask price
75 | string comment; // Broker comment to operation (by default it is filled by description of trade
76 | // server return code)
77 | uint request_id; // Request ID set by the terminal during the dispatch
78 | uint retcode_external; // Return code of an external trading system
79 | };
80 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Expert/Expert.mqh:
--------------------------------------------------------------------------------
1 | /** Disclaimer and Licence
2 |
3 | * This file is free software: you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation, either version 3 of the License, or
6 | * (at your option) any later version.
7 |
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 |
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program. If not, see .
15 |
16 | * All trading involves risk. You should have received the risk warnings
17 | * and terms of use in the README.MD file distributed with this software.
18 | * See the README.MD file for more information and before using this software.
19 |
20 | **/
21 | /**=
22 | *
23 | * Disclaimer and Licence
24 | *
25 | * This file is free software: you can redistribute it and/or modify
26 | * it under the terms of the GNU General Public License as published by
27 | * the Free Software Foundation, either version 3 of the License, or
28 | * (at your option) any later version.
29 | *
30 | * This program is distributed in the hope that it will be useful,
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 | * GNU General Public License for more details.
34 | *
35 | * You should have received a copy of the GNU General Public License
36 | * along with this program. If not, see .
37 | *
38 | * All trading involves risk. You should have received the risk warnings
39 | * and terms of use in the README.MD file distributed with this software.
40 | * See the README.MD file for more information and before using this software.
41 | *
42 | **/
43 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Expert/ExpertBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | ExpertBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "../Common/CommonBase.mqh"
34 | #include "../Common/Defines.mqh"
35 | #include "../Trade/Trade.mqh"
36 |
37 | class CExpertBase : public CCommonBase {
38 |
39 | private:
40 | protected:
41 | CTradeCustom Trade;
42 | CPositionInfoCustom PositionInfo;
43 |
44 | double mOrderSize;
45 | string mTradeComment;
46 | long mMagic;
47 |
48 | bool mFirstTime;
49 | MqlTick mLastTick;
50 |
51 | virtual void CloseAll( ENUM_POSITION_TYPE type, double price );
52 | virtual void Setup() { return; }
53 | virtual void Loop() { return; }
54 |
55 | public:
56 | CExpertBase();
57 | CExpertBase( double orderSize, string tradeComment, long magic );
58 | ~CExpertBase() {}
59 |
60 | virtual int OnInit() { return ( INIT_SUCCEEDED ); }
61 | virtual void OnDeinit( const int reason ) { return; }
62 | virtual void OnTick();
63 |
64 | bool TradeAllowed();
65 | };
66 |
67 | CExpertBase::CExpertBase() { CExpertBase( 0, "", 0 ); }
68 |
69 | CExpertBase::CExpertBase( double orderSize, string tradeComment, long magic ) {
70 |
71 | mOrderSize = orderSize;
72 | mTradeComment = tradeComment;
73 | mMagic = magic;
74 |
75 | Trade.SetExpertMagicNumber( magic );
76 |
77 | mFirstTime = true;
78 | }
79 |
80 | void CExpertBase::OnTick() {
81 |
82 | // is trading allowed
83 | if ( !TradeAllowed() ) return;
84 |
85 | // Just the first time
86 | // Here because this is where we have data loaded
87 | if ( mFirstTime ) {
88 | Setup();
89 | }
90 |
91 | if ( !SymbolInfoTick( mSymbol, mLastTick ) ) return; // If no data available exit and try again
92 |
93 | Loop();
94 | }
95 |
96 | bool CExpertBase::TradeAllowed() {
97 |
98 | // Some general get out early conditions
99 | return ( TerminalInfoInteger( TERMINAL_TRADE_ALLOWED ) && MQLInfoInteger( MQL_TRADE_ALLOWED ) &&
100 | AccountInfoInteger( ACCOUNT_TRADE_EXPERT ) &&
101 | AccountInfoInteger( ACCOUNT_TRADE_ALLOWED ) );
102 | }
103 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Expert/LegBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | LegBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "ExpertBase.mqh"
34 |
35 | class CLegBase : public CExpertBase {
36 |
37 | private:
38 | protected:
39 | ENUM_POSITION_TYPE mLegType;
40 |
41 | public:
42 | CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic );
43 | ~CLegBase() {}
44 | };
45 |
46 | CLegBase::CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic )
47 | : CExpertBase( orderSize, tradeComment, magic ) {
48 |
49 | mLegType = legType;
50 | }
51 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Framework.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | #ifndef FRAMEWORK_VERSION
35 | #define FRAMEWORK_VERSION
36 | #define FRAMEWORK_VERSION_3_01
37 | #endif
38 |
39 | #ifdef FRAMEWORK_VERSION_3_01
40 |
41 | #include "Common/CommonBase.mqh"
42 | #include "Expert/ExpertBase.mqh"
43 | #include "Expert/LegBase.mqh"
44 | #include "Trade/Trade.mqh"
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Trade/PositionInfo.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo.mqh
4 | Framework 3.01
5 |
6 | Copyright 2013-2022, Orchard Forex
7 | https://www.orchardforex.com
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | #property copyright "Copyright 2021, Orchard Forex"
35 | #property link "https://orchardforex.com"
36 | #property version "1.01"
37 | #property strict
38 |
39 | #ifdef __MQL4__
40 | #include "PositionInfo_mql4.mqh"
41 | #endif
42 | #ifdef __MQL5__
43 | #include "PositionInfo_mql5.mqh"
44 | #endif
45 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Trade/PositionInfo_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo_mql4.mqh
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2021, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.01"
36 | #property strict
37 |
38 | #include "../Common/Defines.mqh"
39 |
40 | class CPositionInfo {
41 |
42 | public:
43 | bool SelectByIndex( int index );
44 |
45 | int Magic() { return ( OrderMagicNumber() ); }
46 | ENUM_POSITION_TYPE PositionType() { return ( ( ENUM_POSITION_TYPE )OrderType() ); }
47 | double PriceOpen() { return ( OrderOpenPrice() ); }
48 | double StopLoss() { return ( OrderStopLoss() ); }
49 | string Symbol() { return ( OrderSymbol() ); }
50 | double TakeProfit() { return ( OrderTakeProfit() ); }
51 | int Ticket() { return ( OrderTicket() ); }
52 | };
53 |
54 | /*
55 | * CPositionInfoCustom::SelectByIndex
56 | * Select an order by indexed position
57 | * @param - index : index position of order to select
58 | * @return - ticket number : 0 if the order is not buy/sell or is closed or not found
59 | */
60 | bool CPositionInfo::SelectByIndex( int index ) {
61 |
62 | if ( !OrderSelect( index, SELECT_BY_POS, MODE_TRADES ) ) return ( false );
63 | if ( OrderType() != ORDER_TYPE_BUY && OrderType() != ORDER_TYPE_SELL ) return ( false );
64 | if ( OrderCloseTime() > 0 ) return ( false );
65 | return ( OrderTicket() > 0 );
66 | }
67 |
68 | class CPositionInfoCustom : public CPositionInfo {
69 |
70 | public:
71 | int Total() { return ( OrdersTotal() ); }
72 | };
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Trade/PositionInfo_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | PositionInfo_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CPositionInfoCustom : public CPositionInfo {
36 |
37 | public:
38 | int Total() { return ( PositionsTotal() ); }
39 | };
40 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Trade/Trade.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Trade_mql4.mqh"
35 | #endif
36 | #ifdef __MQL5__
37 | #include "Trade_mql5.mqh"
38 | #endif
39 |
40 | #include "PositionInfo.mqh"
41 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.01/Trade/Trade_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CTradeCustom : public CTrade {
36 |
37 | private:
38 | protected: // member variables
39 | public: // constructors
40 | public:
41 | bool PositionCloseByType( const string symbol, ENUM_POSITION_TYPE positionType,
42 | const ulong deviation = ULONG_MAX );
43 | void PositionCountByType( const string symbol, int &count[] );
44 | };
45 |
46 | bool CTradeCustom::PositionCloseByType( const string symbol, ENUM_POSITION_TYPE positionType,
47 | const ulong deviation = ULONG_MAX ) {
48 |
49 | bool result = true;
50 | int cnt = PositionsTotal();
51 | for ( int i = cnt - 1; i >= 0; i-- ) {
52 | ulong ticket = PositionGetTicket( i );
53 | if ( PositionSelectByTicket( ticket ) ) {
54 | if ( PositionGetString( POSITION_SYMBOL ) == symbol &&
55 | PositionGetInteger( POSITION_TYPE ) == positionType &&
56 | PositionGetInteger( POSITION_MAGIC ) == m_magic ) {
57 | result &= PositionClose( ticket, deviation );
58 | }
59 | }
60 | else {
61 | m_result.retcode = TRADE_RETCODE_REJECT;
62 | result = false;
63 | }
64 | }
65 |
66 | return ( result );
67 | }
68 |
69 | void CTradeCustom::PositionCountByType( const string symbol, int &count[] ) {
70 |
71 | ArrayResize( count, 6 );
72 | ArrayInitialize( count, 0 );
73 |
74 | int cnt = PositionsTotal();
75 | for ( int i = cnt - 1; i >= 0; i-- ) {
76 | ulong ticket = PositionGetTicket( i );
77 | if ( PositionSelectByTicket( ticket ) ) {
78 | if ( PositionGetString( POSITION_SYMBOL ) == symbol &&
79 | PositionGetInteger( POSITION_MAGIC ) == m_magic ) {
80 | count[( int )PositionGetInteger( POSITION_TYPE )]++;
81 | }
82 | }
83 | }
84 |
85 | return;
86 | }
87 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Common/CommonBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | CommonBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | #include "Defines.mqh"
36 |
37 | #define _INIT_CHECK_FAIL \
38 | if ( mInitResult != INIT_SUCCEEDED ) return ( mInitResult );
39 | #define _INIT_ERROR( msg ) return ( InitError( msg, INIT_PARAMETERS_INCORRECT ) );
40 | #define _INIT_ASSERT( condition, msg ) \
41 | if ( !condition ) return ( InitError( msg, INIT_FAILED ) );
42 |
43 | class CCommonBase : public CObject {
44 |
45 | private:
46 | protected: // Members
47 | int mDigits;
48 | string mSymbol;
49 | ENUM_TIMEFRAMES mTimeframe;
50 |
51 | string mInitMessage;
52 | int mInitResult;
53 |
54 | protected: // Constructors
55 | //
56 | // Constructors
57 | //
58 | CCommonBase() { Init( _Symbol, ( ENUM_TIMEFRAMES )_Period ); }
59 | CCommonBase( string symbol ) { Init( symbol, ( ENUM_TIMEFRAMES )_Period ); }
60 | CCommonBase( int timeframe ) { Init( _Symbol, ( ENUM_TIMEFRAMES )timeframe ); }
61 | CCommonBase( ENUM_TIMEFRAMES timeframe ) { Init( _Symbol, timeframe ); }
62 | CCommonBase( string symbol, int timeframe ) { Init( symbol, ( ENUM_TIMEFRAMES )timeframe ); }
63 | CCommonBase( string symbol, ENUM_TIMEFRAMES timeframe ) { Init( symbol, timeframe ); }
64 |
65 | //
66 | // Destructors
67 | //
68 | ~CCommonBase(){};
69 |
70 | int Init( string symbol, ENUM_TIMEFRAMES timeframe );
71 |
72 | protected: // Functions
73 | int InitError( string initMessage, int initResult ) {
74 | mInitMessage = initMessage;
75 | mInitResult = initResult;
76 | if ( initMessage != "" ) Print( initMessage );
77 | return ( initResult );
78 | }
79 |
80 | double PointsToDouble( int points ) {
81 | return ( points * SymbolInfoDouble( mSymbol, SYMBOL_POINT ) );
82 | }
83 |
84 | public: // Properties
85 | int InitResult() { return ( mInitResult ); }
86 | string InitMessage() { return ( mInitMessage ); }
87 |
88 | public: // Functions
89 | };
90 |
91 | int CCommonBase::Init( string symbol, ENUM_TIMEFRAMES timeframe ) {
92 |
93 | InitError( "", INIT_SUCCEEDED );
94 |
95 | mSymbol = symbol;
96 | mTimeframe = timeframe;
97 | mDigits = ( int )SymbolInfoInteger( symbol, SYMBOL_DIGITS );
98 |
99 | return ( INIT_SUCCEEDED );
100 | }
101 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Common/Defines.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Defines_mql4.mqh"
35 | #endif
36 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Common/Defines_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines_mql4
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | enum ENUM_POSITION_TYPE
34 | {
35 | POSITION_TYPE_BUY,
36 | POSITION_TYPE_SELL
37 | };
38 |
39 | // Some return code definitions
40 | enum ENUM_TRADE_RETCODES
41 | {
42 | TRADE_RETCODE_INVALID = 10013, // Invalid request
43 | };
44 |
45 | struct MqlTradeRequest
46 | {
47 | int action; // Trade operation type (as int here)
48 | ulong magic; // Expert Advisor ID (magic number)
49 | ulong order; // Order ticket
50 | string symbol; // Trade symbol
51 | double volume; // Requested volume for a deal in lots
52 | double price; // Price
53 | double stoplimit; // StopLimit level of the order
54 | double sl; // Stop Loss level of the order
55 | double tp; // Take Profit level of the order
56 | ulong deviation; // Maximal possible deviation from the requested price
57 | ENUM_ORDER_TYPE type; // Order type
58 | int type_filling; // Order execution type (int here)
59 | int type_time; // Order expiration type (int here)
60 | datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
61 | string comment; // Order comment
62 | ulong position; // Position ticket
63 | ulong position_by; // The ticket of an opposite position
64 | };
65 |
66 | struct MqlTradeResult
67 | {
68 | uint retcode; // Operation return code
69 | ulong deal; // Deal ticket, if it is performed
70 | ulong order; // Order ticket, if it is placed
71 | double volume; // Deal volume, confirmed by broker
72 | double price; // Deal price, confirmed by broker
73 | double bid; // Current Bid price
74 | double ask; // Current Ask price
75 | string comment; // Broker comment to operation (by default it is filled by description of trade
76 | // server return code)
77 | uint request_id; // Request ID set by the terminal during the dispatch
78 | uint retcode_external; // Return code of an external trading system
79 | };
80 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Expert/Expert.mqh:
--------------------------------------------------------------------------------
1 | /** Disclaimer and Licence
2 |
3 | * This file is free software: you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation, either version 3 of the License, or
6 | * (at your option) any later version.
7 |
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 |
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program. If not, see .
15 |
16 | * All trading involves risk. You should have received the risk warnings
17 | * and terms of use in the README.MD file distributed with this software.
18 | * See the README.MD file for more information and before using this software.
19 |
20 | **/
21 | /**=
22 | *
23 | * Disclaimer and Licence
24 | *
25 | * This file is free software: you can redistribute it and/or modify
26 | * it under the terms of the GNU General Public License as published by
27 | * the Free Software Foundation, either version 3 of the License, or
28 | * (at your option) any later version.
29 | *
30 | * This program is distributed in the hope that it will be useful,
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 | * GNU General Public License for more details.
34 | *
35 | * You should have received a copy of the GNU General Public License
36 | * along with this program. If not, see .
37 | *
38 | * All trading involves risk. You should have received the risk warnings
39 | * and terms of use in the README.MD file distributed with this software.
40 | * See the README.MD file for more information and before using this software.
41 | *
42 | **/
43 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Expert/LegBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | LegBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "ExpertBase.mqh"
34 |
35 | class CLegBase : public CExpertBase {
36 |
37 | private:
38 | protected:
39 | ENUM_POSITION_TYPE mLegType;
40 |
41 | public:
42 | CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic );
43 | ~CLegBase() {}
44 | };
45 |
46 | CLegBase::CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic )
47 | : CExpertBase( orderSize, tradeComment, magic ) {
48 |
49 | mLegType = legType;
50 | }
51 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Framework.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | #ifndef FRAMEWORK_VERSION
35 | #define FRAMEWORK_VERSION
36 | #define FRAMEWORK_VERSION_3_02
37 | #endif
38 |
39 | #ifdef FRAMEWORK_VERSION_3_02
40 |
41 | #include "Common/CommonBase.mqh"
42 | #include "Expert/ExpertBase.mqh"
43 | #include "Expert/LegBase.mqh"
44 | #include "Trade/Trade.mqh"
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Trade/PositionInfo.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo.mqh
4 | Framework 3.01
5 |
6 | Copyright 2013-2022, Orchard Forex
7 | https://www.orchardforex.com
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | #property copyright "Copyright 2021, Orchard Forex"
35 | #property link "https://orchardforex.com"
36 | #property version "1.01"
37 | #property strict
38 |
39 | #ifdef __MQL4__
40 | #include "PositionInfo_mql4.mqh"
41 | #endif
42 | #ifdef __MQL5__
43 | #include "PositionInfo_mql5.mqh"
44 | #endif
45 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Trade/PositionInfo_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo_mql4.mqh
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2021, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.01"
36 | #property strict
37 |
38 | #include "../Common/Defines.mqh"
39 |
40 | class CPositionInfo {
41 |
42 | public:
43 | bool SelectByIndex( int index );
44 |
45 | int Magic() { return ( OrderMagicNumber() ); }
46 | ENUM_POSITION_TYPE PositionType() { return ( ( ENUM_POSITION_TYPE )OrderType() ); }
47 | double PriceOpen() { return ( OrderOpenPrice() ); }
48 | double StopLoss() { return ( OrderStopLoss() ); }
49 | string Symbol() { return ( OrderSymbol() ); }
50 | double TakeProfit() { return ( OrderTakeProfit() ); }
51 | int Ticket() { return ( OrderTicket() ); }
52 | };
53 |
54 | /*
55 | * CPositionInfoCustom::SelectByIndex
56 | * Select an order by indexed position
57 | * @param - index : index position of order to select
58 | * @return - ticket number : 0 if the order is not buy/sell or is closed or not found
59 | */
60 | bool CPositionInfo::SelectByIndex( int index ) {
61 |
62 | if ( !OrderSelect( index, SELECT_BY_POS, MODE_TRADES ) ) return ( false );
63 | if ( OrderType() != ORDER_TYPE_BUY && OrderType() != ORDER_TYPE_SELL ) return ( false );
64 | if ( OrderCloseTime() > 0 ) return ( false );
65 | return ( OrderTicket() > 0 );
66 | }
67 |
68 | class CPositionInfoCustom : public CPositionInfo {
69 |
70 | public:
71 | int Total() { return ( OrdersTotal() ); }
72 | };
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Trade/PositionInfo_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | PositionInfo_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CPositionInfoCustom : public CPositionInfo {
36 |
37 | public:
38 | int Total() { return ( PositionsTotal() ); }
39 | };
40 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Trade/Trade.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Trade_mql4.mqh"
35 | #endif
36 | #ifdef __MQL5__
37 | #include "Trade_mql5.mqh"
38 | #endif
39 |
40 | #include "PositionInfo.mqh"
41 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.02/Trade/Trade_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CTradeCustom : public CTrade {
36 |
37 | private:
38 | protected: // member variables
39 | public: // constructors
40 | public:
41 | bool PositionCloseByType( const string symbol, ENUM_POSITION_TYPE positionType,
42 | const ulong deviation = ULONG_MAX );
43 | void PositionCountByType( const string symbol, int &count[] );
44 | };
45 |
46 | bool CTradeCustom::PositionCloseByType( const string symbol, ENUM_POSITION_TYPE positionType,
47 | const ulong deviation = ULONG_MAX ) {
48 |
49 | bool result = true;
50 | int cnt = PositionsTotal();
51 | for ( int i = cnt - 1; i >= 0; i-- ) {
52 | ulong ticket = PositionGetTicket( i );
53 | if ( PositionSelectByTicket( ticket ) ) {
54 | if ( PositionGetString( POSITION_SYMBOL ) == symbol &&
55 | PositionGetInteger( POSITION_TYPE ) == positionType &&
56 | PositionGetInteger( POSITION_MAGIC ) == m_magic ) {
57 | result &= PositionClose( ticket, deviation );
58 | }
59 | }
60 | else {
61 | m_result.retcode = TRADE_RETCODE_REJECT;
62 | result = false;
63 | }
64 | }
65 |
66 | return ( result );
67 | }
68 |
69 | void CTradeCustom::PositionCountByType( const string symbol, int &count[] ) {
70 |
71 | ArrayResize( count, 6 );
72 | ArrayInitialize( count, 0 );
73 |
74 | int cnt = PositionsTotal();
75 | for ( int i = cnt - 1; i >= 0; i-- ) {
76 | ulong ticket = PositionGetTicket( i );
77 | if ( PositionSelectByTicket( ticket ) ) {
78 | if ( PositionGetString( POSITION_SYMBOL ) == symbol &&
79 | PositionGetInteger( POSITION_MAGIC ) == m_magic ) {
80 | count[( int )PositionGetInteger( POSITION_TYPE )]++;
81 | }
82 | }
83 | }
84 |
85 | return;
86 | }
87 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Common/CommonBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | CommonBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | #include "Defines.mqh"
36 |
37 | #define _INIT_CHECK_FAIL \
38 | if ( mInitResult != INIT_SUCCEEDED ) return ( mInitResult );
39 | #define _INIT_ERROR( msg ) return ( InitError( msg, INIT_PARAMETERS_INCORRECT ) );
40 | #define _INIT_ASSERT( condition, msg ) \
41 | if ( !condition ) return ( InitError( msg, INIT_FAILED ) );
42 |
43 | class CCommonBase : public CObject {
44 |
45 | private:
46 | protected: // Members
47 | int mDigits;
48 | string mSymbol;
49 | ENUM_TIMEFRAMES mTimeframe;
50 |
51 | string mInitMessage;
52 | int mInitResult;
53 |
54 | protected: // Constructors
55 | //
56 | // Constructors
57 | //
58 | CCommonBase() { Init( _Symbol, ( ENUM_TIMEFRAMES )_Period ); }
59 | CCommonBase( string symbol ) { Init( symbol, ( ENUM_TIMEFRAMES )_Period ); }
60 | CCommonBase( int timeframe ) { Init( _Symbol, ( ENUM_TIMEFRAMES )timeframe ); }
61 | CCommonBase( ENUM_TIMEFRAMES timeframe ) { Init( _Symbol, timeframe ); }
62 | CCommonBase( string symbol, int timeframe ) { Init( symbol, ( ENUM_TIMEFRAMES )timeframe ); }
63 | CCommonBase( string symbol, ENUM_TIMEFRAMES timeframe ) { Init( symbol, timeframe ); }
64 |
65 | //
66 | // Destructors
67 | //
68 | ~CCommonBase(){};
69 |
70 | int Init( string symbol, ENUM_TIMEFRAMES timeframe );
71 |
72 | protected: // Functions
73 | int InitError( string initMessage, int initResult ) {
74 | mInitMessage = initMessage;
75 | mInitResult = initResult;
76 | if ( initMessage != "" ) Print( initMessage );
77 | return ( initResult );
78 | }
79 |
80 | double PointsToDouble( int points ) {
81 | return ( points * SymbolInfoDouble( mSymbol, SYMBOL_POINT ) );
82 | }
83 |
84 | public: // Properties
85 | int InitResult() { return ( mInitResult ); }
86 | string InitMessage() { return ( mInitMessage ); }
87 |
88 | public: // Functions
89 | };
90 |
91 | int CCommonBase::Init( string symbol, ENUM_TIMEFRAMES timeframe ) {
92 |
93 | InitError( "", INIT_SUCCEEDED );
94 |
95 | mSymbol = symbol;
96 | mTimeframe = timeframe;
97 | mDigits = ( int )SymbolInfoInteger( symbol, SYMBOL_DIGITS );
98 |
99 | return ( INIT_SUCCEEDED );
100 | }
101 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Common/Defines.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Defines_mql4.mqh"
35 | #endif
36 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Common/Defines_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines_mql4
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | enum ENUM_POSITION_TYPE
34 | {
35 | POSITION_TYPE_BUY,
36 | POSITION_TYPE_SELL
37 | };
38 |
39 | // Some return code definitions
40 | enum ENUM_TRADE_RETCODES
41 | {
42 | TRADE_RETCODE_INVALID = 10013, // Invalid request
43 | };
44 |
45 | // To handle the changes of buffer names, will grow as needed
46 | enum ENUM_INDICATOR_BUFFERS
47 | {
48 | MAIN_LINE = MODE_MAIN,
49 | SIGNAL_LINE = MODE_SIGNAL,
50 | };
51 |
52 | struct MqlTradeRequest
53 | {
54 | int action; // Trade operation type (as int here)
55 | ulong magic; // Expert Advisor ID (magic number)
56 | ulong order; // Order ticket
57 | string symbol; // Trade symbol
58 | double volume; // Requested volume for a deal in lots
59 | double price; // Price
60 | double stoplimit; // StopLimit level of the order
61 | double sl; // Stop Loss level of the order
62 | double tp; // Take Profit level of the order
63 | ulong deviation; // Maximal possible deviation from the requested price
64 | ENUM_ORDER_TYPE type; // Order type
65 | int type_filling; // Order execution type (int here)
66 | int type_time; // Order expiration type (int here)
67 | datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
68 | string comment; // Order comment
69 | ulong position; // Position ticket
70 | ulong position_by; // The ticket of an opposite position
71 | };
72 |
73 | struct MqlTradeResult
74 | {
75 | uint retcode; // Operation return code
76 | ulong deal; // Deal ticket, if it is performed
77 | ulong order; // Order ticket, if it is placed
78 | double volume; // Deal volume, confirmed by broker
79 | double price; // Deal price, confirmed by broker
80 | double bid; // Current Bid price
81 | double ask; // Current Ask price
82 | string comment; // Broker comment to operation (by default it is filled by description of trade
83 | // server return code)
84 | uint request_id; // Request ID set by the terminal during the dispatch
85 | uint retcode_external; // Return code of an external trading system
86 | };
87 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Expert/Expert.mqh:
--------------------------------------------------------------------------------
1 | /** Disclaimer and Licence
2 |
3 | * This file is free software: you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation, either version 3 of the License, or
6 | * (at your option) any later version.
7 |
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 |
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program. If not, see .
15 |
16 | * All trading involves risk. You should have received the risk warnings
17 | * and terms of use in the README.MD file distributed with this software.
18 | * See the README.MD file for more information and before using this software.
19 |
20 | **/
21 | /**=
22 | *
23 | * Disclaimer and Licence
24 | *
25 | * This file is free software: you can redistribute it and/or modify
26 | * it under the terms of the GNU General Public License as published by
27 | * the Free Software Foundation, either version 3 of the License, or
28 | * (at your option) any later version.
29 | *
30 | * This program is distributed in the hope that it will be useful,
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 | * GNU General Public License for more details.
34 | *
35 | * You should have received a copy of the GNU General Public License
36 | * along with this program. If not, see .
37 | *
38 | * All trading involves risk. You should have received the risk warnings
39 | * and terms of use in the README.MD file distributed with this software.
40 | * See the README.MD file for more information and before using this software.
41 | *
42 | **/
43 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Expert/LegBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | LegBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "ExpertBase.mqh"
34 |
35 | class CLegBase : public CExpertBase {
36 |
37 | private:
38 | protected:
39 | ENUM_POSITION_TYPE mLegType;
40 |
41 | public:
42 | CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic );
43 | ~CLegBase() {}
44 | };
45 |
46 | CLegBase::CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic )
47 | : CExpertBase( orderSize, tradeComment, magic ) {
48 |
49 | mLegType = legType;
50 | }
51 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Framework.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | /*
35 | * V3.03
36 | * Added indicator classes
37 | *
38 | */
39 |
40 | #ifndef FRAMEWORK_VERSION
41 | #define FRAMEWORK_VERSION
42 | #define FRAMEWORK_VERSION_3_03
43 | #endif
44 |
45 | #ifdef FRAMEWORK_VERSION_3_03
46 |
47 | #include "Common/CommonBase.mqh"
48 | #include "Expert/ExpertBase.mqh"
49 | #include "Expert/LegBase.mqh"
50 | #include "Indicators/Indicators.mqh"
51 | #include "Trade/Trade.mqh"
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Indicators/IndicatorBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | IndicatorBase.mqh
3 |
4 | Copyright 2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "../Common/CommonBase.mqh"
32 | #include "../Common/Defines.mqh"
33 |
34 | class CIndicatorBase : public CCommonBase {
35 |
36 | private:
37 | protected: // member variables
38 | // Only used for MQL5 but will not hurt MQL4 to be defined
39 | int mIndicatorHandle;
40 |
41 | public: // constructors
42 | CIndicatorBase() : CCommonBase() { Init(); }
43 | CIndicatorBase( string symbol, ENUM_TIMEFRAMES timeframe ) : CCommonBase( symbol, timeframe ) {
44 | Init();
45 | }
46 | ~CIndicatorBase();
47 |
48 | int Init();
49 |
50 | public:
51 | virtual double GetData( const int index ) { return ( GetData( 0, index ) ); }
52 | virtual double GetData( const int bufferNum, const int index ) { return ( 0 ); }
53 | };
54 |
55 | CIndicatorBase::~CIndicatorBase() {
56 |
57 | #ifdef __MQL5__
58 |
59 | if ( mIndicatorHandle != INVALID_HANDLE ) IndicatorRelease( mIndicatorHandle );
60 |
61 | #endif
62 | }
63 |
64 | int CIndicatorBase::Init() {
65 |
66 | if ( InitResult() != INIT_SUCCEEDED ) return ( InitResult() );
67 |
68 | #ifdef __MQL5__
69 | // Clean up here in case of a restart
70 | if ( mIndicatorHandle != INVALID_HANDLE ) IndicatorRelease( mIndicatorHandle );
71 | #endif
72 | mIndicatorHandle = INVALID_HANDLE;
73 |
74 | return ( INIT_SUCCEEDED );
75 | }
76 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Indicators/IndicatorHA.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | IndicatorHA.mqh
3 |
4 | Copyright 2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | #ifdef __MQL4__
34 | #define HAIndicator "Indicators\\Heiken Ashi.ex4"
35 | #endif
36 | #ifdef __MQL5__
37 | #define HAIndicator "Indicators\\Examples\\Heiken_Ashi.ex5"
38 | #endif
39 | #resource "\\" + HAIndicator
40 |
41 | enum ENUM_HA_BUFFER
42 | {
43 | #ifdef __MQL4__
44 | HA_BUFFER_LOHI,
45 | HA_BUFFER_HILO,
46 | HA_BUFFER_OPEN,
47 | HA_BUFFER_CLOSE,
48 | #endif
49 | #ifdef __MQL5__
50 | HA_BUFFER_OPEN,
51 | HA_BUFFER_HILO,
52 | HA_BUFFER_LOHI,
53 | HA_BUFFER_CLOSE,
54 | #endif
55 | };
56 |
57 | class CIndicatorHA : public CIndicatorBase {
58 |
59 | private:
60 | protected: // member variables
61 | void Init();
62 |
63 | public: // constructors
64 | CIndicatorHA();
65 | CIndicatorHA( string symbol, ENUM_TIMEFRAMES timeframe );
66 | ~CIndicatorHA();
67 |
68 | public:
69 | virtual double GetData( const int buffer_num, const int index );
70 | };
71 |
72 | CIndicatorHA::CIndicatorHA() : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) { Init(); }
73 |
74 | CIndicatorHA::CIndicatorHA( string symbol, ENUM_TIMEFRAMES timeframe )
75 | : CIndicatorBase( symbol, timeframe ) {
76 |
77 | Init();
78 | }
79 |
80 | void CIndicatorHA::Init() {
81 |
82 | if ( mInitResult != INIT_SUCCEEDED ) return;
83 |
84 | // For MQL5 create the indicator handle here
85 | #ifdef __MQL5__
86 | mIndicatorHandle = iCustom( mSymbol, mTimeframe, "::" + HAIndicator );
87 | if ( mIndicatorHandle == INVALID_HANDLE ) {
88 | InitError( "Failed to create indicator handle", INIT_FAILED );
89 | return;
90 | }
91 | #endif
92 |
93 | InitError( "", INIT_SUCCEEDED );
94 | }
95 |
96 | CIndicatorHA::~CIndicatorHA() {}
97 |
98 | double CIndicatorHA::GetData( const int buffer_num, const int index ) {
99 |
100 | double value = 0;
101 | #ifdef __MQL4__
102 | value = iCustom( mSymbol, mTimeframe, "::" + HAIndicator, buffer_num, index );
103 | #endif
104 |
105 | #ifdef __MQL5__
106 | double bufferData[];
107 | ArraySetAsSeries( bufferData, true );
108 | int cnt = CopyBuffer( mIndicatorHandle, buffer_num, index, 1, bufferData );
109 | if ( cnt > 0 ) value = bufferData[0];
110 | #endif
111 |
112 | return ( value );
113 | }
114 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Indicators/Indicators.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * Indicators.mqh
3 | *
4 | * Copyright 2022 Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | /*
32 | * This file is only to have a common place to load all indicators
33 | *
34 | */
35 |
36 | #include "IndicatorBase.mqh"
37 |
38 | #include "IndicatorHA.mqh"
39 | #include "IndicatorStochastic.mqh"
40 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Trade/PositionInfo.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo.mqh
4 | Framework 3.01
5 |
6 | Copyright 2013-2022, Orchard Forex
7 | https://www.orchardforex.com
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | #property copyright "Copyright 2021, Orchard Forex"
35 | #property link "https://orchardforex.com"
36 | #property version "1.01"
37 | #property strict
38 |
39 | #ifdef __MQL4__
40 | #include "PositionInfo_mql4.mqh"
41 | #endif
42 | #ifdef __MQL5__
43 | #include "PositionInfo_mql5.mqh"
44 | #endif
45 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Trade/PositionInfo_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo_mql4.mqh
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2021, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.01"
36 | #property strict
37 |
38 | #include "../Common/Defines.mqh"
39 |
40 | class CPositionInfo {
41 |
42 | public:
43 | bool SelectByIndex( int index );
44 |
45 | int Magic() { return ( OrderMagicNumber() ); }
46 | ENUM_POSITION_TYPE PositionType() { return ( ( ENUM_POSITION_TYPE )OrderType() ); }
47 | double PriceOpen() { return ( OrderOpenPrice() ); }
48 | double StopLoss() { return ( OrderStopLoss() ); }
49 | string Symbol() { return ( OrderSymbol() ); }
50 | double TakeProfit() { return ( OrderTakeProfit() ); }
51 | int Ticket() { return ( OrderTicket() ); }
52 | };
53 |
54 | /*
55 | * CPositionInfoCustom::SelectByIndex
56 | * Select an order by indexed position
57 | * @param - index : index position of order to select
58 | * @return - ticket number : 0 if the order is not buy/sell or is closed or not found
59 | */
60 | bool CPositionInfo::SelectByIndex( int index ) {
61 |
62 | if ( !OrderSelect( index, SELECT_BY_POS, MODE_TRADES ) ) return ( false );
63 | if ( OrderType() != ORDER_TYPE_BUY && OrderType() != ORDER_TYPE_SELL ) return ( false );
64 | if ( OrderCloseTime() > 0 ) return ( false );
65 | return ( OrderTicket() > 0 );
66 | }
67 |
68 | class CPositionInfoCustom : public CPositionInfo {
69 |
70 | public:
71 | int Total() { return ( OrdersTotal() ); }
72 | };
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Trade/PositionInfo_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | PositionInfo_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CPositionInfoCustom : public CPositionInfo {
36 |
37 | public:
38 | int Total() { return ( PositionsTotal() ); }
39 | };
40 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Trade/Trade.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Trade_mql4.mqh"
35 | #endif
36 | #ifdef __MQL5__
37 | #include "Trade_mql5.mqh"
38 | #endif
39 |
40 | #include "PositionInfo.mqh"
41 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.03/Trade/Trade_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CTradeCustom : public CTrade {
36 |
37 | private:
38 | protected: // member variables
39 | public: // constructors
40 | public:
41 | bool PositionCloseByType( const string symbol, ENUM_POSITION_TYPE positionType,
42 | const ulong deviation = ULONG_MAX );
43 | void PositionCountByType( const string symbol, int &count[] );
44 | };
45 |
46 | bool CTradeCustom::PositionCloseByType( const string symbol, ENUM_POSITION_TYPE positionType,
47 | const ulong deviation = ULONG_MAX ) {
48 |
49 | bool result = true;
50 | int cnt = PositionsTotal();
51 | for ( int i = cnt - 1; i >= 0; i-- ) {
52 | ulong ticket = PositionGetTicket( i );
53 | if ( PositionSelectByTicket( ticket ) ) {
54 | if ( PositionGetString( POSITION_SYMBOL ) == symbol &&
55 | PositionGetInteger( POSITION_TYPE ) == positionType &&
56 | PositionGetInteger( POSITION_MAGIC ) == m_magic ) {
57 | result &= PositionClose( ticket, deviation );
58 | }
59 | }
60 | else {
61 | m_result.retcode = TRADE_RETCODE_REJECT;
62 | result = false;
63 | }
64 | }
65 |
66 | return ( result );
67 | }
68 |
69 | void CTradeCustom::PositionCountByType( const string symbol, int &count[] ) {
70 |
71 | ArrayResize( count, 6 );
72 | ArrayInitialize( count, 0 );
73 |
74 | int cnt = PositionsTotal();
75 | for ( int i = cnt - 1; i >= 0; i-- ) {
76 | ulong ticket = PositionGetTicket( i );
77 | if ( PositionSelectByTicket( ticket ) ) {
78 | if ( PositionGetString( POSITION_SYMBOL ) == symbol &&
79 | PositionGetInteger( POSITION_MAGIC ) == m_magic ) {
80 | count[( int )PositionGetInteger( POSITION_TYPE )]++;
81 | }
82 | }
83 | }
84 |
85 | return;
86 | }
87 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Common/CommonBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | CommonBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | #include "Defines.mqh"
36 |
37 | #define _INIT_CHECK_FAIL \
38 | if ( mInitResult != INIT_SUCCEEDED ) return ( mInitResult );
39 | #define _INIT_ERROR( msg ) return ( InitError( msg, INIT_PARAMETERS_INCORRECT ) );
40 | #define _INIT_ASSERT( condition, msg ) \
41 | if ( !condition ) return ( InitError( msg, INIT_FAILED ) );
42 |
43 | class CCommonBase : public CObject {
44 |
45 | private:
46 | protected: // Members
47 | int mDigits;
48 | string mSymbol;
49 | ENUM_TIMEFRAMES mTimeframe;
50 |
51 | string mInitMessage;
52 | int mInitResult;
53 |
54 | protected: // Constructors
55 | //
56 | // Constructors
57 | //
58 | CCommonBase() { Init( _Symbol, ( ENUM_TIMEFRAMES )_Period ); }
59 | CCommonBase( string symbol ) { Init( symbol, ( ENUM_TIMEFRAMES )_Period ); }
60 | CCommonBase( int timeframe ) { Init( _Symbol, ( ENUM_TIMEFRAMES )timeframe ); }
61 | CCommonBase( ENUM_TIMEFRAMES timeframe ) { Init( _Symbol, timeframe ); }
62 | CCommonBase( string symbol, int timeframe ) { Init( symbol, ( ENUM_TIMEFRAMES )timeframe ); }
63 | CCommonBase( string symbol, ENUM_TIMEFRAMES timeframe ) { Init( symbol, timeframe ); }
64 |
65 | //
66 | // Destructors
67 | //
68 | ~CCommonBase(){};
69 |
70 | int Init( string symbol, ENUM_TIMEFRAMES timeframe );
71 |
72 | protected: // Functions
73 | int InitError( string initMessage, int initResult ) {
74 | mInitMessage = initMessage;
75 | mInitResult = initResult;
76 | if ( initMessage != "" ) Print( initMessage );
77 | return ( initResult );
78 | }
79 |
80 | double PointsToDouble( int points ) {
81 | return ( points * SymbolInfoDouble( mSymbol, SYMBOL_POINT ) );
82 | }
83 |
84 | public: // Properties
85 | int InitResult() { return ( mInitResult ); }
86 | string InitMessage() { return ( mInitMessage ); }
87 |
88 | public: // Functions
89 | };
90 |
91 | int CCommonBase::Init( string symbol, ENUM_TIMEFRAMES timeframe ) {
92 |
93 | InitError( "", INIT_SUCCEEDED );
94 |
95 | mSymbol = symbol;
96 | mTimeframe = timeframe;
97 | mDigits = ( int )SymbolInfoInteger( symbol, SYMBOL_DIGITS );
98 |
99 | return ( INIT_SUCCEEDED );
100 | }
101 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Common/Defines.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Defines_mql4.mqh"
35 | #endif
36 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Common/Defines_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines_mql4
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | enum ENUM_POSITION_TYPE
34 | {
35 | POSITION_TYPE_BUY,
36 | POSITION_TYPE_SELL
37 | };
38 |
39 | // Some return code definitions
40 | enum ENUM_TRADE_RETCODES
41 | {
42 | TRADE_RETCODE_INVALID = 10013, // Invalid request
43 | };
44 |
45 | // To handle the changes of buffer names, will grow as needed
46 | enum ENUM_INDICATOR_BUFFERS
47 | {
48 | MAIN_LINE = MODE_MAIN,
49 | SIGNAL_LINE = MODE_SIGNAL,
50 | };
51 |
52 | enum ENUM_ORDER_TYPE_TIME
53 | {
54 | ORDER_TIME_GTC,
55 | ORDER_TIME_DAY,
56 | ORDER_TIME_SPECIFIED,
57 | ORDER_TIME_SPECIFIED_DAY,
58 | };
59 |
60 | struct MqlTradeRequest
61 | {
62 | int action; // Trade operation type (as int here)
63 | ulong magic; // Expert Advisor ID (magic number)
64 | ulong order; // Order ticket
65 | string symbol; // Trade symbol
66 | double volume; // Requested volume for a deal in lots
67 | double price; // Price
68 | double stoplimit; // StopLimit level of the order
69 | double sl; // Stop Loss level of the order
70 | double tp; // Take Profit level of the order
71 | ulong deviation; // Maximal possible deviation from the requested price
72 | ENUM_ORDER_TYPE type; // Order type
73 | int type_filling; // Order execution type (int here)
74 | int type_time; // Order expiration type (int here)
75 | datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
76 | string comment; // Order comment
77 | ulong position; // Position ticket
78 | ulong position_by; // The ticket of an opposite position
79 | };
80 |
81 | struct MqlTradeResult
82 | {
83 | uint retcode; // Operation return code
84 | ulong deal; // Deal ticket, if it is performed
85 | ulong order; // Order ticket, if it is placed
86 | double volume; // Deal volume, confirmed by broker
87 | double price; // Deal price, confirmed by broker
88 | double bid; // Current Bid price
89 | double ask; // Current Ask price
90 | string comment; // Broker comment to operation (by default it is filled by description of trade
91 | // server return code)
92 | uint request_id; // Request ID set by the terminal during the dispatch
93 | uint retcode_external; // Return code of an external trading system
94 | };
95 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Expert/Expert.mqh:
--------------------------------------------------------------------------------
1 | /** Disclaimer and Licence
2 |
3 | * This file is free software: you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation, either version 3 of the License, or
6 | * (at your option) any later version.
7 |
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 |
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program. If not, see .
15 |
16 | * All trading involves risk. You should have received the risk warnings
17 | * and terms of use in the README.MD file distributed with this software.
18 | * See the README.MD file for more information and before using this software.
19 |
20 | **/
21 | /**=
22 | *
23 | * Disclaimer and Licence
24 | *
25 | * This file is free software: you can redistribute it and/or modify
26 | * it under the terms of the GNU General Public License as published by
27 | * the Free Software Foundation, either version 3 of the License, or
28 | * (at your option) any later version.
29 | *
30 | * This program is distributed in the hope that it will be useful,
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 | * GNU General Public License for more details.
34 | *
35 | * You should have received a copy of the GNU General Public License
36 | * along with this program. If not, see .
37 | *
38 | * All trading involves risk. You should have received the risk warnings
39 | * and terms of use in the README.MD file distributed with this software.
40 | * See the README.MD file for more information and before using this software.
41 | *
42 | **/
43 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Expert/LegBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | LegBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "ExpertBase.mqh"
34 |
35 | class CLegBase : public CExpertBase {
36 |
37 | private:
38 | protected:
39 | ENUM_POSITION_TYPE mLegType;
40 |
41 | public:
42 | CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic );
43 | ~CLegBase() {}
44 | };
45 |
46 | CLegBase::CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic )
47 | : CExpertBase( orderSize, tradeComment, magic ) {
48 |
49 | mLegType = legType;
50 | }
51 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Framework.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | /*
35 | * V3.04
36 | * More indicators and made some methods common
37 | * MA
38 | * Fractals
39 | *
40 | */
41 |
42 | #ifndef FRAMEWORK_VERSION
43 | #define FRAMEWORK_VERSION
44 | #define FRAMEWORK_VERSION_3_04
45 | #endif
46 |
47 | #ifdef FRAMEWORK_VERSION_3_04
48 |
49 | #include "Common/CommonBase.mqh"
50 | #include "Expert/ExpertBase.mqh"
51 | #include "Expert/LegBase.mqh"
52 | #include "Indicators/Indicators.mqh"
53 | #include "Trade/Trade.mqh"
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Indicators/IndicatorBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | IndicatorBase.mqh
3 |
4 | Copyright 2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "../Common/CommonBase.mqh"
32 | #include "../Common/Defines.mqh"
33 |
34 | class CIndicatorBase : public CCommonBase {
35 |
36 | private:
37 | protected: // member variables
38 | // Only used for MQL5 but will not hurt MQL4 to be defined
39 | int mIndicatorHandle;
40 |
41 | public: // constructors
42 | CIndicatorBase() : CCommonBase() { Init(); }
43 | CIndicatorBase( string symbol, ENUM_TIMEFRAMES timeframe ) : CCommonBase( symbol, timeframe ) {
44 | Init();
45 | }
46 | ~CIndicatorBase();
47 |
48 | int Init();
49 |
50 | public:
51 | virtual double GetData( const int index ) { return ( GetData( 0, index ) ); }
52 | virtual double GetData( const int bufferNum, const int index );
53 | int handle() { return ( mIndicatorHandle ); }
54 | };
55 |
56 | CIndicatorBase::~CIndicatorBase() {
57 |
58 | #ifdef __MQL5__
59 |
60 | if ( mIndicatorHandle != INVALID_HANDLE ) IndicatorRelease( mIndicatorHandle );
61 |
62 | #endif
63 | }
64 |
65 | int CIndicatorBase::Init() {
66 |
67 | if ( InitResult() != INIT_SUCCEEDED ) return ( InitResult() );
68 |
69 | #ifdef __MQL5__
70 | // Clean up here in case of a restart
71 | if ( mIndicatorHandle != INVALID_HANDLE ) IndicatorRelease( mIndicatorHandle );
72 | #endif
73 | mIndicatorHandle = INVALID_HANDLE;
74 |
75 | return ( INIT_SUCCEEDED );
76 | }
77 |
78 | #ifdef __MQL5__
79 | double CIndicatorBase::GetData( const int buffer_num, const int index ) {
80 |
81 | double value = 0;
82 |
83 | // Get data from a buffer for MQL5
84 | // Improve all of this later when there is a need for an array of results
85 | double bufferData[];
86 | ArraySetAsSeries( bufferData, true );
87 | int cnt = CopyBuffer( mIndicatorHandle, buffer_num, index, 1, bufferData );
88 | if ( cnt > 0 ) value = bufferData[0];
89 |
90 | return ( value );
91 | }
92 | #endif
93 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Indicators/IndicatorFractal.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorFractal.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | class CIndicatorFractal : public CIndicatorBase {
34 |
35 | private:
36 | protected: // member variables
37 | void Init();
38 |
39 | public: // constructors
40 | CIndicatorFractal();
41 | CIndicatorFractal( string symbol, ENUM_TIMEFRAMES timeframe );
42 | ~CIndicatorFractal();
43 |
44 | public:
45 | #ifdef __MQL4__
46 | virtual double GetData( const int buffer_num, const int index );
47 | #endif
48 | };
49 |
50 | CIndicatorFractal::CIndicatorFractal() : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
51 |
52 | Init();
53 | }
54 |
55 | CIndicatorFractal::CIndicatorFractal( string symbol, ENUM_TIMEFRAMES timeframe )
56 | : CIndicatorBase( symbol, timeframe ) {
57 |
58 | Init();
59 | }
60 |
61 | void CIndicatorFractal::Init() {
62 |
63 | if ( mInitResult != INIT_SUCCEEDED ) return;
64 |
65 | // For MQL5 create the indicator handle here
66 | #ifdef __MQL5__
67 | mIndicatorHandle = iFractals( mSymbol, mTimeframe );
68 | if ( mIndicatorHandle == INVALID_HANDLE ) {
69 | InitError( "Failed to create indicator handle", INIT_FAILED );
70 | return;
71 | }
72 | #endif
73 |
74 | InitError( "", INIT_SUCCEEDED );
75 | }
76 |
77 | CIndicatorFractal::~CIndicatorFractal() {}
78 |
79 | #ifdef __MQL4__
80 | double CIndicatorFractal::GetData( const int buffer_num, const int index ) {
81 |
82 | return ( iFractals( mSymbol, mTimeframe, buffer_num, index ) );
83 | }
84 | #endif
85 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Indicators/IndicatorHA.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | IndicatorHA.mqh
3 |
4 | Copyright 2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | #ifdef __MQL4__
34 | #define HAIndicator "Indicators\\Heiken Ashi.ex4"
35 | #endif
36 | #ifdef __MQL5__
37 | #define HAIndicator "Indicators\\Examples\\Heiken_Ashi.ex5"
38 | #endif
39 | #resource "\\" + HAIndicator
40 |
41 | enum ENUM_HA_BUFFER
42 | {
43 | #ifdef __MQL4__
44 | HA_BUFFER_LOHI,
45 | HA_BUFFER_HILO,
46 | HA_BUFFER_OPEN,
47 | HA_BUFFER_CLOSE,
48 | #endif
49 | #ifdef __MQL5__
50 | HA_BUFFER_OPEN,
51 | HA_BUFFER_HILO,
52 | HA_BUFFER_LOHI,
53 | HA_BUFFER_CLOSE,
54 | #endif
55 | };
56 |
57 | class CIndicatorHA : public CIndicatorBase {
58 |
59 | private:
60 | protected: // member variables
61 | void Init();
62 |
63 | public: // constructors
64 | CIndicatorHA();
65 | CIndicatorHA( string symbol, ENUM_TIMEFRAMES timeframe );
66 | ~CIndicatorHA();
67 |
68 | public:
69 | #ifdef __MQL4__
70 | virtual double GetData( const int buffer_num, const int index );
71 | #endif
72 | };
73 |
74 | CIndicatorHA::CIndicatorHA() : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) { Init(); }
75 |
76 | CIndicatorHA::CIndicatorHA( string symbol, ENUM_TIMEFRAMES timeframe )
77 | : CIndicatorBase( symbol, timeframe ) {
78 |
79 | Init();
80 | }
81 |
82 | void CIndicatorHA::Init() {
83 |
84 | if ( mInitResult != INIT_SUCCEEDED ) return;
85 |
86 | // For MQL5 create the indicator handle here
87 | #ifdef __MQL5__
88 | mIndicatorHandle = iCustom( mSymbol, mTimeframe, "::" + HAIndicator );
89 | if ( mIndicatorHandle == INVALID_HANDLE ) {
90 | InitError( "Failed to create indicator handle", INIT_FAILED );
91 | return;
92 | }
93 | #endif
94 |
95 | InitError( "", INIT_SUCCEEDED );
96 | }
97 |
98 | CIndicatorHA::~CIndicatorHA() {}
99 |
100 | #ifdef __MQL4__
101 | double CIndicatorHA::GetData( const int buffer_num, const int index ) {
102 |
103 | return ( iCustom( mSymbol, mTimeframe, "::" + HAIndicator, buffer_num, index ) );
104 | }
105 | #endif
106 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Indicators/IndicatorMA.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorMA.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | class CIndicatorMA : public CIndicatorBase {
34 |
35 | private:
36 | protected: // member variables
37 | int mPeriod;
38 | ENUM_MA_METHOD mMethod;
39 | ENUM_APPLIED_PRICE mAppliedPrice;
40 |
41 | void Init( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice );
42 |
43 | public: // constructors
44 | CIndicatorMA( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice );
45 | CIndicatorMA( string symbol, ENUM_TIMEFRAMES timeframe, int period, ENUM_MA_METHOD method,
46 | ENUM_APPLIED_PRICE appliedPrice );
47 | ~CIndicatorMA();
48 |
49 | public:
50 | #ifdef __MQL4__
51 | virtual double GetData( const int buffer_num, const int index );
52 | #endif
53 | };
54 |
55 | CIndicatorMA::CIndicatorMA( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice )
56 | : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
57 |
58 | Init( period, method, appliedPrice );
59 | }
60 |
61 | CIndicatorMA::CIndicatorMA( string symbol, ENUM_TIMEFRAMES timeframe, int period,
62 | ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice )
63 | : CIndicatorBase( symbol, timeframe ) {
64 |
65 | Init( period, method, appliedPrice );
66 | }
67 |
68 | void CIndicatorMA::Init( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice ) {
69 |
70 | if ( mInitResult != INIT_SUCCEEDED ) return;
71 |
72 | mPeriod = period;
73 | mMethod = method;
74 | mAppliedPrice = appliedPrice;
75 |
76 | // For MQL5 create the indicator handle here
77 | #ifdef __MQL5__
78 | mIndicatorHandle = iMA( mSymbol, mTimeframe, mPeriod, 0, mMethod, mAppliedPrice );
79 | if ( mIndicatorHandle == INVALID_HANDLE ) {
80 | InitError( "Failed to create indicator handle", INIT_FAILED );
81 | return;
82 | }
83 | #endif
84 |
85 | InitError( "", INIT_SUCCEEDED );
86 | }
87 |
88 | CIndicatorMA::~CIndicatorMA() {}
89 |
90 | #ifdef __MQL4__
91 | double CIndicatorMA::GetData( const int buffer_num, const int index ) {
92 |
93 | double value = iMA( mSymbol, mTimeframe, mPeriod, 0, mMethod, mAppliedPrice, index );
94 | return ( value );
95 | }
96 | #endif
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Indicators/Indicators.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * Indicators.mqh
3 | *
4 | * Copyright 2022 Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | /*
32 | * This file is only to have a common place to load all indicators
33 | *
34 | */
35 |
36 | #include "IndicatorBase.mqh"
37 |
38 | #include "IndicatorHA.mqh"
39 | #include "IndicatorFractal.mqh"
40 | #include "IndicatorMA.mqh"
41 | #include "IndicatorStochastic.mqh"
42 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Trade/PositionInfo.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo.mqh
4 | Framework 3.01
5 |
6 | Copyright 2013-2022, Orchard Forex
7 | https://www.orchardforex.com
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | #property copyright "Copyright 2021, Orchard Forex"
35 | #property link "https://orchardforex.com"
36 | #property version "1.01"
37 | #property strict
38 |
39 | #ifdef __MQL4__
40 | #include "PositionInfo_mql4.mqh"
41 | #endif
42 | #ifdef __MQL5__
43 | #include "PositionInfo_mql5.mqh"
44 | #endif
45 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Trade/PositionInfo_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo_mql4.mqh
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2021, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.01"
36 | #property strict
37 |
38 | #include "../Common/Defines.mqh"
39 |
40 | class CPositionInfo {
41 |
42 | public:
43 | bool SelectByIndex( int index );
44 |
45 | int Magic() { return ( OrderMagicNumber() ); }
46 | ENUM_POSITION_TYPE PositionType() { return ( ( ENUM_POSITION_TYPE )OrderType() ); }
47 | double PriceOpen() { return ( OrderOpenPrice() ); }
48 | double StopLoss() { return ( OrderStopLoss() ); }
49 | string Symbol() { return ( OrderSymbol() ); }
50 | double TakeProfit() { return ( OrderTakeProfit() ); }
51 | int Ticket() { return ( OrderTicket() ); }
52 | };
53 |
54 | /*
55 | * CPositionInfoCustom::SelectByIndex
56 | * Select an order by indexed position
57 | * @param - index : index position of order to select
58 | * @return - ticket number : 0 if the order is not buy/sell or is closed or not found
59 | */
60 | bool CPositionInfo::SelectByIndex( int index ) {
61 |
62 | if ( !OrderSelect( index, SELECT_BY_POS, MODE_TRADES ) ) return ( false );
63 | if ( OrderType() != ORDER_TYPE_BUY && OrderType() != ORDER_TYPE_SELL ) return ( false );
64 | if ( OrderCloseTime() > 0 ) return ( false );
65 | return ( OrderTicket() > 0 );
66 | }
67 |
68 | class CPositionInfoCustom : public CPositionInfo {
69 |
70 | public:
71 | int Total() { return ( OrdersTotal() ); }
72 | };
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Trade/PositionInfo_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | PositionInfo_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CPositionInfoCustom : public CPositionInfo {
36 |
37 | public:
38 | int Total() { return ( PositionsTotal() ); }
39 | };
40 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.04/Trade/Trade.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Trade_mql4.mqh"
35 | #endif
36 | #ifdef __MQL5__
37 | #include "Trade_mql5.mqh"
38 | #endif
39 |
40 | #include "PositionInfo.mqh"
41 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Common/CommonBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | CommonBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | #include "Defines.mqh"
36 |
37 | #define _INIT_CHECK_FAIL \
38 | if ( mInitResult != INIT_SUCCEEDED ) return ( mInitResult );
39 | #define _INIT_ERROR( msg ) return ( InitError( msg, INIT_PARAMETERS_INCORRECT ) );
40 | #define _INIT_ASSERT( condition, msg ) \
41 | if ( !condition ) return ( InitError( msg, INIT_FAILED ) );
42 |
43 | class CCommonBase : public CObject {
44 |
45 | private:
46 | protected: // Members
47 | int mDigits;
48 | string mSymbol;
49 | ENUM_TIMEFRAMES mTimeframe;
50 |
51 | string mInitMessage;
52 | int mInitResult;
53 |
54 | protected: // Constructors
55 | //
56 | // Constructors
57 | //
58 | CCommonBase() { Init( _Symbol, ( ENUM_TIMEFRAMES )_Period ); }
59 | CCommonBase( string symbol ) { Init( symbol, ( ENUM_TIMEFRAMES )_Period ); }
60 | CCommonBase( int timeframe ) { Init( _Symbol, ( ENUM_TIMEFRAMES )timeframe ); }
61 | CCommonBase( ENUM_TIMEFRAMES timeframe ) { Init( _Symbol, timeframe ); }
62 | CCommonBase( string symbol, int timeframe ) { Init( symbol, ( ENUM_TIMEFRAMES )timeframe ); }
63 | CCommonBase( string symbol, ENUM_TIMEFRAMES timeframe ) { Init( symbol, timeframe ); }
64 |
65 | //
66 | // Destructors
67 | //
68 | ~CCommonBase(){};
69 |
70 | int Init( string symbol, ENUM_TIMEFRAMES timeframe );
71 |
72 | protected: // Functions
73 | int InitError( string initMessage, int initResult ) {
74 | mInitMessage = initMessage;
75 | mInitResult = initResult;
76 | if ( initMessage != "" ) Print( initMessage );
77 | return ( initResult );
78 | }
79 |
80 | double PointsToDouble( int points ) {
81 | return ( points * SymbolInfoDouble( mSymbol, SYMBOL_POINT ) );
82 | }
83 |
84 | public: // Properties
85 | int InitResult() { return ( mInitResult ); }
86 | string InitMessage() { return ( mInitMessage ); }
87 |
88 | public: // Functions
89 | };
90 |
91 | int CCommonBase::Init( string symbol, ENUM_TIMEFRAMES timeframe ) {
92 |
93 | InitError( "", INIT_SUCCEEDED );
94 |
95 | mSymbol = symbol;
96 | mTimeframe = timeframe;
97 | mDigits = ( int )SymbolInfoInteger( symbol, SYMBOL_DIGITS );
98 |
99 | return ( INIT_SUCCEEDED );
100 | }
101 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Common/Defines.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Defines_mql4.mqh"
35 | #endif
36 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Common/Defines_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines_mql4
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | enum ENUM_POSITION_TYPE
34 | {
35 | POSITION_TYPE_BUY,
36 | POSITION_TYPE_SELL
37 | };
38 |
39 | // Some return code definitions
40 | enum ENUM_TRADE_RETCODES
41 | {
42 | TRADE_RETCODE_INVALID = 10013, // Invalid request
43 | };
44 |
45 | // To handle the changes of buffer names, will grow as needed
46 | enum ENUM_INDICATOR_BUFFERS
47 | {
48 | MAIN_LINE = MODE_MAIN,
49 | SIGNAL_LINE = MODE_SIGNAL,
50 | };
51 |
52 | enum ENUM_ORDER_TYPE_TIME
53 | {
54 | ORDER_TIME_GTC,
55 | ORDER_TIME_DAY,
56 | ORDER_TIME_SPECIFIED,
57 | ORDER_TIME_SPECIFIED_DAY,
58 | };
59 |
60 | struct MqlTradeRequest
61 | {
62 | int action; // Trade operation type (as int here)
63 | ulong magic; // Expert Advisor ID (magic number)
64 | ulong order; // Order ticket
65 | string symbol; // Trade symbol
66 | double volume; // Requested volume for a deal in lots
67 | double price; // Price
68 | double stoplimit; // StopLimit level of the order
69 | double sl; // Stop Loss level of the order
70 | double tp; // Take Profit level of the order
71 | ulong deviation; // Maximal possible deviation from the requested price
72 | ENUM_ORDER_TYPE type; // Order type
73 | int type_filling; // Order execution type (int here)
74 | int type_time; // Order expiration type (int here)
75 | datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
76 | string comment; // Order comment
77 | ulong position; // Position ticket
78 | ulong position_by; // The ticket of an opposite position
79 | };
80 |
81 | struct MqlTradeResult
82 | {
83 | uint retcode; // Operation return code
84 | ulong deal; // Deal ticket, if it is performed
85 | ulong order; // Order ticket, if it is placed
86 | double volume; // Deal volume, confirmed by broker
87 | double price; // Deal price, confirmed by broker
88 | double bid; // Current Bid price
89 | double ask; // Current Ask price
90 | string comment; // Broker comment to operation (by default it is filled by description of trade
91 | // server return code)
92 | uint request_id; // Request ID set by the terminal during the dispatch
93 | uint retcode_external; // Return code of an external trading system
94 | };
95 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Expert/Expert.mqh:
--------------------------------------------------------------------------------
1 | /** Disclaimer and Licence
2 |
3 | * This file is free software: you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation, either version 3 of the License, or
6 | * (at your option) any later version.
7 |
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 |
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program. If not, see .
15 |
16 | * All trading involves risk. You should have received the risk warnings
17 | * and terms of use in the README.MD file distributed with this software.
18 | * See the README.MD file for more information and before using this software.
19 |
20 | **/
21 | /**=
22 | *
23 | * Disclaimer and Licence
24 | *
25 | * This file is free software: you can redistribute it and/or modify
26 | * it under the terms of the GNU General Public License as published by
27 | * the Free Software Foundation, either version 3 of the License, or
28 | * (at your option) any later version.
29 | *
30 | * This program is distributed in the hope that it will be useful,
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 | * GNU General Public License for more details.
34 | *
35 | * You should have received a copy of the GNU General Public License
36 | * along with this program. If not, see .
37 | *
38 | * All trading involves risk. You should have received the risk warnings
39 | * and terms of use in the README.MD file distributed with this software.
40 | * See the README.MD file for more information and before using this software.
41 | *
42 | **/
43 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Expert/LegBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | LegBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "ExpertBase.mqh"
34 |
35 | class CLegBase : public CExpertBase {
36 |
37 | private:
38 | protected:
39 | ENUM_POSITION_TYPE mLegType;
40 |
41 | public:
42 | CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic );
43 | ~CLegBase() {}
44 | };
45 |
46 | CLegBase::CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic )
47 | : CExpertBase( orderSize, tradeComment, magic ) {
48 |
49 | mLegType = legType;
50 | }
51 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Framework.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | /*
35 | * V3.05
36 | * RSI and MACD indicators
37 | *
38 | */
39 |
40 | #ifndef FRAMEWORK_VERSION
41 | #define FRAMEWORK_VERSION
42 | #define FRAMEWORK_VERSION_3_05
43 | #endif
44 |
45 | #ifdef FRAMEWORK_VERSION_3_05
46 |
47 | #include "Common/CommonBase.mqh"
48 | #include "Expert/ExpertBase.mqh"
49 | #include "Expert/LegBase.mqh"
50 | #include "Indicators/Indicators.mqh"
51 | #include "Trade/Trade.mqh"
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Indicators/IndicatorBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | IndicatorBase.mqh
3 |
4 | Copyright 2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "../Common/CommonBase.mqh"
32 | #include "../Common/Defines.mqh"
33 |
34 | class CIndicatorBase : public CCommonBase {
35 |
36 | private:
37 | protected: // member variables
38 | // Only used for MQL5 but will not hurt MQL4 to be defined
39 | int mIndicatorHandle;
40 |
41 | public: // constructors
42 | CIndicatorBase() : CCommonBase() { Init(); }
43 | CIndicatorBase( string symbol, ENUM_TIMEFRAMES timeframe ) : CCommonBase( symbol, timeframe ) {
44 | Init();
45 | }
46 | ~CIndicatorBase();
47 |
48 | int Init();
49 |
50 | public:
51 | virtual double GetData( const int index ) { return ( GetData( 0, index ) ); }
52 | virtual double GetData( const int bufferNum, const int index );
53 | int handle() { return ( mIndicatorHandle ); }
54 | };
55 |
56 | CIndicatorBase::~CIndicatorBase() {
57 |
58 | #ifdef __MQL5__
59 |
60 | if ( mIndicatorHandle != INVALID_HANDLE ) IndicatorRelease( mIndicatorHandle );
61 |
62 | #endif
63 | }
64 |
65 | int CIndicatorBase::Init() {
66 |
67 | if ( InitResult() != INIT_SUCCEEDED ) return ( InitResult() );
68 |
69 | #ifdef __MQL5__
70 | // Clean up here in case of a restart
71 | if ( mIndicatorHandle != INVALID_HANDLE ) IndicatorRelease( mIndicatorHandle );
72 | #endif
73 | mIndicatorHandle = INVALID_HANDLE;
74 |
75 | return ( INIT_SUCCEEDED );
76 | }
77 |
78 | #ifdef __MQL5__
79 | double CIndicatorBase::GetData( const int buffer_num, const int index ) {
80 |
81 | double value = 0;
82 |
83 | // Get data from a buffer for MQL5
84 | // Improve all of this later when there is a need for an array of results
85 | double bufferData[];
86 | ArraySetAsSeries( bufferData, true );
87 | int cnt = CopyBuffer( mIndicatorHandle, buffer_num, index, 1, bufferData );
88 | if ( cnt > 0 ) value = bufferData[0];
89 |
90 | return ( value );
91 | }
92 | #endif
93 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Indicators/IndicatorFractal.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorFractal.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | class CIndicatorFractal : public CIndicatorBase {
34 |
35 | private:
36 | protected: // member variables
37 | void Init();
38 |
39 | public: // constructors
40 | CIndicatorFractal();
41 | CIndicatorFractal( string symbol, ENUM_TIMEFRAMES timeframe );
42 | ~CIndicatorFractal();
43 |
44 | public:
45 | #ifdef __MQL4__
46 | virtual double GetData( const int buffer_num, const int index );
47 | #endif
48 | };
49 |
50 | CIndicatorFractal::CIndicatorFractal() : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
51 |
52 | Init();
53 | }
54 |
55 | CIndicatorFractal::CIndicatorFractal( string symbol, ENUM_TIMEFRAMES timeframe )
56 | : CIndicatorBase( symbol, timeframe ) {
57 |
58 | Init();
59 | }
60 |
61 | void CIndicatorFractal::Init() {
62 |
63 | if ( mInitResult != INIT_SUCCEEDED ) return;
64 |
65 | // For MQL5 create the indicator handle here
66 | #ifdef __MQL5__
67 | mIndicatorHandle = iFractals( mSymbol, mTimeframe );
68 | if ( mIndicatorHandle == INVALID_HANDLE ) {
69 | InitError( "Failed to create indicator handle", INIT_FAILED );
70 | return;
71 | }
72 | #endif
73 |
74 | InitError( "", INIT_SUCCEEDED );
75 | }
76 |
77 | CIndicatorFractal::~CIndicatorFractal() {}
78 |
79 | #ifdef __MQL4__
80 | double CIndicatorFractal::GetData( const int buffer_num, const int index ) {
81 |
82 | return ( iFractals( mSymbol, mTimeframe, buffer_num, index ) );
83 | }
84 | #endif
85 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Indicators/IndicatorHA.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | IndicatorHA.mqh
3 |
4 | Copyright 2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | #ifdef __MQL4__
34 | #define HAIndicator "Indicators\\Heiken Ashi.ex4"
35 | #endif
36 | #ifdef __MQL5__
37 | #define HAIndicator "Indicators\\Examples\\Heiken_Ashi.ex5"
38 | #endif
39 | #resource "\\" + HAIndicator
40 |
41 | enum ENUM_HA_BUFFER
42 | {
43 | #ifdef __MQL4__
44 | HA_BUFFER_LOHI,
45 | HA_BUFFER_HILO,
46 | HA_BUFFER_OPEN,
47 | HA_BUFFER_CLOSE,
48 | #endif
49 | #ifdef __MQL5__
50 | HA_BUFFER_OPEN,
51 | HA_BUFFER_HILO,
52 | HA_BUFFER_LOHI,
53 | HA_BUFFER_CLOSE,
54 | #endif
55 | };
56 |
57 | class CIndicatorHA : public CIndicatorBase {
58 |
59 | private:
60 | protected: // member variables
61 | void Init();
62 |
63 | public: // constructors
64 | CIndicatorHA();
65 | CIndicatorHA( string symbol, ENUM_TIMEFRAMES timeframe );
66 | ~CIndicatorHA();
67 |
68 | public:
69 | #ifdef __MQL4__
70 | virtual double GetData( const int buffer_num, const int index );
71 | #endif
72 | };
73 |
74 | CIndicatorHA::CIndicatorHA() : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) { Init(); }
75 |
76 | CIndicatorHA::CIndicatorHA( string symbol, ENUM_TIMEFRAMES timeframe )
77 | : CIndicatorBase( symbol, timeframe ) {
78 |
79 | Init();
80 | }
81 |
82 | void CIndicatorHA::Init() {
83 |
84 | if ( mInitResult != INIT_SUCCEEDED ) return;
85 |
86 | // For MQL5 create the indicator handle here
87 | #ifdef __MQL5__
88 | mIndicatorHandle = iCustom( mSymbol, mTimeframe, "::" + HAIndicator );
89 | if ( mIndicatorHandle == INVALID_HANDLE ) {
90 | InitError( "Failed to create indicator handle", INIT_FAILED );
91 | return;
92 | }
93 | #endif
94 |
95 | InitError( "", INIT_SUCCEEDED );
96 | }
97 |
98 | CIndicatorHA::~CIndicatorHA() {}
99 |
100 | #ifdef __MQL4__
101 | double CIndicatorHA::GetData( const int buffer_num, const int index ) {
102 |
103 | return ( iCustom( mSymbol, mTimeframe, "::" + HAIndicator, buffer_num, index ) );
104 | }
105 | #endif
106 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Indicators/IndicatorMA.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorMA.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | class CIndicatorMA : public CIndicatorBase {
34 |
35 | private:
36 | protected: // member variables
37 | int mPeriod;
38 | ENUM_MA_METHOD mMethod;
39 | ENUM_APPLIED_PRICE mAppliedPrice;
40 |
41 | void Init( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice );
42 |
43 | public: // constructors
44 | CIndicatorMA( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice );
45 | CIndicatorMA( string symbol, ENUM_TIMEFRAMES timeframe, int period, ENUM_MA_METHOD method,
46 | ENUM_APPLIED_PRICE appliedPrice );
47 | ~CIndicatorMA();
48 |
49 | public:
50 | #ifdef __MQL4__
51 | virtual double GetData( const int buffer_num, const int index );
52 | #endif
53 | };
54 |
55 | CIndicatorMA::CIndicatorMA( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice )
56 | : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
57 |
58 | Init( period, method, appliedPrice );
59 | }
60 |
61 | CIndicatorMA::CIndicatorMA( string symbol, ENUM_TIMEFRAMES timeframe, int period,
62 | ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice )
63 | : CIndicatorBase( symbol, timeframe ) {
64 |
65 | Init( period, method, appliedPrice );
66 | }
67 |
68 | void CIndicatorMA::Init( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice ) {
69 |
70 | if ( mInitResult != INIT_SUCCEEDED ) return;
71 |
72 | mPeriod = period;
73 | mMethod = method;
74 | mAppliedPrice = appliedPrice;
75 |
76 | // For MQL5 create the indicator handle here
77 | #ifdef __MQL5__
78 | mIndicatorHandle = iMA( mSymbol, mTimeframe, mPeriod, 0, mMethod, mAppliedPrice );
79 | if ( mIndicatorHandle == INVALID_HANDLE ) {
80 | InitError( "Failed to create indicator handle", INIT_FAILED );
81 | return;
82 | }
83 | #endif
84 |
85 | InitError( "", INIT_SUCCEEDED );
86 | }
87 |
88 | CIndicatorMA::~CIndicatorMA() {}
89 |
90 | #ifdef __MQL4__
91 | double CIndicatorMA::GetData( const int buffer_num, const int index ) {
92 |
93 | double value = iMA( mSymbol, mTimeframe, mPeriod, 0, mMethod, mAppliedPrice, index );
94 | return ( value );
95 | }
96 | #endif
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Indicators/IndicatorRSI.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorRSI.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | class CIndicatorRSI : public CIndicatorBase {
34 |
35 | private:
36 | protected: // member variables
37 | int mPeriod;
38 | ENUM_MA_METHOD mMethod;
39 | ENUM_APPLIED_PRICE mAppliedPrice;
40 |
41 | void Init( int period, ENUM_APPLIED_PRICE appliedPrice );
42 |
43 | public: // constructors
44 | CIndicatorRSI( int period, ENUM_APPLIED_PRICE appliedPrice );
45 | CIndicatorRSI( string symbol, ENUM_TIMEFRAMES timeframe, int period,
46 | ENUM_APPLIED_PRICE appliedPrice );
47 | ~CIndicatorRSI();
48 |
49 | public:
50 | #ifdef __MQL4__
51 | virtual double GetData( const int buffer_num, const int index );
52 | #endif
53 | };
54 |
55 | CIndicatorRSI::CIndicatorRSI( int period, ENUM_APPLIED_PRICE appliedPrice )
56 | : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
57 |
58 | Init( period, appliedPrice );
59 | }
60 |
61 | CIndicatorRSI::CIndicatorRSI( string symbol, ENUM_TIMEFRAMES timeframe, int period,
62 | ENUM_APPLIED_PRICE appliedPrice )
63 | : CIndicatorBase( symbol, timeframe ) {
64 |
65 | Init( period, appliedPrice );
66 | }
67 |
68 | void CIndicatorRSI::Init( int period, ENUM_APPLIED_PRICE appliedPrice ) {
69 |
70 | if ( mInitResult != INIT_SUCCEEDED ) return;
71 |
72 | mPeriod = period;
73 | mAppliedPrice = appliedPrice;
74 |
75 | // For MQL5 create the indicator handle here
76 | #ifdef __MQL5__
77 | mIndicatorHandle = iRSI( mSymbol, mTimeframe, mPeriod, mAppliedPrice );
78 | if ( mIndicatorHandle == INVALID_HANDLE ) {
79 | InitError( "Failed to create indicator handle", INIT_FAILED );
80 | return;
81 | }
82 | #endif
83 |
84 | InitError( "", INIT_SUCCEEDED );
85 | }
86 |
87 | CIndicatorRSI::~CIndicatorRSI() {}
88 |
89 | #ifdef __MQL4__
90 | double CIndicatorRSI::GetData( const int buffer_num, const int index ) {
91 |
92 | double value = iRSI( mSymbol, mTimeframe, mPeriod, mAppliedPrice, index );
93 | return ( value );
94 | }
95 | #endif
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Indicators/Indicators.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * Indicators.mqh
3 | *
4 | * Copyright 2022 Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | /*
32 | * This file is only to have a common place to load all indicators
33 | *
34 | */
35 |
36 | #include "IndicatorBase.mqh"
37 |
38 | #include "IndicatorFractal.mqh"
39 | #include "IndicatorHA.mqh"
40 | #include "IndicatorMA.mqh"
41 | #include "IndicatorMACD.mqh"
42 | #include "IndicatorRSI.mqh"
43 | #include "IndicatorStochastic.mqh"
44 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Trade/PositionInfo.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo.mqh
4 | Framework 3.01
5 |
6 | Copyright 2013-2022, Orchard Forex
7 | https://www.orchardforex.com
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | #property copyright "Copyright 2021, Orchard Forex"
35 | #property link "https://orchardforex.com"
36 | #property version "1.01"
37 | #property strict
38 |
39 | #ifdef __MQL4__
40 | #include "PositionInfo_mql4.mqh"
41 | #endif
42 | #ifdef __MQL5__
43 | #include "PositionInfo_mql5.mqh"
44 | #endif
45 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Trade/PositionInfo_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo_mql4.mqh
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2021, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.01"
36 | #property strict
37 |
38 | #include "../Common/Defines.mqh"
39 |
40 | class CPositionInfo {
41 |
42 | public:
43 | bool SelectByIndex( int index );
44 |
45 | int Magic() { return ( OrderMagicNumber() ); }
46 | ENUM_POSITION_TYPE PositionType() { return ( ( ENUM_POSITION_TYPE )OrderType() ); }
47 | double PriceOpen() { return ( OrderOpenPrice() ); }
48 | double StopLoss() { return ( OrderStopLoss() ); }
49 | string Symbol() { return ( OrderSymbol() ); }
50 | double TakeProfit() { return ( OrderTakeProfit() ); }
51 | int Ticket() { return ( OrderTicket() ); }
52 | };
53 |
54 | /*
55 | * CPositionInfoCustom::SelectByIndex
56 | * Select an order by indexed position
57 | * @param - index : index position of order to select
58 | * @return - ticket number : 0 if the order is not buy/sell or is closed or not found
59 | */
60 | bool CPositionInfo::SelectByIndex( int index ) {
61 |
62 | if ( !OrderSelect( index, SELECT_BY_POS, MODE_TRADES ) ) return ( false );
63 | if ( OrderType() != ORDER_TYPE_BUY && OrderType() != ORDER_TYPE_SELL ) return ( false );
64 | if ( OrderCloseTime() > 0 ) return ( false );
65 | return ( OrderTicket() > 0 );
66 | }
67 |
68 | class CPositionInfoCustom : public CPositionInfo {
69 |
70 | public:
71 | int Total() { return ( OrdersTotal() ); }
72 | };
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Trade/PositionInfo_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | PositionInfo_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CPositionInfoCustom : public CPositionInfo {
36 |
37 | public:
38 | int Total() { return ( PositionsTotal() ); }
39 | };
40 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.05/Trade/Trade.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Trade_mql4.mqh"
35 | #endif
36 | #ifdef __MQL5__
37 | #include "Trade_mql5.mqh"
38 | #endif
39 |
40 | #include "PositionInfo.mqh"
41 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Common/CommonBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | CommonBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | #include "Defines.mqh"
36 |
37 | #define _INIT_CHECK_FAIL \
38 | if ( mInitResult != INIT_SUCCEEDED ) return ( mInitResult );
39 | #define _INIT_ERROR( msg ) return ( InitError( msg, INIT_PARAMETERS_INCORRECT ) );
40 | #define _INIT_ASSERT( condition, msg ) \
41 | if ( !condition ) return ( InitError( msg, INIT_FAILED ) );
42 |
43 | class CCommonBase : public CObject {
44 |
45 | private:
46 | protected: // Members
47 | int mDigits;
48 | string mSymbol;
49 | ENUM_TIMEFRAMES mTimeframe;
50 |
51 | string mInitMessage;
52 | int mInitResult;
53 |
54 | protected: // Constructors
55 | //
56 | // Constructors
57 | //
58 | CCommonBase() { Init( _Symbol, ( ENUM_TIMEFRAMES )_Period ); }
59 | CCommonBase( string symbol ) { Init( symbol, ( ENUM_TIMEFRAMES )_Period ); }
60 | CCommonBase( int timeframe ) { Init( _Symbol, ( ENUM_TIMEFRAMES )timeframe ); }
61 | CCommonBase( ENUM_TIMEFRAMES timeframe ) { Init( _Symbol, timeframe ); }
62 | CCommonBase( string symbol, int timeframe ) { Init( symbol, ( ENUM_TIMEFRAMES )timeframe ); }
63 | CCommonBase( string symbol, ENUM_TIMEFRAMES timeframe ) { Init( symbol, timeframe ); }
64 |
65 | //
66 | // Destructors
67 | //
68 | ~CCommonBase(){};
69 |
70 | int Init( string symbol, ENUM_TIMEFRAMES timeframe );
71 |
72 | protected: // Functions
73 | int InitError( string initMessage, int initResult ) {
74 | mInitMessage = initMessage;
75 | mInitResult = initResult;
76 | if ( initMessage != "" ) Print( initMessage );
77 | return ( initResult );
78 | }
79 |
80 | double PointsToDouble( int points ) {
81 | return ( points * SymbolInfoDouble( mSymbol, SYMBOL_POINT ) );
82 | }
83 |
84 | public: // Properties
85 | int InitResult() { return ( mInitResult ); }
86 | string InitMessage() { return ( mInitMessage ); }
87 |
88 | public: // Functions
89 | };
90 |
91 | int CCommonBase::Init( string symbol, ENUM_TIMEFRAMES timeframe ) {
92 |
93 | InitError( "", INIT_SUCCEEDED );
94 |
95 | mSymbol = symbol;
96 | mTimeframe = timeframe;
97 | mDigits = ( int )SymbolInfoInteger( symbol, SYMBOL_DIGITS );
98 |
99 | return ( INIT_SUCCEEDED );
100 | }
101 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Common/Defines.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Defines_mql4.mqh"
35 | #endif
36 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Common/Defines_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines_mql4
3 | Framework version 3.00
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | enum ENUM_POSITION_TYPE
34 | {
35 | POSITION_TYPE_BUY,
36 | POSITION_TYPE_SELL
37 | };
38 |
39 | // Some return code definitions
40 | enum ENUM_TRADE_RETCODES
41 | {
42 | TRADE_RETCODE_INVALID = 10013, // Invalid request
43 | };
44 |
45 | // To handle the changes of buffer names, will grow as needed
46 | enum ENUM_INDICATOR_BUFFERS
47 | {
48 | MAIN_LINE = MODE_MAIN,
49 | SIGNAL_LINE = MODE_SIGNAL,
50 | };
51 |
52 | enum ENUM_ORDER_TYPE_TIME
53 | {
54 | ORDER_TIME_GTC,
55 | ORDER_TIME_DAY,
56 | ORDER_TIME_SPECIFIED,
57 | ORDER_TIME_SPECIFIED_DAY,
58 | };
59 |
60 | struct MqlTradeRequest
61 | {
62 | int action; // Trade operation type (as int here)
63 | ulong magic; // Expert Advisor ID (magic number)
64 | ulong order; // Order ticket
65 | string symbol; // Trade symbol
66 | double volume; // Requested volume for a deal in lots
67 | double price; // Price
68 | double stoplimit; // StopLimit level of the order
69 | double sl; // Stop Loss level of the order
70 | double tp; // Take Profit level of the order
71 | ulong deviation; // Maximal possible deviation from the requested price
72 | ENUM_ORDER_TYPE type; // Order type
73 | int type_filling; // Order execution type (int here)
74 | int type_time; // Order expiration type (int here)
75 | datetime expiration; // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
76 | string comment; // Order comment
77 | ulong position; // Position ticket
78 | ulong position_by; // The ticket of an opposite position
79 | };
80 |
81 | struct MqlTradeResult
82 | {
83 | uint retcode; // Operation return code
84 | ulong deal; // Deal ticket, if it is performed
85 | ulong order; // Order ticket, if it is placed
86 | double volume; // Deal volume, confirmed by broker
87 | double price; // Deal price, confirmed by broker
88 | double bid; // Current Bid price
89 | double ask; // Current Ask price
90 | string comment; // Broker comment to operation (by default it is filled by description of trade
91 | // server return code)
92 | uint request_id; // Request ID set by the terminal during the dispatch
93 | uint retcode_external; // Return code of an external trading system
94 | };
95 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Expert/Expert.mqh:
--------------------------------------------------------------------------------
1 | /** Disclaimer and Licence
2 |
3 | * This file is free software: you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation, either version 3 of the License, or
6 | * (at your option) any later version.
7 |
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 |
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program. If not, see .
15 |
16 | * All trading involves risk. You should have received the risk warnings
17 | * and terms of use in the README.MD file distributed with this software.
18 | * See the README.MD file for more information and before using this software.
19 |
20 | **/
21 | /**=
22 | *
23 | * Disclaimer and Licence
24 | *
25 | * This file is free software: you can redistribute it and/or modify
26 | * it under the terms of the GNU General Public License as published by
27 | * the Free Software Foundation, either version 3 of the License, or
28 | * (at your option) any later version.
29 | *
30 | * This program is distributed in the hope that it will be useful,
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 | * GNU General Public License for more details.
34 | *
35 | * You should have received a copy of the GNU General Public License
36 | * along with this program. If not, see .
37 | *
38 | * All trading involves risk. You should have received the risk warnings
39 | * and terms of use in the README.MD file distributed with this software.
40 | * See the README.MD file for more information and before using this software.
41 | *
42 | **/
43 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Expert/LegBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | LegBase.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include "ExpertBase.mqh"
34 |
35 | class CLegBase : public CExpertBase {
36 |
37 | private:
38 | protected:
39 | ENUM_POSITION_TYPE mLegType;
40 |
41 | public:
42 | CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic );
43 | ~CLegBase() {}
44 | };
45 |
46 | CLegBase::CLegBase( ENUM_POSITION_TYPE legType, double orderSize, string tradeComment, long magic )
47 | : CExpertBase( orderSize, tradeComment, magic ) {
48 |
49 | mLegType = legType;
50 | }
51 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Framework.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Framework.mqh
3 | Framework 3.06
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | /*
35 | * V3.06
36 | * Added ResultPrice() to mql4 CTradeCustom
37 | *
38 | */
39 |
40 | #ifndef FRAMEWORK_VERSION
41 | #define FRAMEWORK_VERSION
42 | #define FRAMEWORK_VERSION_3_06
43 | #endif
44 |
45 | #ifdef FRAMEWORK_VERSION_3_06
46 |
47 | #include "Common/CommonBase.mqh"
48 | #include "Expert/ExpertBase.mqh"
49 | #include "Expert/LegBase.mqh"
50 | #include "Indicators/Indicators.mqh"
51 | #include "Trade/Trade.mqh"
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Indicators/IndicatorBands.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorBands.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | #include "IndicatorBase.mqh"
10 |
11 | class CIndicatorBands : public CIndicatorBase {
12 |
13 | private:
14 |
15 | protected: // member variables
16 | int mPeriod;
17 | double mDeviation;
18 | ENUM_APPLIED_PRICE mAppliedPrice;
19 |
20 | void Init( int period, double deviation, ENUM_APPLIED_PRICE appliedPrice );
21 |
22 | public: // constructors
23 | CIndicatorBands( int period, double deviation, ENUM_APPLIED_PRICE appliedPrice );
24 | CIndicatorBands( string symbol, ENUM_TIMEFRAMES timeframe, int period, double deviation, ENUM_APPLIED_PRICE appliedPrice );
25 | ~CIndicatorBands();
26 |
27 | public:
28 |
29 | };
30 |
31 | CIndicatorBands::CIndicatorBands( int period, double deviation, ENUM_APPLIED_PRICE appliedPrice ) : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
32 | Init( period, deviation, appliedPrice );
33 | }
34 |
35 | CIndicatorBands::CIndicatorBands( string symbol, ENUM_TIMEFRAMES timeframe, int period, double deviation, ENUM_APPLIED_PRICE appliedPrice ) : CIndicatorBase( symbol, timeframe ) {
36 | Init( period, deviation, appliedPrice );
37 | }
38 |
39 | void CIndicatorBands::Init( int period, double deviation, ENUM_APPLIED_PRICE appliedPrice ) {
40 |
41 | if ( mInitResult != INIT_SUCCEEDED ) return;
42 |
43 | mPeriod = period;
44 | mDeviation = deviation;
45 | mAppliedPrice = appliedPrice;
46 |
47 | // For MQL5 create the indicator handle here
48 |
49 | mIndicatorHandle = iBands( mSymbol, mTimeframe, mPeriod, 0, mDeviation, mAppliedPrice );
50 | if ( mIndicatorHandle == INVALID_HANDLE ) {
51 | InitError( "Failed to create indicator handle", INIT_FAILED );
52 | return;
53 | }
54 |
55 | InitError( "", INIT_SUCCEEDED );
56 | }
57 |
58 | CIndicatorBands::~CIndicatorBands() {}
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Indicators/IndicatorBase.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | IndicatorBase.mqh
3 |
4 | Copyright 2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "../Common/CommonBase.mqh"
32 | #include "../Common/Defines.mqh"
33 |
34 | class CIndicatorBase : public CCommonBase {
35 |
36 | private:
37 | protected: // member variables
38 | // Only used for MQL5 but will not hurt MQL4 to be defined
39 | int mIndicatorHandle;
40 |
41 | public: // constructors
42 | CIndicatorBase() : CCommonBase() { Init(); }
43 | CIndicatorBase( string symbol, ENUM_TIMEFRAMES timeframe ) : CCommonBase( symbol, timeframe ) {
44 | Init();
45 | }
46 | ~CIndicatorBase();
47 |
48 | int Init();
49 |
50 | public:
51 | virtual double GetData( const int index ) { return ( GetData( 0, index ) ); }
52 | virtual double GetData( const int bufferNum, const int index );
53 | int handle() { return ( mIndicatorHandle ); }
54 | };
55 |
56 | CIndicatorBase::~CIndicatorBase() {
57 |
58 | #ifdef __MQL5__
59 |
60 | if ( mIndicatorHandle != INVALID_HANDLE ) IndicatorRelease( mIndicatorHandle );
61 |
62 | #endif
63 | }
64 |
65 | int CIndicatorBase::Init() {
66 |
67 | if ( InitResult() != INIT_SUCCEEDED ) return ( InitResult() );
68 |
69 | #ifdef __MQL5__
70 | // Clean up here in case of a restart
71 | if ( mIndicatorHandle != INVALID_HANDLE ) IndicatorRelease( mIndicatorHandle );
72 | #endif
73 | mIndicatorHandle = INVALID_HANDLE;
74 |
75 | return ( INIT_SUCCEEDED );
76 | }
77 |
78 | #ifdef __MQL5__
79 | double CIndicatorBase::GetData( const int buffer_num, const int index ) {
80 |
81 | double value = 0;
82 |
83 | // Get data from a buffer for MQL5
84 | // Improve all of this later when there is a need for an array of results
85 | double bufferData[];
86 | ArraySetAsSeries( bufferData, true );
87 | int cnt = CopyBuffer( mIndicatorHandle, buffer_num, index, 1, bufferData );
88 | if ( cnt > 0 ) value = bufferData[0];
89 |
90 | return ( value );
91 | }
92 | #endif
93 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Indicators/IndicatorFractal.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorFractal.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | class CIndicatorFractal : public CIndicatorBase {
34 |
35 | private:
36 | protected: // member variables
37 | void Init();
38 |
39 | public: // constructors
40 | CIndicatorFractal();
41 | CIndicatorFractal( string symbol, ENUM_TIMEFRAMES timeframe );
42 | ~CIndicatorFractal();
43 |
44 | public:
45 | #ifdef __MQL4__
46 | virtual double GetData( const int buffer_num, const int index );
47 | #endif
48 | };
49 |
50 | CIndicatorFractal::CIndicatorFractal() : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
51 |
52 | Init();
53 | }
54 |
55 | CIndicatorFractal::CIndicatorFractal( string symbol, ENUM_TIMEFRAMES timeframe )
56 | : CIndicatorBase( symbol, timeframe ) {
57 |
58 | Init();
59 | }
60 |
61 | void CIndicatorFractal::Init() {
62 |
63 | if ( mInitResult != INIT_SUCCEEDED ) return;
64 |
65 | // For MQL5 create the indicator handle here
66 | #ifdef __MQL5__
67 | mIndicatorHandle = iFractals( mSymbol, mTimeframe );
68 | if ( mIndicatorHandle == INVALID_HANDLE ) {
69 | InitError( "Failed to create indicator handle", INIT_FAILED );
70 | return;
71 | }
72 | #endif
73 |
74 | InitError( "", INIT_SUCCEEDED );
75 | }
76 |
77 | CIndicatorFractal::~CIndicatorFractal() {}
78 |
79 | #ifdef __MQL4__
80 | double CIndicatorFractal::GetData( const int buffer_num, const int index ) {
81 |
82 | return ( iFractals( mSymbol, mTimeframe, buffer_num, index ) );
83 | }
84 | #endif
85 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Indicators/IndicatorHA.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | IndicatorHA.mqh
3 |
4 | Copyright 2022, Orchard Forex
5 | https://www.orchardforex.com
6 |
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | #ifdef __MQL4__
34 | #define HAIndicator "Indicators\\Heiken Ashi.ex4"
35 | #endif
36 | #ifdef __MQL5__
37 | #define HAIndicator "Indicators\\Examples\\Heiken_Ashi.ex5"
38 | #endif
39 | #resource "\\" + HAIndicator
40 |
41 | enum ENUM_HA_BUFFER
42 | {
43 | #ifdef __MQL4__
44 | HA_BUFFER_LOHI,
45 | HA_BUFFER_HILO,
46 | HA_BUFFER_OPEN,
47 | HA_BUFFER_CLOSE,
48 | #endif
49 | #ifdef __MQL5__
50 | HA_BUFFER_OPEN,
51 | HA_BUFFER_HILO,
52 | HA_BUFFER_LOHI,
53 | HA_BUFFER_CLOSE,
54 | #endif
55 | };
56 |
57 | class CIndicatorHA : public CIndicatorBase {
58 |
59 | private:
60 | protected: // member variables
61 | void Init();
62 |
63 | public: // constructors
64 | CIndicatorHA();
65 | CIndicatorHA( string symbol, ENUM_TIMEFRAMES timeframe );
66 | ~CIndicatorHA();
67 |
68 | public:
69 | #ifdef __MQL4__
70 | virtual double GetData( const int buffer_num, const int index );
71 | #endif
72 | };
73 |
74 | CIndicatorHA::CIndicatorHA() : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) { Init(); }
75 |
76 | CIndicatorHA::CIndicatorHA( string symbol, ENUM_TIMEFRAMES timeframe )
77 | : CIndicatorBase( symbol, timeframe ) {
78 |
79 | Init();
80 | }
81 |
82 | void CIndicatorHA::Init() {
83 |
84 | if ( mInitResult != INIT_SUCCEEDED ) return;
85 |
86 | // For MQL5 create the indicator handle here
87 | #ifdef __MQL5__
88 | mIndicatorHandle = iCustom( mSymbol, mTimeframe, "::" + HAIndicator );
89 | if ( mIndicatorHandle == INVALID_HANDLE ) {
90 | InitError( "Failed to create indicator handle", INIT_FAILED );
91 | return;
92 | }
93 | #endif
94 |
95 | InitError( "", INIT_SUCCEEDED );
96 | }
97 |
98 | CIndicatorHA::~CIndicatorHA() {}
99 |
100 | #ifdef __MQL4__
101 | double CIndicatorHA::GetData( const int buffer_num, const int index ) {
102 |
103 | return ( iCustom( mSymbol, mTimeframe, "::" + HAIndicator, buffer_num, index ) );
104 | }
105 | #endif
106 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Indicators/IndicatorMA.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorMA.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | class CIndicatorMA : public CIndicatorBase {
34 |
35 | private:
36 | protected: // member variables
37 | int mPeriod;
38 | ENUM_MA_METHOD mMethod;
39 | ENUM_APPLIED_PRICE mAppliedPrice;
40 |
41 | void Init( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice );
42 |
43 | public: // constructors
44 | CIndicatorMA( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice );
45 | CIndicatorMA( string symbol, ENUM_TIMEFRAMES timeframe, int period, ENUM_MA_METHOD method,
46 | ENUM_APPLIED_PRICE appliedPrice );
47 | ~CIndicatorMA();
48 |
49 | public:
50 | #ifdef __MQL4__
51 | virtual double GetData( const int buffer_num, const int index );
52 | #endif
53 | };
54 |
55 | CIndicatorMA::CIndicatorMA( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice )
56 | : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
57 |
58 | Init( period, method, appliedPrice );
59 | }
60 |
61 | CIndicatorMA::CIndicatorMA( string symbol, ENUM_TIMEFRAMES timeframe, int period,
62 | ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice )
63 | : CIndicatorBase( symbol, timeframe ) {
64 |
65 | Init( period, method, appliedPrice );
66 | }
67 |
68 | void CIndicatorMA::Init( int period, ENUM_MA_METHOD method, ENUM_APPLIED_PRICE appliedPrice ) {
69 |
70 | if ( mInitResult != INIT_SUCCEEDED ) return;
71 |
72 | mPeriod = period;
73 | mMethod = method;
74 | mAppliedPrice = appliedPrice;
75 |
76 | // For MQL5 create the indicator handle here
77 | #ifdef __MQL5__
78 | mIndicatorHandle = iMA( mSymbol, mTimeframe, mPeriod, 0, mMethod, mAppliedPrice );
79 | if ( mIndicatorHandle == INVALID_HANDLE ) {
80 | InitError( "Failed to create indicator handle", INIT_FAILED );
81 | return;
82 | }
83 | #endif
84 |
85 | InitError( "", INIT_SUCCEEDED );
86 | }
87 |
88 | CIndicatorMA::~CIndicatorMA() {}
89 |
90 | #ifdef __MQL4__
91 | double CIndicatorMA::GetData( const int buffer_num, const int index ) {
92 |
93 | double value = iMA( mSymbol, mTimeframe, mPeriod, 0, mMethod, mAppliedPrice, index );
94 | return ( value );
95 | }
96 | #endif
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Indicators/IndicatorRSI.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * IndicatorRSI.mqh
3 | *
4 | * Copyright 2022, Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | #include "IndicatorBase.mqh"
32 |
33 | class CIndicatorRSI : public CIndicatorBase {
34 |
35 | private:
36 | protected: // member variables
37 | int mPeriod;
38 | ENUM_MA_METHOD mMethod;
39 | ENUM_APPLIED_PRICE mAppliedPrice;
40 |
41 | void Init( int period, ENUM_APPLIED_PRICE appliedPrice );
42 |
43 | public: // constructors
44 | CIndicatorRSI( int period, ENUM_APPLIED_PRICE appliedPrice );
45 | CIndicatorRSI( string symbol, ENUM_TIMEFRAMES timeframe, int period,
46 | ENUM_APPLIED_PRICE appliedPrice );
47 | ~CIndicatorRSI();
48 |
49 | public:
50 | #ifdef __MQL4__
51 | virtual double GetData( const int buffer_num, const int index );
52 | #endif
53 | };
54 |
55 | CIndicatorRSI::CIndicatorRSI( int period, ENUM_APPLIED_PRICE appliedPrice )
56 | : CIndicatorBase( Symbol(), ( ENUM_TIMEFRAMES )Period() ) {
57 |
58 | Init( period, appliedPrice );
59 | }
60 |
61 | CIndicatorRSI::CIndicatorRSI( string symbol, ENUM_TIMEFRAMES timeframe, int period,
62 | ENUM_APPLIED_PRICE appliedPrice )
63 | : CIndicatorBase( symbol, timeframe ) {
64 |
65 | Init( period, appliedPrice );
66 | }
67 |
68 | void CIndicatorRSI::Init( int period, ENUM_APPLIED_PRICE appliedPrice ) {
69 |
70 | if ( mInitResult != INIT_SUCCEEDED ) return;
71 |
72 | mPeriod = period;
73 | mAppliedPrice = appliedPrice;
74 |
75 | // For MQL5 create the indicator handle here
76 | #ifdef __MQL5__
77 | mIndicatorHandle = iRSI( mSymbol, mTimeframe, mPeriod, mAppliedPrice );
78 | if ( mIndicatorHandle == INVALID_HANDLE ) {
79 | InitError( "Failed to create indicator handle", INIT_FAILED );
80 | return;
81 | }
82 | #endif
83 |
84 | InitError( "", INIT_SUCCEEDED );
85 | }
86 |
87 | CIndicatorRSI::~CIndicatorRSI() {}
88 |
89 | #ifdef __MQL4__
90 | double CIndicatorRSI::GetData( const int buffer_num, const int index ) {
91 |
92 | double value = iRSI( mSymbol, mTimeframe, mPeriod, mAppliedPrice, index );
93 | return ( value );
94 | }
95 | #endif
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Indicators/Indicators.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | * Indicators.mqh
3 | *
4 | * Copyright 2022 Orchard Forex
5 | * https://orchardforex.com
6 | *
7 | */
8 |
9 | /**=
10 | *
11 | * Disclaimer and Licence
12 | *
13 | * This file is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program. If not, see .
25 | *
26 | * All trading involves risk. You should have received the risk warnings
27 | * and terms of use in the README.MD file distributed with this software.
28 | * See the README.MD file for more information and before using this software.
29 | *
30 | **/
31 | /*
32 | * This file is only to have a common place to load all indicators
33 | *
34 | */
35 |
36 | #include "IndicatorBase.mqh"
37 |
38 | #include "IndicatorFractal.mqh"
39 | #include "IndicatorHA.mqh"
40 | #include "IndicatorMA.mqh"
41 | #include "IndicatorMACD.mqh"
42 | #include "IndicatorRSI.mqh"
43 | #include "IndicatorStochastic.mqh"
44 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Trade/PositionInfo.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo.mqh
4 | Framework 3.01
5 |
6 | Copyright 2013-2022, Orchard Forex
7 | https://www.orchardforex.com
8 |
9 | */
10 |
11 | /**=
12 | *
13 | * Disclaimer and Licence
14 | *
15 | * This file is free software: you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation, either version 3 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program. If not, see .
27 | *
28 | * All trading involves risk. You should have received the risk warnings
29 | * and terms of use in the README.MD file distributed with this software.
30 | * See the README.MD file for more information and before using this software.
31 | *
32 | **/
33 |
34 | #property copyright "Copyright 2021, Orchard Forex"
35 | #property link "https://orchardforex.com"
36 | #property version "1.01"
37 | #property strict
38 |
39 | #ifdef __MQL4__
40 | #include "PositionInfo_mql4.mqh"
41 | #endif
42 | #ifdef __MQL5__
43 | #include "PositionInfo_mql5.mqh"
44 | #endif
45 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Trade/PositionInfo_mql4.mqh:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | PositionInfo_mql4.mqh
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #property copyright "Copyright 2021, Orchard Forex"
34 | #property link "https://orchardforex.com"
35 | #property version "1.01"
36 | #property strict
37 |
38 | #include "../Common/Defines.mqh"
39 |
40 | class CPositionInfo {
41 |
42 | public:
43 | bool SelectByIndex( int index );
44 |
45 | int Magic() { return ( OrderMagicNumber() ); }
46 | ENUM_POSITION_TYPE PositionType() { return ( ( ENUM_POSITION_TYPE )OrderType() ); }
47 | double PriceOpen() { return ( OrderOpenPrice() ); }
48 | double StopLoss() { return ( OrderStopLoss() ); }
49 | string Symbol() { return ( OrderSymbol() ); }
50 | double TakeProfit() { return ( OrderTakeProfit() ); }
51 | int Ticket() { return ( OrderTicket() ); }
52 | };
53 |
54 | /*
55 | * CPositionInfoCustom::SelectByIndex
56 | * Select an order by indexed position
57 | * @param - index : index position of order to select
58 | * @return - ticket number : 0 if the order is not buy/sell or is closed or not found
59 | */
60 | bool CPositionInfo::SelectByIndex( int index ) {
61 |
62 | if ( !OrderSelect( index, SELECT_BY_POS, MODE_TRADES ) ) return ( false );
63 | if ( OrderType() != ORDER_TYPE_BUY && OrderType() != ORDER_TYPE_SELL ) return ( false );
64 | if ( OrderCloseTime() > 0 ) return ( false );
65 | return ( OrderTicket() > 0 );
66 | }
67 |
68 | class CPositionInfoCustom : public CPositionInfo {
69 |
70 | public:
71 | int Total() { return ( OrdersTotal() ); }
72 | };
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Trade/PositionInfo_mql5.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | PositionInfo_mql5.mqh
3 | Framework 3.01
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #include
34 |
35 | class CPositionInfoCustom : public CPositionInfo {
36 |
37 | public:
38 | int Total() { return ( PositionsTotal() ); }
39 | };
40 |
--------------------------------------------------------------------------------
/Include/Orchard/Frameworks/Framework_3.06/Trade/Trade.mqh:
--------------------------------------------------------------------------------
1 | /*
2 | Trade.mqh
3 | Framework 3.06
4 |
5 | Copyright 2013-2022, Orchard Forex
6 | https://www.orchardforex.com
7 |
8 | */
9 |
10 | /**=
11 | *
12 | * Disclaimer and Licence
13 | *
14 | * This file is free software: you can redistribute it and/or modify
15 | * it under the terms of the GNU General Public License as published by
16 | * the Free Software Foundation, either version 3 of the License, or
17 | * (at your option) any later version.
18 | *
19 | * This program is distributed in the hope that it will be useful,
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | * GNU General Public License for more details.
23 | *
24 | * You should have received a copy of the GNU General Public License
25 | * along with this program. If not, see .
26 | *
27 | * All trading involves risk. You should have received the risk warnings
28 | * and terms of use in the README.MD file distributed with this software.
29 | * See the README.MD file for more information and before using this software.
30 | *
31 | **/
32 |
33 | #ifdef __MQL4__
34 | #include "Trade_mql4.mqh"
35 | #endif
36 | #ifdef __MQL5__
37 | #include "Trade_mql5.mqh"
38 | #endif
39 |
40 | #include "PositionInfo.mqh"
41 |
--------------------------------------------------------------------------------