stereotradermt api referencehave full access to all functions of mql4/5 and in case if you are a...

51
StereoMQL API Reference 2.00 (V 2044)

Upload: others

Post on 15-Apr-2020

21 views

Category:

Documents


4 download

TRANSCRIPT

StereoMQLAPIReference2.00

(V2044)

2

Contents1.APIforDevelopers2.0 4

1.1 TheEstimator 41.2 Easycoding 51.3 ArchitectureofSEAs 51.4Stepstobuild 61.5Event-Processing 7

2.Processinglogic 112.1Orientation 112.2StereoTraderhostdata 13

3.Accessingbars 153.1The_Barsobject 15

3.1.1Basicdata 153.1.2Shapesandmeasuring 163.1.3Barinteractionandpattern 163.1.4Advanced 173.1.5Indications 17

3.2Singlebars 183.2.1Predefinedsinglebarobjects 183.2.2Dataofthecurrentbar 193.2.3BasicdataofsingleCBarobjects 203.2.4Memberfunctionsforshapesandmeasuring 213.1.5Barinteraction 22

4.Signals 234.1Setupfunctions 234.2Basiccommands 25

4.1.1Open/closepositions 254.1.2Blocking/Unblocking 26

4.2Pendingorders 264.2.1Ordersettings 274.2.2Ordermodification 28

4.3Managingtrades 284.3.1StereoFuturemode 284.3.2FunctionsforStereoHedgemode 294.3.3Commandsformanualexits 31

4.4Commandsforautomatedexits 334.5Commandsforstrategicorders 344.7Messages 36

3

4.8Otherfunctions 364.9APIvariables 37

4.9.1Common 374.9.2Tradingdata 38

4.10Statusrequests 394.11Sourcecodeexample 40

5.Drawing 425.1Drawinglines 425.2Drawingrectangles 425.3Drawingclusters 435.4Drawingarrows 435.5Drawinghighlightzones 435.6Drawingfilters 445.7Drawingtracelines 445.8Drawingtext 445.9Drawingcandles 44

6.Dialogfields 45

7.Notesforadvanceddevelopers 477.1Classframe 47

8.Furtherclasses&functionsoftheAPI 488.1CompatibilityMT4/MT5 488.2File__MT_native.mqh 488.3File__ChartExt.mqh 488.4FileXVars.mqh 488.5FileComment.mqh 49

Copyright/Impressum 50

4

1.APIforDevelopers2.0TheAPI2.0isnowcalledStereoMQLandisdedicatedtoallthosetradersanddevelopers,whoarelookingforaneasywaytodevelopautomations.AnyautomationswhicharecreatedusingStereoMQLarecompatibletoStereoTraderforMetaTrader4andMetaTrader5withoutanychanges.

AnyautomationswhicharecreatedforStereoTraderarecalledStereoExpertAdvisors (SEA).SuchanSEA isdevelopedasanindicatorwhichsendstradingsignalstoStereoTrader.

Onehand,theAPIitselfistheinterfacebutontheotherhandit isalsoaverypowerfulclassconstruct,whichmakesitveryeasytoevaluatebars, indicationsetc.andtobuiltautomatedprocessesinavery“human”way,whichisnormallynotavailabletoMetaTrader.

1.1 TheEstimatorStereoTradercomeswithamodulecalled“Estimator”.TheEstimatorallowsyoutobackteststrategiesvisually.Trades, including visualisation of trailing stops become visible in the chart, results are displayed on the flywithoutrunningtheStrategy-Tester.Thismakesisverycomfortabletodevelopandverifystrategies.Assoonasaparameter is changedat thepanel, theEstimatorvisualizes thechanges in thechart. The followingpictureshowstheRangeBreakOutstrategy,whichisincludedassamplewiththeAPI.

(StereoTraderwithEstimator–tradesbecomevisibleinthechart)

5

1.2 EasycodingAshortexample?ThefollowingcodeevaluatesthecurrentATR(averagetruerange)andopensaposition, ifthelastbarexceedstheATRtwice.

//+------------------------------------------------------------------+ //| Include the API and define the SEA | //+------------------------------------------------------------------+ #include <StereoTrader_API\StereoAPI.mqh> DECLARE_SEA_BEGIN("CandleATR01") //+------------------------------------------------------------------+ //| Iteration | //+------------------------------------------------------------------+ SEA_EVALUATE { //--- Get out if last bar is below ATR x 2.0 if (_LastBar.Range()<_Bars.ATR(14)* 2.0) return; //--- Bullish candle, buy ... else if (_LastBar.IsBullish()) Buy(); //--- Bearish candle, sell if (_LastBar.IsBearish()) Sell(); return; } //+------------------------------------------------------------------+ //| Indication | //+------------------------------------------------------------------+ SEA_INDICATE { // Optional drawing functions } //+------------------------------------------------------------------+ //| End declaration of StereoEA | //+------------------------------------------------------------------+ DECLARE_SEA_END

That´sit!

WithnativeMQL,thecodeforthesamepurposewouldbemorethanahundredlines.Butneverthelessyoustillhave full access to all functions of MQL4/5 and in case if you are a skilled programmer, there will be nolimitationsatall.

1.3 ArchitectureofSEAsTheAPIofStereoTraderisdesignedpurelyobjectoriented.Tounderstandthis,especiallyforthosewhoarenotfamiliarwithobjectorientedprogramming,thefollowingfigureshouldhelptodemonstratethelogic.

6

(Thesignalflow)

The blue box is the environment/scope, where “you” are. From here, you have direct access to any tradecommands,tradefunctions,tradevariablesandsoon.Therefore,ifacommande.g.forbuyingissend,thereisnoprefix.Example:

Buy(); Flat(); ...

Theotherobjectsrepresenttheelementsasdescribed.Wheneveryouaccessafunctionoftheseobjects,suchfunctioncallsarealwayspreceededbythenameoftheobject.Example:

double atr=_Bars.ATR(14,1);

And so on. This is how object oriented programming works – basically. The result is less code and betterunderstandingofthecode.

1.4StepstobuildThe API allows for very quick and very efficient development of Stereo Expert Advisors (SEAs) which areactuallyindicatorsthatsendtradecommandstotheStereoTrader,whichactsasahost.Allthiswithoutallthehassleofordermanagement,becausethisisdoneentirelybyStereoTrader.

TocreatesuchanSEA,usetheMetaTraderEditorandcreateanewindicator.Thenremoveallthecodeandusethefollowingbase:

1.IncludetheAPI

#include <StereoTrader_API\StereoAPI.mqh>

2.DeclaretheSEAusingthemacro

DECLARE_SEA_BEGIN(“My SEA”)

3.DefinethefunctionSEA_EVALUATEandevaluateyoursignalshere

SEA_EVALUATE { if (…)

Buy();

7

else Sell();

} 4.Attheendofthefile,usethemacro

DECLARE_SEA_END

Thisisallwhatneedstobecodedbasically.

(StereoTraderwithSampleSEAloaded,tradesarevisualizedbytheEstimator)

1.5Event-ProcessingThe code of every SEA is executed within event function blocks. Such functions are processed duringinitialization, timer processing orwhen the user changes a parameter. For each event there is a pre definedfunctionandthecodeshouldbelocatedonlywithinsuchfunctions.Everyfunctionisrepresentedbyamacro,theseareexplainedbelow.

Donotconfusewiththecomplexity. InmostcasesyouwillneedonlythemainfunctionswhichareSEA_INIT,SEA_INDICATE,SEA_EVALUATE.

SEA_INIT {}

Original:virtualboolOnInit(SSTData&_Host)

Executed one time at initialization/start of the SEA. This block is used for variableinitializationsandtosetupparametersoftheSEA.

Returnvalue:trueincaseofsuccess,falseifnot.

8

SEA_DEINIT {}

Original:virtualvoidOnDeinit(SSTData&_Host,constintreason)

ExecutedonetimebeforetheSEAisterminated

SEA_DEACTIVATE {}

Original:virtualvoidOnDeactivatet(SSTData&_Host)

Executed when SEA is deactivated, e. g. when AutoTrading was switched off. ThefunctionisalsoexecutedpriortoSEA_DEINIT.

SEA_RESET {}

Original:virtualvoidOnReset(SSTData&_Host)

Executed every time when the SEA is resetted. Such a reset occurs whenever thecalculation/indication becomes invalid. In other words, when the user changes aparameter at thepanel, at StereoTraderpanel etc.. The function is also executed afterSEA_INITduringthefirstreset.

SEA_INITPANEL {}

Original:virtualvoidOnInitPanel(SSTData&_Host)

ExecutedonetimebeforethefirstexecutionofSEA_EVALUATE

SEA_INDICATE {}

Original:virtualvoidOnIndicate(SSTData&_Host)

Executedwitheverybar.Usedforcalculationsanddrawings,doesNOTacceptanytradecommandssuchasBuy()orFlat()

SEA_EVALUATE {} *

Original:virtualvoidOnEvaluate(SSTData&_Host)

Executedwitheverybaror tick afterSEA_INDICATE.Shall beused for calculationsandtradecommandexecutionssuchasBuy(),BuyOrder(),Flat()etc.

SEA_TIMER {} *

Original:virtualvoidOnTimer(SSTData&_Host)

Executed on timer intervals, as specified by SetTimer() function during SEA_INIT. Thefunctiondoesalsoaccepttradecommands.

SEA_USER {} *

Original:virtualboolOnUserInput(SSTData&_Host)

9

Executed whenever the user changes a parameter at the SEA-panel or StereoTrader-panel,priortoSEA_RESET.Thefunctiondoesaccepttradecommands.

Returnvalue:trueifcalculationbecomesinvalidandaresetshalloccur

SEA_CHARTEVENT {}

Original:virtualvoidOnChartEvent(SSTData&_Host,const int id,const long& lparam,constdouble&dparam,conststring&sparam)

Executedwithanychart-eventandidenticaltotheMT4/MT5function.Pleaserefertothedocumentation of MetaTrader for additional information. The function parameters id,lparam,dparamandsparamarepassedasusualandreturncodeisvoid.

