sending trading signals in a universal expert advisor - mql4 articles

Upload: vulpe-maria

Post on 10-Jan-2016

280 views

Category:

Documents


7 download

DESCRIPTION

fdh

TRANSCRIPT

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 1/15

    Introduction

    Some time ago I decided to try to universalize and unitize a process ofdeveloping Expert Advisors in the topic "The Development of a UniversalExpert Advisor". This implied working out a certain standard of developingmainunitbricks,which later couldbeused to construct ExpertAdvisors likefrompartsofanconstructionkit.Partlythistaskwasimplemented.IofferedastructureofauniversalEAandanideaofauniversaluseofsignalsofdifferentindicators.InthisarticleIwillcontinuethisworkIwilltrytouniversalizetheprocess of forming and sending trading signals and item management inExpertAdvisors.InthiscontextanitemmeansanoperationBUYorSELL,alllater discussion will refer to such operations. This article does not describepending orders BUYLIMIT, BUYSTOP, SELLLIMIT and SELLSTOP, but at theendofthearticleIwillshow,thatthismyapproachcanbeeasilyappliedonthem.

    ClassificationofTradingSignals

    Thereareseveraltypesoftradingsignals:

    1. Buy2. Sell3. Additionalbuy(averaging)4. Additionalsell(averaging)5. Fullbuyclose6. Fullsellclose7. Partialbuyclose8. Partialsellclose.

    Ifwetransposethedecisionaboutaveragingandpartialclosingfromtheunitof trading signals formation into the positions and ordersmanagement unit,thislistwillbereducedtothefollowing:

    1. Buy2. Sell

    Download MetaTrader 5

    IGOR KIM

    METATRADER 4 EXAMPLES

    SENDING TRADING SIGNALS IN AUNIVERSAL EXPERT ADVISOR

    17 July 2007, 13:41

    0 629

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 2/15

    3. Closebuy4. Closesell5. Donothing(normaloperationofEArequiressuchsignal).

    Assumingthis,theoperationschemeofEAshouldbethefollowing:

    1. Asignalitemcreatesatradingsignal2. A tradingsignalenters thepositionsmanagementunit,whichdecides

    on new openings, averaging, partial or full closing and sends theshortened trading signal into the program unit of trading signalsprocessing

    3. The unit of trading signals processing directly performs tradingoperations.

    InthisarticleIwouldliketodwellondifferentwaysofformingtradingsignalsand ways of their sending to positions management unit, i.e. the interfacebetweentheunits,mentionedinpoints1and2.

    SwingTradingonOnePosition

    Themeaningofsuchtradingisthefollowing:beforeopeninganewposition,the previous one should be closed. The new position is opposite to thepreviousone.Ifitwasbuy,weopensellandviceverse.Inthiscasemomentsofpositionopeningandclosingconcurintime,thatiswhyclosingsignalscanbe omitted. So the implementation of swing trading requires sending onlythreetradingsignals:buy,sellanddonothing.Thesesignalscanbesentusingoneintvariable.Forexample:

    1buy0donothing1sell.

    Thenthepartofanalysingmarketsituationandcreatingatradingsignalcanbewritteninaseparatefunction,forexampleGetTradeSignal(),

    whichreturnstheabovementionedintegervalues.Activationofthisfunctioniseasiestdonedirectlyinthepositionsmanagementunit.

    //++//|Returnstradingsignal:|//|1buy|//|0donothing|//|1sell|//|Parameters:|//|symnameoftheinstrument(""currentsymbol)|//|tftimeframe(0currenttimeframe)|//++intGetTradeSignal(stringsym="",inttf=0){intbs=0if(sym=="")sym=Symbol()//Blockofanalysisassigningavaluetothevariablebsreturn(bs)}//++

    //++

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 3/15

    In this case a single local variable bs of the integer type acts as a linkerbetween two program units. The full text of the example source code forswingtradingbyonepositionislocatedinthefileeSampleSwing.mq4.

    SimpleTradingonOnePosition

    This case is a little more difficult. Though in the market there is only onepositionateachpointoftime,itsclosingisnotconnectedwiththeopeningofanotherone.Thatiswhyasuccessfulpositionsmanagementrequiresusingallfivesignals:buy,sell, closebuyposition,closesellposition,anddonothing.They can be sent in one integer type variable with the following valuesassigned:

    2closesellposition

    1buy

    0donothing

    1sell

    //|Positionsmanagement|//++voidManagePositions(){doublesl=0,tp=0intbs=GetTradeSignal()if(bs>0){if(ExistPositions("",OP_SELL))ClosePositions("",OP_SELL)if(!ExistPositions("",OP_BUY)){if(StopLoss!=0)sl=AskStopLoss*Pointif(TakeProfit!=0)tp=Ask+TakeProfit*PointOpenPosition("",OP_BUY,sl,tp)}}if(bs

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 4/15

    2closebuyposition.

    Positionsmanagementunitcanbewritteninonefunction:

    ThefulltextoftheexamplesourcecodeforsimpletradingbyonepositionislocatedinthefileeSampleSimple.mq4.

    Themaindisadvantageofsendingatradingsignalinonevariableisthatyoucannot send several signals simultaneously (disadvantages of a serialinterface) forexample,youcannotopen inbothdirections,oropenwithasimultaneousclosingofanexistingposition,orcloseallpositions.Partiallythisdisadvantagecanbeeliminatedbydividingasignalintotwointegers.

    Therearethreewaysofdividingasignal:

    1. Open inonevariable,close inanotherone.Youcancombineopeningandclosing, i.e. organize swing trading,but you cannotopen inbothdirectionsorclosecounterdirectionpositions

    2. BUY positions (open and close) are in one variable, SELL positions(open and close) are in another one. You can open positions in bothdirectionsandcloseallpositionsatonce,butyoucannotsimultaneouslyopen and close, for example, buy or sell position, i.e. you cannotreopen

    3. OpenBUYandcloseSELLinonevariable,openSELLandcloseBUYinanother.Youcanopeninbothdirectionsandcloseallpositions,butyou

    //++//|Positionsmanagement|//++voidManagePositions(){doublesl=0,tp=0intbs=GetTradeSignal()if(ExistPositions()){if(bs==2)ClosePositions("",OP_SELL)if(bs==2)ClosePositions("",OP_BUY)}else{if(bs==1){if(StopLoss!=0)sl=AskStopLoss*Pointif(TakeProfit!=0)tp=Ask+TakeProfit*PointOpenPosition("",OP_BUY,sl,tp)}if(bs==1){if(StopLoss!=0)sl=Bid+StopLoss*Pointif(TakeProfit!=0)tp=BidTakeProfit*PointOpenPosition("",OP_SELL,sl,tp)}}}//++

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 5/15

    cannotorganiseswingtrading.

    Letustrytoimplementthesecondvariant,becausereopeningisratherrare.No one wants to lose money at spread. The second variant can beimplementedinseveralways.

    1.Two functions returnvalues into two localvariables.One functioncreatessignalsforbuying,thesecondoneforselling.

    //++//|Returnstradingsignalforlongpositions:|//|1buy|//|0donothing|//|1closeBUY|//|Parameters:|//|symnameoftheinstrument(""currentsymbol)|//|tftimeframe(0currenttimeframe)|//++intGetTradeSignalBuy(stringsym="",inttf=0){intbs=0if(sym=="")sym=Symbol()//Blockofanalysisassigningavaluetothevariablebsreturn(bs)}//++//|Returnstradingsignalforshortpositions:|//|1sell|//|0donothing|//|1closeSELL|//|Parameters:|//|symnameoftheinstrument(""currentsymbol)|//|tftimeframe(0currenttimeframe//++intGetTradeSignalSell(stringsym="",inttf=0){intbs=0if(sym=="")sym=Symbol()//Blockofanalysisassigningavaluetothevariablebsreturn(bs)}//++//|Positionsmanagement|//++voidManagePositions(){doublesl=0,tp=0intbs=GetTradeSignalBuy()intss=GetTradeSignalSell()if(ExistPositions()){if(bs

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 6/15

    Thisisasimpleandconvenientwaytocreateandsendatradingsignal,butasignalunit isdivided into two functionswhichwouldprobably slowdown itsoperation.

    2.Twoglobalvariablesacquirevaluesinonefunction.

    {if(StopLoss!=0)sl=AskStopLoss*Pointif(TakeProfit!=0)tp=Ask+TakeProfit*PointOpenPosition("",OP_BUY,sl,tp)}if(ss>0){if(StopLoss!=0)sl=Bid+StopLoss*Pointif(TakeProfit!=0)tp=BidTakeProfit*PointOpenPosition("",OP_SELL,sl,tp)}}}//++

    //++BuySignal=0SellSignal=0//++//|Createstradingsignals.|//|Parameters:|//|symnameoftheinstrument(""currentsymbol)|//|tftimeframe(0currenttimeframe)|//++voidFormTradeSignals(stringsym="",inttf=0){if(sym=="")sym=Symbol()//BlockofanalysisassigningavaluetothevariableBuySignalandSellSignal}//++//|Positionsmanagement|//++voidManagePositions(){doublesl=0,tp=0FormTradeSignals()if(ExistPositions()){if(BuySignal

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 7/15

    Itisclearfromthissourcecode,thatrealizationwithglobalvariablesdoesnotdiffermuchfromthefirstmethod.Theapparentadvantageisthatthesignalmodeisinonefunction.

    3.Twolocalvariablesarepassedbyreferencetoonefunction.

    OpenPosition("",OP_BUY,sl,tp)}if(SellSignal>0){if(StopLoss!=0)sl=Bid+StopLoss*Pointif(TakeProfit!=0)tp=BidTakeProfit*PointOpenPosition("",OP_SELL,sl,tp)}}}//++

    //++//|Returnstradingsignals.|//|Parameters:|//|bsBUYsignal|//|ssSELLsignal|//|symnameoftheinstrument(""currentsymbol)|//|tftimeframe(0currenttimeframe)|//++voidGetTradeSignals(int&bs,int&ss,stringsym="",inttf={if(sym=="")sym=Symbol()//Blockofanalysisassigningavaluetovariablesbsandss}//++//|Positionsmanagement|//++voidManagePositions(){doublesl=0,tp=0intbs=0,ss=0GetTradeSignals(bs,ss)if(ExistPositions()){if(bs0){if(StopLoss!=0)

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 8/15

    4.Anarrayoftwoelements.Ifitisglobal,itisinitializedinsidethefunction.Ifitislocal,itispassedbyreference.Everythingiseasyhereonearrayinsteadof two variables. Global elements and local elements by reference werediscussedearlier.Nothingnew.

    And, finally, we can organize a fullvalued parallel interface sending tradingsignals,dividing it into fourvariables.Forpositionsmanagementeachsignalhastwostates:existsornot.Thatiswhyweshouldbetterdealwithvariablesof logical type.You can combine signals, sending themusing four variables,limitless.Hereisanexampleofacodewithanarrayoffourelementsoflogicaltype.

    sl=Bid+StopLoss*Pointif(TakeProfit!=0)tp=BidTakeProfit*PointOpenPosition("",OP_SELL,sl,tp)}}}//++

    //++//|Returnstradingsignals.|//|Parameters:|//|msarrayofsignals|//|symnameoftheinstrument(""currentsymbol)|//|tftimeframe(0currenttimeframe)|//++voidGetTradeSignals(bool&ms[],stringsym="",inttf=0){if(sym=="")sym=Symbol()//Blockofanalysisfillingmsarray://ms[0]=True//Buy//ms[1]=True//Sell//ms[2]=True//CloseBuy//ms[3]=True//CloseSell}//++//|Positionsmanagement|//++voidManagePositions(){boolms[4]={False,False,False,False}doublesl=0,tp=0GetTradeSignals(ms)if(ExistPositions()){if(ms[2])ClosePositions("",OP_BUY)if(ms[3])ClosePositions("",OP_SELL)}if(!ExistPositions()){if(ms[0]){if(StopLoss!=0)sl=AskStopLoss*Point

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 9/15

    Implementationwithlocalvariables,passedbyreferencetoonefunction,andwith global variables, initialized inside one function, should not cause anyproblems.However,initializationoffourlocalvariablesbyvalues,returnedbyfourdifferentfunctions,ishardlyreasonable.

    SupportingtheMainPosition

    Whenasignalcomes,oneposition isopened.Itbecomesthemainposition.All other signal entries against the main position are ignored. Additionalpositionsareopenedonsignals,correspondingwiththemainposition.Attheclosingofthemainposition,alladditionalpositionsarealsoclosed.

    Sendingtradingsignalsforthistacticscanbeimplementedusingone,twoorfour variables.All thiswasdescribedearlier.Thedifficulty, you canmeet, isprovidingtheconnection:onesignaloneposition.Incaseoftradingononepositionthisquestionwassolvedbyasimplecheckofthepositionexistenceusing the function ExistPositions(). If there is a position, entrance signal isomitted,nopositionentrancesignalisperformed.

    So,therearedifferentwaysout:

    1. Providingapausebetweenentrances.Theeasiestrealization2. One bar one entrance. A variety of the firstway. The realization is

    alsoeasy3. Numerating signals and controlling arrays of signals and tickets of

    orders. This is the most difficult implementation with a doubtfulreliability.

    Thisistheexampleofacodeforthefirstmethod:

    if(TakeProfit!=0)tp=Ask+TakeProfit*PointOpenPosition("",OP_BUY,sl,tp)}if(ms[1]){if(StopLoss!=0)sl=Bid+StopLoss*Pointif(TakeProfit!=0)tp=BidTakeProfit*PointOpenPosition("",OP_SELL,sl,tp)}}}//++

    //++externintPauseBetweenEntrys=3600//Pausebetweenentrancesinseconds//++//|Positionsmanagement|//++voidManagePositions(){boolms[4]={False,False,False,False}doublesl=0,tp=0GetTradeSignals(ms)if(ExistPositions()){if(ms[2])

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 10/15

    The full text of the example source code for the tacticswith supporting themainpositionislocatedinthefileeSampleMain.mq4.

    SwingTradingwithAveraging

    ClosePositions("",OP_BUY)if(ms[3])ClosePositions("",OP_SELL)}if(SecondsAfterOpenLastPos()>=PauseBetweenEntrys){if(ms[0]){if(StopLoss!=0)sl=AskStopLoss*Pointif(TakeProfit!=0)tp=Ask+TakeProfit*PointOpenPosition("",OP_BUY,sl,tp)}if(ms[1]){if(StopLoss!=0)sl=Bid+StopLoss*Pointif(TakeProfit!=0)tp=BidTakeProfit*PointOpenPosition("",OP_SELL,sl,tp)}}}//++//|Returnsnumberofsecondsafterthelastpositionisopened.|//|Parameters:|//|symnameoftheinstrument(""currentsymbol)|//|opoperation(1anyposition)|//|mnMagicNumber(1anymagicnumber)|//++datetimeSecondsAfterOpenLastPos(stringsym="",intop=1,int{datetimeootinti,k=OrdersTotal()if(sym=="")sym=Symbol()for(i=0iki++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==sym){if(OrderType()==OP_BUY||OrderType()==OP_SELL{if(op0||OrderType()==op){if(mn0||OrderMagicNumber()==mn){if(ootOrderOpenTime())oot=OrderOpenTime()}}}}}}return(CurTime()oot)}//++

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 11/15

    Whenanentrancesignalcomes,onepositionisopened.Basedonallfurthersignals in the direction of the first position, new additional positions areopened.Whenasignalcomesagainst theexistingpositions,allpositionsareclosedandoneposition isopened in thedirectionof thesignal.The tradingsignalisrepeated.

    Sendingandexecutionoftradingsignalsforswingtradingononepositionhasbeendiscussed.Letusadaptthisexampletoimplementtheoptionofopeningadditionalpositions.Toprovidetheconnectiononesignaloneposition,letususetherestrictionofentrancepossibilitybyatimeperiodofonebar.Onebaroneentrance.

    //++//|Positionsmanagement|//++voidManagePositions(){doublesl=0,tp=0intbs=GetTradeSignal()if(bs>0){if(ExistPositions("",OP_SELL))ClosePositions("",OP_SELL)if(NumberOfBarLastPos()>0){if(StopLoss!=0)sl=AskStopLoss*Pointif(TakeProfit!=0)tp=Ask+TakeProfit*PointOpenPosition("",OP_BUY,sl,tp)}}if(bs0){if(StopLoss!=0)sl=Bid+StopLoss*Pointif(TakeProfit!=0)tp=BidTakeProfit*PointOpenPosition("",OP_SELL,sl,tp)}}}//++//|Returnsthebarnumberofthelastpositionopeningor1.|//|Parameters:|//|symnameoftheinstrument(""currentsymbol)|//|tftimeframe(0currenttimeframe)|//|opoperation(1anyposition)|//|mnMagicNumber(1anymagicnumber)|//++intNumberOfBarLastPos(stringsym="",inttf=0,intop=1,int{datetimeootinti,k=OrdersTotal()if(sym=="")sym=Symbol()for(i=0iki++){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 12/15

    The full textof theexamplesourcecode forswing tradingwithaveraging islocatedinthefileeSampleSwingAdd.mq4.

    PortfolioTactics

    Foreach tradingsignaloneposition isopenedandsupported irrespectiveofothers.

    Atfirstsightthisisthemostcomplicatedvariantoftradingsignalsexecutioninterms of software implementation. Here except sending trading signals, youneedtosendthebelongingofasignaltooneportfoliooranother.Butifyoudividethesignals intogroups,whichconstituteaportfolio,youwillsee, thateachseparategroup isa simpleoneposition trading.Thewayof combininggroupsintoaportfolioisevident:assignauniquenumbertoeachgroupandsetasearchofallgroupsinacycle.Hereisanexampleoffoursignalgroups:

    if(OrderSymbol()==sym){if(OrderType()==OP_BUY||OrderType()==OP_SELL{if(op0||OrderType()==op){if(mn0||OrderMagicNumber()==mn){if(ootOrderOpenTime())oot=OrderOpenTime}}}}}}return(iBarShift(sym,tf,oot,True))}//++

    //++//|Returnstradingsignals.|//|Parameters:|//|msarrayofsignals|//|nsnumberofasignal|//|symnameoftheinstrument(""currentsymbol)|//|tftimeframe(0currenttimeframe)|//++voidGetTradeSignals(bool&ms[],intns,stringsym="",inttf{if(sym=="")sym=Symbol()//Switchingsignalgroupsusingoperatorsswitchorif//Blockofanalysisfulfillingthearrayms://ms[0]=True//Buy//ms[1]=True//Sell//ms[2]=True//CloseBuy//ms[3]=True//CloseSell}//++//|Positionsmanagement|//++voidManagePositions(){boolms[4]doublesl=0,tp=0inti

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 13/15

    ThefulltextoftheexamplesourcecodeforprofiletacticsislocatedinthefileeSampleCase.mq4.

    TradingSignalsforOrders

    Let us view the list of trading signals, necessary for working with pendingorders.

    1. SetBuyLimit2. SetSellLimit3. SetBuyStop4. SetSellStop5. DeleteBuyLimit6. DeleteSellLimit7. DeleteBuyStop8. DeleteSellStop9. ModifyBuyLimit

    10. ModifySellLimit11. ModifyBuyStop12. ModifySellStop.

    You can easily guess that with pending orders you could want to sendsimultaneouslyfourormoretradingsignals.AndwhatiftheEAlogicrequiresworkingbothwithpositionsandorders?

    Hereistheextendedfulllistofalltradingsignals.

    1. OpenBuy2. OpenSell3. SetBuyLimit

    for(i=0i4i++){ArrayInitialize(ms,False)GetTradeSignals(ms,i)if(ExistPositions("",1,MAGIC+i)){if(ms[2])ClosePositions("",OP_BUY,MAGIC+i)if(ms[3])ClosePositions("",OP_SELL,MAGIC+i)}if(!ExistPositions("",1,MAGIC+i)){if(ms[0]){if(StopLoss!=0)sl=AskStopLoss*Pointif(TakeProfit!=0)tp=Ask+TakeProfit*PointOpenPosition("",OP_BUY,sl,tp,MAGIC+i)}if(ms[1]){if(StopLoss!=0)sl=Bid+StopLoss*Pointif(TakeProfit!=0)tp=BidTakeProfit*PointOpenPosition("",OP_SELL,sl,tp,MAGIC+i)}}}}//++

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 14/15

    4. SetSellLimit5. SetBuyStop6. SetSellStop7. CloseBuy8. CloseSell9. DeleteBuyLimit

    10. DeleteSellLimit11. DeleteBuyStop12. DeleteSellStop13. ModifyBuyLimit14. ModifySellLimit15. ModifyBuyStop16. ModifySellStop.

    Sixteentradingsignals!Twobytes!Therewasalsoanideatosendsignalsasabinarynumber,but inastring.Forexample,00101...,where thepositionofzerooronewouldbeinchargeofadefinitesignal.Buttherewouldbealotoffuss with substrings and decoding of signals. So, you see, that the mostconvenient way out is an array with the number of elements, equal to thenumberof signals.Besides, forbetter convenienceof reference to thearrayelements, indexes can be defined as constants. MQL4 already containsOP_BUY,OP_SELLandsoon.Wecaneasilycontinue:

    #defineOP_CLOSEBUY6#defineOP_CLOSESELL7#defineOP_DELETEBUYLIMIT8#defineOP_DELETESELLLIMIT9#defineOP_DELETEBUYSTOP10#defineOP_DELETESELLSTOP11#defineOP_MODIFYBUYLIMIT12#defineOP_MODIFYSELLLIMIT13#defineOP_MODIFYBUYSTOP14#defineOP_MODIFYSELLSTOP15

    and refer to thearrayelements:ms[OP_BUY]orms[OP_MODIFYSELLLIMIT]insteadofms[0]andms[13].Still,thisisthematteroftaste.Ipreferconciseandsimplecodes,thatiswhyIchoosefigures.

    Letuscontinue.Everythingseemseasyandnice!Butwealsoneedpricelevelsof setting orders, stops and takeprofit levels for positions, because eachtradingsignalcanbeartheinformationaboutacertainstopandtakeprofitandacertainpricelevelofsettinganorder.Buthowcanwepassthisinformationtogetherwithatradingsignal?Iofferthefollowingwayout:

    1. Declare a twodimensional arraywith a number of lines equal to thenumberofsignals,andthreecolumns

    2. Thefirstcolumnwillpointbythezerovalueattheabsenceofasignal,by the nonzero value at the existence of a signal for a position (apricelevelofsettinganorder)

    3. Thesecondcolumnstops4. Thethirdcolumntakeprofitlevels.

    Thefulltextoftheexamplesourcecodefortradingwithorders is locatedinthefileeSampleOrders.mq4.

    Andwhat,ifweneedtosetseveralBuyLimitorseveralSellStop?Andtoopenpositions?Inthiscasewewilldoasdescribedinthepart"PortfolioTactics"ofthis article, i.e. use a profile tacticswith position and order identification bymagicnumbers.

    Conclusion

  • 9/14/2015 'SendingTradingSignalsinaUniversalExpertAdvisorMQL4Articles

    https://www.mql5.com/en/articles/1436 15/15

    Itistimetosumeverythingup:

    1. Sending signals usingone variablehas somedisadvantageof a serialinterfaceonlyonesignalcanbesentateachpointoftime

    2. Implementing a parallel interface leads to the larger number ofvariables and complicates their management, but allows sendingsimultaneouslydozensofsignals.

    So, using one or another method of sending trading signals must bedeterminedbyexpediency.

    TranslatedfromRussianbyMetaQuotesSoftwareCorp.Originalarticle:http://articles.mql4.com/ru/articles/1436

    TranslatedfromRussianbyMetaQuotesSoftwareCorp.Originalarticle:https://www.mql5.com/ru/articles/1436

    Attachedfiles| DownloadZIPbPositions.mqh (20.13KB)eSampleCase.mq4 (7.12KB)eSampleMain.mq4 (7.94KB)eSampleOrders.mq4 (14.71KB)eSampleSimple.mq4 (6.88KB)eSampleSwing.mq4 (6.8KB)eSampleSwingAdd.mq4 (8.01KB)

    Warning:AllrightstothesematerialsarereservedbyMQL5Ltd.Copyingorreprintingofthesematerialsinwholeor

    JoinusdownloadMetaTrader5!

    MQL5StrategyLanguage|SourceCodeLibrary|HowtoWriteanExpertAdvisororanIndicator|Order

    DevelopmentofExpertAdvisorDownloadMetaTrader5|MetaTrader5TradePlatform|ApplicationStore|MQL5CloudNetwork

    About|WebsiteHistory|TermsandConditions|PrivacyPolicy|ContactsCopyright20002015,MQL5Ltd.

    Windows iPhone/iPad MacOS Android Linux