A System: Code Sample 1
Files:
a.mq4
24 kb
Introduction
1. A System is MQL4 automation for MetaTrader 4 Client Terminal.
2. A System: Code Sample 1 introduces A System: Core Principles methodology.
3. The similar code structure was used in Automation sample for the MetaTrader 4 Client Terminal.
4. A System: Code Sample 1 features:
4.1. A System controls computing run time and processor usage;
4.2. A System can start and run correctly when market is off;
4.3. A System has convenient and reliable exception handler.
Instructions
1. Copy A System: Code Sample 1 to MetaEditor.
2. Adiust MetaEditor window size to 122 columns x 45 lines.
3. Use <Page Up> and <Page Down> keys for the code navigation.
4. Tags //<*> must remain on their screen positions.
int init () { A.System () ; }
int start () { A.System () ; }
//< A.System: Structure >
// A.Memory: allocation 14 elements in 1 page
// A.Core: property 1 element in 1 page / function 4 / interface 3
// A.Module: property 1 element in 1 page / function 2 / interface 1
//</A.System: Structure >
//< A.Memory: Allocation 0001 >
#define ac.SystemName "A" // 0001
// 0002
string ac.State [ 2 ] = { "Off" , "On" } ; // 0003
#define ac.On 1 // 0004
#define ac.Off 0 // 0005
// 0006
string ac.Command [ 5 ] = { "Empty" , "Run" , "Wait" , "Lock" , "Reset" } ; // 0007
#define ac.Reset 4 // 0008
#define ac.Lock 3 // 0009
#define ac.Wait 2 // 0010
#define ac.Run 1 // 0011
#define ac.Empty 0 // 0012
// 0013
#define ac.Modules 4 // 0014
// 0015
int ac.RunLimit [ ] = { 0 , 25 , 25 , 25 , 25 } ; // 0016
// 0017
#define ac.RunPeriod 1000 // 0018
// 0019
#define ac.RunTimeout 2000 // 0020
//</A.Memory: Allocation 0001 >
//< A.Core: Structure >
//< property >
//< 0001> apr.Core.MainPage // int 1 + double 0 + string 0 = elements 1
//< 0002>
//< 0003>
//< 0004>
//< 0005>
//< 0006>
//< 0007>
//< 0008>
//< 0009>
//< 0010>
//</ property >
//< function >
//< 0001> afr.Core.TimerStart // input 0 / code 1 / output 0
//< 0002> afi.Core.TimerCount // input 0 / code 5 / output 1
//< 0003> afr.Core.TimerPause // input 1 / code 1 / output 0
//< 0004> afr.Core.TimerControl // input 0 / code 2 / output 0
//< 0005>
//< 0006>
//< 0007>
//< 0008>
//< 0009>
//< 0010>
//</ function >
//< interface >
//< 0001> aii.Core.State // input 0 / code 10 / output 1
//< 0002> aii.Core.Command // input 0 / code 12 / output 1
//< 0003> aii.Core.Exception // input 1 / code 9 / output 1
//< 0004>
//< 0005>
//< 0006>
//< 0007>
//< 0008>
//< 0009>
//< 0010>
//</ interface >
//</A.Core: Structure >
//< A.Core: Property 0001 >
//< head >
// apr.Core.MainPage // int 1 + double 0 + string 0 = elements 1
//
//
//
//
//
//< / head >
//< body >
int avi.Core.TimeStamp ; // 0001
// 0002
// 0003
// 0004
// 0005
// 0006
// 0007
// 0008
// 0009
// 0010
// 0011
// 0012
// 0013
// 0014
// 0015
// 0016
// 0017
// 0018
// 0019
// 0020
// 0021
// 0022
// 0023
// 0024
//</ body >
//</A.Core: Property 0001 >
//< A.Core: Function 0001 >
//< head >
int afr.Core.TimerStart ( // input 0 / code 1 / output 0
//
//
//
//
) //
//< / head >
{//< body >
avi.Core.TimeStamp = GetTickCount () ; // 01
}//</ body >
//</A.Core: Function 0001 >
//< A.Core: Function 0002 >
//< head >
int afi.Core.TimerCount ( // input 0 / code 5 / output 1
//
//
//
//
) //
//< / head >
{//< body >
static int ali.Result ; // 01
// 02
ali.Result = GetTickCount () - avi.Core.TimeStamp ; // 03
// 04
return ( ali.Result ) ; // 05
}//</ body >
//</A.Core: Function 0002 >
//< A.Core: Function 0003 >
//< head >
int afr.Core.TimerPause ( // input 1 / code 1 / output 0
//
int aai.Interval //
//
//
) //
//< / head >
{//< body >
Sleep ( aai.Interval ) ; // 01
}//</ body >
//</A.Core: Function 0003 >

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register