SEA_LOADDATA {}

Original:virtualvoidOnLoadData(SSTData&_Host)

ExecutedwhenSEAloadspresetdata.Youmayusethisfunctiontoloadadditionaldata,whichmayalsobesavedwiththepresetfile.Availablefunctionsare

double LoadDouble(void) bool LoadBool(void) int LoadInt(void) string LoadText(void)

Please note that all data is stored sequentially, therefore the order and count of dataduringloadingandsavingmustbealwaysidentical.

Ifyouneedtoaccessthepresetfileonyourown,thefilehandleisstoredinthevariablem_filehandle.

SEA_SAVEDATA {}

Original:virtualvoidOnSaveData(SSTData&_Host)

ExecutedwhenSEAsavespresetdata.Youmayusethisfunctiontosaveadditionaldata,whichmayalsobesavedwiththepresetfile.Availablefunctionsare

void SaveDouble(double value) void SaveBool(bool value) void SaveInt(int value) void SaveText(string value)

Please note that all data is stored sequentially, therefore the order and count of dataduringloadingandsavingmustbealwaysidentical.

Ifyouneedtoaccessthepresetfileonyourown,thefilehandleisstoredinthevariablem_filehandle.

SEA_LOADDEFAULT {}

Original:virtualvoidOnLoadDefault(SSTData&_Host)

10

ExecutedinsteadofSEA_LOADDATAwhenpresetfiledoesnotexist.

SEA_HOST {}

Original:virtualboolOnHost(SSTData&_Host)

ExecutedwhendatahaschangedinStereoTraderand_Hoststructurewasupdated

Returnvalue:trueifresetisgenerallypossibleafterexecution.

* All functions with an asterisk allow for the usage of trade commands

11

2.ProcessinglogicIt´salsonecessarytounderstandtheflowofprocessing,beforeyoustarttodevelopownstrategies.

Thereare twokey functions,SEA_INDICATEandSEA_EVALUATE.SEA_INDICATE is called foreverybar in thechart,SEA_EVALUATEisonlycalledwhenevaluationisrequested,e.g.whenautotradingisusedorestimationisactivated.

ThefunctionmacroSEA_INDICATEcanbeusedtoseparateindications,suchasdrawings,calculationsetc.fromevaluationprocesses.ThefunctionSEA_INDICATEiscalledonetimeforeachbar.

SEA_EVALUATEisprocessedforeverybarfromlefttorightwhichcouldproduceasignal.Incaseofoperatingtickbytick,SEA_EVALUATEiscalledoneverytick.Incaseofoperatingwithfinishedbarsonly,SEA_EVALUATEiscalledonlywhenanewbarisopened.

2.1OrientationAsmentioned before, the evaluation functions SEA_INDICATE and SEA_EVALUATE are processed per bar ortick,fromlefttoright,frompasttopresent.Inotherwords,you“are”alwaysatthe“current”bar,nomatterif“current”issomewhereinthepastorif it isthelastbarinthechart.Youdon´tneedtocareaboutit,theAPImanagesthisforyou.

Thebars in thechartare representedby the_Barsobject.The functionsof thisobjectmostly requireashiftvaluetoadressaspecificbaroraspecificsetofbars.Ashiftvalueofzero(default)pointstothecurrentbarwhicheitherhasjustbeenopened(finishedbarmode)orwhichisjustabouttobeprocessed(tickmode).

Thismethodof adressingbars is completelydifferent tonativeMQLprogramming,butmakes itmuchmoreeasytoproducereadableandcompactcode.

Forexample,ifyouwanttoevaluatetheATRoftherecentlyfinished14bars,thefunctioncallwouldjustbe:

int atr=_Bars.ATR(14,1);

Andifyouneedtoknowifthebarbeforethepreviouslyclosedbarisabullishhammer,thecodewouldbe:

if (_Bars.IsHammer(2) && _Bars.IsBullish(2)) ...

Additionaly,therearesomefunctionstosupporttheorientation:

12

IsFirstBar ()

returnstrueiftheveryfirstbar(leftside)isprocessed

IsLastBar ()

returnstrueiftheverylastbar(rightside)isprocessed

IsNewHour()

returnstrueifthecurrentbarstartsinanewhour

IsNewDay ()

returnstrueifthecurrentbarstartsinanewday

IsNewWeek()

returnstrueifthecurrentbarstartsinanewweek

IsNewBar ()

returnstrueifanewbarisbuiltandanotheroneisjustfinished.Ifonedoesnotoperateoneverytick,thisvalueisalwaystrue.

IsCurrentDay(int shift=0)

Trueifthedateoftheadressedbarisinthecurrentday(localtime)

IsCurrentWeek(int shift=0)

Trueiftheadressedbarisinthecurrentweek(localtime)

IsInPeriod(int days, int shift=0)

Trueiftheadressedbarisininatimerange,measuredfromlocaltimeuntilthespecifiednumberofdaysbackwars.Thisfunctionisuseful, ifan indicationshallbedisplayedonlyfore.g.14daysbackwards.

_BarsCount

Containsthenumberofallbarsinthechart

_Index

Containstheindexofthecurrentprocessedbarfromlefttoright,whereby0istheveryfirst bar on the left side. This variable may be used, if an SEA needs access to anarray/bufferwhichispartofanindicationbuiltinOnCalculate().

Forexample,thefollowingcodeisanextractfromanSEAwhichbuildsandvisualizestheATRbytheusageofOnCalculate()andstorestheresults intothebufferm_atr[].WithinSEA_EVALUATE,thebuffervaluesareaccessibledirectlyby_Index.

SEA_EVALUATE { double atr=m_atr[_Index]; }

_Shift

13

Currentshiftvalue,ifit´snecessarytocalculateindicationswhicharenotpartoftheAPI.Withoutanyheadache,it´seasytoaddadditionalcalculationswhicharebasedonnativeMQL.

SEA_EVALUATE { double mfi=iMFI(NULL,PERIOD_CURRENT,20,_Shift); }

2.2StereoTraderhostdataAstructurewhichcontainsmostrelevantdataoftheStereoTraderhostplatformispassedtoeveryfunction.Thisstructureisaccesiblebyitsname

_Host

andcontainsinformationsuchas

- Symbolprofiledata

- Symboldetails

- Serialnumbers

- Build

- Strategyname

- Colors

- Timesettings

- Settingsofthepoolpanel

Toseewhichmembervariablesandfunctionsareavailable,justtype“_Host.”Intheeditor,andtheMT-editorwilldisplayalistandadescriptionofthevariables.

Memberswhichstartwithuppercaseletters,arefunctions,othersarevariables.

Example#1–retrievethenameoftheselectedstrategy,editionandnameoftheprofilecontractname

//+------------------------------------------------------------------+ //| Init | //+------------------------------------------------------------------+

14

SEA_INIT { Print(“ Strategy: “, _Host.StrategyName() + “ Edition: “, _Host.Edition() + “ Contract: “, _Host.ContractName()); // ... }

Example#2–retrievingcolorsettings

//+------------------------------------------------------------------+ //| Host update | //+------------------------------------------------------------------+ SEA_HOST { color cbull = _Host.clr_bull; color cbear = _Host.clr_bear; // ... }

15

3.Accessingbars

3.1The_BarsobjectAsmentionedbefore, specificbarsor specific setsofbarsareaccessibleby theobject_Bars. Theparametershiftpointstotherelativepositionofthebarinthechart,measuredfromthecurrentbar.Ashiftvalueofzeropointstothecurrentbarwherebyavalueof1pointstothepreviouslyclosedbarandsoon.

3.1.1Basicdatadouble _Bars.Open(shift=0)

double _Bars.Close(shift=0)

double _Bars.High(shift=0)

double _Bars.Low(shift=0)

Returnstheratesoftheselectedbar.

datetime _Bars.Time(shift=0)

Returnstherawtimedataoftheselectedbar.

string _Bars.TimeString(shift=0)

Returnsthetimedataoftheselectedbarasstring.

string _Bars.DateString(shift=0)

Returnsthedateoftheselectedbarasstring.

int _Bars.Year(shift=0)

int _Bars.Month(shift=0)

int _Bars.Day(shift=0)

int _Bars.Hour(shift=0)

int _Bars.Minute(shift=0)

int _Bars.Second(shift=0)

int _Bars.DayOfWeek(shift=0)

int _Bars.DayOfYear(shift=0)

Returnstimeanddatevaluesofaselectedbar.

long _Bars.RealVolume(shift=0)

Returnstherealvolume(MT5)oftheselectedbar.

long _Bars.TickVolume(shift=0)

Returnsthetickvolumeoftheselectedbar.

double _Bars.Gap(shift=0)

Returnstherangeofthegapbetweentheselectedbarandthebarbefore.

16

3.1.2Shapesandmeasuring

bool _Bars.IsBullish(shift=0)

bool _Bars.IsBearish(shift=0)

bool _Bars.IsDoji(double tolerance=0, shift=0)

Evaluatesifabarisbullishorbearishoradoji.

double _Bars.Range(shift=0)

Therangeofabarfromhightolow.

double _Bars.TrueRange(shift=0)

TheTrueRangeofabarincludinggap–ifpresent.

double _Bars.BodyRange(shift=0)

double _Bars.WickRange(shift=0)

double _Bars.TailRange(shift=0)

Therangeofthebarsbody,wickortail.

double _Bars.BodyPart(shift=0)

double _Bars.WickPart(shift=0)

double _Bars.TailPart(shift=0)

Thepartofeitherthebody,thewickorthetailofbar.Thereturnvalueisalwaysbetween0.0and1.0(0%to100%)

bool _Bars.IsHammer(shift=0)

bool _Bars.IsShootingStar(shift=0)

Returnstheshapeofabar.

double _Bars.FiboPrice(double levelmult, shift=0)

Returnsthefibonaccipriceofaspecificbar.Theparameterlevelmultspecificiesthelevelasmultiplicationvalue.

double _Bars.PivotPrice(ENUM_PIVOT_POINT p, shift=0)

Returnsthepivotpriceofaspecificbar.Theparameterpspecificiestherequestedpivotpoint,whichisoneofthefollowing:

PIVOT_POINT_MAIN PIVOT_POINT_S1 PIVOT_POINT_S2 PIVOT_POINT_R1 PIVOT_POINT_R2

3.1.3Barinteractionandpatternbool _Bars.IsCrossing(double price, int shift=0)

Returnstrueifthebariscrossingapricelevel

bool _Bars.IsTouchingHigh(double price, int shift=0)

17

Returnstrueifthebarswickistouchingorcrossingapricelevel

bool _Bars.IsTouchingLow(double price, int shift=0)

Returnstrueifthebarstailistouchingorcrossingapricelevel

bool _Bars.IsEngulfingLong(int shift=0)

bool _Bars.IsEngulfingShort(int shift=0)

Returnstrueincaseofalong/shortengulfingpattern

bool _Bars.IsReversingLong(int shift=0)

bool _Bars.IsReversingShort(int shift=0)

Returnstrueincaseofalong/shortreversalpattern

3.1.4Advanced

Bool GetOLHC(double &o, double &l, double &h, double &c, int shift=0)

Returnsopen,low,highandclosevaluesofaspecificbar

CBar * _Bars.BarGet(int shift=0)

ReturnsanobjectpointertoaCBarobjectwhichholdsdataofaspecificbar.

bool BarGetSeries(CBar &bars[], int cntbars, int shift=0)

FillsanCBararraywithdata.

bool BarUpdate(CBar &bar, int shift=0)

UpdatesaCBarobject

3.1.5Indications

The_Barsobjectallowsalsoaccesstomultiplebars, for indicationsetc.Thecurrently implementedfunctionsare:

bool _Bars.IsCrossingUp (series[], int shift=0)

bool _Bars.IsCrossingDown (series[], int shift=0)

Returnstrueiftheselectedbariscrossingaseriesbuffer.

double _Bars.ATR (int span=14, int shift=0)

CalculatestheAverageTrueRange.

double _Bars.AR (int span=14, int shift=0, ENUMARMODE mode=ARMODENORMAL, ENUMCANDLEBASE base=WRONGVALUE)

Calculates the Average Range of a specific number of bars. The function is able tocalculate the range only of open and close prices, if base is set toCANDLE_BASE_OPENCLOSE.

Furhtermore, when mode is set to ATR_MODE_BEARISH or ATR_MODE_BULLISH, thefunctioncalculatesonlytherangeofbullishorbearishbars.

18

double _Bars.HighestHigh (int span, int shift=0)

double _Bars.LowestLow (int span, int shift=0)

Returnsthehighesthighorlowestlowinaspecificrangeofbars.

double _Bars.SMA (int periods, int shift=0)

double _Bars.EMA (int periods, int shift=0)

double _Bars.SMMA (int periods, int shift=0)

double _Bars.LWMA (int periods, int shift=0)

Calculatesdifferenttypesofmovingaverages.

long _Bars.TickVolumeAverage(int periods=14, int shift=0)

long _Bars.RealVolumeAverage(int periods=14, int shift=0)

Calculatesaveragesofvolume.

double _Bars.RSI(int periods=14, int shift=0)

CalculatestheRSI

double _Bars.StochasticMain(int period_k=5, int period_d=3, int slowing=3, int shift=0)

double _Bars.StochasticSignal(int period_k=5, int period_d=3, int slowing=3, int shift=0)

SIGNAL _Bars.Stochastic(int period_k, int period_d, int slowing, double signallinedistance=20, int shift=0)

Calculatesstochastic.

bool _Bars.IsLocalHigh(int bars, int shift=0, double tolerance=0)

bool _Bars.IsLocalLow(int bars, int shift=0, double tolerance=0)

Evaluatesifabarmarksalocalhighorlow

bool _Bars.IsSMASlopingUp(int period, int span=2, int shift=0)

bool _Bars.IsEMASlopingUp(int period, int span=2, int shift=0)

bool _Bars.IsLWMASlopingUp(int period, int span=2, int shift=0)

bool _Bars.IsSMMASlopingUp(int period, int span=2, int shift=0)

bool _Bars.IsSMASlopingDown(int period, int span=2, int shift=0)

bool _Bars.IsEMASlopingDown(int period, int span=2, int shift=0)

bool _Bars.IsLWMASlopingDown(int period, int span=2, int shift=0)

bool _Bars.IsSMMASlopingDown(int period, int span=2, int shift=0)

Evaluatesifmovingaverageisslopingupwardsordownwards

3.2SinglebarsBesidesaccessingaseriesofbars,therearealsoobjectswhichrepresentasinglebar.TheseobjectsbelongtotheclassCBar.Ofcourseit´spossibletodefinealsoowninstancesofsuchanCBarobject.

3.2.1Predefinedsinglebarobjects

Thepredefinedsinglebarobjectsare:

19

_CurBar

Thecurrentbar.

_PrevBar

Thepreviouslyfinishedbar

_CurHour

Thecurrenthour

_PrevHour

Theprevioushour

_CurDay, _PrevDay, _CurWeek and _PrevWeek.

Example:

bool hammer=_CurBar.IsHammer(); datetime t=_PrevBar.Time; double weekhigh=_CurWeek.High;

3.2.2Dataofthecurrentbar

Tomakecodingeasier,thefollowingvariablescontainalreadysomeinformationaboutthecurrentbar,copiedfromthe_CurBarobject.

_Price

Thedealprice.IncaseifanSEAoperateswitheachtick,thevariablereturnsthecurrentclosepriceoftheunfinishedbar.Otherwiseit´stheopenpriceofthenextbar.

_Bid / _Ask

Thecorrespondingbidoraskprice

Someselfexplainingvariableswhichreturnresultsofthecurrent–thenew–bar.IncaseiftheSEAoperateswithfinishedbarsonly,thevariables_Low,_High,_Openand_Closehaveallthesamevalue:Theopenprice.

_Open

_Low

_High

_Close

_TickVolume

_RealVolume

_Time

_Hour

_Minute

_Day

20

_DayOfWeek

_Month

_Year

Furtherpredefinedvariableswhichcontaindataofthecurrentbar:

_SymbolName

Containsthecurrentsymbolname

_TimeFrame

Containsthecurrenttimeframe

_BarsCount

Thenumberofbarsinthechart

3.2.3BasicdataofsingleCBarobjects

Analoguetothefunctionsofthe_Barsobject,CBarobjectshavealsofunctionsandmembervariablestoaccessthedataofbars.Ofcourse,singlebarsneveruseashiftparameter,becausesuchobjectsalwaysrepresentonespecificbar.

Membervariables:

double .Open

double .Close

double .High

double .Low

Containthespecificrateofabar.

Please note: In case of the _CurBar object while not operating in tick mode, thesemembervariableshaveallthesamevaluetoavoidmiscalculationswhentheEstimatorisactive.

datetime .Time

Containstherawtimedata.

int .Year

int .Month

int .Day

int .Hour

int .Minute

int .Second

int .DayOfWeek

int .DayOfYear

21

Containtimeanddatevalues.

long .RealVolume

Containstherealvolume(MT5only).

long .TickVolume

Containsthetickvolume.

double .Gap

Containstherangeofthegapbetweenthebarinrelationtothepreviousbar.

Memberfunctions/methods:

string .TimeString()

Returnsthetimedataoftheselectedbarasstring.

string .DateString()

Returnsthedateoftheselectedbarasstring.

3.2.4Memberfunctionsforshapesandmeasuring

bool .IsBullish()

bool .IsBearish()

bool .IsDoji(double tolerance=0)

Evaluatesifabarisbullishorbearishoradoji.

double .Range()

Therangeofabarfromhightolow.

double .TrueRange()

TheTrueRangeofabarincludinggap–ifpresent.

double .BodyRange()

double .WickRange()

double .TailRange()

Therangeofthebarsbody,wickortail.

double .BodyPart()

double .WickPart()

double .TailPart()

Thepartofeitherthebody,thewickorthetailofbar.Thereturnvalueisalwaysbetween0.0and1.0(0%to100%)

bool .IsHammer(double tailmin=0.55)

bool .IsShootingStar(double wickmin=0.55)

Returntheshapeofabar.

22

bool .IsSolid(double wickmax=0.15, double tailmax=0.15)

Returns true if the bar is solid whereby wick and tail must not exceed the specifiedmaximalvaluesforwickandtail.

double .FiboPrice(double levelmult, shift=0)

Returnsthefibonaccipriceofaspecificbar.Theparameterlevelmultspecificiesthelevelasmultiplicationvalue.

double .PivotPrice(ENUM_PIVOT_POINT p, shift=0)

Returnsthepivotpriceofaspecificbar.Theparameterpspecificiestherequestedpivotpoint,whichisoneofthefollowing:

PIVOT_POINT_MAIN PIVOT_POINT_S1 PIVOT_POINT_S2 PIVOT_POINT_R1 PIVOT_POINT_R2

3.1.5Barinteraction

bool .IsCrossing(double price)

Returnstrueifthebariscrossingapricelevel

bool .IsBreaking(double price)

Returnstrueifthebodyofthebarcrossesaspecificpricelevel.

bool .IsBreakingLong(double price, double exceed=0)

bool .IsBreakingShort(double price, double exceed=0)

Returnstrueifthebodyofthebarcrossespricebullish/bearish.

bool .IsTouchingHigh(double price)

Returnstrueifthebarswickistouchingorcrossingapricelevel

bool .IsTouchingLow(double price)

Returnstrueifthebarstailistouchingorcrossingapricelevel

23

4.Signals

4.1SetupfunctionsAnySEAgetsregisteredautomaticallybythebaseclass.ThefunctionSEA_INIT(OnInit())maybeusedtodefinebehaviour and parameters of the StereoEA, but is not needed in any case. Any such property should be setduringOnInit.

SEA_INIT {

SetEveryTick(true); SetTradeModes(TRADE_MODE_STEREO_FUTURE); //--- Other stuff //... //--- Success return true; }

Anyinitializationisoptional.Allofthesefunctionmaybeusedforownpurposesifneededonly.

void SetOnCalculate (bool flag, bool arraysasseries)

IndicatesthattheSEAisusingastandardOnCalculate()functionblockforindications,asitis thenormalwaywhendeveloping indicatorswithMQL. If thisproperty isnotset, theOnCalculate()willnotbecalled.

Theparameterarrayasseriesspecifies,thatthepassedarrayssuchasclose[],open[]willbe preprocessed before OnCalculate() is used. For more informations aboutOnCalculate(),pleaserefertotheMQLlanguagereferenceofMetaQuotes.

void SetIndicate (bool flag)

InformstheAPI if theSEAusesan indicationblock.Thisprovidesanalternativeway touse indicationswhichmaydrawon thechart. TheSEA_INDICATEblock is alwayscalledprior to SEA_EVALUATE and within its not possible to use any trade commands. Bydefault,thispropertyisactivated.

SEA_INDICATE {

if (_Hour==m_time1.Hour() && _Minute==m_time1.Minute()) { DrawLine("Timeline @%price (%time)",_Price,clrDarkOrange,_Time); return; }

void SetEvaluate (bool flag)

TellstheAPIiftheSEAusesanevaluationblock,whichisusedtoevaluatecandlesandtosendtradecommands.Bydefault,thispropertyisactivated.

SEA_EVALUATE {

if (...) Buy(); }

void SetDaysToProcess(int days=0)

24

Limitsthenumberofthepastdaystoprocessforindicationandestimation.Youmayusethisfunctiontospeedupprocessingwhenusingcomplexindications.

void SetTimeWindow(int beginh, int beginm, int endh, int endm)

Limitsthehoursofprocessingtoaspecifictimerange.

void SetDefaultShift(shift=1)

Thedefaultnumberofbarswhichareshiftedbackwardsinanyevaluations.

(Defaultshift1–leftside–anddefaultshift0–rightside)

Onthe leftside,whendealingwith finishedcandles, thedefaultshift is 1,whichmeansanyshift-valueisaddedby1andthenotyetfinishedbarisaccessiblebyashiftvalueof-1.

_Bars.Example:

SetDefaultShift(1); if (_Bars.IsHammer()) //--- last closed bar Buy(); DuringSEA_EVALUATE,thisexampledetectsahammerinthepreviousbar.Incaseifthedefaultshiftwouldbe0,thesameexamplewouldhavetolooklikethis

DefaultShift(0); if (_Bars.IsHammer(1)) //--- last closed bar Buy();

void SetEveryTick (bool flag)

Indicates if the functionmacroSEA_EVALUATE is calledonevery tick. If thisproperty isnot set, the functionwillbe calledonlywhenanewbar/candle is about tobecreated.Nevertheless, duringSEA_EVALUATE you still have the additional possibility to test, if anew bar has just been created by using the IsNewBar() function to avoid unnecessarycalculationtime.

void SetSignalRules (ENUM_SEA_OPPOSITEFLAG flag, bool overlap)

Defines the behaviour in case of counter signals, e. g. Buy() when short positions areopened,orSell()whenlongpositionsareactive.Possiblevaluesare

SEA_OPPOSITE_NONE // Open the position SEA_OPPOSITE_NOTRADE // Prohibit opening SEA_OPPOSITE_CLOSE // Close opposite

25

Theparameteroverlapspecifiesifmultiplesignals/positionsofthesamedirection(Buy()/Sell())areallowedatthesametime.Bydefault,thisisrestrictedtooneposition/signal.

void SetSignalMinDistance (int bars)

Specifies the minimal distance between Buy() and Sell() signals, meaured in bars. Bydefault,thisvalueis1,whichmeans,onlyonesignalperbarisallowed.

void SetRoom(double roompoints)

Predefines a minimal room between orders to prevent overlapping orders. Theparameter roompoints defines the space around any neworderwhich shall be verifiedfirst.Ifroompointsissetto10,StereoTraderwouldnotcreateanorderifthereisalreadyanotherorderorpositionofthesamedirectionwithininadistanceof10points.

void SetTradeModes (supportedmode=0xFFFF)

supportedmodedefinesthemodeinwhichtheSEAworks,whereby–0xFFFF(standard)meansallmodes.ThefollowingenumconstantsaredefinedandmaybecombinedbyabitwiseORoperation:

TRADE_MODE_SINGLE_HEDGE = 1 TRADE_MODE_SINGLE_NOHEDGE = 2 TRADE_MODE_STEREO_HEDGE = 4 TRADE_MODE_STEREO_FUTURE = 8

void SetTrueRangeMode (supportedmode=0xFFFF)

supportedmode defines the true rangemeasurementmethod. If suchamode is set, allbar values are calculated on the base of their true range including gaps. Hereby twodifferentmodesmaybe used, the normalmode,which adds gaps to the bar after thegap,andtheforwardingmode,whichaddsthegaptothepreviousbar.

TRUERANGE_MODE_NONE = 0 TRUERANGE_MODE_NORMAL = 1 TRUERANGE_MODE_FORWARD = 2

void SetUsesVars(bool flag=true)

Indicates that local trading variables are used. By default, this is enabled. A disablingincreasedthebacktestingspeed,incaseifnovariablesareused.

void SetExpirationDate(datetime date)

LimitstheusablityofanSEAtoaspecificdate.

4.2BasiccommandsWhentalkingaboutsignals,primilarythefunctionsBuy()andSell()aremeant.

4.1.1Open/closepositions

void Buy (string info=NULL)

void Sell (string info=NULL)

26

Sendsasignaltoopenabuy/sellpositionortoactivatethestrategiclong/shortorderindependenceofwhichordermodeisselectedattheAutoTradingpanel.

Theparameter info isusedastooltiptextof thesignalarrowwhich isdisplayedonthechart.

void Flat ();

void FlatLong ();

void FlatShort ();

Closeallpositionsanddeleteallorders.

void CloseBuy (double profitpoints=-9999999)

void CloseSell (double profitpoints=-9999999)

Closeallbuy/sellpositions

void CloseAll (double profitpoints=-999999)

Closeallpositions

4.1.2Blocking/Unblocking

void BlockBuy()

SendsasignaltopreventautotradingfromopeninganybuypositionsorsendinganybuyordersofanySEA.

void BlockSell()

SendsasignaltopreventautotradingfromopeninganysellpositionsorsendinganysellordersofanySEA

void BlockAll()

SendsasignaltopreventautotradingfromopeninganypositionsorsendinganyordersofanySEA.

4.2Pendingorders

void BuyOrder (double price)

void SellOrder (double price)

Sendsasignaltoplaceabuyorsellorderatthe leveloftheparameterprice. Ifprice isbelow the current price, a limit order is sent, if the price is above, a stop order isgenerated.

void BuyMTO (double distance=2)

void SellMTO (double distance=2)

Sendsasignaltoopenamarkettrailorder(MTO)foreitherbuyingorselling.TheMTOvariantcanbemoreeffectivethananormalmarketorder,especiallywhensendingafterabarwasjustclosed.

void DeleteBuyOrders()

27

void DeleteSellOrders()

Removeallbuy/sellorders.

void DeleteAllOrders()

Guess…;)

4.2.1Ordersettings

Anyattribute/settingofanordermustbesentpriortotheactualcommandwhichplacesanorder.

void OrderId (string id)

Defines an order id. The value is used to identify orders sent by the SEA for furthermodification,selectionordeletion.Thereisnoobligationtousethisfunction,orderswillalsobeplacedwithoutanid.

void OrderSize (double size)

Setstheabsolutesizeofaneworderorpositionaslotvalue.

void OrderSizeRel (double factor)

Multipliesthecurrentordersizewiththevalueinfactor.

void OrderComment (string comment)

Defines the comment for any following neworder. In case ofmultiple orders in a rowwith different comments, this function must be called prior to each function, whichgeneratesanorderoropensaposition.

void OrderLimitPullback (double points)

Definesthelimitpullbackforanyfollowingnewlimitorder.Incaseofmultipleordersinarow with different values, this function must be called prior to each function, whichgeneratesalimitorder.

void OrderAttrOCO (bool flag=true)

SetstheCSandCOflagandforcescancellationofanyotherorderwhenexecuted.Incaseofmultipleordersinarowwithdifferentflags,thisfunctionmustbecalledpriortoeachfunction,whichgeneratesanorder.

void OrderAttrCS (bool flag=true)

Sets the CS flag (order cancels siblinb others) for any following new order. In case ofmultipleorders in a rowwithdifferent flags, this functionmustbe calledprior toeachfunction,whichgeneratesanorder.

void OrderAttrCO (bool flag=true)

SetstheCOflag(canceloppositeorders)foranyfollowingneworder.Incaseofmultipleorders ina rowwithdifferent flags, this functionmustbecalledprior toeachfunction,whichgeneratesanorder.

void OrderAttrREV (bool flag=true)

Sets the REV flag (reverse position) for any following new order. In case of multipleorders ina rowwithdifferent flags, this functionmustbecalledprior toeachfunction,whichgeneratesanorder.

28

void OrderAttrNET (bool flag=true)

SetstheNETflag(ordercompensatesoppositepositions)foranyfollowingneworder.Incaseofmultipleordersinarowwithdifferentflags,thisfunctionmustbecalledpriortoeachfunction,whichgeneratesanorder.

void OrderTrail (ENUM_SEA_TRAILMODE mode, double distancepts, int period=0)

Indicatesthatthenextorderwhichissentshallbetrailedwiththegivenparameters.Thefollowingvaluescanbeusedfortheparametermode

SEA_TRAIL_NONE = 0 SEA_TRAIL_DST = 1 SEA_TRAIL_PLH = 2 SEA_TRAIL_MA = 3 SEA_TRAIL_PLH_PEAK = 5 SEA_TRAIL_PLH_CLOSE = 6 distancepts is the trailing distance as point value, period is only used for trailing withmovingaveragesorotherperiodictrails.

4.2.2Ordermodification

void MoveOrder (string id, double price)

Moves a pending order to another price. To use this function proper, the commandOrderId()whichdefinestheidofanorderhastobeusedpriorwithuniquenamesforanyneworder.

4.3Managingtrades

4.3.1StereoFuturemode

ThefollowingfunctionsaretobeusedinsinglemodeandtheStereoFuturemode.

void SL (double points)

Setsormodifiesthestoploss.

void SLAbsolute (double price)

Setsthestoplosstoanabsoluteprice.Ifthepostionisnotopenedyet,thevalueissavedandtheTPwillbeadjustedassoonasthepositionisopened.

Pleasenote,thatthiscommandshavetobeusedafteranyordercommandsuchas.Buy()or.BuyOrder(),otherwisepriorcallsofthefunctionshavenoeffect.

void TP (double points)

Setsthetakeprofit.

void TPAbsolute (double price)

Sets the takeprofit to an absolute price. If thepostion is not opened yet, the value issavedandtheTPwillbeadjustedassoonasthepositionisopened.

Pleasenote,thatthiscommandshavetobeusedafteranyordercommandsuchasBuy()orBuyOrder(),otherwisepriorcallsofthefunctionshavenoeffect.

29

void TrailMode (ENUM_SEA_TRAILMODE mode, double distancepoints, int periods=0)

Definesthetrailingmode.

Theparametermodedefinesthemode,distancepointsthedistanceaspoints.Incaseofperiodic low/high trailing or trailing based on moving averages, the paramter periodsdefinestheperiodstobeused.modeisoneofthefollowing:

SEA_TRAIL_NONE = 0 SEA_TRAIL_DST = 1 SEA_TRAIL_PLH = 2 SEA_TRAIL_MA = 3 SEA_TRAIL_EOP_DST = 4 SEA_TRAIL_PLH_PEAK = 5 SEA_TRAIL_PLH_CLOSE = 6

void TrailDistance (double points)

Definesthetrailingdistance.

void TrailBegin (double points)

Defineswheretrailingbegins,relativetothebreakeven.

The value defines also the break even trigger, in case ifBEActivate is used to save thebreakeven.

void BEAdd (double points)

Definestheadditionalpointstoaddtobreakeven.

void SLActivate (bool flag)

Activatesordeactivatesthestoploss.

void TPActivate (bool flag)

Activatesordeactivatesthetakeprofit.

void TrailActivate (bool flag)

Activatesordeactivatesthetrailingstop.

void BEActivate (bool flag)

Activatesordeactivatesthebreakevensavefunction.

4.3.2FunctionsforStereoHedgemode

Thefollowingfunctionsaretobeusedinvirtualmodeonly.

void SLBuy (double points)

void SLSell (double points)

Setsthestoplossaspointsofopenedbuy/sellpositionswithinthepool.

void SLBuyAbsolute (double price)

void SLSellAbsolute (double price)

30

Setsthestoplossofopenedpositionswithinthepooltoanabsoluteprice.Ifthepostionisnotopenedyet,thevalueissavedandtheTPwillbeadjustedassoonasthepositionisopened.

Pleasenote,thatthiscommandshavetobeusedafteranyordercommandsuchas.Buy()or.BuyOrder(),otherwisepriorcallsofthefunctionshavenoeffect.

void TPBuy (double points)

void TPSell (double points)

Setsthetakeprofitaspointsofopenedbuy/sellpositionswithinthepool.

void TPBuyAbsolute (double price)

void TPSellAbsolute (double price)

Sets the take profit of opened positions within the pool to an absolute price. If thepostionisnotopenedyet,thevalue issavedandtheTPwillbeadjustedassoonasthepositionisopened.

Pleasenote,thatthiscommandshavetobeusedafteranyordercommandsuchas.Buy()or.BuyOrder(),otherwisepriorcallsofthefunctionshavenoeffect.

void TrailModeBuy (ENUM_SEA_TRAILMODE mode)

void TrailModeSell (ENUM_SEA_TRAILMODE mode, double distancepoints, int periods=0)

Setsthetrailingmodeofopenedbuy/sellpositionswithinthepool.

Theparametermodedefinesthemode,distancepointsthedistanceaspoints.Incaseofperiodic low/high trailing or trailing based on moving averages, the paramter periodsdefinestheperiodstobeused.modeisoneofthefollowing:

SEA_TRAIL_NONE = 0 SEA_TRAIL_DST = 1 SEA_TRAIL_PLH = 2 SEA_TRAIL_MA = 3 SEA_TRAIL_EOP_DST = 4 SEA_TRAIL_PLH_PEAK = 5 SEA_TRAIL_PLH_CLOSE = 6

void TrailDistanceBuy (double points)

void TrailDistanceSell (double points)

Setsthetrailingdistanceinpointsofopenedbuy/sellpositionswithinthepool.

void TrailBeginBuy (double points)

void TrailBeginSell (double points)

Defineswhere trailing begins. The value defines also the break even trigger, in case ifBEActivateBuyorBEActivateSellisusedtosavethebreakeven.

Setsthebreakeventriggervalueinpointsofopenedbuy/sellpositionswithinthepool.

31

void BEAddBuy (double points)

void BEAddSell (double points)

Definestheadditionalpointstoaddtobreakevenofopenedbuy/sellpositionswithinthepool.

void SLActivateBuy (bool flag)

void SLActivateSell (bool flag)

Stoplossactivation/deactivationofopenedbuy/sellpositionswithinthepool.

void TPActivateBuy (bool flag)

void TPActivateSell (bool flag)

Takeprofitactivation/deactivationofopenedbuy/sellpositionswithinthepool.

void TrailActivateBuy (bool flag)

void TrailActivateSell (bool flag)

Trailingstopactivation/deactivationofopenedbuy/sellpositionswithinthepool.

void BEActivateBuy (bool flag)

void BEActivateSell (bool flag)

Breakevensaveactivation/deactivationofopenedbuy/sellpositionswithinthepool.

4.3.3Commandsformanualexits

Thefollowingfunctionsaretobeusedformanualexitsandarealmostsimilartothebuttonsbelowtheorderpanels.

void Flat() / FlatLong() / FlatShort()

Closesallpositionsanddeletesallorders.

bool IsFlat (bool checkorders=false)

Returns truewhen there is not opened position. If checkorders is set to true, pendingordersarealsorecognized.

void CloseBuy (string id=NULL, double minprofit=-999999999)

SendsasignaltocloseallbuypositionsoftheSEA.Incaseofstrategicordering,thisalsoforcesadeactivationofthecorrespondingStayfunctionality.

If id isspecified,thefunctionaffectsonlyorderswhichmatchtheid,wherebywildcardsmybeusedintheid.

Ifminprofitisspecified,thefunctionforcesonlytheclosingofallparticularbuypositionswhichhaveaprofitofatleastthespecifiedvalueaspoints.

void CloseSell (string id=NULL, double minprofit=-999999999)

SendsasignaltocloseallsellpositionsoftheSEA.Incaseofstrategicordering,thisalsoforcesadeactivationofthecorrespondingStayfunctionality.

32

If id isspecified,thefunctionaffectsonlyorderswhichmatchtheid,wherebywildcardsmybeusedintheid.

Ifminprofitistspecified,thefunctionforcesonlytheclosingofallparticularsellpositionswhichhaveaprofitofatleastthespecifiedvalueaspoints.

void CloseAll (string id=NULL, double minprofit=-999999999)

SendsasignaltocloseallpositionsoftheSEA.Incaseofstrategicordering,thisforcesadeactivationoftheSidealgorithmanditsStayfunctionality.

If id isspecified,thefunctionaffectsonlyorderswhichmatchtheid,wherebywildcardsmybeusedintheid.

Ifminprofit istspecified, thefunctionforcesonlytheclosingofallparticularbuyorsellpositionswhichhaveaprofitofatleastthespecifiedvalueaspoints.

void DeleteBuyOrders(string id=NULL)

Sends a signal to deletes any pending buy orders of the SEA. If id is specified, thecommandwill only affect such orderswhichmatch the specified id value. Hereby thevalueforidmaybeusedwithwildcards.Exampleforwildcards:

DeleteBuyOrders(“OrderName*”)–woulddeleteallordersfromthisSEAwithanidthatstartswiththeletters“OrderName”.

DeleteBuyOrders(“*OrderName”)–woulddeleteallordersfromthisSEAwithanidthatendswiththeletters“OrderName”.

DeleteBuyOrders(“OrderName”)–woulddeleteallorderscreatedbythisSEAwithanidthatmatches“OrderName”exactly.

In case of the usage of strategic orders, this also forces a deactivation of thecorrespondingForcefunctionality

void DeleteSellOrders(string id=NULL)

Sends a signal to deletes any pending sell orders of the SEA. If id is specified, thecommandwill only affect such orderswhichmatch the specified id value. Hereby thevalueforidmaybeusedwithwildcards.

In case of strategic ordering, this also forces a deactivation of the corresponding Stayfunctionality

void DeleteAllOrders(string id=NULL)

SendsasignaltodeletesanypendingordersoftheSEA.If id isspecified,thecommandwillonlyaffectsuchorderswhichmatchthespecified idvalue. Herebythevaluefor idmaybeusedwithwildcards.

Incaseofstrategicordering,thisalsoforcesadeactivationoftheStaySidefunctionality.

33

4.4CommandsforautomatedexitsThefollowingfunctionsaretobeusedtocontrol furtherautomatedexists,suchasdisplayedattheAutoExitpanel.Pleaserefertothedescriptionofautoexitingtolearnaboutthefunctionalityofallitsparameters.

void AEPoolSL (double points)

Setsthepoolstoplossinpoints.

void AEPoolTP (double points)

Setsthepooltakeprofitinpoints.

void AEPoolSLActivate (bool flag)

ActivatesordeactivatesthePoolstoploss.

void AEPoolTPActivate (bool flag)

ActivatesordeactivatesthePooltakeprofit.

void AETradeMaxReduction (double amount)

Sets the Trade P/L stop loss as amount. If amount is negative, it´s interpreted aspercentagevalueofthecurrentequity.

void AETradeMaxGrowth (double amount)

Sets the Trade P/L take profit as amount. If amount is negative, it´s interpreted aspercentagevalueofthecurrentequity.

void AETradeMaxReductionActivate (bool flag)

ActivatesordeactivatestheTradeP/Lstoploss.

void AETradeMaxGrowthActivate (bool flag)

ActivatesordeactivatestheTradeP/Ltakeprofit.

void AETradeTrailBegin (double amount)

SpecifiesthebeginningoftheTradeP/Ltrailingstopasamount.

void AETradeTrailDistance (double amount)

SpecifiesthedistanceoftheTradeP/Ltrailingstopasamount.

void AETradeTrailActivate (bool flag)

ActivatesordeactivatestrailingstoplossforTradePL

void AEEquitySL (double amount)

SetstheEquitystoplossasamount.Ifamountisnegative,it´sinterpretedaspercentagevalueofthecurrentequity.

void AEEquityTP (double amount)

Sets the Equity take profit as amount. If amount is negative, it´s interpreted aspercentagevalueofthecurrentequity.

34

void AEEquitySLActivate (bool flag)

ActivatesordeactivatestheEquitystoploss.

void AEEquityTPActivate (bool flag)

ActivatesordeactivatestheEquitytakeprofit.

void AEEquityDeactivate (bool flag)

Enables or disables the automateddeactivationof any automatedprocesseswhen theEquitySLorEquityTPwastriggered.

void AETimeBegin (int hh, int mm)

Setsthebegintime.

void AETimeFlat (int hh, int mm)

Setstheflattime.

void AETimeFlatActivate (bool flag)

Enablesordisablesthetimebasedexit.

void AERemoveOrdersFlat (bool flag)

Activates or deactivates the automated deletion of remaining orders whenever allpositionsareclosed.

4.5CommandsforstrategicordersThefollowingfunctionsareformodificationofthesettingsforstrategicordersasshownattheStrategicOrderpanel.Pleaserefertothedescriptionofstrategicorderstounderstandthefunctionalityofallitsparameters.

void SOrderATRMode (string mode)

DefinestheATRmodeasdisplayedinthedropdownlist.

void SOrderDistance (double points)

Defines thedistancebetweenparticularordersaspoints. IfATR isused, theparameterpointsbecomesamultiplierforthecalculatedATR(averagetruerange).

void SOrderSLRel (double points)

Defines the relative distance for stop loss, based on the absolute distance betweenorders.

void SOrderTrailBeginRel (double points)

Definestherelativedistanceforthetrailbegin,basedontheabsolutedistancebetweenorders.

void SOrderTrailDistanceRel (double points)

Definestherelativedistancefortrailing,basedontheabsolutedistancebetweenorders.

35

void SOrderProgressLimit (double factor)

Setsthefactorofordersizeprogressionoflimitorders.

void SOrderProgressStop (double factor)

Setsthefactorofordersizeprogressionofstoporders.

void SOrderSizeMultiplyBuy(double size)

Setstheinitiallotsizeofthefirstbuyorderorposition.

void SOrderSizeMultiplySell (double size)

Setstheinitiallotsizeofthefirstsellorderorposition.

void SOrderAttributes (bool attr_oco, bool attr_co, bool attr_rev, bool attr_net)

Activatesordeactivatestheattributes.

void SOrderInitial (string enumvalue, double distance=1)

Definesthetypeoftheinitialorder. Incaseof“MTO”or“EOP”,theparameterdistanceholdsthetrailingdistancefortheorder.

void SOrderChainLimits(bool flag)

Activates/deactivateschainingofMITlimitpullbackorders

void SOrderQuantity (int cntlimits, int cntstops)

Definesthecountoforderswhicharetobegenerated.

void SOrderLong ()

Sends a signal to execute a long order strategy which equates a manual click on thebutton.

void SOrderSide()

Sends a signal to execute a side order strategy which equates a manual click on thebutton.

void SOrderShort()

Sends a signal to execute a short order strategywhich equates amanual click on thebutton.

void SOrderStayLong(bool flag)

Activates/deactivatesthestay-functionalityforlongstrategyorders.

void SOrderStayShort(bool flag)

Activates/deactivatesthestay-functionalityforsidestrategyorders.

void SOrderStayShort(bool flag)

Activates/deactivatesthestay-functionalityforshortstrategyorders.

36

4.7Messages

void MessageFloat (string text, string title=NULL)

Displaysafloatingmessageonthechartinasemi-transparentoverlaywindow

void MessageOK (string text, string title=NULL)

Displaysamessageinawindowwhichtheuserneedstoconfirm

void MessageChart (string text, string title=NULL)

Displaysascrollingmessageintheupperleftcornerofthechart

void _Print (string text, string text2, ...);

PrintsaformattedmessageintheMetaTraderTerminal.

4.8Otherfunctions

double PriceToPoints (double pricevalue)

Convertsapricebasedvaluetoapointbasedvalueinaccordancetothelocaldefinitionofapoint.

double PointsToPrice (double pointvalue)

Convertsapointbasedvaluetoapricebasedvalueinaccordancetothelocaldefinitionofapoint.

bool IsTradingHours(void)

Returnstruewhenthecurrentlyprocessedbar/tickisinthetimerangewhichisspecifiedattheprofiledefinitionoftheunderlyingsymbol.

bool IsProfileDataPresent(void)

Returnstruewhenprofiledataisspecifiedforthesymbol

bool IsTimeAllowed(void)

Returnstruewhenthecurrentlyprocessedbar/tickisinthetimerangewhichisspecifiedatAuto-Exit-PanelofStereoTrader

bool IsInTimeWindow(void)

Returnstruewhenthecurrenltyprocessedbar/tickisinthetimerangewhichisspecifiedbySetTimeWindow()function

4.9Optionsvoid OptionMITLimitOrders (bool flag)

37

Enables/disablestheMITfunctionalityforlimitorders.

void OptionMITStopOrders (bool flag)

Enables/disablestheMITfunctionalityforstoporders.

void OptionMITSLTP (bool flag)

Enables/disablestheMITfunctionalityforstoplossandtakeprofit.

void OptionMITSLSoft (int smaperiods)

DefinestheperiodswhichisusedtocalculatethemovingaverageforsoftSL.Thisoptiontakes only effect ifOptionMITSLTP(true) was executed before or if the correspondingoptionwasenabledat theSetup. Incaseof smaperiods=0 theSLworksasanormalSLand is triggered as soon the level was reached, otherwise a simplemoving average isusedtocalculatethetriggerlevel,whichsoftensthestoplossonhighvolatility.

void OptionSLTPAdjust (bool flag)

Ifactivated,thisresultsinadjustmentofstoplossand/ortakeprofitafterafurtherorderwas filled, based on the specified amount of points for SL and/or TP. If this option isdisabled,thepositionofstoplossand/ortakeprofitstaysfixedatthedistancetothefirstfilledorderinthepool.(Thisoptiontakeseffectonlyinvirtualmodes)

void OptionOrderRoom (double roompoints)

Predefines a minimal room between orders to prevent overlapping orders. Theparameter roompoints defines the space around any neworderwhich shall be verifiedfirst.Ifroompointsissetto10,StereoTraderwouldnotcreateanorderifthereisalreadyanotherorderorpositionofthesamedirectionwithininadistanceof10points.

4.9APIvariablesStereoTraderprovidesseveral tradevariableswhichareupdatedonevery tick.ThesevariablesarecalledAPIvariables.

Duetothecircumstance,thatSEAsworkinamessagequeue,theprovidedvariablesarevalidforthedurationofonetick.Thismeans,e.g.,ifaCloseAll()isexecutedoranyothertradecommandsuchasBuy(),thenumberofopenedpositions,returnedbyGetCntPos()remainsunchangeduntilthenexttickforcesthenextexecutionof SEA_EVALUATE. Clear, because StereoTrader gets informed about CloseAll() when the code exits theSEA_EVALUATEblock.

4.9.1Common

The following functions return the values of globalAPI variables,which are common for all SEAs.Use thesefunctionsinsteadofthecorrespondingMetaTrader4functionstoensure,thatyougetcorrectresults.

datetime GetServerTime()

Returnstheservertime.

double GetEquity()

Returnsthecurrentequityasdouble.

double GetBalance()

Returnsthecurrentaccountbalanceasdouble.

38

double GetSpread ()

Returnsthecurrentabsolutespread

4.9.2Tradingdata

double GetOrderSize()

Sizeofneworderassetintheorderpanels.

double GetPL()

ReturnsthecurrentPoolP/Lascurrencyamount.

double GetPLBuy()

ReturnsthecurrentP/Lofallbuypositionsascurrencyamount.

double GetPLSell()

ReturnsthecurrentP/Lofallsellpositionsascurrencyamount.

double GetPLPoints()

ReturnsthecurrentPoolP/Laspointvalue.

double GetPLBuyPoints()

ReturnsthecurrentP/Lofallbuypositionsaspointvalue.

double GetPLSellPoints()

ReturnsthecurrentP/Lofallsellpositionsaspointvalue.

double GetPLTrade()

ReturnsthecurrentTradeP/Lascurrencyamount.

double GetBE()

Returnstheaccumulatedbreakevenofallpositionsinthepoolaspricevalue.

double GetBEBuy()

Returnsthebreakeven/averagepriceofallbuypositionsinthepoolaspricevalue.

double GetBESell()

Returnsthebreakeven/averagepriceofallpositionsinthepoolaspricevalue.

int GetCntPos()

Returnstheaccumulatednumberofallopenedpositionswithinthepool.Accumulationmeansinthiscase,ifthepoolcontains10sellpositionsand12buypositions,thefunctionwouldreturn+2.

39

int GetCntPosBuy()

Returnsthenumberofallopenedbuypositionswithinthepool.

int GetCntPosSell()

Returnsthenumberofallopenedsellpositionswithinthepool.

int GetCntOrders()

Returns the accumulatednumberof all orderswithin thepool.Accumulationmeans inthiscase,ifthepoolcontains10sellordersand12buyorders,thefunctionwouldreturn+2.

int GetCntOrdersBuy()

Returnsthenumberofallbuyorderswithinthepool.

int GetCntOrdersSell()

Returnsthenumberofallsellorderswithinthepool.

double GetSize()

Returns the accumulated size of all opened positions within the pool. Accumulationmeansinthiscase,ifthepoolcontains10lotsonthesellsideand12onthebuyside,thefunctionwouldreturn+2.

double GetSizeBuy()

Returnsthesummarizedsizeofallopenedbuypositionswithinthepool.

double GetSizeSell()

Returnsthesummarizedsizeofallopenedsellpositionswithinthepool.

If local issettotrue,thefunctionreturnsonlythenumberofpositionswhichbelongtothisclient.

4.10StatusrequestsThefollowingfunctionsareprovidedassoonastheSEAclientwasregistered.Sameaswith initialization,theusageofthesefunctionsisoptional.

bool IsRegistered()

Returnstheregistrationstateoftheclient.

ENUM_TRADE_MODE TradeMode()

Incase ifanSEAsupportsmultiplemodes,thisfunction isusedto identifythemode, inwhichStereoTraderisoperating.Thevalueisoneofthefollowing:

TRADE_MODE_SINGLE_HEDGE = 1 TRADE_MODE_SINGLE_NOHEDGE = 2 TRADE_MODE_STEREO_HEDGE = 4 TRADE_MODE_STEREO_FUTURE = 8

bool IsHedging()

40

Returnstrueifthecurrentmodeiscapableofhedging.

bool IsAcknowledged ()

ChecksiftheSEAwasacknowledgedbythehost.

bool IsHostPresent ()

ChecksifStereoTraderisloaded.

bool IsLongAllowed ()

Returnstrueiflongtradesareallowed

bool IsShortAllowed ()

Returnstrueifshorttradesareallowed

4.11SourcecodeexampleThe following shows the full source code in which the functionality of two crossing moving averages isimplemented.

//+------------------------------------------------------------------+ //| CrossingMA_01.mq4 | //| Copyright 2017 by Dirk Hilger | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, Dirk Hilger" #property link "https://www.stereotrader.net" #property version "1.00" #property strict /* DESCRIPTION: CrossingMA buys or sells when one moving average crosses another. It can furhtermore test the curve of such if its sloping up or down. The example also shows the usage of an input panel. */ //+------------------------------------------------------------------+ //| Includes | //+------------------------------------------------------------------+ #include <StereoTrader_API\StereoAPI.mqh> //--- Remove these lines if indicator shall not appear in a separate window #property indicator_separate_window #property indicator_height 48 //+------------------------------------------------------------------+ //| Declaration of StereoEA | //+------------------------------------------------------------------+ DECLARE_SEA_BEGIN("CrossingMA01") //+------------------------------------------------------------------+ //| Fields | //+------------------------------------------------------------------+ CSNumEdit ma_fast; // Fast MA CSNumEdit ma_slow; // Slow MA CSButton ma_checkcurve; // Check curve direction //+------------------------------------------------------------------+

41

//| Optional initialization function | //+------------------------------------------------------------------+ SEA_INIT { //--- Add input fields _Panel.AddNumEdit(ma_fast,"Fast MA",20); _Panel.AddNumEdit(ma_slow,"Slow MA",200); _Panel.AddButton(ma_checkcurve,"Curve"); //--- Return success return(true); } //+------------------------------------------------------------------+ //| Iteration | //+------------------------------------------------------------------+ SEA_EVALUATE { //--- MA levels double mafast=_Bars.SMA((int)ma_fast.Value()); double mafastspan=_Bars.SMA((int)ma_fast.Value(),2); double maslow=_Bars.SMA((int)ma_slow.Value()); double maslowspan=_Bars.SMA((int)ma_slow.Value(),2); //--- Long signal bool buysignal=true; //--- Fast MA is above/equal slow MA buysignal&=mafast>=maslow; //--- Fast MA was below __e_ma_slow MA buysignal&=mafastspan<maslowspan; //--- Direction check if (ma_checkcurve.Pressed()) { buysignal&=mafast>mafastspan; buysignal&=maslow>maslowspan; } if (buysignal) { Buy(); return; } //--- Short signal ? bool shortsignal=true; //--- Fast MA is below/equal __e_ma_slow MA shortsignal&=mafast<=maslow; //--- Fast MA was above __e_ma_slow MA shortsignal&=mafastspan>maslowspan; //--- Direction check if (ma_checkcurve.Pressed()) { shortsignal&=maslow<maslowspan; shortsignal&=mafast<mafastspan; } if (shortsignal) { Sell(); return; } //--- No signal return; } //+------------------------------------------------------------------+ //| Declaration of StereoEA | //+------------------------------------------------------------------+ DECLARE_SEA_END

42

5.DrawingStereoTraderallowsforeasydrawingofclusters,highlightzones,arrowsandlines.ThedrawingfunctionsmaybeusedwithinSEA_INDICATEaswellaswithinSEA_EVALUATE

This chapter is not implemented yet entirely, please refer to the samples such as RangeBreakOut orDstFromTime.Thefunctionsare:

5.1DrawinglinesAnyfunctionwhichdrawsalinereturnsanintegervalue.Thisvaluerepresentstheidofsuchanobjectwhichisusedforanyfutheroperationwiththisobject.

int DrawLine(string text, double pricebegin, color clr, datetime timebegin=0, datetime timeend=0, int width=1, ENUM_LINE_STYLE style=STYLE_SOLID, string tooltip=NULL)

int DrawLineFibo(string text, double low, double high, double fibomult,datetime timebegin, datetime timeend, color clr, int width=1,ENUM_LINE_STYLE style=STYLE_SOLID,string tooltip=NULL)

int DrawLinePivot(string text, double low, double high, double close, ENUM_PIVOT_POINT p, datetime timebegin, color clr, datetime timeend=TIME_INFINITE, int width=1, ENUM_LINE_STYLE style=STYLE_SOLID, string tooltip=NULL)

int DrawLineTrend (string text, datetime, datetime timebegin, double pricebegin, datetime timeend, double priceend, color clr, int width=1,ENUM_LINE_STYLE style=STYLE_SOLID,string tooltip=NULL)

bool UpdateLine(int id, string text, datetime timebegin, double pricebegin, datetime timeend, double priceend, color clr, int width=1,ENUM_LINE_STYLE style=STYLE_SOLID,string tooltip=NULL)

int DrawLineV(datetime time, color clr, int width=1, ENUM_LINE_STYLE style=STYLE_SOLID, string tooltip=NULL)

bool MoveLine(int id, double price, string text=NULL, string tooltip=NULL, datetime timebegin=-1)

bool MoveLine(int id, double pricebegin, double priceend, datetime timebegin, datetime timeend, string text=NULL, string tooltip=NULL);

bool DeleteLine(int id)

5.2DrawingrectanglesAnyfunctionwhichdrawsarectanglereturnsan integervalue.Thisvaluerepresentsthe idofsuchanobjectwhichisusedforanyfutheroperationwiththisobject.

int DrawRectangle(datetime timebegin, double pricebegin, datetime timeend, double priceend,color clr,string text=NULL,string tooltip=NULL);

bool UpdateRectangle (int id, datetime timebegin, double pricebegin, datetime timeend, double priceend,color clr,string text=NULL,string tooltip=NULL);

bool DeleteRectangle(int id=-1)

43

5.3DrawingclustersAnyfunctionwhichdrawsaclusterreturnsanintegervalue.Thisvaluerepresentstheidofsuchanobjectwhichisusedforanyfutheroperationwiththisobject.

bool DrawClusterLong(string text, datetime timebegin, double pricebegin, datetime timeend, double priceend, string tooltip=NULL) ;

bool DrawClusterShort(string text, datetime timebegin, double pricebegin, datetime timeend, double priceend, string tooltip=NULL) ;

bool DrawCluster(string text, datetime timebegin, double pricebegin, datetime timeend, double priceend, color clr_cluster, color clrtext, string tooltip=NULL)

bool UpdateCluster(int id, string text, datetime timebegin, double pricebegin, datetime timeend, double priceend, color clr_cluster, color clrtext, string tooltip=NULL);

void SetDrawClusterType(bool fillcluster, int linethickness);

bool DeleteCluster(int id);

5.4DrawingarrowsAny functionwhich draws an arrow returns an integer value. This value represents the id of such an objectwhichisusedforanyfutheroperationwiththisobject.

int DrawArrowLong(double price, string text=NULL, int size=2, int shift=0) ;

int DrawArrowShort(double price, string text=NULL, int size=2, int shift=0) ;

int DrawArrowLong(string text=NULL, int size=2,int shift=0);

int DrawArrowShort(string text=NULL, int size=2,int shift=0);

int DrawArrowLong(double price, double time, int size=2, string tooltip=NULL, ENUM_ARROW_ANCHOR anchor=WRONG_VALUE);

int DrawArrowShort(double price, double time, int size=2, string tooltip=NULL, ENUM_ARROW_ANCHOR anchor=WRONG_VALUE);

bool DeleteArrow(int id);

5.5DrawinghighlightzonesAny functionwhich draws a highlight zone returns an integer value. This value represents the id of such anobjectwhichisusedforanyfutheroperationwiththisobject.

int DrawHighlightLong(int shift=0, int minutes=-1);

int DrawHighlightShort(int shift=0, int minutes=-1);

int DrawHighlightLong(datetime timebegin, int minutes=-1);

int DrawHighlightShort(datetime timebegin, int minutes=-1);

int DrawHighlight(color clr=clrNONE, int shift=0, int minutes=-1);

int DrawHighlight(datetime timebegin, color clr=clrNONE, int minutes=-1);

bool MoveHighlight(int id, datetime newtime);

bool ShiftHighlight(int id, int bars=1);

bool ToolTipHighlight(int id, string text);

44

5.6Drawingfiltersbool DrawFilterLong(int shift=0)

bool DrawFilterShort(int shift=0)

bool DrawFilterNone(int shift=0)

bool DrawFilter(int filter, datetime timebegin=0, datetime timeend=0, int shift=0) ;

5.7Drawingtracelinesbool DrawTraceLineInit(int id=-1, color clr=clrBlue, int width=1, ENUM_LINE_STYLE style=STYLE_SOLID, string tooltip=NULL)

bool DrawTraceLineBegin(int id, double price, color clr=clrNONE, int shift=0)

bool DrawTraceLineBegin(int id, double price, datetime timebegin, color clr=clrNONE)

bool DrawTraceLineUpdate(int id, double price, color clr=clrNONE, int shift=0)

bool DrawTraceLineUpdate(int id, double price, datetime time, color clr=clrNONE)

5.8DrawingtextAnyfunctionwhichdrawstextreturnsanintegervalue.Thisvaluerepresentstheidofsuchanobjectwhichisusedforanyfutheroperationwiththisobject.

int DrawTextBox(string text,datetime dt, double price);

int DrawTextBox(string text, int shift=0);

bool DeleteTextBox(int id);

5.9DrawingcandlesAnyfunctionwhichdrawsacandlereturnsanintegervalue.Thisvaluerepresentstheidofsuchanobjectwhichisusedforanyfutheroperationwiththisobject.

int DrawCandle(CBar &bar, datetime time, datetime timeend);

int DrawCandle(CBar *bar, datetime time, datetime timeend);

bool UpdateCandle(int id, CBar &bar);

bool UpdateCandle(int id, CBar *bar);

bool DeleteCandle(int id);

45

6.DialogfieldsStereoTrader allows for easy implementing of dialog fields which are located on a panel. The object whichallowsaccesstoallsuchfieldsisdefinedas_Panel.

(Thischapterisnotimplementedyet.)

//+------------------------------------------------------------------+ //| VolumeBreakout.mq4 | //| Copyright 2016, Dirk Hilger | //| https://www.stereotrader.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, Dirk Hilger" #property link "https://www.stereotrader.net" #property version "1.00" #property strict //+----------------------------- -------------------------------------+ //| Indicator properties | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_height 48 //+------------------------------------------------------------------+ //| Includes | //+------------------------------------------------------------------+ #include <StereoTrader_API\StereoAPI.mqh> //+------------------------------------------------------------------+ //| StereoEA declaration | //+------------------------------------------------------------------+ DECLARE_SEA_BEGIN("VolBreakOut") //+------------------------------------------------------------------+ //| Objects | //+------------------------------------------------------------------+ CSButton m_mode; //--- Intrabar / prev bar CSNumEdit m_lookback; //--- Edit field shift CSNumEdit m_mult; //--- Edit field span CSNumEdit m_minpips; //--- Edit field Slow MA //+------------------------------------------------------------------+ //| Initialization function | //+------------------------------------------------------------------+ SEA_INIT { //--- Settings // We start operating on the previous bar SetDefaultShift(1); //--- Allow multiple trades signals same direction SetSignalOverlap(false); //--- Close opposite in case of countersignal SetSignalOpposite(SEA_OPPOSITE_CLOSE); //--- Add panel title _Panel.AddTitle(m_name); //--- Add edit fields _Panel.AddButton(m_mode,"Mode","Close","Tick",false); _Panel.AddNumEdit(m_lookback,"Vol Span",14); _Panel.AddNumEdit(m_mult,"Vol Th",2.0,1); _Panel.AddNumEdit(m_minpips,"Body pips",10); //--- return(true); } //+------------------------------------------------------------------+ //| Check signal | //+------------------------------------------------------------------+ SEA_EVALUATE { static long averagevolume=0; static int span=0;

46

static double mult=0; static double minbarrange=0; //--- Calculate on new bar and fetch fields on new bar (saves time) if (IsNewBar()) { //--- Fields span=MAX(1,(int)m_lookback.Value()); mult=mult=m_mult.Value(); minbarrange = PointsToPrice(m_minpips.Value()); if (m_mode.Pressed()) { SetEveryTick(true); averagevolume=_Bars.TickVolumeAverage(span,1); } else { SetEveryTick(false); averagevolume=_Bars.TickVolumeAverage(span); } //--- Average volume } //--- Checks if (averagevolume==0) { Print("No volume info present! Bar: ",_Index); return; } if (_Bars.BodyRange()<minbarrange) return; //--- Check volume long volThis=_Bars.TickVolume(); if (volThis>=(averagevolume*mult)) { if (_Bars.IsBullish()) Buy(); else Sell(); } } DECLARE_SEA_END

47

7.Notesforadvanceddevelopers

7.1ClassframeAny code between DECLARE_SEA_BEGIN and DECLARE_SEA_END is part of a class which derives from the base classesCStereoEAandCStereoEAEvents, themacrosdefinetheframetoembedanyfunction intotheclassCSEADev. Incase ifyouusedearlierversionsoftheAPI,thecodeisstillcompatible.ThenameofthepublicCStereoEAEventsclassobjectis__SEA.

• SEA_INITisreplacedbyvirtualboolOnInit()

• SEA_EVALUATEisamacrowhichisreplacedbyvirtualvoidOnEvaluate()

• SEA_INDICATEisamacrowhichisreplacedbyvirtualvoidOnIndicate()

• SEA_DEINITisreplacedbyvirtualvoidOnDeinit(constintreason)

• SEA_CHARTEVENTbyvirtualvoidOnChartEvent(…)

• SEA_CALCULATEbyvirtualvoidOnCalculate(…).

Insteadofusingthesemacros,youmayfeelfreetousethenormalfunctionnames.

48

8.Furtherclasses&functionsoftheAPIThe functions described before are local functions of the SEA framework, inside the class CSEADev, defined byDECLARE_SEA_BEGINandDECLARE_SEA_END.TheAPIcontainsmuchmorefunctionsandclasseswhichmaybeusedbyanSEA.

8.1CompatibilityMT4/MT5It´shighlyrecommendedtoNOTusenativeMetaTraderfunctions,ratheryoushoulduseonlythefunctionsoftheAPIfilesinstead. The reason is the compatibility betweendifferentbuildsofMetaTrader aswell as compatiblitybetweenMT4andMT5.Whenusingthesefunctions,youarealways100%compatible.IfyoutakealookattheforumsofMetaQuotes,youwillfind hundreds of desperate users who worry about porting from MT4 to MT5. If you decide to develop with theframework/APIofStereoTrader,youdon´thavetoworryaboutitall–youarealwayscompatiblewithoutanychange.

8.2File__MT_native.mqhThisfilecontainspublicfunctionsforthemostcommonreasons.ThefunctionsreplacemanynativeMTlanguagecommands,italsocontainsusefulmacros.Almosteveryfunctionnamebeginswiththeprefix“__MT_”.Pleasefeelalsofreetotakealookatthefileandtofindadditionalfunctionsforyourpurposes.

Thefilealsocontainsseveralpublicobjects.Theseare

• __TerminalbyCMTTerminalclass–propertiesandfunctionsregardingtheenvironment

• __AccountbyCMTAccountclass–propertiesandfunctionsregardingtheaccountandbroker

• __TimebyCTimeNativeclass–accesstotimefunctions

8.3File__ChartExt.mqhThisfilecontainstheclassCChartExtaswellasapublicobjectnamed

__Chart

Theobjectallowsforquickaccessandenhancedfunctionalityof/withthechart.

8.4FileXVars.mqhThisfilecontainsclasswhichallowforextendedvariablesharingbetweendifferentchartsandinstancesofMT4andMT5.Itreplacesandenhancesthefunctionalityofglobalvariables,whichyoumayknowfromMQL.BesidestheclassCXVarsthereareseveralpredefinedpublicobjects:

• __ChartVars–allowsforsharingvariablesinsideonechartandmaybeaccessedbymultipleSEAs

• __LocalVars–allowsforsharingvariablesinsidetheMT4orMT5environmentandbetweendifferentcharts

• __GlobalVars–variablesharingbetweenmultipleinstancesofeitherMT4orMT5

• __GlobalMTXVars–variablesharingbetweenallinstancesofMetaTrader

Theseobjectscanbeaccessedwithoutanyinitializationordeinitialization.

Themostimportantfunctionsare:

49

bool SetDouble(string name, double value, bool permanent=false)

Stores a double value by a given name. If permanent is set to true, the variable willoverduetheruntimeofanSEA.

bool SetString(string name, string value, bool permanent=false)

Stores a string value by a given name. If permanent is set to true, the variable willoverduetheruntimeofanSEA.

double GetDouble(string name)

Readsadoublevaluebyagivenname.

string GetString(string name)

Readsastringvaluebyagivenname.

bool IsDefined(string name)

Returnstrueifthevariableisdefined

bool Delete(string name)

Readsastringvaluebyagivenname.

Ifyouwanttousetheclassforfurhterpurposes,thesefunctionsallowtocreateownvariabledatabases:

bool InitByChart(string prefix=NULL, CHART id=NULL, bool commonfolder=false)

Createsoropensadatabasebyusingthecurrentchart.

bool Init(string filename, bool commonfolder=false)

Createsoropensanindividualdatabase.

8.5FileComment.mqhYoumayknowtheMQLcommand“Comment”.TheCCommentclassenhancesthefunctionalityofprintingtextintheupperleftcornerofthechart.Commentsmaydisplayedinseparateblocks,wherebyeachinheritant/instancedefinesablock.Youmaydefineyourowninstanceoryoumayusethepredefinedpublicobject__Comment.

Please note that SEAs should not use the class object, rather you should use the functionMessageChart(). Thisway youensurethatStereoTraderhandlestheoutputandmanagesitwithoutputsofotherSEAs.

void Append(string value)

Addsatexttothecommentblock

void Clear()

Deletesallcomments

50

Copyright/ImpressumStereoTraderisdevelopedundergermancopyrightprotectionby

DirkHilgerGottesweg64

50969CologneGermany

[email protected]

Allrightsarereserved.UsageofStereoTraderisalwaysonyourownrisk.

51

Getreadyforsuccess.