C:\Users\User\Desktop\EAs\Blessing_3_v3.9.6.17.mq5 C:\Users\User\Desktop\EAs\Blessing_3_v3.9.6.16.mq5
//+---------------------------------------------------------------------+¤ //+---------------------------------------------------------------------+¤
//|············································Blessing_3_v3.9.6.17.mq5· //|············································Blessing_3_v3.9.6.15.mq5·
//|·····················································October·32020· //|·····················································August·292020·
//|····································································· //|·····································································
//|·····In·no·event·will·authors·be·liable·for·any·damages·whatsoever.·· //|·····In·no·event·will·authors·be·liable·for·any·damages·whatsoever.··
//|·························Use·at·your·own·risk.······················· //|·························Use·at·your·own·risk.·······················
//|····································································· //|·····································································
//|··This·EA·is·dedicated·to·Mike·McKeough,·member·of·the·Blessing···· //|··This·EA·is·dedicated·to·Mike·McKeough,·member·of·the·Blessing····
//|··Development·Group,·who·passed·away·on·Saturday,·31st·July·2010.···· //|··Development·Group,·who·passed·away·on·Saturday,·31st·July·2010.····
//|··His·contributions·to·the·development·of·this·EA·have·helped·make··· //|··His·contributions·to·the·development·of·this·EA·have·helped·make···
//|··it·what·it·is·today,·and·we·will·miss·his·enthusiasm,·dedication··· //|··it·what·it·is·today,·and·we·will·miss·his·enthusiasm,·dedication···
//|··and·desire·to·make·this·the·best·EA·possible.······················ //|··and·desire·to·make·this·the·best·EA·possible.······················
//|··Rest·In·Peace.····················································· //|··Rest·In·Peace.·····················································
//+---------------------------------------------------------------------+¤ //+---------------------------------------------------------------------+¤
//·This·work·has·been·entered·into·the·public·domain·by·its·authors·...¤ //·This·work·has·been·entered·into·the·public·domain·by·its·authors·...¤
//·Copyrights·have·been·rescinded.¤ //·Copyrights·have·been·rescinded.¤
//·¤ //·¤
//·The·conversion·of·this·EA·to·the·MetaTrader·version·was·requested¤ //·The·conversion·of·this·EA·to·the·MetaTrader·version·was·requested¤
//·to·developer·by·the·Forex·Factory·community,·with·the·monetary·¤ //·to·developer·by·the·Forex·Factory·community,·with·the·monetary·¤
//·contribution·and·many·hours·of·work·and·dedication·to·implement·¤ //·contribution·and·many·hours·of·work·and·dedication·to·implement·¤
//·improvements.·Thanks·to·all·of·them!¤ //·improvements.·Thanks·to·all·of·them!¤
//¤ //¤
//+---------------------------------------------------------------------+¤ //+---------------------------------------------------------------------+¤
¤ ¤
#property·copyright·""¤ #property·copyright·""¤
#property·link······"https://www.forexfactory.com/thread/792598-most-famous-blessing-396-ea-and-setfiles?goto=lastpost"¤ #property·link······"https://www.forexfactory.com/thread/792598-most-famous-blessing-396-ea-and-setfiles?goto=lastpost"¤
#property·version···""¤ #property·version···""¤
¤ ¤
///////////////////////////¤ ///////////////////////////¤
//MT4·Orders¤ //MT4·Orders¤
//////////////////////////¤ //////////////////////////¤
//·MQL4&5-code¤ //·MQL4&5-code¤
¤ ¤
//·������������·�������������·MT4·�·MT5·��������·������.¤ //·������������·�������������·MT4·�·MT5·��������·������.¤
//·https://www.mql5.com/ru/code/16006¤ //·https://www.mql5.com/ru/code/16006¤
¤ ¤
//·������·mqh-����·�����·����������������·#include·���������·��������·�·��������·�·MQL5·(MT5-Hedge)·�����·���·��,·���·�·MQL4.¤ //·������·mqh-����·�����·����������������·#include·���������·��������·�·��������·�·MQL5·(MT5-Hedge)·�����·���·��,·���·�·MQL4.¤
//·�.�.·��������·��������·�������·(���)·����������·����������·MQL4.·���·����·�����������·�����������·�����������·������������¤ //·�.�.·��������·��������·�������·(���)·����������·����������·MQL4.·���·����·�����������·�����������·�����������·������������¤
//·MQL5-��������·�������.·�·���������,·�����������·MQL5-����������·�����·����������·����������·��������.¤ //·MQL5-��������·�������.·�·���������,·�����������·MQL5-����������·�����·����������·����������·��������.¤
//·�����·�����·���������·���������·������·��·�����.·�����������·��·�����������!¤ //·�����·�����·���������·���������·������·��·�����.·�����������·��·�����������!¤
¤ ¤
//·���·��������·MQL4·->·MQL5·��������·�������·�������·������·��·���������.¤ //·���·��������·MQL4·->·MQL5·��������·�������·�������·������·��·���������.¤
//·����������·������·������·����·�������·�·������·(����·��������·��������·���������������·�·MT4·���·#property·strict):¤ //·����������·������·������·����·�������·�·������·(����·��������·��������·���������������·�·MT4·���·#property·strict):¤
¤ ¤
//·#include·<MT4Orders.mqh>·//·����·����·#include·<Expert/Expert.mqh>,·��������·���·�������·�����¤ //·#include·<MT4Orders.mqh>·//·����·����·#include·<Expert/Expert.mqh>,·��������·���·�������·�����¤
¤ ¤
//·����������·��������·(����������·�����·������)·�·�����·MQL5-�����,·�����·��������·�·MT5-���·���·�·MT4-���,·����·���������·��������·��.¤ //·����������·��������·(����������·�����·������)·�·�����·MQL5-�����,·�����·��������·�·MT5-���·���·�·MT4-���,·����·���������·��������·��.¤
¤ ¤
//·�����·��������·�����·�����������·���·����,·�������·���������·��·��������·��������·��·����·��������·"�����·�������"¤ //·�����·��������·�����·�����������·���·����,·�������·���������·��·��������·��������·��·����·��������·"�����·�������"¤
//·���·���������,·�����������·��������,·�����������·�·�.�.¤ //·���·���������,·�����������·��������,·�����������·�·�.�.¤
¤ ¤
//·������·������·�����������·������·��������·�������.¤ //·������·������·�����������·������·��������·�������.¤
¤ ¤
//·������·�����������·��������·��������·������·����������,·�����·MQL4-���·�����·��������·�·MT5·���·���������,·��·�������.¤ //·������·�����������·��������·��������·������·����������,·�����·MQL4-���·�����·��������·�·MT5·���·���������,·��·�������.¤
¤ ¤
//·���·��·�����������:¤ //·���·��·�����������:¤
//···CloseBy-�������·����·����·��·��·�����.·��������,·�·�������,·�����·�����������.¤ //···CloseBy-�������·����·����·��·��·�����.·��������,·�·�������,·�����·�����������.¤
//···�����������·TP·�·SL·��������·�������·��·������·������·(build·1470)·MQL5·�����·������·��·�����.¤ //···�����������·TP·�·SL·��������·�������·��·������·������·(build·1470)·MQL5·�����·������·��·�����.¤
//···����·DEAL_ENTRY_INOUT·�·DEAL_ENTRY_OUT_BY·������.¤ //···����·DEAL_ENTRY_INOUT·�·DEAL_ENTRY_OUT_BY·������.¤
¤ ¤
//·�����������:¤ //·�����������:¤
//···�·MT4·OrderSelect·�·������·SELECT_BY_TICKET·��������·�����·����������·��·MODE_TRADES/MODE_HISTORY,¤ //···�·MT4·OrderSelect·�·������·SELECT_BY_TICKET·��������·�����·����������·��·MODE_TRADES/MODE_HISTORY,¤
//···�.�.·"�����·������·��������·����������·���������������·������".¤ //···�.�.·"�����·������·��������·����������·���������������·������".¤
//···�·MT5·�����·������·��·��������,¤ //···�·MT5·�����·������·��·��������,¤
//···�������·OrderSelect·�·������·SELECT_BY_TICKET·�����·���������·����������·������·���·�����������·�������:¤ //···�������·OrderSelect·�·������·SELECT_BY_TICKET·�����·���������·����������·������·���·�����������·�������:¤
//·····MODE_TRADES:··������������·�������·������������·�����·������·����������·�����¤ //·····MODE_TRADES:··������������·�������·������������·�����·������·����������·�����¤
//·····MODE_HISTORY:·������·����������·�����·������������·�������·������������·�����¤ //·····MODE_HISTORY:·������·����������·�����·������������·�������·������������·�����¤
//¤ //¤
//·��������������,·OrderSelect·�·������·SELECT_BY_TICKET·�·MT5·�·������·�������·(�·�������)·�����·�������·��·��,·���·������������·�·MT4.¤ //·��������������,·OrderSelect·�·������·SELECT_BY_TICKET·�·MT5·�·������·�������·(�·�������)·�����·�������·��·��,·���·������������·�·MT4.¤
//¤ //¤
//·����·�������·OrdersTotal()·��·�������·����������,·��·������������·��������·�����·���������������·MT5-��������.¤ //·����·�������·OrdersTotal()·��·�������·����������,·��·������������·��������·�����·���������������·MT5-��������.¤
¤ ¤
//·������·���������:¤ //·������·���������:¤
//·03.08.2016:¤ //·03.08.2016:¤
//···�����·�������·�·����������·������·��·�������-�������.¤ //···�����·�������·�·����������·������·��·�������-�������.¤
//·29.09.2016:¤ //·29.09.2016:¤
//···Add:·�����������·������·��·�����·(SYMBOL_TRADE_EXECUTION_EXCHANGE).·����������,·���·�����·Netto(��·Hedge)-mode.¤ //···Add:·�����������·������·��·�����·(SYMBOL_TRADE_EXECUTION_EXCHANGE).·����������,·���·�����·Netto(��·Hedge)-mode.¤
//···Add:·����������··"����·����·#include·<Trade/Trade.mqh>,·��������·���·�������·�����"¤ //···Add:·����������··"����·����·#include·<Trade/Trade.mqh>,·��������·���·�������·�����"¤
//········��������·��·"����·����·#include·<Expert/Expert.mqh>,·��������·���·�������·�����".¤ //········��������·��·"����·����·#include·<Expert/Expert.mqh>,·��������·���·�������·�����".¤
//···Fix:·OrderSend·������-�������·����������·�����·�������,·�·��·������.¤ //···Fix:·OrderSend·������-�������·����������·�����·�������,·�·��·������.¤
//·13.11.2016:¤ //·13.11.2016:¤
//···Add:·������·�������������·OrderSend,·OrderModify,·OrderClose,·OrderDelete·�·��������·����������·(����-����·�·�������)·���·�·MT4.¤ //···Add:·������·�������������·OrderSend,·OrderModify,·OrderClose,·OrderDelete·�·��������·����������·(����-����·�·�������)·���·�·MT4.¤
//········������������·�����·�������������·�����·������·�����·MT4ORDERS::OrderSend_MaxPause·�·���.·�������·�����·�������������·�·MT5·~1·��.¤ //········������������·�����·�������������·�����·������·�����·MT4ORDERS::OrderSend_MaxPause·�·���.·�������·�����·�������������·�·MT5·~1·��.¤
//········��-���������·������������·�����·�������������·�����·�����·�������.·MT4ORDERS::OrderSend_MaxPause·����������·�������������.¤ //········��-���������·������������·�����·�������������·�����·�����·�������.·MT4ORDERS::OrderSend_MaxPause·����������·�������������.¤
//···Add:·���������·��������·SlipPage·(OrderSend,·OrderClose)·������·��·����������·������-�������·������·�·Instant-������,¤ //···Add:·���������·��������·SlipPage·(OrderSend,·OrderClose)·������·��·����������·������-�������·������·�·Instant-������,¤
//········��·�����·����·������·���·�������·�����·��������·���·����������·��·�������·ENUM_ORDER_TYPE_FILLING:¤ //········��·�����·����·������·���·�������·�����·��������·���·����������·��·�������·ENUM_ORDER_TYPE_FILLING:¤
//········ORDER_FILLING_FOK,·ORDER_FILLING_IOC·���·ORDER_FILLING_RETURN.¤ //········ORDER_FILLING_FOK,·ORDER_FILLING_IOC·���·ORDER_FILLING_RETURN.¤
//········�·������·����������·�������·���·��·���������·��������·���������·����·����������·�������������·�����·������·�������·�����.¤ //········�·������·����������·�������·���·��·���������·��������·���������·����·����������·�������������·�����·������·�������·�����.¤
//········�������:¤ //········�������:¤
//··········OrderSend(Symb,·Type,·Lots,·Price,·ORDER_FILLING_FOK,·SL,·TP)·���������·���������������·�����·�·�����·����������·ORDER_FILLING_FOK¤ //··········OrderSend(Symb,·Type,·Lots,·Price,·ORDER_FILLING_FOK,·SL,·TP)·���������·���������������·�����·�·�����·����������·ORDER_FILLING_FOK¤
//··········OrderSend(Symb,·Type,·Lots,·Price,·ORDER_FILLING_IOC,·SL,·TP)·���������·���������������·�����·�·�����·����������·ORDER_FILLING_IOC¤ //··········OrderSend(Symb,·Type,·Lots,·Price,·ORDER_FILLING_IOC,·SL,·TP)·���������·���������������·�����·�·�����·����������·ORDER_FILLING_IOC¤
//··········OrderClose(Ticket,·Lots,·Price,·ORDER_FILLING_RETURN)·���������·���������������·������-�����·�·�����·����������·ORDER_FILLING_RETURN¤ //··········OrderClose(Ticket,·Lots,·Price,·ORDER_FILLING_RETURN)·���������·���������������·������-�����·�·�����·����������·ORDER_FILLING_RETURN¤
//···Add:·OrdersHistoryTotal()·�·OrderSelect(Pos,·SELECT_BY_POS,·MODE_HISTORY)·������������·��������·�����������·������.¤ //···Add:·OrdersHistoryTotal()·�·OrderSelect(Pos,·SELECT_BY_POS,·MODE_HISTORY)·������������·��������·�����������·������.¤
//········�·����������·��·��������·���������·����������.¤ //········�·����������·��·��������·���������·����������.¤
//·08.02.2017:¤ //·08.02.2017:¤
//···Add:·����������·MT4ORDERS::LastTradeRequest·�·MT4ORDERS::LastTradeResult·��������·���������������·������·MT5-OrderSend.¤ //···Add:·����������·MT4ORDERS::LastTradeRequest·�·MT4ORDERS::LastTradeResult·��������·���������������·������·MT5-OrderSend.¤
//·14.06.2017:¤ //·14.06.2017:¤
//···Add:·��������·����������·����������·����������·�����������·SL/TP·��������·�������·(��������·�����·OrderClose).¤ //···Add:·��������·����������·����������·����������·�����������·SL/TP·��������·�������·(��������·�����·OrderClose).¤
//···Add:·MagicNumber·������·�����·���·long·����·(������·���·int·�����).¤ //···Add:·MagicNumber·������·�����·���·long·����·(������·���·int·�����).¤
//···Add:·����·�·OrderSend,·OrderClose·���·OrderModify·��������·�������·��������·(�����·���������)·������·������·INT_MAX,·��·�����·�����������¤ //···Add:·����·�·OrderSend,·OrderClose·���·OrderModify·��������·�������·��������·(�����·���������)·������·������·INT_MAX,·��·�����·�����������¤
//········���������������·��������·MT5-������·(MT4ORDERS::LastTradeRequest),·��·���������·��·��·�����.·������·�����·�����·���������·���·MT5-��������,¤ //········���������������·��������·MT5-������·(MT4ORDERS::LastTradeRequest),·��·���������·��·��·�����.·������·�����·�����·���������·���·MT5-��������,¤
//········���������·�������·������·��������·�·MT4ORDERS::LastTradeCheckResult.¤ //········���������·�������·������·��������·�·MT4ORDERS::LastTradeCheckResult.¤
//········�·������·��������·��������·OrderModify·�·OrderClose·������·true,·�����·false.¤ //········�·������·��������·��������·OrderModify·�·OrderClose·������·true,·�����·false.¤
//········OrderSend·������·�·������·������,·�����·-1.¤ //········OrderSend·������·�·������·������,·�����·-1.¤
//¤ //¤
//········����·��·���������������·��������·�������·��������·������·�����·INT_MIN,·��·������·�·������·��������·MT5-��������·���������������¤ //········����·��·���������������·��������·�������·��������·������·�����·INT_MIN,·��·������·�·������·��������·MT5-��������·���������������¤
//········���������·�������(���·�·������·�·INT_MAX)·��·�����·���������.¤ //········���������·�������(���·�·������·�·INT_MAX)·��·�����·���������.¤
//···Add:·���������·�����������·�������·MQL4-��������·��������:·OrderSendAsync,·OrderModifyAsync,·OrderCloseAsync,·OrderDeleteAsync.¤ //···Add:·���������·�����������·�������·MQL4-��������·��������:·OrderSendAsync,·OrderModifyAsync,·OrderCloseAsync,·OrderDeleteAsync.¤
//········����������·���������������·Result.request_id·�·������·�����,·�����·0.¤ //········����������·���������������·Result.request_id·�·������·�����,·�����·0.¤
//·03.08.2017:¤ //·03.08.2017:¤
//···Add:·���������·OrderCloseBy.¤ //···Add:·���������·OrderCloseBy.¤
//···Add:·��������·������·OrderSelect·�·MODE_TRADES-������.·������·����·�����������·��������·������·����������·������·�����¤ //···Add:·��������·������·OrderSelect·�·MODE_TRADES-������.·������·����·�����������·��������·������·����������·������·�����¤
//········���������������·MT4-Order-�������,·����·����·MT5-�������/�����(��·�·�������)·�������·��·�����·MT4Orders.¤ //········���������������·MT4-Order-�������,·����·����·MT5-�������/�����(��·�·�������)·�������·��·�����·MT4Orders.¤
//········��������,·�����·MT5-PositionSelect*-�������·���·MT5-OrderSelect.¤ //········��������,·�����·MT5-PositionSelect*-�������·���·MT5-OrderSelect.¤
//···Add:·���������·OrderOpenPriceRequest()·�·OrderClosePriceRequest()·���������·����·���������·�������·���·��������/��������·�������.¤ //···Add:·���������·OrderOpenPriceRequest()·�·OrderClosePriceRequest()·���������·����·���������·�������·���·��������/��������·�������.¤
//········�·�������·������·�������·��������·���������·���������������·���������������·�������.¤ //········�·�������·������·�������·��������·���������·���������������·���������������·�������.¤
//·26.08.2017:¤ //·26.08.2017:¤
//···Add:·���������·OrderOpenTimeMsc()·�·OrderCloseTimeMsc()·���������������·�����·�·�������������.¤ //···Add:·���������·OrderOpenTimeMsc()·�·OrderCloseTimeMsc()·���������������·�����·�·�������������.¤
//···Fix:·������·���·��������·������·�����·���·int,·���·�·MT4.·��-��·���������·�������·������·��·�������·int-����·�·MT5,·���·�������·�������·��·long.¤ //···Fix:·������·���·��������·������·�����·���·int,·���·�·MT4.·��-��·���������·�������·������·��·�������·int-����·�·MT5,·���·�������·�������·��·long.¤
//········��������������,·OrderTicket·�·OrderSend·����������·long-��������.·�����·��������·����·��·����,·���·�·�·MT4·(int),·����������·�����¤ //········��������������,·OrderTicket·�·OrderSend·����������·long-��������.·�����·��������·����·��·����,·���·�·�·MT4·(int),·����������·�����¤
//········������������·���������·������·�����·#include·<MT4Orders.mqh>¤ //········������������·���������·������·�����·#include·<MT4Orders.mqh>¤
¤ ¤
//········#define·MT4_TICKET_TYPE·//·���������·OrderSend·�·OrderTicket·����������·��������·������·��·����,·���·�·MT4·int.¤ //········#define·MT4_TICKET_TYPE·//·���������·OrderSend·�·OrderTicket·����������·��������·������·��·����,·���·�·MT4·int.¤
//·03.09.2017:¤ //·03.09.2017:¤
//···Add:·���������·OrderTicketOpen()··�����·MT5-������·��������·�������¤ //···Add:·���������·OrderTicketOpen()··�����·MT5-������·��������·�������¤
//··················OrderOpenReason()··�������·����������·MT5-������·��������·(�������·��������·�������)¤ //··················OrderOpenReason()··�������·����������·MT5-������·��������·(�������·��������·�������)¤
//··················OrderCloseReason()·�������·����������·MT5-������·��������·(�������·��������·�������)¤ //··················OrderCloseReason()·�������·����������·MT5-������·��������·(�������·��������·�������)¤
//·14.09.2017:¤ //·14.09.2017:¤
//···Fix:·������·����������·��·�����·�������·MT5-������,·�������·��·�����·���������·ORDER_STATE_PLACED.¤ //···Fix:·������·����������·��·�����·�������·MT5-������,·�������·��·�����·���������·ORDER_STATE_PLACED.¤
//········�����·����������·������·���·��������·MT5-������·�����·��·����������·���������·������¤ //········�����·����������·������·���·��������·MT5-������·�����·��·����������·���������·������¤
//¤ //¤
//········#define·MT4ORDERS_SELECTFILTER_OFF·//·���������·MT4Orders.mqh·������·���·�������·MT5-������¤ //········#define·MT4ORDERS_SELECTFILTER_OFF·//·���������·MT4Orders.mqh·������·���·�������·MT5-������¤
//·16.10.2017:¤ //·16.10.2017:¤
//···Fix:·OrdersHistoryTotal()·���������·��·�����·������·���������·�����·��·�����·����������.¤ //···Fix:·OrdersHistoryTotal()·���������·��·�����·������·���������·�����·��·�����·����������.¤
//·13.02.2018¤ //·13.02.2018¤
//···Add:·���������·�����������·����������·����������·MT5-OrderSend.¤ //···Add:·���������·�����������·����������·����������·MT5-OrderSend.¤
//···Fix:·������·"��������"·������·�����������·MT5-������·(SL/TP/SO,·partial/full·close).¤ //···Fix:·������·"��������"·������·�����������·MT5-������·(SL/TP/SO,·partial/full·close).¤
//···Fix:·��������·�����������·SL/TP·��������·�������·�����·OrderClose·��������������·��������,·����·���������·StopLevel.¤ //···Fix:·��������·�����������·SL/TP·��������·�������·�����·OrderClose·��������������·��������,·����·���������·StopLevel.¤
//·15.02.2018¤ //·15.02.2018¤
//···Fix:·��������·�������������·MT5-OrderSend·������·���������·���������·�����������·����������·ECN/STP.¤ //···Fix:·��������·�������������·MT5-OrderSend·������·���������·���������·�����������·����������·ECN/STP.¤
//·06.03.2018¤ //·06.03.2018¤
//···Add:·���������·TICKET_TYPE·�·MAGIC_TYPE,·�����·�����·����·������·������·������������������·���¤ //···Add:·���������·TICKET_TYPE·�·MAGIC_TYPE,·�����·�����·����·������·������·������������������·���¤
//········���·��������������·������������·(�������·strict-�����·MQL4).¤ //········���·��������������·������������·(�������·strict-�����·MQL4).¤
//·30.05.2018¤ //·30.05.2018¤
//···Add:·��������·������·�·��������·��������,·�������·�������·��������·����������·�����·�������������������·�¤ //···Add:·��������·������·�·��������·��������,·�������·�������·��������·����������·�����·�������������������·�¤
//········������������·������·�����·���·VPS.·������������·�����������·Generic-����������.¤ //········������������·������·�����·���·VPS.·������������·�����������·Generic-����������.¤
//········����·��·�������·������������·Generic-����������,·��·��������·������·�����·������·�·��������.¤ //········����·��·�������·������������·Generic-����������,·��·��������·������·�����·������·�·��������.¤
//········���·�����·�����·��·MT4Orders-����������·���������·������¤ //········���·�����·�����·��·MT4Orders-����������·���������·������¤
//¤ //¤
//········#define·MT4ORDERS_FASTHISTORY_OFF·//·���������·�������·����������·�������·��������·��·����������·Generic-����������.¤ //········#define·MT4ORDERS_FASTHISTORY_OFF·//·���������·�������·����������·�������·��������·��·����������·Generic-����������.¤
//·02.11.2018¤ //·02.11.2018¤
//···Fix:·����·��������·MT4-�������·��·��·������������·������·��·�����·����·�������.¤ //···Fix:·����·��������·MT4-�������·��·��·������������·������·��·�����·����·�������.¤
//···Fix:·������·������·�����������·����������·���������·��������·��������.¤ //···Fix:·������·������·�����������·����������·���������·��������·��������.¤
//·26.11.2018¤ //·26.11.2018¤
//···Fix:·������·�·�����������·��������·MT4-�������:·���������·�·���������������·�����·�����������·������·����,·���·�·�����������.¤ //···Fix:·������·�·�����������·��������·MT4-�������:·���������·�·���������������·�����·�����������·������·����,·���·�·�����������.¤
//···Fix:·�����������·������·���������·MT5-OrdersTotal·�·MT5-PositionsTotal·��·�����·�������·MT4-OrdersTotal·�·MT4-OrderSelect.¤ //···Fix:·�����������·������·���������·MT5-OrdersTotal·�·MT5-PositionsTotal·��·�����·�������·MT4-OrdersTotal·�·MT4-OrderSelect.¤
//···Fix:·������,·�������·�������·�������,·��·��·������·���������·MT5,·�����������·������·��·�����������.¤ //···Fix:·������,·�������·�������·�������,·��·��·������·���������·MT5,·�����������·������·��·�����������.¤
//·17.01.2019¤ //·17.01.2019¤
//···Fix:·����������·��������·������·���·������·����������·�������.¤ //···Fix:·����������·��������·������·���·������·����������·�������.¤
//·08.02.2019¤ //·08.02.2019¤
//···Add:·�����������·�������·�����������·���·���������·��������·�����·OrderClose.¤ //···Add:·�����������·�������·�����������·���·���������·��������·�����·OrderClose.¤
//········����·�����·�������·�����������·��������·�������·���·���������·��������,·�·OrderClose·�����·���·������.¤ //········����·�����·�������·�����������·��������·�������·���·���������·��������,·�·OrderClose·�����·���·������.¤
//·20.02.2019¤ //·20.02.2019¤
//···Fix:·�·������·����������·MT5-������·��·������������·MT5-������·����������·�����·�������·�������������·�������.·�·������·�������·�������·��·����.¤ //···Fix:·�·������·����������·MT5-������·��·������������·MT5-������·����������·�����·�������·�������������·�������.·�·������·�������·�������·��·����.¤
//·13.03.2019¤ //·13.03.2019¤
//···Add:·���������·OrderTicketID()·PositionID·MT5-������·���·MT5-�������,·�����·�����������·MT4-������.¤ //···Add:·���������·OrderTicketID()·PositionID·MT5-������·���·MT5-�������,·�����·�����������·MT4-������.¤
//···Add:·SELECT_BY_TICKET·���������·���·����·MT5-�������·(�·MT5-PositionID).¤ //···Add:·SELECT_BY_TICKET·���������·���·����·MT5-�������·(�·MT5-PositionID).¤
//·02.11.2019¤ //·02.11.2019¤
//···Fix:·���������������·���,·��������·�·����·��������·���·CloseBy-�������.¤ //···Fix:·���������������·���,·��������·�·����·��������·���·CloseBy-�������.¤
//·12.01.2020¤ //·12.01.2020¤
//···Fix:·OrderTicketID()·���·����������·������·����������·������·����������·��������.¤ //···Fix:·OrderTicketID()·���·����������·������·����������·������·����������·��������.¤
//···Fix:·��������������·SELECT_BY_TICKET-�����·��·OrderTicketID()·(MT5-PositionID).¤ //···Fix:·��������������·SELECT_BY_TICKET-�����·��·OrderTicketID()·(MT5-PositionID).¤
//···Fix:·��������·��������·�����������·������·����������·���·�������·�������������·�·���������.¤ //···Fix:·��������·��������·�����������·������·����������·���·�������·�������������·�·���������.¤
¤ ¤
#ifdef·__MQL5__¤ #ifdef·__MQL5__¤
#ifndef·__MT4ORDERS__¤ #ifndef·__MT4ORDERS__¤
¤ ¤
#define·__MT4ORDERS__·"2020.01.12"¤ #define·__MT4ORDERS__·"2020.01.12"¤
#define·MT4ORDERS_SLTP_OLD·//·���������·�������·���������·�����������·SL/TP·��������·�������·�����·OrderClose¤ #define·MT4ORDERS_SLTP_OLD·//·���������·�������·���������·�����������·SL/TP·��������·�������·�����·OrderClose¤
#define·MT4_TICKET_TYPE¤  
¤ ¤
#ifdef·MT4_TICKET_TYPE¤ #ifdef·MT4_TICKET_TYPE¤
··#define·TICKET_TYPE·int¤ ··#define·TICKET_TYPE·int¤
··#define·MAGIC_TYPE··int¤ ··#define·MAGIC_TYPE··int¤
¤ ¤
··#undef·MT4_TICKET_TYPE¤ ··#undef·MT4_TICKET_TYPE¤
#else·//·MT4_TICKET_TYPE¤ #else·//·MT4_TICKET_TYPE¤
··#define·TICKET_TYPE·long¤ ··#define·TICKET_TYPE·long¤
··#define·MAGIC_TYPE··long¤ ··#define·MAGIC_TYPE··long¤
#endif·//·MT4_TICKET_TYPE¤ #endif·//·MT4_TICKET_TYPE¤
¤ ¤
struct·MT4_ORDER¤ struct·MT4_ORDER¤
··long·Ticket;¤ ··long·Ticket;¤
··int·Type;¤ ··int·Type;¤
¤ ¤
··long·TicketOpen;¤ ··long·TicketOpen;¤
··long·TicketID;¤ ··long·TicketID;¤
¤ ¤
··double·Lots;¤ ··double·Lots;¤
¤ ¤
··string·Symbol;¤ ··string·Symbol;¤
··string·Comment;¤ ··string·Comment;¤
¤ ¤
··double·OpenPriceRequest;¤ ··double·OpenPriceRequest;¤
··double·OpenPrice;¤ ··double·OpenPrice;¤
¤ ¤
··long·OpenTimeMsc;¤ ··long·OpenTimeMsc;¤
··datetime·OpenTime;¤ ··datetime·OpenTime;¤
¤ ¤
··ENUM_DEAL_REASON·OpenReason;¤ ··ENUM_DEAL_REASON·OpenReason;¤
¤ ¤
··double·StopLoss;¤ ··double·StopLoss;¤
··double·TakeProfit;¤ ··double·TakeProfit;¤
¤ ¤
··double·ClosePriceRequest;¤ ··double·ClosePriceRequest;¤
··double·ClosePrice;¤ ··double·ClosePrice;¤
¤ ¤
··long·CloseTimeMsc;¤ ··long·CloseTimeMsc;¤
··datetime·CloseTime;¤ ··datetime·CloseTime;¤
¤ ¤
··ENUM_DEAL_REASON·CloseReason;¤ ··ENUM_DEAL_REASON·CloseReason;¤
¤ ¤
··ENUM_ORDER_STATE·State;¤ ··ENUM_ORDER_STATE·State;¤
¤ ¤
··datetime·Expiration;¤ ··datetime·Expiration;¤
¤ ¤
··long·MagicNumber;¤ ··long·MagicNumber;¤
¤ ¤
··double·Profit;¤ ··double·Profit;¤
¤ ¤
··double·Commission;¤ ··double·Commission;¤
··double·Swap;¤ ··double·Swap;¤
¤ ¤
#define·POSITION_SELECT·(-1)¤ #define·POSITION_SELECT·(-1)¤
#define·ORDER_SELECT·(-2)¤ #define·ORDER_SELECT·(-2)¤
¤ ¤
··static·const·MT4_ORDER·GetPositionData(·void· ··static·const·MT4_ORDER·GetPositionData(·void·
·· ··
····MT4_ORDER·Res·{0};¤ ····MT4_ORDER·Res·{0};¤
¤ ¤
····Res.Ticket·::PositionGetInteger(POSITION_TICKET);¤ ····Res.Ticket·::PositionGetInteger(POSITION_TICKET);¤
····Res.Type·(int)::PositionGetInteger(POSITION_TYPE);¤ ····Res.Type·(int)::PositionGetInteger(POSITION_TYPE);¤
¤ ¤
····Res.Lots·::PositionGetDouble(POSITION_VOLUME);¤ ····Res.Lots·::PositionGetDouble(POSITION_VOLUME);¤
¤ ¤
····Res.Symbol·::PositionGetString(POSITION_SYMBOL);¤ ····Res.Symbol·::PositionGetString(POSITION_SYMBOL);¤
//····Res.Comment·NULL;·//·MT4ORDERS::CheckPositionCommissionComment();¤ //····Res.Comment·NULL;·//·MT4ORDERS::CheckPositionCommissionComment();¤
¤ ¤
····Res.OpenPrice·::PositionGetDouble(POSITION_PRICE_OPEN);¤ ····Res.OpenPrice·::PositionGetDouble(POSITION_PRICE_OPEN);¤
····Res.OpenTime·(datetime)::PositionGetInteger(POSITION_TIME);¤ ····Res.OpenTime·(datetime)::PositionGetInteger(POSITION_TIME);¤
¤ ¤
····Res.StopLoss·::PositionGetDouble(POSITION_SL);¤ ····Res.StopLoss·::PositionGetDouble(POSITION_SL);¤
····Res.TakeProfit·::PositionGetDouble(POSITION_TP);¤ ····Res.TakeProfit·::PositionGetDouble(POSITION_TP);¤
¤ ¤
····Res.ClosePrice·::PositionGetDouble(POSITION_PRICE_CURRENT);¤ ····Res.ClosePrice·::PositionGetDouble(POSITION_PRICE_CURRENT);¤
····Res.CloseTime·0;¤ ····Res.CloseTime·0;¤
¤ ¤
····Res.Expiration·0;¤ ····Res.Expiration·0;¤
¤ ¤
····Res.MagicNumber·::PositionGetInteger(POSITION_MAGIC);¤ ····Res.MagicNumber·::PositionGetInteger(POSITION_MAGIC);¤
¤ ¤
····Res.Profit·::PositionGetDouble(POSITION_PROFIT);¤ ····Res.Profit·::PositionGetDouble(POSITION_PROFIT);¤
¤ ¤
····Res.Swap·::PositionGetDouble(POSITION_SWAP);¤ ····Res.Swap·::PositionGetDouble(POSITION_SWAP);¤
¤ ¤
//····Res.Commission·UNKNOWN_COMMISSION;·//·MT4ORDERS::CheckPositionCommissionComment();¤ //····Res.Commission·UNKNOWN_COMMISSION;·//·MT4ORDERS::CheckPositionCommissionComment();¤
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·const·MT4_ORDER·GetOrderData(·void· ··static·const·MT4_ORDER·GetOrderData(·void·
·· ··
····MT4_ORDER·Res·{0};¤ ····MT4_ORDER·Res·{0};¤
¤ ¤
····Res.Ticket·::OrderGetInteger(ORDER_TICKET);¤ ····Res.Ticket·::OrderGetInteger(ORDER_TICKET);¤
····Res.Type·(int)::OrderGetInteger(ORDER_TYPE);¤ ····Res.Type·(int)::OrderGetInteger(ORDER_TYPE);¤
¤ ¤
····Res.Lots·::OrderGetDouble(ORDER_VOLUME_CURRENT);¤ ····Res.Lots·::OrderGetDouble(ORDER_VOLUME_CURRENT);¤
¤ ¤
····Res.Symbol·::OrderGetString(ORDER_SYMBOL);¤ ····Res.Symbol·::OrderGetString(ORDER_SYMBOL);¤
····Res.Comment·::OrderGetString(ORDER_COMMENT);¤ ····Res.Comment·::OrderGetString(ORDER_COMMENT);¤
¤ ¤
····Res.OpenPrice·::OrderGetDouble(ORDER_PRICE_OPEN);¤ ····Res.OpenPrice·::OrderGetDouble(ORDER_PRICE_OPEN);¤
····Res.OpenTime·(datetime)::OrderGetInteger(ORDER_TIME_SETUP);¤ ····Res.OpenTime·(datetime)::OrderGetInteger(ORDER_TIME_SETUP);¤
¤ ¤
····Res.StopLoss·::OrderGetDouble(ORDER_SL);¤ ····Res.StopLoss·::OrderGetDouble(ORDER_SL);¤
····Res.TakeProfit·::OrderGetDouble(ORDER_TP);¤ ····Res.TakeProfit·::OrderGetDouble(ORDER_TP);¤
¤ ¤
····Res.ClosePrice·::OrderGetDouble(ORDER_PRICE_CURRENT);¤ ····Res.ClosePrice·::OrderGetDouble(ORDER_PRICE_CURRENT);¤
····Res.CloseTime·0;·//·(datetime)::OrderGetInteger(ORDER_TIME_DONE)¤ ····Res.CloseTime·0;·//·(datetime)::OrderGetInteger(ORDER_TIME_DONE)¤
¤ ¤
····Res.Expiration·(datetime)::OrderGetInteger(ORDER_TIME_EXPIRATION);¤ ····Res.Expiration·(datetime)::OrderGetInteger(ORDER_TIME_EXPIRATION);¤
¤ ¤
····Res.MagicNumber·::OrderGetInteger(ORDER_MAGIC);¤ ····Res.MagicNumber·::OrderGetInteger(ORDER_MAGIC);¤
¤ ¤
····Res.Profit·0;¤ ····Res.Profit·0;¤
¤ ¤
····Res.Commission·0;¤ ····Res.Commission·0;¤
····Res.Swap·0;¤ ····Res.Swap·0;¤
¤ ¤
····if·(!Res.OpenPrice)¤ ····if·(!Res.OpenPrice)¤
······Res.OpenPrice·Res.ClosePrice;¤ ······Res.OpenPrice·Res.ClosePrice;¤
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··string·ToString(·void·const¤ ··string·ToString(·void·const¤
·· ··
····static·const·string·Types[]·{"buy",·"sell",·"buy·limit",·"sell·limit",·"buy·stop",·"sell·stop",·"balance"};¤ ····static·const·string·Types[]·{"buy",·"sell",·"buy·limit",·"sell·limit",·"buy·stop",·"sell·stop",·"balance"};¤
····const·int·digits·(int)::SymbolInfoInteger(this.Symbol,·SYMBOL_DIGITS);¤ ····const·int·digits·(int)::SymbolInfoInteger(this.Symbol,·SYMBOL_DIGITS);¤
¤ ¤
····MT4_ORDER·TmpOrder·{0};¤ ····MT4_ORDER·TmpOrder·{0};¤
¤ ¤
····if·(this.Ticket·==·POSITION_SELECT)¤ ····if·(this.Ticket·==·POSITION_SELECT)¤
···· ····
······TmpOrder·MT4_ORDER::GetPositionData();¤ ······TmpOrder·MT4_ORDER::GetPositionData();¤
¤ ¤
······TmpOrder.Comment·this.Comment;¤ ······TmpOrder.Comment·this.Comment;¤
······TmpOrder.Commission·this.Commission;¤ ······TmpOrder.Commission·this.Commission;¤
···· ····
····else·if·(this.Ticket·==·ORDER_SELECT)¤ ····else·if·(this.Ticket·==·ORDER_SELECT)¤
······TmpOrder·MT4_ORDER::GetOrderData();¤ ······TmpOrder·MT4_ORDER::GetOrderData();¤
¤ ¤
····return(((this.Ticket·==·POSITION_SELECT)·||·(this.Ticket·==·ORDER_SELECT))·TmpOrder.ToString()· ····return(((this.Ticket·==·POSITION_SELECT)·||·(this.Ticket·==·ORDER_SELECT))·TmpOrder.ToString()·
···········("#"·(string)this.Ticket· ···········("#"·(string)this.Ticket·
············(string)this.OpenTime· ············(string)this.OpenTime·
············((this.Type·::ArraySize(Types))·Types[this.Type]·"unknown")· ············((this.Type·::ArraySize(Types))·Types[this.Type]·"unknown")·
············::DoubleToString(this.Lots,·2)· ············::DoubleToString(this.Lots,·2)·
············(::StringLen(this.Symbol)·this.Symbol·NULL)· ············(::StringLen(this.Symbol)·this.Symbol·NULL)·
············::DoubleToString(this.OpenPrice,·digits)· ············::DoubleToString(this.OpenPrice,·digits)·
············::DoubleToString(this.StopLoss,·digits)· ············::DoubleToString(this.StopLoss,·digits)·
············::DoubleToString(this.TakeProfit,·digits)· ············::DoubleToString(this.TakeProfit,·digits)·
············((this.CloseTime·0)·((string)this.CloseTime·")·"")· ············((this.CloseTime·0)·((string)this.CloseTime·")·"")·
············::DoubleToString(this.ClosePrice,·digits)· ············::DoubleToString(this.ClosePrice,·digits)·
············::DoubleToString(this.Commission,·2)· ············::DoubleToString(this.Commission,·2)·
············::DoubleToString(this.Swap,·2)· ············::DoubleToString(this.Swap,·2)·
············::DoubleToString(this.Profit,·2)· ············::DoubleToString(this.Profit,·2)·
············((this.Comment·==·"")·""·(this.Comment·"))· ············((this.Comment·==·"")·""·(this.Comment·"))·
············(string)this.MagicNumber· ············(string)this.MagicNumber·
············(((this.Expiration·0)·("·expiration·(string)this.Expiration):·""))));¤ ············(((this.Expiration·0)·("·expiration·(string)this.Expiration):·""))));¤
·· ··
};¤ };¤
¤ ¤
#define·RESERVE_SIZE·1000¤ #define·RESERVE_SIZE·1000¤
#define·DAY·(24·3600)¤ #define·DAY·(24·3600)¤
#define·HISTORY_PAUSE·(MT4HISTORY::IsTester·5)¤ #define·HISTORY_PAUSE·(MT4HISTORY::IsTester·5)¤
#define·END_TIME·D'31.12.3000·23:59:59'¤ #define·END_TIME·D'31.12.3000·23:59:59'¤
#define·THOUSAND·1000¤ #define·THOUSAND·1000¤
#define·LASTTIME(A)·········································· #define·LASTTIME(A)··········································
··if·(Time##A·>=·LastTimeMsc)································ ··if·(Time##A·>=·LastTimeMsc)································
··························································· ···························································
····const·datetime·TmpTime·(datetime)(Time##A·THOUSAND);· ····const·datetime·TmpTime·(datetime)(Time##A·THOUSAND);·
····························································· ·····························································
····if·(TmpTime·this.LastTime)····························· ····if·(TmpTime·this.LastTime)·····························
··························································· ···························································
······this.LastTotalOrders·0;······························ ······this.LastTotalOrders·0;······························
······this.LastTotalDeals·0;······························· ······this.LastTotalDeals·0;·······························
····························································· ·····························································
······this.LastTime·TmpTime;······························· ······this.LastTime·TmpTime;·······························
······LastTimeMsc·this.LastTime·THOUSAND;················ ······LastTimeMsc·this.LastTime·THOUSAND;················
··························································· ···························································
····························································· ·····························································
····this.LastTotal##A##s++;·································· ····this.LastTotal##A##s++;··································
·· ··
¤ ¤
#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ #ifndef·MT4ORDERS_FASTHISTORY_OFF¤
··#include·<Generic\HashMap.mqh>¤ ··#include·<Generic\HashMap.mqh>¤
#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ #endif·//·MT4ORDERS_FASTHISTORY_OFF¤
¤ ¤
class·MT4HISTORY¤ class·MT4HISTORY¤
private:¤ private:¤
··static·const·bool·MT4HISTORY::IsTester;¤ ··static·const·bool·MT4HISTORY::IsTester;¤
//··static·long·MT4HISTORY::AccountNumber;¤ //··static·long·MT4HISTORY::AccountNumber;¤
¤ ¤
#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ #ifndef·MT4ORDERS_FASTHISTORY_OFF¤
··CHashMap<ulong,·ulong>·DealsIn;··//·��·PositionID·����������·DealIn.¤ ··CHashMap<ulong,·ulong>·DealsIn;··//·��·PositionID·����������·DealIn.¤
··CHashMap<ulong,·ulong>·DealsOut;·//·��·PositionID·����������·DealOut.¤ ··CHashMap<ulong,·ulong>·DealsOut;·//·��·PositionID·����������·DealOut.¤
#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ #endif·//·MT4ORDERS_FASTHISTORY_OFF¤
¤ ¤
··long·Tickets[];¤ ··long·Tickets[];¤
··uint·Amount;¤ ··uint·Amount;¤
¤ ¤
··datetime·LastTime;¤ ··datetime·LastTime;¤
¤ ¤
··int·LastTotalDeals;¤ ··int·LastTotalDeals;¤
··int·LastTotalOrders;¤ ··int·LastTotalOrders;¤
¤ ¤
··datetime·LastInitTime;¤ ··datetime·LastInitTime;¤
¤ ¤
··bool·RefreshHistory(·void· ··bool·RefreshHistory(·void·
·· ··
····bool·Res·false;¤ ····bool·Res·false;¤
¤ ¤
····const·datetime·LastTimeCurrent·::TimeCurrent();¤ ····const·datetime·LastTimeCurrent·::TimeCurrent();¤
¤ ¤
····if·(!MT4HISTORY::IsTester·&&·((LastTimeCurrent·>=·this.LastInitTime·DAY)/*·||·(MT4HISTORY::AccountNumber·!=·::AccountInfoInteger(ACCOUNT_LOGIN))*/))¤ ····if·(!MT4HISTORY::IsTester·&&·((LastTimeCurrent·>=·this.LastInitTime·DAY)/*·||·(MT4HISTORY::AccountNumber·!=·::AccountInfoInteger(ACCOUNT_LOGIN))*/))¤
···· ····
····//··MT4HISTORY::AccountNumber·::AccountInfoInteger(ACCOUNT_LOGIN);¤ ····//··MT4HISTORY::AccountNumber·::AccountInfoInteger(ACCOUNT_LOGIN);¤
¤ ¤
······this.LastTime·0;¤ ······this.LastTime·0;¤
¤ ¤
······this.LastTotalOrders·0;¤ ······this.LastTotalOrders·0;¤
······this.LastTotalDeals·0;¤ ······this.LastTotalDeals·0;¤
¤ ¤
······this.Amount·0;¤ ······this.Amount·0;¤
¤ ¤
······::ArrayResize(this.Tickets,·this.Amount,·RESERVE_SIZE);¤ ······::ArrayResize(this.Tickets,·this.Amount,·RESERVE_SIZE);¤
¤ ¤
······this.LastInitTime·LastTimeCurrent;¤ ······this.LastInitTime·LastTimeCurrent;¤
¤ ¤
····#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ ····#ifndef·MT4ORDERS_FASTHISTORY_OFF¤
······this.DealsIn.Clear();¤ ······this.DealsIn.Clear();¤
······this.DealsOut.Clear();¤ ······this.DealsOut.Clear();¤
····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
···· ····
¤ ¤
····const·datetime·LastTimeCurrentLeft·LastTimeCurrent·HISTORY_PAUSE;¤ ····const·datetime·LastTimeCurrentLeft·LastTimeCurrent·HISTORY_PAUSE;¤
¤ ¤
····if·(::HistorySelect(this.LastTime,·END_TIME))·//·https://www.mql5.com/ru/forum/285631/page79#comment_9884935¤ ····if·(::HistorySelect(this.LastTime,·END_TIME))·//·https://www.mql5.com/ru/forum/285631/page79#comment_9884935¤
···· ····
······const·int·TotalOrders·::HistoryOrdersTotal();¤ ······const·int·TotalOrders·::HistoryOrdersTotal();¤
······const·int·TotalDeals·::HistoryDealsTotal();¤ ······const·int·TotalDeals·::HistoryDealsTotal();¤
¤ ¤
······Res·((TotalOrders·this.LastTotalOrders)·||·(TotalDeals·this.LastTotalDeals));¤ ······Res·((TotalOrders·this.LastTotalOrders)·||·(TotalDeals·this.LastTotalDeals));¤
¤ ¤
······if·(Res)¤ ······if·(Res)¤
······ ······
········int·iOrder·this.LastTotalOrders;¤ ········int·iOrder·this.LastTotalOrders;¤
········int·iDeal·this.LastTotalDeals;¤ ········int·iDeal·this.LastTotalDeals;¤
¤ ¤
········ulong·TicketOrder·0;¤ ········ulong·TicketOrder·0;¤
········ulong·TicketDeal·0;¤ ········ulong·TicketDeal·0;¤
¤ ¤
········long·TimeOrder·(iOrder·TotalOrders)·::HistoryOrderGetInteger((TicketOrder·::HistoryOrderGetTicket(iOrder)),·ORDER_TIME_DONE_MSC)·LONG_MAX;¤ ········long·TimeOrder·(iOrder·TotalOrders)·::HistoryOrderGetInteger((TicketOrder·::HistoryOrderGetTicket(iOrder)),·ORDER_TIME_DONE_MSC)·LONG_MAX;¤
········long·TimeDeal·(iDeal·TotalDeals)·::HistoryDealGetInteger((TicketDeal·::HistoryDealGetTicket(iDeal)),·DEAL_TIME_MSC)·LONG_MAX;¤ ········long·TimeDeal·(iDeal·TotalDeals)·::HistoryDealGetInteger((TicketDeal·::HistoryDealGetTicket(iDeal)),·DEAL_TIME_MSC)·LONG_MAX;¤
¤ ¤
········if·(this.LastTime·LastTimeCurrentLeft)¤ ········if·(this.LastTime·LastTimeCurrentLeft)¤
········ ········
··········this.LastTotalOrders·0;¤ ··········this.LastTotalOrders·0;¤
··········this.LastTotalDeals·0;¤ ··········this.LastTotalDeals·0;¤
¤ ¤
··········this.LastTime·LastTimeCurrentLeft;¤ ··········this.LastTime·LastTimeCurrentLeft;¤
········ ········
¤ ¤
········long·LastTimeMsc·this.LastTime·THOUSAND;¤ ········long·LastTimeMsc·this.LastTime·THOUSAND;¤
¤ ¤
········while·((iDeal·TotalDeals)·||·(iOrder·TotalOrders))¤ ········while·((iDeal·TotalDeals)·||·(iOrder·TotalOrders))¤
··········if·(TimeOrder·TimeDeal)¤ ··········if·(TimeOrder·TimeDeal)¤
·········· ··········
············LASTTIME(Order)¤ ············LASTTIME(Order)¤
¤ ¤
············if·(MT4HISTORY::IsMT4Order(TicketOrder))¤ ············if·(MT4HISTORY::IsMT4Order(TicketOrder))¤
············ ············
··············this.Amount·::ArrayResize(this.Tickets,·this.Amount·1,·RESERVE_SIZE);¤ ··············this.Amount·::ArrayResize(this.Tickets,·this.Amount·1,·RESERVE_SIZE);¤
¤ ¤
··············this.Tickets[this.Amount·1]·-(long)TicketOrder;¤ ··············this.Tickets[this.Amount·1]·-(long)TicketOrder;¤
············ ············
¤ ¤
············iOrder++;¤ ············iOrder++;¤
¤ ¤
············TimeOrder·(iOrder·TotalOrders)·::HistoryOrderGetInteger((TicketOrder·::HistoryOrderGetTicket(iOrder)),·ORDER_TIME_DONE_MSC)·LONG_MAX;¤ ············TimeOrder·(iOrder·TotalOrders)·::HistoryOrderGetInteger((TicketOrder·::HistoryOrderGetTicket(iOrder)),·ORDER_TIME_DONE_MSC)·LONG_MAX;¤
·········· ··········
··········else¤ ··········else¤
·········· ··········
············LASTTIME(Deal)¤ ············LASTTIME(Deal)¤
¤ ¤
············if·(MT4HISTORY::IsMT4Deal(TicketDeal))¤ ············if·(MT4HISTORY::IsMT4Deal(TicketDeal))¤
············ ············
··············this.Amount·::ArrayResize(this.Tickets,·this.Amount·1,·RESERVE_SIZE);¤ ··············this.Amount·::ArrayResize(this.Tickets,·this.Amount·1,·RESERVE_SIZE);¤
¤ ¤
··············this.Tickets[this.Amount·1]·(long)TicketDeal;¤ ··············this.Tickets[this.Amount·1]·(long)TicketDeal;¤
¤ ¤
············#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ ············#ifndef·MT4ORDERS_FASTHISTORY_OFF¤
··············this.DealsOut.Add(::HistoryDealGetInteger(TicketDeal,·DEAL_POSITION_ID),·TicketDeal);¤ ··············this.DealsOut.Add(::HistoryDealGetInteger(TicketDeal,·DEAL_POSITION_ID),·TicketDeal);¤
············#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ············#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
············ ············
··········#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ ··········#ifndef·MT4ORDERS_FASTHISTORY_OFF¤
············else·if·((ENUM_DEAL_ENTRY)::HistoryDealGetInteger(TicketDeal,·DEAL_ENTRY)·==·DEAL_ENTRY_IN)¤ ············else·if·((ENUM_DEAL_ENTRY)::HistoryDealGetInteger(TicketDeal,·DEAL_ENTRY)·==·DEAL_ENTRY_IN)¤
··············this.DealsIn.Add(::HistoryDealGetInteger(TicketDeal,·DEAL_POSITION_ID),·TicketDeal);¤ ··············this.DealsIn.Add(::HistoryDealGetInteger(TicketDeal,·DEAL_POSITION_ID),·TicketDeal);¤
··········#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ··········#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
¤ ¤
············iDeal++;¤ ············iDeal++;¤
¤ ¤
············TimeDeal·(iDeal·TotalDeals)·::HistoryDealGetInteger((TicketDeal·::HistoryDealGetTicket(iDeal)),·DEAL_TIME_MSC)·LONG_MAX;¤ ············TimeDeal·(iDeal·TotalDeals)·::HistoryDealGetInteger((TicketDeal·::HistoryDealGetTicket(iDeal)),·DEAL_TIME_MSC)·LONG_MAX;¤
·········· ··········
······ ······
······else·if·(LastTimeCurrentLeft·this.LastTime)¤ ······else·if·(LastTimeCurrentLeft·this.LastTime)¤
······ ······
········this.LastTime·LastTimeCurrentLeft;¤ ········this.LastTime·LastTimeCurrentLeft;¤
¤ ¤
········this.LastTotalOrders·0;¤ ········this.LastTotalOrders·0;¤
········this.LastTotalDeals·0;¤ ········this.LastTotalDeals·0;¤
······ ······
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
public:¤ public:¤
··static·bool·IsMT4Deal(·const·ulong·&Ticket· ··static·bool·IsMT4Deal(·const·ulong·&Ticket·
·· ··
····const·ENUM_DEAL_TYPE·DealType·(ENUM_DEAL_TYPE)::HistoryDealGetInteger(Ticket,·DEAL_TYPE);¤ ····const·ENUM_DEAL_TYPE·DealType·(ENUM_DEAL_TYPE)::HistoryDealGetInteger(Ticket,·DEAL_TYPE);¤
····const·ENUM_DEAL_ENTRY·DealEntry·(ENUM_DEAL_ENTRY)::HistoryDealGetInteger(Ticket,·DEAL_ENTRY);¤ ····const·ENUM_DEAL_ENTRY·DealEntry·(ENUM_DEAL_ENTRY)::HistoryDealGetInteger(Ticket,·DEAL_ENTRY);¤
¤ ¤
····return(((DealType·!=·DEAL_TYPE_BUY)·&&·(DealType·!=·DEAL_TYPE_SELL))·||······//·��·��������·������¤ ····return(((DealType·!=·DEAL_TYPE_BUY)·&&·(DealType·!=·DEAL_TYPE_SELL))·||······//·��·��������·������¤
···········((DealEntry·==·DEAL_ENTRY_OUT)·||·(DealEntry·==·DEAL_ENTRY_OUT_BY)));·//·��������¤ ···········((DealEntry·==·DEAL_ENTRY_OUT)·||·(DealEntry·==·DEAL_ENTRY_OUT_BY)));·//·��������¤
·· ··
¤ ¤
··static·bool·IsMT4Order(·const·ulong·&Ticket· ··static·bool·IsMT4Order(·const·ulong·&Ticket·
·· ··
····//·����·����������·�����·����������,·���·ORDER_POSITION_ID·�����������.¤ ····//·����·����������·�����·����������,·���·ORDER_POSITION_ID·�����������.¤
····//·https://www.mql5.com/ru/forum/170952/page70#comment_6543162¤ ····//·https://www.mql5.com/ru/forum/170952/page70#comment_6543162¤
····//·https://www.mql5.com/ru/forum/93352/page19#comment_6646726¤ ····//·https://www.mql5.com/ru/forum/93352/page19#comment_6646726¤
····//·���·������·�·��������,·�����·��������·�����·���·��������·��������,·�·�����·������?¤ ····//·���·������·�·��������,·�����·��������·�����·���·��������·��������,·�·�����·������?¤
····return(/*(::HistoryOrderGetDouble(Ticket,·ORDER_VOLUME_CURRENT)·0)·||*/·!::HistoryOrderGetInteger(Ticket,·ORDER_POSITION_ID));¤ ····return(/*(::HistoryOrderGetDouble(Ticket,·ORDER_VOLUME_CURRENT)·0)·||*/·!::HistoryOrderGetInteger(Ticket,·ORDER_POSITION_ID));¤
·· ··
¤ ¤
··MT4HISTORY(·void·Amount(::ArrayResize(this.Tickets,·0,·RESERVE_SIZE)),¤ ··MT4HISTORY(·void·Amount(::ArrayResize(this.Tickets,·0,·RESERVE_SIZE)),¤
·······················LastTime(0),·LastTotalDeals(0),·LastTotalOrders(0),·LastInitTime(0)¤ ·······················LastTime(0),·LastTotalDeals(0),·LastTotalOrders(0),·LastInitTime(0)¤
·· ··
//····this.RefreshHistory();·//·����·�������·��·������������,·�������·��������·�������.¤ //····this.RefreshHistory();·//·����·�������·��·������������,·�������·��������·�������.¤
·· ··
¤ ¤
··ulong·GetPositionDealIn(·const·ulong·PositionIdentifier·-1·//·������,·�.�.·����������·������·�������·�����·����¤ ··ulong·GetPositionDealIn(·const·ulong·PositionIdentifier·-1·//·������,·�.�.·����������·������·�������·�����·����¤
·· ··
····ulong·Ticket·0;¤ ····ulong·Ticket·0;¤
¤ ¤
····if·(PositionIdentifier·==·-1)¤ ····if·(PositionIdentifier·==·-1)¤
···· ····
······const·ulong·MyPositionIdentifier·::PositionGetInteger(POSITION_IDENTIFIER);¤ ······const·ulong·MyPositionIdentifier·::PositionGetInteger(POSITION_IDENTIFIER);¤
¤ ¤
····#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ ····#ifndef·MT4ORDERS_FASTHISTORY_OFF¤
······if·(!this.DealsIn.TryGetValue(MyPositionIdentifier,·Ticket))¤ ······if·(!this.DealsIn.TryGetValue(MyPositionIdentifier,·Ticket))¤
····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
······ ······
········const·datetime·PosTime·(datetime)::PositionGetInteger(POSITION_TIME);¤ ········const·datetime·PosTime·(datetime)::PositionGetInteger(POSITION_TIME);¤
¤ ¤
········if·(::HistorySelect(PosTime,·PosTime))¤ ········if·(::HistorySelect(PosTime,·PosTime))¤
········ ········
··········const·int·Total·::HistoryDealsTotal();¤ ··········const·int·Total·::HistoryDealsTotal();¤
¤ ¤
··········for·(int·0;·Total;·i++)¤ ··········for·(int·0;·Total;·i++)¤
·········· ··········
············const·ulong·TicketDeal·::HistoryDealGetTicket(i);¤ ············const·ulong·TicketDeal·::HistoryDealGetTicket(i);¤
¤ ¤
············if·((::HistoryDealGetInteger(TicketDeal,·DEAL_POSITION_ID)·==·MyPositionIdentifier)·/*&&¤ ············if·((::HistoryDealGetInteger(TicketDeal,·DEAL_POSITION_ID)·==·MyPositionIdentifier)·/*&&¤
················((ENUM_DEAL_ENTRY)::HistoryDealGetInteger(TicketDeal,·DEAL_ENTRY)·==·DEAL_ENTRY_IN)·*/)·//·������·����������·�·���·�����·DEAL_ENTRY_IN¤ ················((ENUM_DEAL_ENTRY)::HistoryDealGetInteger(TicketDeal,·DEAL_ENTRY)·==·DEAL_ENTRY_IN)·*/)·//·������·����������·�·���·�����·DEAL_ENTRY_IN¤
············ ············
··············Ticket·TicketDeal;¤ ··············Ticket·TicketDeal;¤
¤ ¤
············#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ ············#ifndef·MT4ORDERS_FASTHISTORY_OFF¤
··············this.DealsIn.Add(MyPositionIdentifier,·Ticket);¤ ··············this.DealsIn.Add(MyPositionIdentifier,·Ticket);¤
············#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ············#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
¤ ¤
··············break;¤ ··············break;¤
············ ············
·········· ··········
········ ········
······ ······
···· ····
····else·if·(PositionIdentifier·&&·//·PositionIdentifier·����������·������·�����·����¤ ····else·if·(PositionIdentifier·&&·//·PositionIdentifier·����������·������·�����·����¤
···········#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ ···········#ifndef·MT4ORDERS_FASTHISTORY_OFF¤
·············!this.DealsIn.TryGetValue(PositionIdentifier,·Ticket)·&&¤ ·············!this.DealsIn.TryGetValue(PositionIdentifier,·Ticket)·&&¤
···········#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ···········#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
·············::HistorySelectByPosition(PositionIdentifier)·&&·(::HistoryDealsTotal()·1))·//·������·1,·�·��·?!¤ ·············::HistorySelectByPosition(PositionIdentifier)·&&·(::HistoryDealsTotal()·1))·//·������·1,·�·��·?!¤
···· ····
······Ticket·::HistoryDealGetTicket(0);·//·������·����������·�·���·�����·DEAL_ENTRY_IN¤ ······Ticket·::HistoryDealGetTicket(0);·//·������·����������·�·���·�����·DEAL_ENTRY_IN¤
¤ ¤
······/*¤ ······/*¤
······const·int·Total·::HistoryDealsTotal();¤ ······const·int·Total·::HistoryDealsTotal();¤
¤ ¤
······for·(int·0;·Total;·i++)¤ ······for·(int·0;·Total;·i++)¤
······ ······
········const·ulong·TicketDeal·::HistoryDealGetTicket(i);¤ ········const·ulong·TicketDeal·::HistoryDealGetTicket(i);¤
¤ ¤
········if·(TicketDeal·0)¤ ········if·(TicketDeal·0)¤
··········if·((ENUM_DEAL_ENTRY)::HistoryDealGetInteger(TicketDeal,·DEAL_ENTRY)·==·DEAL_ENTRY_IN)¤ ··········if·((ENUM_DEAL_ENTRY)::HistoryDealGetInteger(TicketDeal,·DEAL_ENTRY)·==·DEAL_ENTRY_IN)¤
·········· ··········
············Ticket·TicketDeal;¤ ············Ticket·TicketDeal;¤
¤ ¤
············break;¤ ············break;¤
·········· ··········
······*/¤ ······*/¤
¤ ¤
····#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ ····#ifndef·MT4ORDERS_FASTHISTORY_OFF¤
······this.DealsIn.Add(PositionIdentifier,·Ticket);¤ ······this.DealsIn.Add(PositionIdentifier,·Ticket);¤
····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
···· ····
¤ ¤
····return(Ticket);¤ ····return(Ticket);¤
·· ··
¤ ¤
··ulong·GetPositionDealOut(·const·ulong·PositionIdentifier· ··ulong·GetPositionDealOut(·const·ulong·PositionIdentifier·
·· ··
····ulong·Ticket·0;¤ ····ulong·Ticket·0;¤
¤ ¤
··#ifndef·MT4ORDERS_FASTHISTORY_OFF¤ ··#ifndef·MT4ORDERS_FASTHISTORY_OFF¤
····if·(!this.DealsOut.TryGetValue(PositionIdentifier,·Ticket)·&&·this.RefreshHistory())¤ ····if·(!this.DealsOut.TryGetValue(PositionIdentifier,·Ticket)·&&·this.RefreshHistory())¤
······this.DealsOut.TryGetValue(PositionIdentifier,·Ticket);¤ ······this.DealsOut.TryGetValue(PositionIdentifier,·Ticket);¤
····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
¤ ¤
····return(Ticket);¤ ····return(Ticket);¤
·· ··
¤ ¤
··int·GetAmount(·void· ··int·GetAmount(·void·
·· ··
····this.RefreshHistory();¤ ····this.RefreshHistory();¤
¤ ¤
····return((int)this.Amount);¤ ····return((int)this.Amount);¤
·· ··
¤ ¤
··long·operator·[](·const·uint·&Pos· ··long·operator·[](·const·uint·&Pos·
·· ··
····long·Res·0;¤ ····long·Res·0;¤
¤ ¤
····if·((Pos·>=·this.Amount)/*·||·(!MT4HISTORY::IsTester·&&·(MT4HISTORY::AccountNumber·!=·::AccountInfoInteger(ACCOUNT_LOGIN)))*/)¤ ····if·((Pos·>=·this.Amount)/*·||·(!MT4HISTORY::IsTester·&&·(MT4HISTORY::AccountNumber·!=·::AccountInfoInteger(ACCOUNT_LOGIN)))*/)¤
···· ····
······this.RefreshHistory();¤ ······this.RefreshHistory();¤
¤ ¤
······if·(Pos·this.Amount)¤ ······if·(Pos·this.Amount)¤
········Res·this.Tickets[Pos];¤ ········Res·this.Tickets[Pos];¤
···· ····
····else¤ ····else¤
······Res·this.Tickets[Pos];¤ ······Res·this.Tickets[Pos];¤
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
};¤ };¤
¤ ¤
static·const·bool·MT4HISTORY::IsTester·::MQLInfoInteger(MQL_TESTER);¤ static·const·bool·MT4HISTORY::IsTester·::MQLInfoInteger(MQL_TESTER);¤
//·static·long·MT4HISTORY::AccountNumber·::AccountInfoInteger(ACCOUNT_LOGIN);¤ //·static·long·MT4HISTORY::AccountNumber·::AccountInfoInteger(ACCOUNT_LOGIN);¤
¤ ¤
#undef·LASTTIME¤ #undef·LASTTIME¤
#undef·THOUSAND¤ #undef·THOUSAND¤
#undef·END_TIME¤ #undef·END_TIME¤
#undef·HISTORY_PAUSE¤ #undef·HISTORY_PAUSE¤
#undef·DAY¤ #undef·DAY¤
#undef·RESERVE_SIZE¤ #undef·RESERVE_SIZE¤
¤ ¤
#define·OP_BUY·ORDER_TYPE_BUY¤ #define·OP_BUY·ORDER_TYPE_BUY¤
#define·OP_SELL·ORDER_TYPE_SELL¤ #define·OP_SELL·ORDER_TYPE_SELL¤
#define·OP_BUYLIMIT·ORDER_TYPE_BUY_LIMIT¤ #define·OP_BUYLIMIT·ORDER_TYPE_BUY_LIMIT¤
#define·OP_SELLLIMIT·ORDER_TYPE_SELL_LIMIT¤ #define·OP_SELLLIMIT·ORDER_TYPE_SELL_LIMIT¤
#define·OP_BUYSTOP·ORDER_TYPE_BUY_STOP¤ #define·OP_BUYSTOP·ORDER_TYPE_BUY_STOP¤
#define·OP_SELLSTOP·ORDER_TYPE_SELL_STOP¤ #define·OP_SELLSTOP·ORDER_TYPE_SELL_STOP¤
#define·OP_BALANCE· #define·OP_BALANCE·
¤ ¤
#define·SELECT_BY_POS· #define·SELECT_BY_POS·
#define·SELECT_BY_TICKET· #define·SELECT_BY_TICKET·
¤ ¤
#define·MODE_TRADES· #define·MODE_TRADES·
#define·MODE_HISTORY· #define·MODE_HISTORY·
¤ ¤
class·MT4ORDERS¤ class·MT4ORDERS¤
private:¤ private:¤
··static·MT4_ORDER·Order;¤ ··static·MT4_ORDER·Order;¤
··static·MT4HISTORY·History;¤ ··static·MT4HISTORY·History;¤
¤ ¤
··static·const·bool·MT4ORDERS::IsTester;¤ ··static·const·bool·MT4ORDERS::IsTester;¤
··static·const·bool·MT4ORDERS::IsHedging;¤ ··static·const·bool·MT4ORDERS::IsHedging;¤
¤ ¤
··static·int·OrderSendBug;¤ ··static·int·OrderSendBug;¤
¤ ¤
··static·bool·HistorySelectOrder(·const·ulong·&Ticket· ··static·bool·HistorySelectOrder(·const·ulong·&Ticket·
·· ··
····return((::HistoryOrderGetInteger(Ticket,·ORDER_TICKET)·==·Ticket)·||·::HistoryOrderSelect(Ticket));¤ ····return((::HistoryOrderGetInteger(Ticket,·ORDER_TICKET)·==·Ticket)·||·::HistoryOrderSelect(Ticket));¤
·· ··
¤ ¤
··static·bool·HistorySelectDeal(·const·ulong·&Ticket· ··static·bool·HistorySelectDeal(·const·ulong·&Ticket·
·· ··
····return((::HistoryDealGetInteger(Ticket,·DEAL_TICKET)·==·Ticket)·||·::HistoryDealSelect(Ticket));¤ ····return((::HistoryDealGetInteger(Ticket,·DEAL_TICKET)·==·Ticket)·||·::HistoryDealSelect(Ticket));¤
·· ··
¤ ¤
#define·UNKNOWN_COMMISSION·DBL_MIN¤ #define·UNKNOWN_COMMISSION·DBL_MIN¤
#define·UNKNOWN_REQUEST_PRICE·DBL_MIN¤ #define·UNKNOWN_REQUEST_PRICE·DBL_MIN¤
#define·UNKNOWN_TICKET· #define·UNKNOWN_TICKET·
//·#define·UNKNOWN_REASON·(-1)¤ //·#define·UNKNOWN_REASON·(-1)¤
¤ ¤
··static·bool·CheckNewTicket(·void· ··static·bool·CheckNewTicket(·void·
·· ··
····static·long·PrevPosTimeUpdate·0;¤ ····static·long·PrevPosTimeUpdate·0;¤
····static·long·PrevPosTicket·0;¤ ····static·long·PrevPosTicket·0;¤
¤ ¤
····const·long·PosTimeUpdate·::PositionGetInteger(POSITION_TIME_UPDATE_MSC);¤ ····const·long·PosTimeUpdate·::PositionGetInteger(POSITION_TIME_UPDATE_MSC);¤
····const·long·PosTicket·::PositionGetInteger(POSITION_TICKET);¤ ····const·long·PosTicket·::PositionGetInteger(POSITION_TICKET);¤
¤ ¤
····//·��·������,·����·������������·������·�����·�������·��·�����·MT4Orders¤ ····//·��·������,·����·������������·������·�����·�������·��·�����·MT4Orders¤
····//·�����������·MQL5-PositionSelect*·�·MQL5-OrderSelect·���������.¤ ····//·�����������·MQL5-PositionSelect*·�·MQL5-OrderSelect·���������.¤
····//·����·��������·����������,·�.�.·���������·���������·�������·PositionSelect·�·����·������������·��������·������·�·�������¤ ····//·����·��������·����������,·�.�.·���������·���������·�������·PositionSelect·�·����·������������·��������·������·�·�������¤
····const·bool·Res·((PosTimeUpdate·!=·PrevPosTimeUpdate)·||·(PosTicket·!=·PrevPosTicket));¤ ····const·bool·Res·((PosTimeUpdate·!=·PrevPosTimeUpdate)·||·(PosTicket·!=·PrevPosTicket));¤
¤ ¤
····if·(Res)¤ ····if·(Res)¤
···· ····
······MT4ORDERS::GetPositionData();¤ ······MT4ORDERS::GetPositionData();¤
¤ ¤
······PrevPosTimeUpdate·PosTimeUpdate;¤ ······PrevPosTimeUpdate·PosTimeUpdate;¤
······PrevPosTicket·PosTicket;¤ ······PrevPosTicket·PosTicket;¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·bool·CheckPositionTicketOpen(·void· ··static·bool·CheckPositionTicketOpen(·void·
·· ··
····if·((MT4ORDERS::Order.TicketOpen·==·UNKNOWN_TICKET)·||·MT4ORDERS::CheckNewTicket())¤ ····if·((MT4ORDERS::Order.TicketOpen·==·UNKNOWN_TICKET)·||·MT4ORDERS::CheckNewTicket())¤
······MT4ORDERS::Order.TicketOpen·(long)MT4ORDERS::History.GetPositionDealIn();·//·���·��-��·����·�����·�������·�������¤ ······MT4ORDERS::Order.TicketOpen·(long)MT4ORDERS::History.GetPositionDealIn();·//·���·��-��·����·�����·�������·�������¤
¤ ¤
····return(true);¤ ····return(true);¤
·· ··
¤ ¤
··static·bool·CheckPositionCommissionComment(·void· ··static·bool·CheckPositionCommissionComment(·void·
·· ··
····if·((MT4ORDERS::Order.Commission·==·UNKNOWN_COMMISSION)·||·MT4ORDERS::CheckNewTicket())¤ ····if·((MT4ORDERS::Order.Commission·==·UNKNOWN_COMMISSION)·||·MT4ORDERS::CheckNewTicket())¤
···· ····
······MT4ORDERS::Order.Commission·::PositionGetDouble(POSITION_COMMISSION);·//·������·����¤ ······MT4ORDERS::Order.Commission·::PositionGetDouble(POSITION_COMMISSION);·//·������·����¤
······MT4ORDERS::Order.Comment·::PositionGetString(POSITION_COMMENT);¤ ······MT4ORDERS::Order.Comment·::PositionGetString(POSITION_COMMENT);¤
¤ ¤
······if·(!MT4ORDERS::Order.Commission·||·(MT4ORDERS::Order.Comment·==·""))¤ ······if·(!MT4ORDERS::Order.Commission·||·(MT4ORDERS::Order.Comment·==·""))¤
······ ······
········MT4ORDERS::CheckPositionTicketOpen();¤ ········MT4ORDERS::CheckPositionTicketOpen();¤
¤ ¤
········const·ulong·Ticket·MT4ORDERS::Order.TicketOpen;¤ ········const·ulong·Ticket·MT4ORDERS::Order.TicketOpen;¤
¤ ¤
········if·((Ticket·0)·&&·MT4ORDERS::HistorySelectDeal(Ticket))¤ ········if·((Ticket·0)·&&·MT4ORDERS::HistorySelectDeal(Ticket))¤
········ ········
··········if·(!MT4ORDERS::Order.Commission)¤ ··········if·(!MT4ORDERS::Order.Commission)¤
·········· ··········
············const·double·LotsIn·::HistoryDealGetDouble(Ticket,·DEAL_VOLUME);¤ ············const·double·LotsIn·::HistoryDealGetDouble(Ticket,·DEAL_VOLUME);¤
¤ ¤
············if·(LotsIn·0)¤ ············if·(LotsIn·0)¤
··············MT4ORDERS::Order.Commission·::HistoryDealGetDouble(Ticket,·DEAL_COMMISSION)·::PositionGetDouble(POSITION_VOLUME)·LotsIn;¤ ··············MT4ORDERS::Order.Commission·::HistoryDealGetDouble(Ticket,·DEAL_COMMISSION)·::PositionGetDouble(POSITION_VOLUME)·LotsIn;¤
·········· ··········
¤ ¤
··········if·(MT4ORDERS::Order.Comment·==·"")¤ ··········if·(MT4ORDERS::Order.Comment·==·"")¤
············MT4ORDERS::Order.Comment·::HistoryDealGetString(Ticket,·DEAL_COMMENT);¤ ············MT4ORDERS::Order.Comment·::HistoryDealGetString(Ticket,·DEAL_COMMENT);¤
········ ········
······ ······
···· ····
¤ ¤
····return(true);¤ ····return(true);¤
·· ··
/*¤ /*¤
··static·bool·CheckPositionOpenReason(·void· ··static·bool·CheckPositionOpenReason(·void·
·· ··
····if·((MT4ORDERS::Order.OpenReason·==·UNKNOWN_REASON)·||·MT4ORDERS::CheckNewTicket())¤ ····if·((MT4ORDERS::Order.OpenReason·==·UNKNOWN_REASON)·||·MT4ORDERS::CheckNewTicket())¤
···· ····
······MT4ORDERS::CheckPositionTicketOpen();¤ ······MT4ORDERS::CheckPositionTicketOpen();¤
¤ ¤
······const·ulong·Ticket·MT4ORDERS::Order.TicketOpen;¤ ······const·ulong·Ticket·MT4ORDERS::Order.TicketOpen;¤
¤ ¤
······if·((Ticket·0)·&&·(MT4ORDERS::IsTester·||·MT4ORDERS::HistorySelectDeal(Ticket)))¤ ······if·((Ticket·0)·&&·(MT4ORDERS::IsTester·||·MT4ORDERS::HistorySelectDeal(Ticket)))¤
········MT4ORDERS::Order.OpenReason·(ENUM_DEAL_REASON)::HistoryDealGetInteger(Ticket,·DEAL_REASON);¤ ········MT4ORDERS::Order.OpenReason·(ENUM_DEAL_REASON)::HistoryDealGetInteger(Ticket,·DEAL_REASON);¤
···· ····
¤ ¤
····return(true);¤ ····return(true);¤
·· ··
*/¤ */¤
··static·bool·CheckPositionOpenPriceRequest(·void· ··static·bool·CheckPositionOpenPriceRequest(·void·
·· ··
····const·long·PosTicket·::PositionGetInteger(POSITION_TICKET);¤ ····const·long·PosTicket·::PositionGetInteger(POSITION_TICKET);¤
¤ ¤
····if·(((MT4ORDERS::Order.OpenPriceRequest·==·UNKNOWN_REQUEST_PRICE)·||·MT4ORDERS::CheckNewTicket())·&&¤ ····if·(((MT4ORDERS::Order.OpenPriceRequest·==·UNKNOWN_REQUEST_PRICE)·||·MT4ORDERS::CheckNewTicket())·&&¤
········!(MT4ORDERS::Order.OpenPriceRequest·(::HistoryOrderSelect(PosTicket)·&&¤ ········!(MT4ORDERS::Order.OpenPriceRequest·(::HistoryOrderSelect(PosTicket)·&&¤
··············································(MT4ORDERS::IsTester·||·(::PositionGetInteger(POSITION_TIME_MSC)·==¤ ··············································(MT4ORDERS::IsTester·||·(::PositionGetInteger(POSITION_TIME_MSC)·==¤
··············································::HistoryOrderGetInteger(PosTicket,·ORDER_TIME_DONE_MSC))))·//·�·�����·��·���·��������?¤ ··············································::HistoryOrderGetInteger(PosTicket,·ORDER_TIME_DONE_MSC))))·//·�·�����·��·���·��������?¤
············································::HistoryOrderGetDouble(PosTicket,·ORDER_PRICE_OPEN)¤ ············································::HistoryOrderGetDouble(PosTicket,·ORDER_PRICE_OPEN)¤
············································::PositionGetDouble(POSITION_PRICE_OPEN)))¤ ············································::PositionGetDouble(POSITION_PRICE_OPEN)))¤
······MT4ORDERS::Order.OpenPriceRequest·::PositionGetDouble(POSITION_PRICE_OPEN);·//·��·������,·����·����·������·�������¤ ······MT4ORDERS::Order.OpenPriceRequest·::PositionGetDouble(POSITION_PRICE_OPEN);·//·��·������,·����·����·������·�������¤
¤ ¤
····return(true);¤ ····return(true);¤
·· ··
¤ ¤
··static·void·GetPositionData(·void· ··static·void·GetPositionData(·void·
·· ··
····MT4ORDERS::Order.Ticket·POSITION_SELECT;¤ ····MT4ORDERS::Order.Ticket·POSITION_SELECT;¤
¤ ¤
····MT4ORDERS::Order.Commission·UNKNOWN_COMMISSION;·//·MT4ORDERS::CheckPositionCommissionComment();¤ ····MT4ORDERS::Order.Commission·UNKNOWN_COMMISSION;·//·MT4ORDERS::CheckPositionCommissionComment();¤
····MT4ORDERS::Order.OpenPriceRequest·UNKNOWN_REQUEST_PRICE;·//·MT4ORDERS::CheckPositionOpenPriceRequest()¤ ····MT4ORDERS::Order.OpenPriceRequest·UNKNOWN_REQUEST_PRICE;·//·MT4ORDERS::CheckPositionOpenPriceRequest()¤
····MT4ORDERS::Order.TicketOpen·UNKNOWN_TICKET;¤ ····MT4ORDERS::Order.TicketOpen·UNKNOWN_TICKET;¤
//····MT4ORDERS::Order.OpenReason·UNKNOWN_REASON;¤ //····MT4ORDERS::Order.OpenReason·UNKNOWN_REASON;¤
¤ ¤
····return;¤ ····return;¤
·· ··
¤ ¤
//·#undef·UNKNOWN_REASON¤ //·#undef·UNKNOWN_REASON¤
#undef·UNKNOWN_TICKET¤ #undef·UNKNOWN_TICKET¤
#undef·UNKNOWN_REQUEST_PRICE¤ #undef·UNKNOWN_REQUEST_PRICE¤
#undef·UNKNOWN_COMMISSION¤ #undef·UNKNOWN_COMMISSION¤
¤ ¤
··static·void·GetOrderData(·void· ··static·void·GetOrderData(·void·
·· ··
····MT4ORDERS::Order.Ticket·ORDER_SELECT;¤ ····MT4ORDERS::Order.Ticket·ORDER_SELECT;¤
¤ ¤
····return;¤ ····return;¤
·· ··
¤ ¤
··static·void·GetHistoryOrderData(·const·ulong·Ticket· ··static·void·GetHistoryOrderData(·const·ulong·Ticket·
·· ··
····MT4ORDERS::Order.Ticket·::HistoryOrderGetInteger(Ticket,·ORDER_TICKET);¤ ····MT4ORDERS::Order.Ticket·::HistoryOrderGetInteger(Ticket,·ORDER_TICKET);¤
····MT4ORDERS::Order.Type·(int)::HistoryOrderGetInteger(Ticket,·ORDER_TYPE);¤ ····MT4ORDERS::Order.Type·(int)::HistoryOrderGetInteger(Ticket,·ORDER_TYPE);¤
¤ ¤
····MT4ORDERS::Order.TicketOpen·MT4ORDERS::Order.Ticket;¤ ····MT4ORDERS::Order.TicketOpen·MT4ORDERS::Order.Ticket;¤
····MT4ORDERS::Order.TicketID·MT4ORDERS::Order.Ticket;¤ ····MT4ORDERS::Order.TicketID·MT4ORDERS::Order.Ticket;¤
¤ ¤
····MT4ORDERS::Order.Lots·::HistoryOrderGetDouble(Ticket,·ORDER_VOLUME_CURRENT);¤ ····MT4ORDERS::Order.Lots·::HistoryOrderGetDouble(Ticket,·ORDER_VOLUME_CURRENT);¤
¤ ¤
····if·(!MT4ORDERS::Order.Lots)¤ ····if·(!MT4ORDERS::Order.Lots)¤
······MT4ORDERS::Order.Lots·::HistoryOrderGetDouble(Ticket,·ORDER_VOLUME_INITIAL);¤ ······MT4ORDERS::Order.Lots·::HistoryOrderGetDouble(Ticket,·ORDER_VOLUME_INITIAL);¤
¤ ¤
····MT4ORDERS::Order.Symbol·::HistoryOrderGetString(Ticket,·ORDER_SYMBOL);¤ ····MT4ORDERS::Order.Symbol·::HistoryOrderGetString(Ticket,·ORDER_SYMBOL);¤
····MT4ORDERS::Order.Comment·::HistoryOrderGetString(Ticket,·ORDER_COMMENT);¤ ····MT4ORDERS::Order.Comment·::HistoryOrderGetString(Ticket,·ORDER_COMMENT);¤
¤ ¤
····MT4ORDERS::Order.OpenTimeMsc·::HistoryOrderGetInteger(Ticket,·ORDER_TIME_SETUP_MSC);¤ ····MT4ORDERS::Order.OpenTimeMsc·::HistoryOrderGetInteger(Ticket,·ORDER_TIME_SETUP_MSC);¤
····MT4ORDERS::Order.OpenTime·(datetime)(MT4ORDERS::Order.OpenTimeMsc·1000);¤ ····MT4ORDERS::Order.OpenTime·(datetime)(MT4ORDERS::Order.OpenTimeMsc·1000);¤
¤ ¤
····MT4ORDERS::Order.OpenPrice·::HistoryOrderGetDouble(Ticket,·ORDER_PRICE_OPEN);¤ ····MT4ORDERS::Order.OpenPrice·::HistoryOrderGetDouble(Ticket,·ORDER_PRICE_OPEN);¤
····MT4ORDERS::Order.OpenPriceRequest·MT4ORDERS::Order.OpenPrice;¤ ····MT4ORDERS::Order.OpenPriceRequest·MT4ORDERS::Order.OpenPrice;¤
¤ ¤
····MT4ORDERS::Order.OpenReason·(ENUM_DEAL_REASON)::HistoryOrderGetInteger(Ticket,·ORDER_REASON);¤ ····MT4ORDERS::Order.OpenReason·(ENUM_DEAL_REASON)::HistoryOrderGetInteger(Ticket,·ORDER_REASON);¤
¤ ¤
····MT4ORDERS::Order.StopLoss·::HistoryOrderGetDouble(Ticket,·ORDER_SL);¤ ····MT4ORDERS::Order.StopLoss·::HistoryOrderGetDouble(Ticket,·ORDER_SL);¤
····MT4ORDERS::Order.TakeProfit·::HistoryOrderGetDouble(Ticket,·ORDER_TP);¤ ····MT4ORDERS::Order.TakeProfit·::HistoryOrderGetDouble(Ticket,·ORDER_TP);¤
¤ ¤
····MT4ORDERS::Order.CloseTimeMsc·::HistoryOrderGetInteger(Ticket,·ORDER_TIME_DONE_MSC);¤ ····MT4ORDERS::Order.CloseTimeMsc·::HistoryOrderGetInteger(Ticket,·ORDER_TIME_DONE_MSC);¤
····MT4ORDERS::Order.CloseTime·(datetime)(MT4ORDERS::Order.CloseTimeMsc·1000);¤ ····MT4ORDERS::Order.CloseTime·(datetime)(MT4ORDERS::Order.CloseTimeMsc·1000);¤
¤ ¤
····MT4ORDERS::Order.ClosePrice·::HistoryOrderGetDouble(Ticket,·ORDER_PRICE_CURRENT);¤ ····MT4ORDERS::Order.ClosePrice·::HistoryOrderGetDouble(Ticket,·ORDER_PRICE_CURRENT);¤
····MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤ ····MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤
¤ ¤
····MT4ORDERS::Order.CloseReason·MT4ORDERS::Order.OpenReason;¤ ····MT4ORDERS::Order.CloseReason·MT4ORDERS::Order.OpenReason;¤
¤ ¤
····MT4ORDERS::Order.State·(ENUM_ORDER_STATE)::HistoryOrderGetInteger(Ticket,·ORDER_STATE);¤ ····MT4ORDERS::Order.State·(ENUM_ORDER_STATE)::HistoryOrderGetInteger(Ticket,·ORDER_STATE);¤
¤ ¤
····MT4ORDERS::Order.Expiration·(datetime)::HistoryOrderGetInteger(Ticket,·ORDER_TIME_EXPIRATION);¤ ····MT4ORDERS::Order.Expiration·(datetime)::HistoryOrderGetInteger(Ticket,·ORDER_TIME_EXPIRATION);¤
¤ ¤
····MT4ORDERS::Order.MagicNumber·::HistoryOrderGetInteger(Ticket,·ORDER_MAGIC);¤ ····MT4ORDERS::Order.MagicNumber·::HistoryOrderGetInteger(Ticket,·ORDER_MAGIC);¤
¤ ¤
····MT4ORDERS::Order.Profit·0;¤ ····MT4ORDERS::Order.Profit·0;¤
¤ ¤
····MT4ORDERS::Order.Commission·0;¤ ····MT4ORDERS::Order.Commission·0;¤
····MT4ORDERS::Order.Swap·0;¤ ····MT4ORDERS::Order.Swap·0;¤
¤ ¤
····return;¤ ····return;¤
·· ··
¤ ¤
··static·string·GetTickFlag(·uint·tickflag· ··static·string·GetTickFlag(·uint·tickflag·
·· ··
····string·flag·(string)tickflag;¤ ····string·flag·(string)tickflag;¤
¤ ¤
··#define·TICKFLAG_MACRO(A)·flag·+=·((bool)(tickflag·TICK_FLAG_##A))·TICK_FLAG_"·#A·"";· ··#define·TICKFLAG_MACRO(A)·flag·+=·((bool)(tickflag·TICK_FLAG_##A))·TICK_FLAG_"·#A·"";·
····························tickflag·-=·tickflag·TICK_FLAG_##A;¤ ····························tickflag·-=·tickflag·TICK_FLAG_##A;¤
····TICKFLAG_MACRO(BID)¤ ····TICKFLAG_MACRO(BID)¤
····TICKFLAG_MACRO(ASK)¤ ····TICKFLAG_MACRO(ASK)¤
····TICKFLAG_MACRO(LAST)¤ ····TICKFLAG_MACRO(LAST)¤
····TICKFLAG_MACRO(VOLUME)¤ ····TICKFLAG_MACRO(VOLUME)¤
····TICKFLAG_MACRO(BUY)¤ ····TICKFLAG_MACRO(BUY)¤
····TICKFLAG_MACRO(SELL)¤ ····TICKFLAG_MACRO(SELL)¤
··#undef·TICKFLAG_MACRO¤ ··#undef·TICKFLAG_MACRO¤
¤ ¤
····if·(tickflag)¤ ····if·(tickflag)¤
······flag·+=·FLAG_UNKNOWN·("·(string)tickflag·")";¤ ······flag·+=·FLAG_UNKNOWN·("·(string)tickflag·")";¤
¤ ¤
····return(flag);¤ ····return(flag);¤
·· ··
¤ ¤
#define·TOSTR(A)·#A·(string)Tick.A¤ #define·TOSTR(A)·#A·(string)Tick.A¤
#define·TOSTR2(A)·#A·::DoubleToString(Tick.A,·digits)¤ #define·TOSTR2(A)·#A·::DoubleToString(Tick.A,·digits)¤
#define·TOSTR3(A)·#A·(string)(A)¤ #define·TOSTR3(A)·#A·(string)(A)¤
¤ ¤
··static·string·TickToString(·const·string·&Symb,·const·MqlTick·&Tick· ··static·string·TickToString(·const·string·&Symb,·const·MqlTick·&Tick·
·· ··
····const·int·digits·(int)::SymbolInfoInteger(Symb,·SYMBOL_DIGITS);¤ ····const·int·digits·(int)::SymbolInfoInteger(Symb,·SYMBOL_DIGITS);¤
¤ ¤
····return(TOSTR3(Symb)·TOSTR(time)·"."·::IntegerToString(Tick.time_msc·1000,·3,·'0')· ····return(TOSTR3(Symb)·TOSTR(time)·"."·::IntegerToString(Tick.time_msc·1000,·3,·'0')·
···········TOSTR2(bid)·TOSTR2(ask)·TOSTR2(last)+·TOSTR(volume)·MT4ORDERS::GetTickFlag(Tick.flags));¤ ···········TOSTR2(bid)·TOSTR2(ask)·TOSTR2(last)+·TOSTR(volume)·MT4ORDERS::GetTickFlag(Tick.flags));¤
·· ··
¤ ¤
··static·string·TickToString(·const·string·&Symb· ··static·string·TickToString(·const·string·&Symb·
·· ··
····MqlTick·Tick·{0};¤ ····MqlTick·Tick·{0};¤
¤ ¤
····return(TOSTR3(::SymbolInfoTick(Symb,·Tick))·MT4ORDERS::TickToString(Symb,·Tick));¤ ····return(TOSTR3(::SymbolInfoTick(Symb,·Tick))·MT4ORDERS::TickToString(Symb,·Tick));¤
·· ··
¤ ¤
#undef·TOSTR3¤ #undef·TOSTR3¤
#undef·TOSTR2¤ #undef·TOSTR2¤
#undef·TOSTR¤ #undef·TOSTR¤
¤ ¤
··static·void·AlertLog(·void· ··static·void·AlertLog(·void·
·· ··
····::Alert("Please·send·the·logs·to·the·coauthor·https://www.mql5.com/en/users/fxsaber");¤ ····::Alert("Please·send·the·logs·to·the·coauthor·https://www.mql5.com/en/users/fxsaber");¤
¤ ¤
····string·Str·::TimeToString(::TimeLocal(),·TIME_DATE);¤ ····string·Str·::TimeToString(::TimeLocal(),·TIME_DATE);¤
····::StringReplace(Str,·".",·NULL);¤ ····::StringReplace(Str,·".",·NULL);¤
¤ ¤
····::Alert(::TerminalInfoString(TERMINAL_PATH)·"\\MQL5\\Logs\\"·Str·".log");¤ ····::Alert(::TerminalInfoString(TERMINAL_PATH)·"\\MQL5\\Logs\\"·Str·".log");¤
¤ ¤
····return;¤ ····return;¤
·· ··
¤ ¤
··static·long·GetTimeCurrent(·void· ··static·long·GetTimeCurrent(·void·
·· ··
····long·Res·0;¤ ····long·Res·0;¤
····MqlTick·Tick·{0};¤ ····MqlTick·Tick·{0};¤
¤ ¤
····for·(int·::SymbolsTotal(true)·1;·>=·0;·i--)¤ ····for·(int·::SymbolsTotal(true)·1;·>=·0;·i--)¤
···· ····
······const·string·SymbName·::SymbolName(i,·true);¤ ······const·string·SymbName·::SymbolName(i,·true);¤
¤ ¤
······if·(!::SymbolInfoInteger(SymbName,·SYMBOL_CUSTOM)·&&·::SymbolInfoTick(SymbName,·Tick)·&&·(Tick.time_msc·Res))¤ ······if·(!::SymbolInfoInteger(SymbName,·SYMBOL_CUSTOM)·&&·::SymbolInfoTick(SymbName,·Tick)·&&·(Tick.time_msc·Res))¤
········Res·Tick.time_msc;¤ ········Res·Tick.time_msc;¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·string·TimeToString(·const·long·time· ··static·string·TimeToString(·const·long·time·
·· ··
····return((string)(datetime)(time·1000)·"."·::IntegerToString(time·1000,·3,·'0'));¤ ····return((string)(datetime)(time·1000)·"."·::IntegerToString(time·1000,·3,·'0'));¤
·· ··
¤ ¤
#define·WHILE(A)·while·((!(Res·(A)))·&&·MT4ORDERS::Waiting())¤ #define·WHILE(A)·while·((!(Res·(A)))·&&·MT4ORDERS::Waiting())¤
¤ ¤
#define·TOSTR(A)··#A·(string)(A)·"\n"¤ #define·TOSTR(A)··#A·(string)(A)·"\n"¤
#define·TOSTR2(A)·#A·EnumToString(A)·("·(string)(A)·")\n"¤ #define·TOSTR2(A)·#A·EnumToString(A)·("·(string)(A)·")\n"¤
¤ ¤
··static·void·GetHistoryPositionData(·const·ulong·Ticket· ··static·void·GetHistoryPositionData(·const·ulong·Ticket·
·· ··
····MT4ORDERS::Order.Ticket·(long)Ticket;¤ ····MT4ORDERS::Order.Ticket·(long)Ticket;¤
····MT4ORDERS::Order.TicketID·::HistoryDealGetInteger(MT4ORDERS::Order.Ticket,·DEAL_POSITION_ID);¤ ····MT4ORDERS::Order.TicketID·::HistoryDealGetInteger(MT4ORDERS::Order.Ticket,·DEAL_POSITION_ID);¤
····MT4ORDERS::Order.Type·(int)::HistoryDealGetInteger(Ticket,·DEAL_TYPE);¤ ····MT4ORDERS::Order.Type·(int)::HistoryDealGetInteger(Ticket,·DEAL_TYPE);¤
¤ ¤
····if·((MT4ORDERS::Order.Type·OP_SELL))¤ ····if·((MT4ORDERS::Order.Type·OP_SELL))¤
······MT4ORDERS::Order.Type·+=·(OP_BALANCE·OP_SELL·1);¤ ······MT4ORDERS::Order.Type·+=·(OP_BALANCE·OP_SELL·1);¤
····else¤ ····else¤
······MT4ORDERS::Order.Type·MT4ORDERS::Order.Type;¤ ······MT4ORDERS::Order.Type·MT4ORDERS::Order.Type;¤
¤ ¤
····MT4ORDERS::Order.Lots·::HistoryDealGetDouble(Ticket,·DEAL_VOLUME);¤ ····MT4ORDERS::Order.Lots·::HistoryDealGetDouble(Ticket,·DEAL_VOLUME);¤
¤ ¤
····MT4ORDERS::Order.Symbol·::HistoryDealGetString(Ticket,·DEAL_SYMBOL);¤ ····MT4ORDERS::Order.Symbol·::HistoryDealGetString(Ticket,·DEAL_SYMBOL);¤
····MT4ORDERS::Order.Comment·::HistoryDealGetString(Ticket,·DEAL_COMMENT);¤ ····MT4ORDERS::Order.Comment·::HistoryDealGetString(Ticket,·DEAL_COMMENT);¤
¤ ¤
····MT4ORDERS::Order.CloseTimeMsc·::HistoryDealGetInteger(Ticket,·DEAL_TIME_MSC);¤ ····MT4ORDERS::Order.CloseTimeMsc·::HistoryDealGetInteger(Ticket,·DEAL_TIME_MSC);¤
····MT4ORDERS::Order.CloseTime·(datetime)(MT4ORDERS::Order.CloseTimeMsc·1000);·//·(datetime)::HistoryDealGetInteger(Ticket,·DEAL_TIME);¤ ····MT4ORDERS::Order.CloseTime·(datetime)(MT4ORDERS::Order.CloseTimeMsc·1000);·//·(datetime)::HistoryDealGetInteger(Ticket,·DEAL_TIME);¤
¤ ¤
····MT4ORDERS::Order.ClosePrice·::HistoryDealGetDouble(Ticket,·DEAL_PRICE);¤ ····MT4ORDERS::Order.ClosePrice·::HistoryDealGetDouble(Ticket,·DEAL_PRICE);¤
¤ ¤
····MT4ORDERS::Order.CloseReason·(ENUM_DEAL_REASON)::HistoryDealGetInteger(Ticket,·DEAL_REASON);;¤ ····MT4ORDERS::Order.CloseReason·(ENUM_DEAL_REASON)::HistoryDealGetInteger(Ticket,·DEAL_REASON);;¤
¤ ¤
····MT4ORDERS::Order.Expiration·0;¤ ····MT4ORDERS::Order.Expiration·0;¤
¤ ¤
····MT4ORDERS::Order.MagicNumber·::HistoryDealGetInteger(Ticket,·DEAL_MAGIC);¤ ····MT4ORDERS::Order.MagicNumber·::HistoryDealGetInteger(Ticket,·DEAL_MAGIC);¤
¤ ¤
····MT4ORDERS::Order.Profit·::HistoryDealGetDouble(Ticket,·DEAL_PROFIT);¤ ····MT4ORDERS::Order.Profit·::HistoryDealGetDouble(Ticket,·DEAL_PROFIT);¤
¤ ¤
····MT4ORDERS::Order.Commission·::HistoryDealGetDouble(Ticket,·DEAL_COMMISSION);¤ ····MT4ORDERS::Order.Commission·::HistoryDealGetDouble(Ticket,·DEAL_COMMISSION);¤
····MT4ORDERS::Order.Swap·::HistoryDealGetDouble(Ticket,·DEAL_SWAP);¤ ····MT4ORDERS::Order.Swap·::HistoryDealGetDouble(Ticket,·DEAL_SWAP);¤
¤ ¤
#ifndef·MT4ORDERS_SLTP_OLD¤ #ifndef·MT4ORDERS_SLTP_OLD¤
····MT4ORDERS::Order.StopLoss·::HistoryDealGetDouble(Ticket,·DEAL_SL);¤ ····MT4ORDERS::Order.StopLoss·::HistoryDealGetDouble(Ticket,·DEAL_SL);¤
····MT4ORDERS::Order.TakeProfit·::HistoryDealGetDouble(Ticket,·DEAL_TP);¤ ····MT4ORDERS::Order.TakeProfit·::HistoryDealGetDouble(Ticket,·DEAL_TP);¤
#else·//·MT4ORDERS_SLTP_OLD¤ #else·//·MT4ORDERS_SLTP_OLD¤
····MT4ORDERS::Order.StopLoss·0;¤ ····MT4ORDERS::Order.StopLoss·0;¤
····MT4ORDERS::Order.TakeProfit·0;¤ ····MT4ORDERS::Order.TakeProfit·0;¤
#endif·//·MT4ORDERS_SLTP_OLD¤ #endif·//·MT4ORDERS_SLTP_OLD¤
¤ ¤
····const·ulong·OrderTicket·::HistoryDealGetInteger(Ticket,·DEAL_ORDER);¤ ····const·ulong·OrderTicket·::HistoryDealGetInteger(Ticket,·DEAL_ORDER);¤
····const·ulong·PosTicket·MT4ORDERS::Order.TicketID;¤ ····const·ulong·PosTicket·MT4ORDERS::Order.TicketID;¤
····const·ulong·OpenTicket·(OrderTicket·0)·MT4ORDERS::History.GetPositionDealIn(PosTicket)·0;¤ ····const·ulong·OpenTicket·(OrderTicket·0)·MT4ORDERS::History.GetPositionDealIn(PosTicket)·0;¤
¤ ¤
····if·(OpenTicket·0)¤ ····if·(OpenTicket·0)¤
···· ····
······const·ENUM_DEAL_REASON·Reason·(ENUM_DEAL_REASON)HistoryDealGetInteger(Ticket,·DEAL_REASON);¤ ······const·ENUM_DEAL_REASON·Reason·(ENUM_DEAL_REASON)HistoryDealGetInteger(Ticket,·DEAL_REASON);¤
······const·ENUM_DEAL_ENTRY·DealEntry·(ENUM_DEAL_ENTRY)::HistoryDealGetInteger(Ticket,·DEAL_ENTRY);¤ ······const·ENUM_DEAL_ENTRY·DealEntry·(ENUM_DEAL_ENTRY)::HistoryDealGetInteger(Ticket,·DEAL_ENTRY);¤
¤ ¤
····//·�������·(OpenTicket·�·OrderTicket)·����������,·���������·GetPositionDealIn,·HistorySelectByPosition¤ ····//·�������·(OpenTicket·�·OrderTicket)·����������,·���������·GetPositionDealIn,·HistorySelectByPosition¤
····#ifdef·MT4ORDERS_FASTHISTORY_OFF¤ ····#ifdef·MT4ORDERS_FASTHISTORY_OFF¤
······const·bool·Res·true;¤ ······const·bool·Res·true;¤
····#else·//·MT4ORDERS_FASTHISTORY_OFF¤ ····#else·//·MT4ORDERS_FASTHISTORY_OFF¤
······//·���������·����������·�������·������·�����·https://www.mql5.com/ru/forum/227423/page2#comment_6543129¤ ······//·���������·����������·�������·������·�����·https://www.mql5.com/ru/forum/227423/page2#comment_6543129¤
······bool·Res·MT4ORDERS::IsTester·MT4ORDERS::HistorySelectOrder(OrderTicket)·MT4ORDERS::Waiting(true);¤ ······bool·Res·MT4ORDERS::IsTester·MT4ORDERS::HistorySelectOrder(OrderTicket)·MT4ORDERS::Waiting(true);¤
¤ ¤
······if·(!Res)¤ ······if·(!Res)¤
········WHILE(MT4ORDERS::HistorySelectOrder(OrderTicket))·//·https://www.mql5.com/ru/forum/304239#comment_10710403¤ ········WHILE(MT4ORDERS::HistorySelectOrder(OrderTicket))·//·https://www.mql5.com/ru/forum/304239#comment_10710403¤
·········· ··········
¤ ¤
······if·(MT4ORDERS::HistorySelectDeal(OpenTicket))·//·�����������·���������,·�.�.·OpenTicket·��������������·�·�������.¤ ······if·(MT4ORDERS::HistorySelectDeal(OpenTicket))·//·�����������·���������,·�.�.·OpenTicket·��������������·�·�������.¤
····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤ ····#endif·//·MT4ORDERS_FASTHISTORY_OFF¤
······ ······
········MT4ORDERS::Order.TicketOpen·(long)OpenTicket;¤ ········MT4ORDERS::Order.TicketOpen·(long)OpenTicket;¤
¤ ¤
········MT4ORDERS::Order.OpenReason·Reason;¤ ········MT4ORDERS::Order.OpenReason·Reason;¤
¤ ¤
········MT4ORDERS::Order.OpenPrice·::HistoryDealGetDouble(OpenTicket,·DEAL_PRICE);¤ ········MT4ORDERS::Order.OpenPrice·::HistoryDealGetDouble(OpenTicket,·DEAL_PRICE);¤
¤ ¤
········MT4ORDERS::Order.OpenTimeMsc·::HistoryDealGetInteger(OpenTicket,·DEAL_TIME_MSC);¤ ········MT4ORDERS::Order.OpenTimeMsc·::HistoryDealGetInteger(OpenTicket,·DEAL_TIME_MSC);¤
········MT4ORDERS::Order.OpenTime·(datetime)(MT4ORDERS::Order.OpenTimeMsc·1000);¤ ········MT4ORDERS::Order.OpenTime·(datetime)(MT4ORDERS::Order.OpenTimeMsc·1000);¤
¤ ¤
········const·double·OpenLots·::HistoryDealGetDouble(OpenTicket,·DEAL_VOLUME);¤ ········const·double·OpenLots·::HistoryDealGetDouble(OpenTicket,·DEAL_VOLUME);¤
¤ ¤
········if·(OpenLots·0)¤ ········if·(OpenLots·0)¤
··········MT4ORDERS::Order.Commission·+=·::HistoryDealGetDouble(OpenTicket,·DEAL_COMMISSION)·MT4ORDERS::Order.Lots·OpenLots;¤ ··········MT4ORDERS::Order.Commission·+=·::HistoryDealGetDouble(OpenTicket,·DEAL_COMMISSION)·MT4ORDERS::Order.Lots·OpenLots;¤
¤ ¤
//········if·(!MT4ORDERS::Order.MagicNumber)·//·������·��������·�������·������·������·����·�����·�������·�����������·������.¤ //········if·(!MT4ORDERS::Order.MagicNumber)·//·������·��������·�������·������·������·����·�����·�������·�����������·������.¤
··········const·long·mag·::HistoryDealGetInteger(OpenTicket,·DEAL_MAGIC);¤ ··········const·long·mag·::HistoryDealGetInteger(OpenTicket,·DEAL_MAGIC);¤
¤ ¤
··········if·(mag)¤ ··········if·(mag)¤
············MT4ORDERS::Order.MagicNumber·mag;¤ ············MT4ORDERS::Order.MagicNumber·mag;¤
¤ ¤
//········if·(MT4ORDERS::Order.Comment·==·"")·//·�����������·��������·�������·������·������·����·�����·�����������·�����������·������.¤ //········if·(MT4ORDERS::Order.Comment·==·"")·//·�����������·��������·�������·������·������·����·�����·�����������·�����������·������.¤
··········const·string·StrComment·::HistoryDealGetString(OpenTicket,·DEAL_COMMENT);¤ ··········const·string·StrComment·::HistoryDealGetString(OpenTicket,·DEAL_COMMENT);¤
¤ ¤
··········if·(StrComment·!=·"")¤ ··········if·(StrComment·!=·"")¤
············MT4ORDERS::Order.Comment·StrComment;¤ ············MT4ORDERS::Order.Comment·StrComment;¤
¤ ¤
········if·(Res)·//·OrderTicket·�����·��·����·�·�������,·��·�����·���������·�����·���·�����.·��������,·�������·������·�������·������·����.¤ ········if·(Res)·//·OrderTicket·�����·��·����·�·�������,·��·�����·���������·�����·���·�����.·��������,·�������·������·�������·������·����.¤
········ ········
······#ifdef·MT4ORDERS_SLTP_OLD¤ ······#ifdef·MT4ORDERS_SLTP_OLD¤
··········//·�����������·��·������:·��.·OrderClose.¤ ··········//·�����������·��·������:·��.·OrderClose.¤
··········MT4ORDERS::Order.StopLoss·::HistoryOrderGetDouble(OrderTicket,·(Reason·==·DEAL_REASON_SL)·ORDER_PRICE_OPEN·ORDER_TP);¤ ··········MT4ORDERS::Order.StopLoss·::HistoryOrderGetDouble(OrderTicket,·(Reason·==·DEAL_REASON_SL)·ORDER_PRICE_OPEN·ORDER_TP);¤
··········MT4ORDERS::Order.TakeProfit·::HistoryOrderGetDouble(OrderTicket,·(Reason·==·DEAL_REASON_TP)·ORDER_PRICE_OPEN·ORDER_SL);¤ ··········MT4ORDERS::Order.TakeProfit·::HistoryOrderGetDouble(OrderTicket,·(Reason·==·DEAL_REASON_TP)·ORDER_PRICE_OPEN·ORDER_SL);¤
······#endif·//·MT4ORDERS_SLTP_OLD¤ ······#endif·//·MT4ORDERS_SLTP_OLD¤
¤ ¤
··········MT4ORDERS::Order.State·(ENUM_ORDER_STATE)::HistoryOrderGetInteger(OrderTicket,·ORDER_STATE);¤ ··········MT4ORDERS::Order.State·(ENUM_ORDER_STATE)::HistoryOrderGetInteger(OrderTicket,·ORDER_STATE);¤
¤ ¤
··········if·(!(MT4ORDERS::Order.ClosePriceRequest·(DealEntry·==·DEAL_ENTRY_OUT_BY)· ··········if·(!(MT4ORDERS::Order.ClosePriceRequest·(DealEntry·==·DEAL_ENTRY_OUT_BY)·
·····················································MT4ORDERS::Order.ClosePrice·::HistoryOrderGetDouble(OrderTicket,·ORDER_PRICE_OPEN)))¤ ·····················································MT4ORDERS::Order.ClosePrice·::HistoryOrderGetDouble(OrderTicket,·ORDER_PRICE_OPEN)))¤
············MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤ ············MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤
¤ ¤
··········if·(!(MT4ORDERS::Order.OpenPriceRequest·(MT4ORDERS::HistorySelectOrder(PosTicket)·&&¤ ··········if·(!(MT4ORDERS::Order.OpenPriceRequest·(MT4ORDERS::HistorySelectOrder(PosTicket)·&&¤
····················································//·�·�����·��·���·��������?¤ ····················································//·�·�����·��·���·��������?¤
····················································(MT4ORDERS::IsTester·||·(::HistoryDealGetInteger(OpenTicket,·DEAL_TIME_MSC)·==·::HistoryOrderGetInteger(PosTicket,·ORDER_TIME_DONE_MSC))))· ····················································(MT4ORDERS::IsTester·||·(::HistoryDealGetInteger(OpenTicket,·DEAL_TIME_MSC)·==·::HistoryOrderGetInteger(PosTicket,·ORDER_TIME_DONE_MSC))))·
···················································::HistoryOrderGetDouble(PosTicket,·ORDER_PRICE_OPEN)·MT4ORDERS::Order.OpenPrice))¤ ···················································::HistoryOrderGetDouble(PosTicket,·ORDER_PRICE_OPEN)·MT4ORDERS::Order.OpenPrice))¤
············MT4ORDERS::Order.OpenPriceRequest·MT4ORDERS::Order.OpenPrice;¤ ············MT4ORDERS::Order.OpenPriceRequest·MT4ORDERS::Order.OpenPrice;¤
········ ········
········else¤ ········else¤
········ ········
··········MT4ORDERS::Order.State·ORDER_STATE_FILLED;¤ ··········MT4ORDERS::Order.State·ORDER_STATE_FILLED;¤
¤ ¤
··········MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤ ··········MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤
··········MT4ORDERS::Order.OpenPriceRequest·MT4ORDERS::Order.OpenPrice;¤ ··········MT4ORDERS::Order.OpenPriceRequest·MT4ORDERS::Order.OpenPrice;¤
········ ········
······ ······
¤ ¤
······if·(!Res)¤ ······if·(!Res)¤
······ ······
········::Alert("HistoryOrderSelect("·(string)OrderTicket·")·BUG!·MT4ORDERS·not·Sync·with·History!");¤ ········::Alert("HistoryOrderSelect("·(string)OrderTicket·")·BUG!·MT4ORDERS·not·Sync·with·History!");¤
········MT4ORDERS::AlertLog();¤ ········MT4ORDERS::AlertLog();¤
¤ ¤
········::Print(TOSTR(__FILE__)·"Version·(string)__MT4ORDERS__·"\n"·TOSTR(__MQLBUILD__)·TOSTR(__DATE__)· ········::Print(TOSTR(__FILE__)·"Version·(string)__MT4ORDERS__·"\n"·TOSTR(__MQLBUILD__)·TOSTR(__DATE__)·
················TOSTR(::AccountInfoString(ACCOUNT_SERVER))·TOSTR2((ENUM_ACCOUNT_TRADE_MODE)::AccountInfoInteger(ACCOUNT_TRADE_MODE))· ················TOSTR(::AccountInfoString(ACCOUNT_SERVER))·TOSTR2((ENUM_ACCOUNT_TRADE_MODE)::AccountInfoInteger(ACCOUNT_TRADE_MODE))·
················TOSTR((bool)::TerminalInfoInteger(TERMINAL_CONNECTED))· ················TOSTR((bool)::TerminalInfoInteger(TERMINAL_CONNECTED))·
················TOSTR(::TerminalInfoInteger(TERMINAL_PING_LAST))·TOSTR(::TerminalInfoDouble(TERMINAL_RETRANSMISSION))· ················TOSTR(::TerminalInfoInteger(TERMINAL_PING_LAST))·TOSTR(::TerminalInfoDouble(TERMINAL_RETRANSMISSION))·
················TOSTR(::TerminalInfoInteger(TERMINAL_BUILD))·TOSTR((bool)::TerminalInfoInteger(TERMINAL_X64))· ················TOSTR(::TerminalInfoInteger(TERMINAL_BUILD))·TOSTR((bool)::TerminalInfoInteger(TERMINAL_X64))·
················TOSTR((bool)::TerminalInfoInteger(TERMINAL_VPS))·TOSTR2((ENUM_PROGRAM_TYPE)::MQLInfoInteger(MQL_PROGRAM_TYPE))· ················TOSTR((bool)::TerminalInfoInteger(TERMINAL_VPS))·TOSTR2((ENUM_PROGRAM_TYPE)::MQLInfoInteger(MQL_PROGRAM_TYPE))·
················TOSTR(::TimeCurrent())·TOSTR(::TimeTradeServer())·TOSTR(MT4ORDERS::TimeToString(MT4ORDERS::GetTimeCurrent()))· ················TOSTR(::TimeCurrent())·TOSTR(::TimeTradeServer())·TOSTR(MT4ORDERS::TimeToString(MT4ORDERS::GetTimeCurrent()))·
················TOSTR(::SymbolInfoString(MT4ORDERS::Order.Symbol,·SYMBOL_PATH))·TOSTR(::SymbolInfoString(MT4ORDERS::Order.Symbol,·SYMBOL_DESCRIPTION))· ················TOSTR(::SymbolInfoString(MT4ORDERS::Order.Symbol,·SYMBOL_PATH))·TOSTR(::SymbolInfoString(MT4ORDERS::Order.Symbol,·SYMBOL_DESCRIPTION))·
················"CurrentTick·="·MT4ORDERS::TickToString(MT4ORDERS::Order.Symbol)·"\n"· ················"CurrentTick·="·MT4ORDERS::TickToString(MT4ORDERS::Order.Symbol)·"\n"·
················TOSTR(::PositionsTotal())·TOSTR(::OrdersTotal())· ················TOSTR(::PositionsTotal())·TOSTR(::OrdersTotal())·
················TOSTR(::HistorySelect(0,·INT_MAX))·TOSTR(::HistoryDealsTotal())·TOSTR(::HistoryOrdersTotal())· ················TOSTR(::HistorySelect(0,·INT_MAX))·TOSTR(::HistoryDealsTotal())·TOSTR(::HistoryOrdersTotal())·
················TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE))·TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_PHYSICAL))· ················TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE))·TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_PHYSICAL))·
················TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_TOTAL))·TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_USED))· ················TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_TOTAL))·TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_USED))·
················TOSTR(::MQLInfoInteger(MQL_MEMORY_LIMIT))·TOSTR(::MQLInfoInteger(MQL_MEMORY_USED))· ················TOSTR(::MQLInfoInteger(MQL_MEMORY_LIMIT))·TOSTR(::MQLInfoInteger(MQL_MEMORY_USED))·
················TOSTR(Ticket)·TOSTR(OrderTicket)·TOSTR(OpenTicket)·TOSTR(PosTicket)· ················TOSTR(Ticket)·TOSTR(OrderTicket)·TOSTR(OpenTicket)·TOSTR(PosTicket)·
················TOSTR(MT4ORDERS::TimeToString(MT4ORDERS::Order.CloseTimeMsc))· ················TOSTR(MT4ORDERS::TimeToString(MT4ORDERS::Order.CloseTimeMsc))·
················TOSTR(MT4ORDERS::HistorySelectOrder(OrderTicket))·TOSTR(::OrderSelect(OrderTicket))· ················TOSTR(MT4ORDERS::HistorySelectOrder(OrderTicket))·TOSTR(::OrderSelect(OrderTicket))·
················(::OrderSelect(OrderTicket)·TOSTR2((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE))·NULL)· ················(::OrderSelect(OrderTicket)·TOSTR2((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE))·NULL)·
················(::HistoryDealsTotal()·TOSTR(::HistoryDealGetTicket(::HistoryDealsTotal()·1))· ················(::HistoryDealsTotal()·TOSTR(::HistoryDealGetTicket(::HistoryDealsTotal()·1))·
···················"DEAL_TIME_MSC·MT4ORDERS::TimeToString(::HistoryDealGetInteger(::HistoryDealGetTicket(::HistoryDealsTotal()·1),·DEAL_TIME_MSC))·"\n"¤ ···················"DEAL_TIME_MSC·MT4ORDERS::TimeToString(::HistoryDealGetInteger(::HistoryDealGetTicket(::HistoryDealsTotal()·1),·DEAL_TIME_MSC))·"\n"¤
·······································NULL)· ·······································NULL)·
················(::HistoryOrdersTotal()·TOSTR(::HistoryOrderGetTicket(::HistoryOrdersTotal()·1))· ················(::HistoryOrdersTotal()·TOSTR(::HistoryOrderGetTicket(::HistoryOrdersTotal()·1))·
···················"ORDER_TIME_DONE_MSC·MT4ORDERS::TimeToString(::HistoryOrderGetInteger(::HistoryOrderGetTicket(::HistoryOrdersTotal()·1),·ORDER_TIME_DONE_MSC))·"\n"¤ ···················"ORDER_TIME_DONE_MSC·MT4ORDERS::TimeToString(::HistoryOrderGetInteger(::HistoryOrderGetTicket(::HistoryOrdersTotal()·1),·ORDER_TIME_DONE_MSC))·"\n"¤
········································NULL));¤ ········································NULL));¤
······ ······
···· ····
····else¤ ····else¤
···· ····
······MT4ORDERS::Order.TicketOpen·MT4ORDERS::Order.Ticket;¤ ······MT4ORDERS::Order.TicketOpen·MT4ORDERS::Order.Ticket;¤
¤ ¤
······if·(!MT4ORDERS::Order.TicketID·&&·(MT4ORDERS::Order.Type·<=·OP_SELL))·//·ID·����������·������·������·����������·�������.¤ ······if·(!MT4ORDERS::Order.TicketID·&&·(MT4ORDERS::Order.Type·<=·OP_SELL))·//·ID·����������·������·������·����������·�������.¤
········MT4ORDERS::Order.TicketID·MT4ORDERS::Order.Ticket;¤ ········MT4ORDERS::Order.TicketID·MT4ORDERS::Order.Ticket;¤
¤ ¤
······MT4ORDERS::Order.OpenPrice·MT4ORDERS::Order.ClosePrice;·//·::HistoryDealGetDouble(Ticket,·DEAL_PRICE);¤ ······MT4ORDERS::Order.OpenPrice·MT4ORDERS::Order.ClosePrice;·//·::HistoryDealGetDouble(Ticket,·DEAL_PRICE);¤
¤ ¤
······MT4ORDERS::Order.OpenTimeMsc·MT4ORDERS::Order.CloseTimeMsc;¤ ······MT4ORDERS::Order.OpenTimeMsc·MT4ORDERS::Order.CloseTimeMsc;¤
······MT4ORDERS::Order.OpenTime·MT4ORDERS::Order.CloseTime;···//·(datetime)::HistoryDealGetInteger(Ticket,·DEAL_TIME);¤ ······MT4ORDERS::Order.OpenTime·MT4ORDERS::Order.CloseTime;···//·(datetime)::HistoryDealGetInteger(Ticket,·DEAL_TIME);¤
¤ ¤
······MT4ORDERS::Order.OpenReason·MT4ORDERS::Order.CloseReason;¤ ······MT4ORDERS::Order.OpenReason·MT4ORDERS::Order.CloseReason;¤
¤ ¤
······MT4ORDERS::Order.State·ORDER_STATE_FILLED;¤ ······MT4ORDERS::Order.State·ORDER_STATE_FILLED;¤
¤ ¤
······MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤ ······MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤
······MT4ORDERS::Order.OpenPriceRequest·MT4ORDERS::Order.OpenPrice;¤ ······MT4ORDERS::Order.OpenPriceRequest·MT4ORDERS::Order.OpenPrice;¤
···· ····
¤ ¤
····bool·Res·MT4ORDERS::IsTester·MT4ORDERS::HistorySelectOrder(OrderTicket)·MT4ORDERS::Waiting(true);¤ ····bool·Res·MT4ORDERS::IsTester·MT4ORDERS::HistorySelectOrder(OrderTicket)·MT4ORDERS::Waiting(true);¤
¤ ¤
····if·(!Res)¤ ····if·(!Res)¤
······WHILE(MT4ORDERS::HistorySelectOrder(OrderTicket))·//·https://www.mql5.com/ru/forum/304239#comment_10710403¤ ······WHILE(MT4ORDERS::HistorySelectOrder(OrderTicket))·//·https://www.mql5.com/ru/forum/304239#comment_10710403¤
········ ········
¤ ¤
····if·((ENUM_ORDER_TYPE)::HistoryOrderGetInteger(OrderTicket,·ORDER_TYPE)·==·ORDER_TYPE_CLOSE_BY)¤ ····if·((ENUM_ORDER_TYPE)::HistoryOrderGetInteger(OrderTicket,·ORDER_TYPE)·==·ORDER_TYPE_CLOSE_BY)¤
···· ····
······const·ulong·PosTicketBy·::HistoryOrderGetInteger(OrderTicket,·ORDER_POSITION_BY_ID);¤ ······const·ulong·PosTicketBy·::HistoryOrderGetInteger(OrderTicket,·ORDER_POSITION_BY_ID);¤
¤ ¤
······if·(PosTicketBy·==·PosTicket)·//·CloseBy-Slave·��·������·������·��·��������·������.¤ ······if·(PosTicketBy·==·PosTicket)·//·CloseBy-Slave·��·������·������·��·��������·������.¤
······ ······
········MT4ORDERS::Order.Lots·0;¤ ········MT4ORDERS::Order.Lots·0;¤
········MT4ORDERS::Order.Commission·0;¤ ········MT4ORDERS::Order.Commission·0;¤
¤ ¤
········MT4ORDERS::Order.ClosePrice·MT4ORDERS::Order.OpenPrice;¤ ········MT4ORDERS::Order.ClosePrice·MT4ORDERS::Order.OpenPrice;¤
········MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤ ········MT4ORDERS::Order.ClosePriceRequest·MT4ORDERS::Order.ClosePrice;¤
······ ······
······else·//·CloseBy-Master·������·��������·��������·��·CloseBy-Slave.¤ ······else·//·CloseBy-Master·������·��������·��������·��·CloseBy-Slave.¤
······ ······
········const·ulong·OpenTicketBy·(OrderTicket·0)·MT4ORDERS::History.GetPositionDealIn(PosTicketBy)·0;¤ ········const·ulong·OpenTicketBy·(OrderTicket·0)·MT4ORDERS::History.GetPositionDealIn(PosTicketBy)·0;¤
¤ ¤
········if·((OpenTicketBy·0)·&&·MT4ORDERS::HistorySelectDeal(OpenTicketBy))¤ ········if·((OpenTicketBy·0)·&&·MT4ORDERS::HistorySelectDeal(OpenTicketBy))¤
········ ········
··········const·double·OpenLots·::HistoryDealGetDouble(OpenTicketBy,·DEAL_VOLUME);¤ ··········const·double·OpenLots·::HistoryDealGetDouble(OpenTicketBy,·DEAL_VOLUME);¤
¤ ¤
··········if·(OpenLots·0)¤ ··········if·(OpenLots·0)¤
············MT4ORDERS::Order.Commission·+=·::HistoryDealGetDouble(OpenTicketBy,·DEAL_COMMISSION)·MT4ORDERS::Order.Lots·OpenLots;¤ ············MT4ORDERS::Order.Commission·+=·::HistoryDealGetDouble(OpenTicketBy,·DEAL_COMMISSION)·MT4ORDERS::Order.Lots·OpenLots;¤
········ ········
······ ······
···· ····
¤ ¤
····return;¤ ····return;¤
·· ··
¤ ¤
··static·bool·Waiting(·const·bool·FlagInit·false· ··static·bool·Waiting(·const·bool·FlagInit·false·
·· ··
····static·ulong·StartTime·0;¤ ····static·ulong·StartTime·0;¤
¤ ¤
····const·bool·Res·FlagInit·false·(::GetMicrosecondCount()·StartTime·MT4ORDERS::OrderSend_MaxPause);¤ ····const·bool·Res·FlagInit·false·(::GetMicrosecondCount()·StartTime·MT4ORDERS::OrderSend_MaxPause);¤
¤ ¤
····if·(FlagInit)¤ ····if·(FlagInit)¤
···· ····
······StartTime·::GetMicrosecondCount();¤ ······StartTime·::GetMicrosecondCount();¤
¤ ¤
······MT4ORDERS::OrderSendBug·0;¤ ······MT4ORDERS::OrderSendBug·0;¤
···· ····
····else·if·(Res)¤ ····else·if·(Res)¤
···· ····
//······::Sleep(0);·//·https://www.mql5.com/ru/forum/170952/page100#comment_8750511¤ //······::Sleep(0);·//·https://www.mql5.com/ru/forum/170952/page100#comment_8750511¤
¤ ¤
······MT4ORDERS::OrderSendBug++;¤ ······MT4ORDERS::OrderSendBug++;¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·bool·EqualPrices(·const·double·Price1,·const·double·&Price2,·const·int·&digits)¤ ··static·bool·EqualPrices(·const·double·Price1,·const·double·&Price2,·const·int·&digits)¤
·· ··
····return(!::NormalizeDouble(Price1·Price2,·digits));¤ ····return(!::NormalizeDouble(Price1·Price2,·digits));¤
·· ··
¤ ¤
··static·bool·HistoryDealSelect2(·MqlTradeResult·&Result·//·�·�����·��������·�����·���·�������·�������������·�·���������.¤ ··static·bool·HistoryDealSelect2(·MqlTradeResult·&Result·//·�·�����·��������·�����·���·�������·�������������·�·���������.¤
·· ··
····//·��������·HistorySelectByPosition·��·HistorySelect(PosTime,·PosTime)¤ ····//·��������·HistorySelectByPosition·��·HistorySelect(PosTime,·PosTime)¤
····if·(!Result.deal·&&·Result.order·&&·::HistorySelectByPosition(::HistoryOrderGetInteger(Result.order,·ORDER_POSITION_ID)))¤ ····if·(!Result.deal·&&·Result.order·&&·::HistorySelectByPosition(::HistoryOrderGetInteger(Result.order,·ORDER_POSITION_ID)))¤
······for·(int·::HistoryDealsTotal()·1;·>=·0;·i--)¤ ······for·(int·::HistoryDealsTotal()·1;·>=·0;·i--)¤
······ ······
········const·ulong·DealTicket·::HistoryDealGetTicket(i);¤ ········const·ulong·DealTicket·::HistoryDealGetTicket(i);¤
¤ ¤
········if·(Result.order·==·::HistoryDealGetInteger(DealTicket,·DEAL_ORDER))¤ ········if·(Result.order·==·::HistoryDealGetInteger(DealTicket,·DEAL_ORDER))¤
········ ········
··········Result.deal·DealTicket;¤ ··········Result.deal·DealTicket;¤
··········Result.price·::HistoryDealGetDouble(DealTicket,·DEAL_PRICE);¤ ··········Result.price·::HistoryDealGetDouble(DealTicket,·DEAL_PRICE);¤
¤ ¤
··········break;¤ ··········break;¤
········ ········
······ ······
¤ ¤
····return(::HistoryDealSelect(Result.deal));¤ ····return(::HistoryDealSelect(Result.deal));¤
·· ··
¤ ¤
/*¤ /*¤
#define·MT4ORDERS_BENCHMARK·Alert(MT4ORDERS::LastTradeRequest.symbol······· #define·MT4ORDERS_BENCHMARK·Alert(MT4ORDERS::LastTradeRequest.symbol·······
··································(string)MT4ORDERS::LastTradeResult.order· ··································(string)MT4ORDERS::LastTradeResult.order·
··································MT4ORDERS::LastTradeResult.comment);············· ··································MT4ORDERS::LastTradeResult.comment);·············
····························Print(ToString(MT4ORDERS::LastTradeRequest)·········· ····························Print(ToString(MT4ORDERS::LastTradeRequest)··········
··································ToString(MT4ORDERS::LastTradeResult));¤ ··································ToString(MT4ORDERS::LastTradeResult));¤
*/¤ */¤
¤ ¤
#define·TMP_MT4ORDERS_BENCHMARK(A)· #define·TMP_MT4ORDERS_BENCHMARK(A)·
··static·ulong·Max##A·0;········· ··static·ulong·Max##A·0;·········
··································· ···································
··if·(Interval##A·Max##A)········ ··if·(Interval##A·Max##A)········
································· ·································
····MT4ORDERS_BENCHMARK············ ····MT4ORDERS_BENCHMARK············
··································· ···································
····Max##A·Interval##A;·········· ····Max##A·Interval##A;··········
·· ··
¤ ¤
··static·void·OrderSend_Benchmark(·const·ulong·&Interval1,·const·ulong·&Interval2· ··static·void·OrderSend_Benchmark(·const·ulong·&Interval1,·const·ulong·&Interval2·
·· ··
····#ifdef·MT4ORDERS_BENCHMARK¤ ····#ifdef·MT4ORDERS_BENCHMARK¤
······TMP_MT4ORDERS_BENCHMARK(1)¤ ······TMP_MT4ORDERS_BENCHMARK(1)¤
······TMP_MT4ORDERS_BENCHMARK(2)¤ ······TMP_MT4ORDERS_BENCHMARK(2)¤
····#endif·//·MT4ORDERS_BENCHMARK¤ ····#endif·//·MT4ORDERS_BENCHMARK¤
¤ ¤
····return;¤ ····return;¤
·· ··
¤ ¤
#undef·TMP_MT4ORDERS_BENCHMARK¤ #undef·TMP_MT4ORDERS_BENCHMARK¤
¤ ¤
··static·string·ToString(·const·MqlTradeRequest·&Request· ··static·string·ToString(·const·MqlTradeRequest·&Request·
·· ··
····return(TOSTR2(Request.action)·TOSTR(Request.magic)·TOSTR(Request.order)· ····return(TOSTR2(Request.action)·TOSTR(Request.magic)·TOSTR(Request.order)·
···········TOSTR(Request.symbol)·TOSTR(Request.volume)·TOSTR(Request.price)· ···········TOSTR(Request.symbol)·TOSTR(Request.volume)·TOSTR(Request.price)·
···········TOSTR(Request.stoplimit)·TOSTR(Request.sl)··TOSTR(Request.tp)· ···········TOSTR(Request.stoplimit)·TOSTR(Request.sl)··TOSTR(Request.tp)·
···········TOSTR(Request.deviation)·TOSTR2(Request.type)·TOSTR2(Request.type_filling)· ···········TOSTR(Request.deviation)·TOSTR2(Request.type)·TOSTR2(Request.type_filling)·
···········TOSTR2(Request.type_time)·TOSTR(Request.expiration)·TOSTR(Request.comment)· ···········TOSTR2(Request.type_time)·TOSTR(Request.expiration)·TOSTR(Request.comment)·
···········TOSTR(Request.position)·TOSTR(Request.position_by));¤ ···········TOSTR(Request.position)·TOSTR(Request.position_by));¤
·· ··
¤ ¤
··static·string·ToString(·const·MqlTradeResult·&Result· ··static·string·ToString(·const·MqlTradeResult·&Result·
·· ··
····return(TOSTR(Result.retcode)·TOSTR(Result.deal)·TOSTR(Result.order)· ····return(TOSTR(Result.retcode)·TOSTR(Result.deal)·TOSTR(Result.order)·
···········TOSTR(Result.volume)·TOSTR(Result.price)·TOSTR(Result.bid)· ···········TOSTR(Result.volume)·TOSTR(Result.price)·TOSTR(Result.bid)·
···········TOSTR(Result.ask)·TOSTR(Result.comment)·TOSTR(Result.request_id)· ···········TOSTR(Result.ask)·TOSTR(Result.comment)·TOSTR(Result.request_id)·
···········TOSTR(Result.retcode_external));¤ ···········TOSTR(Result.retcode_external));¤
·· ··
¤ ¤
··static·bool·OrderSend(·const·MqlTradeRequest·&Request,·MqlTradeResult·&Result· ··static·bool·OrderSend(·const·MqlTradeRequest·&Request,·MqlTradeResult·&Result·
·· ··
····MqlTick·PrevTick·{0};¤ ····MqlTick·PrevTick·{0};¤
¤ ¤
····if·(!MT4ORDERS::IsTester)¤ ····if·(!MT4ORDERS::IsTester)¤
······::SymbolInfoTick(Request.symbol,·PrevTick);¤ ······::SymbolInfoTick(Request.symbol,·PrevTick);¤
¤ ¤
····const·long·PrevTimeCurrent·MT4ORDERS::IsTester·MT4ORDERS::GetTimeCurrent();¤ ····const·long·PrevTimeCurrent·MT4ORDERS::IsTester·MT4ORDERS::GetTimeCurrent();¤
····const·ulong·StartTime1·MT4ORDERS::IsTester·::GetMicrosecondCount();¤ ····const·ulong·StartTime1·MT4ORDERS::IsTester·::GetMicrosecondCount();¤
¤ ¤
····bool·Res·::OrderSend(Request,·Result);¤ ····bool·Res·::OrderSend(Request,·Result);¤
¤ ¤
····const·ulong·Interval1·MT4ORDERS::IsTester·(::GetMicrosecondCount()·StartTime1);¤ ····const·ulong·Interval1·MT4ORDERS::IsTester·(::GetMicrosecondCount()·StartTime1);¤
¤ ¤
····const·ulong·StartTime2·MT4ORDERS::IsTester·::GetMicrosecondCount();¤ ····const·ulong·StartTime2·MT4ORDERS::IsTester·::GetMicrosecondCount();¤
¤ ¤
····if·(Res·&&·!MT4ORDERS::IsTester·&&·(Result.retcode·TRADE_RETCODE_ERROR)·&&·(MT4ORDERS::OrderSend_MaxPause·0))¤ ····if·(Res·&&·!MT4ORDERS::IsTester·&&·(Result.retcode·TRADE_RETCODE_ERROR)·&&·(MT4ORDERS::OrderSend_MaxPause·0))¤
···· ····
······Res·(Result.retcode·==·TRADE_RETCODE_DONE);¤ ······Res·(Result.retcode·==·TRADE_RETCODE_DONE);¤
······MT4ORDERS::Waiting(true);¤ ······MT4ORDERS::Waiting(true);¤
¤ ¤
······//·TRADE_ACTION_CLOSE_BY·�����������·�·�������·��������¤ ······//·TRADE_ACTION_CLOSE_BY·�����������·�·�������·��������¤
······if·(Request.action·==·TRADE_ACTION_DEAL)¤ ······if·(Request.action·==·TRADE_ACTION_DEAL)¤
······ ······
········if·(!Result.deal)¤ ········if·(!Result.deal)¤
········ ········
··········WHILE(::OrderSelect(Result.order)·||·::HistoryOrderSelect(Result.order))¤ ··········WHILE(::OrderSelect(Result.order)·||·::HistoryOrderSelect(Result.order))¤
············ ············
¤ ¤
··········if·(!Res)¤ ··········if·(!Res)¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR(::OrderSelect(Result.order))·TOSTR(::HistoryOrderSelect(Result.order)));¤ ············::Print("Line·(string)__LINE__·"\n"·TOSTR(::OrderSelect(Result.order))·TOSTR(::HistoryOrderSelect(Result.order)));¤
··········else·if·(::OrderSelect(Result.order)·&&·!(Res·((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·==·ORDER_STATE_PLACED)·||¤ ··········else·if·(::OrderSelect(Result.order)·&&·!(Res·((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·==·ORDER_STATE_PLACED)·||¤
··························································((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·==·ORDER_STATE_PARTIAL)))¤ ··························································((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·==·ORDER_STATE_PARTIAL)))¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR(::OrderSelect(Result.order))·TOSTR2((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)));¤ ············::Print("Line·(string)__LINE__·"\n"·TOSTR(::OrderSelect(Result.order))·TOSTR2((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)));¤
········ ········
¤ ¤
········//·����·�����·����������·����������·����������·�����·��������·������·false.¤ ········//·����·�����·����������·����������·����������·�����·��������·������·false.¤
········if·(Res)¤ ········if·(Res)¤
········ ········
··········const·bool·ResultDeal·(!Result.deal)·&&·(!MT4ORDERS::OrderSendBug);¤ ··········const·bool·ResultDeal·(!Result.deal)·&&·(!MT4ORDERS::OrderSendBug);¤
¤ ¤
··········if·(MT4ORDERS::OrderSendBug·&&·(!Result.deal))¤ ··········if·(MT4ORDERS::OrderSendBug·&&·(!Result.deal))¤
············::Print("Line·(string)__LINE__·"\n"·"Before·::HistoryOrderSelect(Result.order):\n"·TOSTR(MT4ORDERS::OrderSendBug)·TOSTR(Result.deal));¤ ············::Print("Line·(string)__LINE__·"\n"·"Before·::HistoryOrderSelect(Result.order):\n"·TOSTR(MT4ORDERS::OrderSendBug)·TOSTR(Result.deal));¤
¤ ¤
··········WHILE(::HistoryOrderSelect(Result.order))¤ ··········WHILE(::HistoryOrderSelect(Result.order))¤
············ ············
¤ ¤
··········//·����·�����·��·����·OrderSend-����·�·���·Result.deal·==· ··········//·����·�����·��·����·OrderSend-����·�·���·Result.deal·==·
··········if·(ResultDeal)¤ ··········if·(ResultDeal)¤
············MT4ORDERS::OrderSendBug·0;¤ ············MT4ORDERS::OrderSendBug·0;¤
¤ ¤
··········if·(!Res)¤ ··········if·(!Res)¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR(::HistoryOrderSelect(Result.order))·TOSTR(::HistoryDealSelect(Result.deal))·TOSTR(::OrderSelect(Result.order)));¤ ············::Print("Line·(string)__LINE__·"\n"·TOSTR(::HistoryOrderSelect(Result.order))·TOSTR(::HistoryDealSelect(Result.deal))·TOSTR(::OrderSelect(Result.order)));¤
··········//·����·������������·�����·��·����������·(���������)·false¤ ··········//·����·������������·�����·��·����������·(���������)·false¤
··········else·if·(!(Res·((ENUM_ORDER_STATE)::HistoryOrderGetInteger(Result.order,·ORDER_STATE)·==·ORDER_STATE_FILLED)·||¤ ··········else·if·(!(Res·((ENUM_ORDER_STATE)::HistoryOrderGetInteger(Result.order,·ORDER_STATE)·==·ORDER_STATE_FILLED)·||¤
···························((ENUM_ORDER_STATE)::HistoryOrderGetInteger(Result.order,·ORDER_STATE)·==·ORDER_STATE_PARTIAL)))¤ ···························((ENUM_ORDER_STATE)::HistoryOrderGetInteger(Result.order,·ORDER_STATE)·==·ORDER_STATE_PARTIAL)))¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR2((ENUM_ORDER_STATE)::HistoryOrderGetInteger(Result.order,·ORDER_STATE)));¤ ············::Print("Line·(string)__LINE__·"\n"·TOSTR2((ENUM_ORDER_STATE)::HistoryOrderGetInteger(Result.order,·ORDER_STATE)));¤
········ ········
¤ ¤
········if·(Res)¤ ········if·(Res)¤
········ ········
··········const·bool·ResultDeal·(!Result.deal)·&&·(!MT4ORDERS::OrderSendBug);¤ ··········const·bool·ResultDeal·(!Result.deal)·&&·(!MT4ORDERS::OrderSendBug);¤
¤ ¤
··········if·(MT4ORDERS::OrderSendBug·&&·(!Result.deal))¤ ··········if·(MT4ORDERS::OrderSendBug·&&·(!Result.deal))¤
············::Print("Line·(string)__LINE__·"\n"·"Before·MT4ORDERS::HistoryDealSelect(Result):\n"·TOSTR(MT4ORDERS::OrderSendBug)·TOSTR(Result.deal));¤ ············::Print("Line·(string)__LINE__·"\n"·"Before·MT4ORDERS::HistoryDealSelect(Result):\n"·TOSTR(MT4ORDERS::OrderSendBug)·TOSTR(Result.deal));¤
¤ ¤
··········WHILE(MT4ORDERS::HistoryDealSelect2(Result))¤ ··········WHILE(MT4ORDERS::HistoryDealSelect2(Result))¤
············ ············
¤ ¤
··········//·����·�����·��·����·OrderSend-����·�·���·Result.deal·==· ··········//·����·�����·��·����·OrderSend-����·�·���·Result.deal·==·
··········if·(ResultDeal)¤ ··········if·(ResultDeal)¤
············MT4ORDERS::OrderSendBug·0;¤ ············MT4ORDERS::OrderSendBug·0;¤
¤ ¤
··········if·(!Res)¤ ··········if·(!Res)¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR(MT4ORDERS::HistoryDealSelect2(Result)));¤ ············::Print("Line·(string)__LINE__·"\n"·TOSTR(MT4ORDERS::HistoryDealSelect2(Result)));¤
········ ········
······ ······
······else·if·(Request.action·==·TRADE_ACTION_PENDING)¤ ······else·if·(Request.action·==·TRADE_ACTION_PENDING)¤
······ ······
········if·(Res)¤ ········if·(Res)¤
········ ········
··········WHILE(::OrderSelect(Result.order))¤ ··········WHILE(::OrderSelect(Result.order))¤
············ ············
¤ ¤
··········if·(!Res)¤ ··········if·(!Res)¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR(::OrderSelect(Result.order)));¤ ············::Print("Line·(string)__LINE__·"\n"·TOSTR(::OrderSelect(Result.order)));¤
··········else·if·(!(Res·((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·==·ORDER_STATE_PLACED)·||¤ ··········else·if·(!(Res·((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·==·ORDER_STATE_PLACED)·||¤
···························((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·==·ORDER_STATE_PARTIAL)))¤ ···························((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·==·ORDER_STATE_PARTIAL)))¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR2((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)));¤ ············::Print("Line·(string)__LINE__·"\n"·TOSTR2((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)));¤
········ ········
········else¤ ········else¤
········ ········
··········WHILE(::HistoryOrderSelect(Result.order))¤ ··········WHILE(::HistoryOrderSelect(Result.order))¤
············ ············
¤ ¤
··········::Print("Line·(string)__LINE__·"\n"·TOSTR(::HistoryOrderSelect(Result.order)));¤ ··········::Print("Line·(string)__LINE__·"\n"·TOSTR(::HistoryOrderSelect(Result.order)));¤
¤ ¤
··········Res·false;¤ ··········Res·false;¤
········ ········
······ ······
······else·if·(Request.action·==·TRADE_ACTION_SLTP)¤ ······else·if·(Request.action·==·TRADE_ACTION_SLTP)¤
······ ······
········if·(Res)¤ ········if·(Res)¤
········ ········
··········const·int·digits·(int)::SymbolInfoInteger(Request.symbol,·SYMBOL_DIGITS);¤ ··········const·int·digits·(int)::SymbolInfoInteger(Request.symbol,·SYMBOL_DIGITS);¤
¤ ¤
··········bool·EqualSL·false;¤ ··········bool·EqualSL·false;¤
··········bool·EqualTP·false;¤ ··········bool·EqualTP·false;¤
¤ ¤
··········do¤ ··········do¤
············if·(Request.position·::PositionSelectByTicket(Request.position)·::PositionSelect(Request.symbol))¤ ············if·(Request.position·::PositionSelectByTicket(Request.position)·::PositionSelect(Request.symbol))¤
············ ············
··············EqualSL·MT4ORDERS::EqualPrices(::PositionGetDouble(POSITION_SL),·Request.sl,·digits);¤ ··············EqualSL·MT4ORDERS::EqualPrices(::PositionGetDouble(POSITION_SL),·Request.sl,·digits);¤
··············EqualTP·MT4ORDERS::EqualPrices(::PositionGetDouble(POSITION_TP),·Request.tp,·digits);¤ ··············EqualTP·MT4ORDERS::EqualPrices(::PositionGetDouble(POSITION_TP),·Request.tp,·digits);¤
············ ············
··········WHILE(EqualSL·&&·EqualTP);¤ ··········WHILE(EqualSL·&&·EqualTP);¤
¤ ¤
··········if·(!Res)¤ ··········if·(!Res)¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR(::PositionGetDouble(POSITION_SL))·TOSTR(::PositionGetDouble(POSITION_TP))· ············::Print("Line·(string)__LINE__·"\n"·TOSTR(::PositionGetDouble(POSITION_SL))·TOSTR(::PositionGetDouble(POSITION_TP))·
····················TOSTR(EqualSL)·TOSTR(EqualTP)· ····················TOSTR(EqualSL)·TOSTR(EqualTP)·
····················TOSTR(Request.position·::PositionSelectByTicket(Request.position)·::PositionSelect(Request.symbol)));¤ ····················TOSTR(Request.position·::PositionSelectByTicket(Request.position)·::PositionSelect(Request.symbol)));¤
········ ········
······ ······
······else·if·(Request.action·==·TRADE_ACTION_MODIFY)¤ ······else·if·(Request.action·==·TRADE_ACTION_MODIFY)¤
······ ······
········if·(Res)¤ ········if·(Res)¤
········ ········
··········const·int·digits·(int)::SymbolInfoInteger(Request.symbol,·SYMBOL_DIGITS);¤ ··········const·int·digits·(int)::SymbolInfoInteger(Request.symbol,·SYMBOL_DIGITS);¤
¤ ¤
··········bool·EqualSL·false;¤ ··········bool·EqualSL·false;¤
··········bool·EqualTP·false;¤ ··········bool·EqualTP·false;¤
··········bool·EqualPrice·false;¤ ··········bool·EqualPrice·false;¤
¤ ¤
··········do¤ ··········do¤
············if·(::OrderSelect(Result.order)·&&·((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·!=·ORDER_STATE_REQUEST_MODIFY))¤ ············if·(::OrderSelect(Result.order)·&&·((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)·!=·ORDER_STATE_REQUEST_MODIFY))¤
············ ············
··············EqualSL·MT4ORDERS::EqualPrices(::OrderGetDouble(ORDER_SL),·Request.sl,·digits);¤ ··············EqualSL·MT4ORDERS::EqualPrices(::OrderGetDouble(ORDER_SL),·Request.sl,·digits);¤
··············EqualTP·MT4ORDERS::EqualPrices(::OrderGetDouble(ORDER_TP),·Request.tp,·digits);¤ ··············EqualTP·MT4ORDERS::EqualPrices(::OrderGetDouble(ORDER_TP),·Request.tp,·digits);¤
··············EqualPrice·MT4ORDERS::EqualPrices(::OrderGetDouble(ORDER_PRICE_OPEN),·Request.price,·digits);¤ ··············EqualPrice·MT4ORDERS::EqualPrices(::OrderGetDouble(ORDER_PRICE_OPEN),·Request.price,·digits);¤
············ ············
··········WHILE((EqualSL·&&·EqualTP·&&·EqualPrice));¤ ··········WHILE((EqualSL·&&·EqualTP·&&·EqualPrice));¤
¤ ¤
··········if·(!Res)¤ ··········if·(!Res)¤
············::Print("Line·(string)__LINE__·"\n"·TOSTR(::OrderGetDouble(ORDER_SL))·TOSTR(Request.sl)+¤ ············::Print("Line·(string)__LINE__·"\n"·TOSTR(::OrderGetDouble(ORDER_SL))·TOSTR(Request.sl)+¤
····················TOSTR(::OrderGetDouble(ORDER_TP))·TOSTR(Request.tp)· ····················TOSTR(::OrderGetDouble(ORDER_TP))·TOSTR(Request.tp)·
····················TOSTR(::OrderGetDouble(ORDER_PRICE_OPEN))·TOSTR(Request.price)· ····················TOSTR(::OrderGetDouble(ORDER_PRICE_OPEN))·TOSTR(Request.price)·
····················TOSTR(EqualSL)·TOSTR(EqualTP)·TOSTR(EqualPrice)· ····················TOSTR(EqualSL)·TOSTR(EqualTP)·TOSTR(EqualPrice)·
····················TOSTR(::OrderSelect(Result.order))· ····················TOSTR(::OrderSelect(Result.order))·
····················TOSTR2((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)));¤ ····················TOSTR2((ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE)));¤
········ ········
······ ······
······else·if·(Request.action·==·TRADE_ACTION_REMOVE)¤ ······else·if·(Request.action·==·TRADE_ACTION_REMOVE)¤
······ ······
········if·(Res)¤ ········if·(Res)¤
··········WHILE(::HistoryOrderSelect(Result.order))¤ ··········WHILE(::HistoryOrderSelect(Result.order))¤
············ ············
¤ ¤
········if·(!Res)¤ ········if·(!Res)¤
··········::Print("Line·(string)__LINE__·"\n"·TOSTR(::HistoryOrderSelect(Result.order)));¤ ··········::Print("Line·(string)__LINE__·"\n"·TOSTR(::HistoryOrderSelect(Result.order)));¤
······ ······
¤ ¤
······const·ulong·Interval2·::GetMicrosecondCount()·StartTime2;¤ ······const·ulong·Interval2·::GetMicrosecondCount()·StartTime2;¤
¤ ¤
······Result.comment·+=·::DoubleToString(Interval1·1000.0,·3)· ······Result.comment·+=·::DoubleToString(Interval1·1000.0,·3)·
······························::DoubleToString(Interval2·1000.0,·3)·("·(string)MT4ORDERS::OrderSendBug·")·ms.";¤ ······························::DoubleToString(Interval2·1000.0,·3)·("·(string)MT4ORDERS::OrderSendBug·")·ms.";¤
¤ ¤
······if·(!Res·||·MT4ORDERS::OrderSendBug)¤ ······if·(!Res·||·MT4ORDERS::OrderSendBug)¤
······ ······
········::Alert(Res·"OrderSend("·(string)Result.order·")·BUG!"·"MT4ORDERS·not·Sync·with·History!");¤ ········::Alert(Res·"OrderSend("·(string)Result.order·")·BUG!"·"MT4ORDERS·not·Sync·with·History!");¤
········MT4ORDERS::AlertLog();¤ ········MT4ORDERS::AlertLog();¤
¤ ¤
········::Print(TOSTR(__FILE__)·"Version·(string)__MT4ORDERS__·"\n"·TOSTR(__MQLBUILD__)·TOSTR(__DATE__)· ········::Print(TOSTR(__FILE__)·"Version·(string)__MT4ORDERS__·"\n"·TOSTR(__MQLBUILD__)·TOSTR(__DATE__)·
················TOSTR(::AccountInfoString(ACCOUNT_SERVER))·TOSTR2((ENUM_ACCOUNT_TRADE_MODE)::AccountInfoInteger(ACCOUNT_TRADE_MODE))· ················TOSTR(::AccountInfoString(ACCOUNT_SERVER))·TOSTR2((ENUM_ACCOUNT_TRADE_MODE)::AccountInfoInteger(ACCOUNT_TRADE_MODE))·
················TOSTR((bool)::TerminalInfoInteger(TERMINAL_CONNECTED))· ················TOSTR((bool)::TerminalInfoInteger(TERMINAL_CONNECTED))·
················TOSTR(::TerminalInfoInteger(TERMINAL_PING_LAST))·TOSTR(::TerminalInfoDouble(TERMINAL_RETRANSMISSION))· ················TOSTR(::TerminalInfoInteger(TERMINAL_PING_LAST))·TOSTR(::TerminalInfoDouble(TERMINAL_RETRANSMISSION))·
················TOSTR(::TerminalInfoInteger(TERMINAL_BUILD))·TOSTR((bool)::TerminalInfoInteger(TERMINAL_X64))· ················TOSTR(::TerminalInfoInteger(TERMINAL_BUILD))·TOSTR((bool)::TerminalInfoInteger(TERMINAL_X64))·
················TOSTR((bool)::TerminalInfoInteger(TERMINAL_VPS))·TOSTR2((ENUM_PROGRAM_TYPE)::MQLInfoInteger(MQL_PROGRAM_TYPE))· ················TOSTR((bool)::TerminalInfoInteger(TERMINAL_VPS))·TOSTR2((ENUM_PROGRAM_TYPE)::MQLInfoInteger(MQL_PROGRAM_TYPE))·
················TOSTR(::TimeCurrent())·TOSTR(::TimeTradeServer())· ················TOSTR(::TimeCurrent())·TOSTR(::TimeTradeServer())·
················TOSTR(MT4ORDERS::TimeToString(MT4ORDERS::GetTimeCurrent()))·TOSTR(MT4ORDERS::TimeToString(PrevTimeCurrent))· ················TOSTR(MT4ORDERS::TimeToString(MT4ORDERS::GetTimeCurrent()))·TOSTR(MT4ORDERS::TimeToString(PrevTimeCurrent))·
················"PrevTick·="·MT4ORDERS::TickToString(Request.symbol,·PrevTick)·"\n"· ················"PrevTick·="·MT4ORDERS::TickToString(Request.symbol,·PrevTick)·"\n"·
················"CurrentTick·="·MT4ORDERS::TickToString(Request.symbol)·"\n"· ················"CurrentTick·="·MT4ORDERS::TickToString(Request.symbol)·"\n"·
················TOSTR(::SymbolInfoString(Request.symbol,·SYMBOL_PATH))·TOSTR(::SymbolInfoString(Request.symbol,·SYMBOL_DESCRIPTION))· ················TOSTR(::SymbolInfoString(Request.symbol,·SYMBOL_PATH))·TOSTR(::SymbolInfoString(Request.symbol,·SYMBOL_DESCRIPTION))·
················TOSTR(::PositionsTotal())·TOSTR(::OrdersTotal())· ················TOSTR(::PositionsTotal())·TOSTR(::OrdersTotal())·
················TOSTR(::HistorySelect(0,·INT_MAX))·TOSTR(::HistoryDealsTotal())·TOSTR(::HistoryOrdersTotal())· ················TOSTR(::HistorySelect(0,·INT_MAX))·TOSTR(::HistoryDealsTotal())·TOSTR(::HistoryOrdersTotal())·
················(::HistoryDealsTotal()·TOSTR(::HistoryDealGetTicket(::HistoryDealsTotal()·1))· ················(::HistoryDealsTotal()·TOSTR(::HistoryDealGetTicket(::HistoryDealsTotal()·1))·
···················"DEAL_TIME_MSC·MT4ORDERS::TimeToString(::HistoryDealGetInteger(::HistoryDealGetTicket(::HistoryDealsTotal()·1),·DEAL_TIME_MSC))·"\n"¤ ···················"DEAL_TIME_MSC·MT4ORDERS::TimeToString(::HistoryDealGetInteger(::HistoryDealGetTicket(::HistoryDealsTotal()·1),·DEAL_TIME_MSC))·"\n"¤
·······································NULL)· ·······································NULL)·
················(::HistoryOrdersTotal()·TOSTR(::HistoryOrderGetTicket(::HistoryOrdersTotal()·1))· ················(::HistoryOrdersTotal()·TOSTR(::HistoryOrderGetTicket(::HistoryOrdersTotal()·1))·
···················"ORDER_TIME_DONE_MSC·MT4ORDERS::TimeToString(::HistoryOrderGetInteger(::HistoryOrderGetTicket(::HistoryOrdersTotal()·1),·ORDER_TIME_DONE_MSC))·"\n"¤ ···················"ORDER_TIME_DONE_MSC·MT4ORDERS::TimeToString(::HistoryOrderGetInteger(::HistoryOrderGetTicket(::HistoryOrdersTotal()·1),·ORDER_TIME_DONE_MSC))·"\n"¤
········································NULL)· ········································NULL)·
················TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE))·TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_PHYSICAL))· ················TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE))·TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_PHYSICAL))·
················TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_TOTAL))·TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_USED))· ················TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_TOTAL))·TOSTR(::TerminalInfoInteger(TERMINAL_MEMORY_USED))·
················TOSTR(::MQLInfoInteger(MQL_MEMORY_LIMIT))·TOSTR(::MQLInfoInteger(MQL_MEMORY_USED))· ················TOSTR(::MQLInfoInteger(MQL_MEMORY_LIMIT))·TOSTR(::MQLInfoInteger(MQL_MEMORY_USED))·
················TOSTR(MT4ORDERS::IsHedging)·TOSTR(Res)·TOSTR(MT4ORDERS::OrderSendBug)· ················TOSTR(MT4ORDERS::IsHedging)·TOSTR(Res)·TOSTR(MT4ORDERS::OrderSendBug)·
················MT4ORDERS::ToString(Request)·MT4ORDERS::ToString(Result));¤ ················MT4ORDERS::ToString(Request)·MT4ORDERS::ToString(Result));¤
······ ······
······else¤ ······else¤
········MT4ORDERS::OrderSend_Benchmark(Interval1,·Interval2);¤ ········MT4ORDERS::OrderSend_Benchmark(Interval1,·Interval2);¤
···· ····
····else·if·(!MT4ORDERS::IsTester)¤ ····else·if·(!MT4ORDERS::IsTester)¤
···· ····
······Result.comment·+=·::DoubleToString(Interval1·1000.0,·3)·ms";¤ ······Result.comment·+=·::DoubleToString(Interval1·1000.0,·3)·ms";¤
¤ ¤
······::Print(TOSTR(::TimeCurrent())·TOSTR(::TimeTradeServer())·TOSTR(PrevTimeCurrent)· ······::Print(TOSTR(::TimeCurrent())·TOSTR(::TimeTradeServer())·TOSTR(PrevTimeCurrent)·
··············MT4ORDERS::TickToString(Request.symbol,·PrevTick)·"\n"·MT4ORDERS::TickToString(Request.symbol)·"\n"· ··············MT4ORDERS::TickToString(Request.symbol,·PrevTick)·"\n"·MT4ORDERS::TickToString(Request.symbol)·"\n"·
··············MT4ORDERS::ToString(Request)·MT4ORDERS::ToString(Result));¤ ··············MT4ORDERS::ToString(Request)·MT4ORDERS::ToString(Result));¤
¤ ¤
//······ExpertRemove();¤ //······ExpertRemove();¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
#undef·TOSTR2¤ #undef·TOSTR2¤
#undef·TOSTR¤ #undef·TOSTR¤
#undef·WHILE¤ #undef·WHILE¤
¤ ¤
··static·ENUM_DAY_OF_WEEK·GetDayOfWeek(·const·datetime·&time· ··static·ENUM_DAY_OF_WEEK·GetDayOfWeek(·const·datetime·&time·
·· ··
····MqlDateTime·sTime·{0};¤ ····MqlDateTime·sTime·{0};¤
¤ ¤
····::TimeToStruct(time,·sTime);¤ ····::TimeToStruct(time,·sTime);¤
¤ ¤
····return((ENUM_DAY_OF_WEEK)sTime.day_of_week);¤ ····return((ENUM_DAY_OF_WEEK)sTime.day_of_week);¤
·· ··
¤ ¤
··static·bool·SessionTrade(·const·string·&Symb· ··static·bool·SessionTrade(·const·string·&Symb·
·· ··
····datetime·TimeNow·::TimeCurrent();¤ ····datetime·TimeNow·::TimeCurrent();¤
¤ ¤
····const·ENUM_DAY_OF_WEEK·DayOfWeek·MT4ORDERS::GetDayOfWeek(TimeNow);¤ ····const·ENUM_DAY_OF_WEEK·DayOfWeek·MT4ORDERS::GetDayOfWeek(TimeNow);¤
¤ ¤
····TimeNow·%=·24·60·60;¤ ····TimeNow·%=·24·60·60;¤
¤ ¤
····bool·Res·false;¤ ····bool·Res·false;¤
····datetime·From,·To;¤ ····datetime·From,·To;¤
¤ ¤
····for·(int·0;·(!Res)·&&·::SymbolInfoSessionTrade(Symb,·DayOfWeek,·i,·From,·To);·i++)¤ ····for·(int·0;·(!Res)·&&·::SymbolInfoSessionTrade(Symb,·DayOfWeek,·i,·From,·To);·i++)¤
······Res·((From·<=·TimeNow)·&&·(TimeNow·To));¤ ······Res·((From·<=·TimeNow)·&&·(TimeNow·To));¤
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·bool·SymbolTrade(·const·string·&Symb· ··static·bool·SymbolTrade(·const·string·&Symb·
·· ··
····MqlTick·Tick;¤ ····MqlTick·Tick;¤
¤ ¤
····return(::SymbolInfoTick(Symb,·Tick)·(Tick.bid·&&·Tick.ask·&&·MT4ORDERS::SessionTrade(Symb)·/*·&&¤ ····return(::SymbolInfoTick(Symb,·Tick)·(Tick.bid·&&·Tick.ask·&&·MT4ORDERS::SessionTrade(Symb)·/*·&&¤
···········((ENUM_SYMBOL_TRADE_MODE)::SymbolInfoInteger(Symb,·SYMBOL_TRADE_MODE)·==·SYMBOL_TRADE_MODE_FULL)·*/)·false);¤ ···········((ENUM_SYMBOL_TRADE_MODE)::SymbolInfoInteger(Symb,·SYMBOL_TRADE_MODE)·==·SYMBOL_TRADE_MODE_FULL)·*/)·false);¤
·· ··
¤ ¤
··static·bool·CorrectResult(·void· ··static·bool·CorrectResult(·void·
·· ··
····::ZeroMemory(MT4ORDERS::LastTradeResult);¤ ····::ZeroMemory(MT4ORDERS::LastTradeResult);¤
¤ ¤
····MT4ORDERS::LastTradeResult.retcode·MT4ORDERS::LastTradeCheckResult.retcode;¤ ····MT4ORDERS::LastTradeResult.retcode·MT4ORDERS::LastTradeCheckResult.retcode;¤
····MT4ORDERS::LastTradeResult.comment·MT4ORDERS::LastTradeCheckResult.comment;¤ ····MT4ORDERS::LastTradeResult.comment·MT4ORDERS::LastTradeCheckResult.comment;¤
¤ ¤
····return(false);¤ ····return(false);¤
·· ··
¤ ¤
··static·bool·NewOrderCheck(·void· ··static·bool·NewOrderCheck(·void·
·· ··
····return((::OrderCheck(MT4ORDERS::LastTradeRequest,·MT4ORDERS::LastTradeCheckResult)·&&¤ ····return((::OrderCheck(MT4ORDERS::LastTradeRequest,·MT4ORDERS::LastTradeCheckResult)·&&¤
···········(MT4ORDERS::IsTester·||·MT4ORDERS::SymbolTrade(MT4ORDERS::LastTradeRequest.symbol)))·||¤ ···········(MT4ORDERS::IsTester·||·MT4ORDERS::SymbolTrade(MT4ORDERS::LastTradeRequest.symbol)))·||¤
···········(!MT4ORDERS::IsTester·&&·MT4ORDERS::CorrectResult()));¤ ···········(!MT4ORDERS::IsTester·&&·MT4ORDERS::CorrectResult()));¤
·· ··
¤ ¤
··static·bool·NewOrderSend(·const·int·&Check· ··static·bool·NewOrderSend(·const·int·&Check·
·· ··
····return((Check·==·INT_MAX)·MT4ORDERS::NewOrderCheck()· ····return((Check·==·INT_MAX)·MT4ORDERS::NewOrderCheck()·
···········(((Check·!=·INT_MIN)·||·MT4ORDERS::NewOrderCheck())·&&·MT4ORDERS::OrderSend(MT4ORDERS::LastTradeRequest,·MT4ORDERS::LastTradeResult)·MT4ORDERS::LastTradeResult.retcode·TRADE_RETCODE_ERROR·false));¤ ···········(((Check·!=·INT_MIN)·||·MT4ORDERS::NewOrderCheck())·&&·MT4ORDERS::OrderSend(MT4ORDERS::LastTradeRequest,·MT4ORDERS::LastTradeResult)·MT4ORDERS::LastTradeResult.retcode·TRADE_RETCODE_ERROR·false));¤
·· ··
¤ ¤
··static·bool·ModifyPosition(·const·long·&Ticket,·MqlTradeRequest·&Request· ··static·bool·ModifyPosition(·const·long·&Ticket,·MqlTradeRequest·&Request·
·· ··
····const·bool·Res·::PositionSelectByTicket(Ticket);¤ ····const·bool·Res·::PositionSelectByTicket(Ticket);¤
¤ ¤
····if·(Res)¤ ····if·(Res)¤
···· ····
······Request.action·TRADE_ACTION_SLTP;¤ ······Request.action·TRADE_ACTION_SLTP;¤
¤ ¤
······Request.position·Ticket;¤ ······Request.position·Ticket;¤
······Request.symbol·::PositionGetString(POSITION_SYMBOL);·//·��������·������·������·��·����������!¤ ······Request.symbol·::PositionGetString(POSITION_SYMBOL);·//·��������·������·������·��·����������!¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·ENUM_ORDER_TYPE_FILLING·GetFilling(·const·string·&Symb,·const·uint·Type·ORDER_FILLING_FOK· ··static·ENUM_ORDER_TYPE_FILLING·GetFilling(·const·string·&Symb,·const·uint·Type·ORDER_FILLING_FOK·
·· ··
····static·ENUM_ORDER_TYPE_FILLING·Res·ORDER_FILLING_FOK;¤ ····static·ENUM_ORDER_TYPE_FILLING·Res·ORDER_FILLING_FOK;¤
····static·string·LastSymb·NULL;¤ ····static·string·LastSymb·NULL;¤
····static·uint·LastType·ORDER_FILLING_FOK;¤ ····static·uint·LastType·ORDER_FILLING_FOK;¤
¤ ¤
····const·bool·SymbFlag·(LastSymb·!=·Symb);¤ ····const·bool·SymbFlag·(LastSymb·!=·Symb);¤
¤ ¤
····if·(SymbFlag·||·(LastType·!=·Type))·//·�����·�������·��������,·�������·�����������·��������·�������.¤ ····if·(SymbFlag·||·(LastType·!=·Type))·//·�����·�������·��������,·�������·�����������·��������·�������.¤
···· ····
······LastType·Type;¤ ······LastType·Type;¤
¤ ¤
······if·(SymbFlag)¤ ······if·(SymbFlag)¤
········LastSymb·Symb;¤ ········LastSymb·Symb;¤
¤ ¤
······const·ENUM_SYMBOL_TRADE_EXECUTION·ExeMode·(ENUM_SYMBOL_TRADE_EXECUTION)::SymbolInfoInteger(Symb,·SYMBOL_TRADE_EXEMODE);¤ ······const·ENUM_SYMBOL_TRADE_EXECUTION·ExeMode·(ENUM_SYMBOL_TRADE_EXECUTION)::SymbolInfoInteger(Symb,·SYMBOL_TRADE_EXEMODE);¤
······const·int·FillingMode·(int)::SymbolInfoInteger(Symb,·SYMBOL_FILLING_MODE);¤ ······const·int·FillingMode·(int)::SymbolInfoInteger(Symb,·SYMBOL_FILLING_MODE);¤
¤ ¤
······Res·(!FillingMode·||·(Type·>=·ORDER_FILLING_RETURN)·||·((FillingMode·(Type·1))·!=·Type·1))· ······Res·(!FillingMode·||·(Type·>=·ORDER_FILLING_RETURN)·||·((FillingMode·(Type·1))·!=·Type·1))·
············(((ExeMode·==·SYMBOL_TRADE_EXECUTION_EXCHANGE)·||·(ExeMode·==·SYMBOL_TRADE_EXECUTION_INSTANT))· ············(((ExeMode·==·SYMBOL_TRADE_EXECUTION_EXCHANGE)·||·(ExeMode·==·SYMBOL_TRADE_EXECUTION_INSTANT))·
·············ORDER_FILLING_RETURN·((FillingMode·==·SYMBOL_FILLING_IOC)·ORDER_FILLING_IOC·ORDER_FILLING_FOK))· ·············ORDER_FILLING_RETURN·((FillingMode·==·SYMBOL_FILLING_IOC)·ORDER_FILLING_IOC·ORDER_FILLING_FOK))·
············(ENUM_ORDER_TYPE_FILLING)Type;¤ ············(ENUM_ORDER_TYPE_FILLING)Type;¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·ENUM_ORDER_TYPE_TIME·GetExpirationType(·const·string·&Symb,·uint·Expiration·ORDER_TIME_GTC· ··static·ENUM_ORDER_TYPE_TIME·GetExpirationType(·const·string·&Symb,·uint·Expiration·ORDER_TIME_GTC·
·· ··
····static·ENUM_ORDER_TYPE_TIME·Res·ORDER_TIME_GTC;¤ ····static·ENUM_ORDER_TYPE_TIME·Res·ORDER_TIME_GTC;¤
····static·string·LastSymb·NULL;¤ ····static·string·LastSymb·NULL;¤
····static·uint·LastExpiration·ORDER_TIME_GTC;¤ ····static·uint·LastExpiration·ORDER_TIME_GTC;¤
¤ ¤
····const·bool·SymbFlag·(LastSymb·!=·Symb);¤ ····const·bool·SymbFlag·(LastSymb·!=·Symb);¤
¤ ¤
····if·((LastExpiration·!=·Expiration)·||·SymbFlag)¤ ····if·((LastExpiration·!=·Expiration)·||·SymbFlag)¤
···· ····
······LastExpiration·Expiration;¤ ······LastExpiration·Expiration;¤
¤ ¤
······if·(SymbFlag)¤ ······if·(SymbFlag)¤
········LastSymb·Symb;¤ ········LastSymb·Symb;¤
¤ ¤
······const·int·ExpirationMode·(int)::SymbolInfoInteger(Symb,·SYMBOL_EXPIRATION_MODE);¤ ······const·int·ExpirationMode·(int)::SymbolInfoInteger(Symb,·SYMBOL_EXPIRATION_MODE);¤
¤ ¤
······if·((Expiration·ORDER_TIME_SPECIFIED_DAY)·||·(!((ExpirationMode·>>·Expiration)·1)))¤ ······if·((Expiration·ORDER_TIME_SPECIFIED_DAY)·||·(!((ExpirationMode·>>·Expiration)·1)))¤
······ ······
········if·((Expiration·ORDER_TIME_SPECIFIED)·||·(ExpirationMode·SYMBOL_EXPIRATION_SPECIFIED))¤ ········if·((Expiration·ORDER_TIME_SPECIFIED)·||·(ExpirationMode·SYMBOL_EXPIRATION_SPECIFIED))¤
··········Expiration·ORDER_TIME_GTC;¤ ··········Expiration·ORDER_TIME_GTC;¤
········else·if·(Expiration·ORDER_TIME_DAY)¤ ········else·if·(Expiration·ORDER_TIME_DAY)¤
··········Expiration·ORDER_TIME_SPECIFIED;¤ ··········Expiration·ORDER_TIME_SPECIFIED;¤
¤ ¤
········uint·<<·Expiration;¤ ········uint·<<·Expiration;¤
¤ ¤
········while·((Expiration·<=·ORDER_TIME_SPECIFIED_DAY)·&&·((ExpirationMode·i)·!=·i))¤ ········while·((Expiration·<=·ORDER_TIME_SPECIFIED_DAY)·&&·((ExpirationMode·i)·!=·i))¤
········ ········
··········<<=·1;¤ ··········<<=·1;¤
··········Expiration++;¤ ··········Expiration++;¤
········ ········
······ ······
¤ ¤
······Res·(ENUM_ORDER_TYPE_TIME)Expiration;¤ ······Res·(ENUM_ORDER_TYPE_TIME)Expiration;¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·bool·ModifyOrder(·const·long·&Ticket,·const·double·&Price,·const·datetime·&Expiration,·MqlTradeRequest·&Request· ··static·bool·ModifyOrder(·const·long·&Ticket,·const·double·&Price,·const·datetime·&Expiration,·MqlTradeRequest·&Request·
·· ··
····const·bool·Res·::OrderSelect(Ticket);¤ ····const·bool·Res·::OrderSelect(Ticket);¤
¤ ¤
····if·(Res)¤ ····if·(Res)¤
···· ····
······Request.action·TRADE_ACTION_MODIFY;¤ ······Request.action·TRADE_ACTION_MODIFY;¤
······Request.order·Ticket;¤ ······Request.order·Ticket;¤
¤ ¤
······Request.price·Price;¤ ······Request.price·Price;¤
¤ ¤
······Request.symbol·::OrderGetString(ORDER_SYMBOL);¤ ······Request.symbol·::OrderGetString(ORDER_SYMBOL);¤
¤ ¤
······//·https://www.mql5.com/ru/forum/1111/page1817#comment_4087275¤ ······//·https://www.mql5.com/ru/forum/1111/page1817#comment_4087275¤
//······Request.type_filling·(ENUM_ORDER_TYPE_FILLING)::OrderGetInteger(ORDER_TYPE_FILLING);¤ //······Request.type_filling·(ENUM_ORDER_TYPE_FILLING)::OrderGetInteger(ORDER_TYPE_FILLING);¤
······Request.type_filling·MT4ORDERS::GetFilling(Request.symbol);¤ ······Request.type_filling·MT4ORDERS::GetFilling(Request.symbol);¤
······Request.type_time·MT4ORDERS::GetExpirationType(Request.symbol,·(uint)Expiration);¤ ······Request.type_time·MT4ORDERS::GetExpirationType(Request.symbol,·(uint)Expiration);¤
¤ ¤
······if·(Expiration·ORDER_TIME_DAY)¤ ······if·(Expiration·ORDER_TIME_DAY)¤
········Request.expiration·Expiration;¤ ········Request.expiration·Expiration;¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·bool·SelectByPosHistory(·const·int·Index· ··static·bool·SelectByPosHistory(·const·int·Index·
·· ··
····const·long·Ticket·MT4ORDERS::History[Index];¤ ····const·long·Ticket·MT4ORDERS::History[Index];¤
····const·bool·Res·(Ticket·0)·::HistoryDealSelect(Ticket)·((Ticket·0)·::HistoryOrderSelect(-Ticket)·false);¤ ····const·bool·Res·(Ticket·0)·::HistoryDealSelect(Ticket)·((Ticket·0)·::HistoryOrderSelect(-Ticket)·false);¤
¤ ¤
····if·(Res)¤ ····if·(Res)¤
···· ····
······if·(Ticket·0)¤ ······if·(Ticket·0)¤
········MT4ORDERS::GetHistoryPositionData(Ticket);¤ ········MT4ORDERS::GetHistoryPositionData(Ticket);¤
······else¤ ······else¤
········MT4ORDERS::GetHistoryOrderData(-Ticket);¤ ········MT4ORDERS::GetHistoryOrderData(-Ticket);¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··//·https://www.mql5.com/ru/forum/227960#comment_6603506¤ ··//·https://www.mql5.com/ru/forum/227960#comment_6603506¤
··static·bool·OrderVisible(·void· ··static·bool·OrderVisible(·void·
·· ··
/*····const·ENUM_ORDER_STATE·OrderState·(ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE);¤ /*····const·ENUM_ORDER_STATE·OrderState·(ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE);¤
¤ ¤
····return((OrderState·==·ORDER_STATE_PLACED)·||·(OrderState·==·ORDER_STATE_PARTIAL));¤ ····return((OrderState·==·ORDER_STATE_PLACED)·||·(OrderState·==·ORDER_STATE_PARTIAL));¤
*/¤ */¤
····bool·Res·!::OrderGetInteger(ORDER_POSITION_ID);¤ ····bool·Res·!::OrderGetInteger(ORDER_POSITION_ID);¤
¤ ¤
····if·(Res)¤ ····if·(Res)¤
···· ····
······const·long·Ticket·::PositionGetInteger(POSITION_TICKET);¤ ······const·long·Ticket·::PositionGetInteger(POSITION_TICKET);¤
¤ ¤
······if·(::PositionSelectByTicket(::OrderGetInteger(ORDER_TICKET)))·//·�����·�·���·�������·�����·����·������������·������·�������·�������·������·��·Hedge-������¤ ······if·(::PositionSelectByTicket(::OrderGetInteger(ORDER_TICKET)))·//·�����·�·���·�������·�����·����·������������·������·�������·�������·������·��·Hedge-������¤
······ ······
········if·(Ticket·&&·(::PositionGetInteger(POSITION_TICKET)·!=·Ticket))¤ ········if·(Ticket·&&·(::PositionGetInteger(POSITION_TICKET)·!=·Ticket))¤
··········::PositionSelectByTicket(Ticket);¤ ··········::PositionSelectByTicket(Ticket);¤
¤ ¤
········Res·false;¤ ········Res·false;¤
······ ······
···· ····
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·ulong·OrderGetTicket(·const·int·Index· ··static·ulong·OrderGetTicket(·const·int·Index·
·· ··
····ulong·Res;¤ ····ulong·Res;¤
····int·PrevTotal;¤ ····int·PrevTotal;¤
····const·long·PrevTicket·::OrderGetInteger(ORDER_TICKET);¤ ····const·long·PrevTicket·::OrderGetInteger(ORDER_TICKET);¤
¤ ¤
····do¤ ····do¤
···· ····
······Res·0;¤ ······Res·0;¤
······PrevTotal·::OrdersTotal();¤ ······PrevTotal·::OrdersTotal();¤
¤ ¤
······if·((Index·>=·0)·&&·(Index·PrevTotal))¤ ······if·((Index·>=·0)·&&·(Index·PrevTotal))¤
······ ······
········int·Count·0;¤ ········int·Count·0;¤
¤ ¤
········for·(int·0;·PrevTotal;·i++)¤ ········for·(int·0;·PrevTotal;·i++)¤
········ ········
··········const·int·Total·::OrdersTotal();¤ ··········const·int·Total·::OrdersTotal();¤
¤ ¤
··········//·��·�����·��������·�����·����������·����������·�������¤ ··········//·��·�����·��������·�����·����������·����������·�������¤
··········if·(Total·!=·PrevTotal)¤ ··········if·(Total·!=·PrevTotal)¤
·········· ··········
············PrevTotal·Total;¤ ············PrevTotal·Total;¤
¤ ¤
············Count·0;¤ ············Count·0;¤
············-1;¤ ············-1;¤
·········· ··········
··········else¤ ··········else¤
·········· ··········
············const·ulong·Ticket·::OrderGetTicket(i);¤ ············const·ulong·Ticket·::OrderGetTicket(i);¤
¤ ¤
············if·(Ticket·&&·MT4ORDERS::OrderVisible())¤ ············if·(Ticket·&&·MT4ORDERS::OrderVisible())¤
············ ············
··············if·(Count·==·Index)¤ ··············if·(Count·==·Index)¤
·············· ··············
················Res·Ticket;¤ ················Res·Ticket;¤
¤ ¤
················break;¤ ················break;¤
·············· ··············
¤ ¤
··············Count++;¤ ··············Count++;¤
············ ············
·········· ··········
········ ········
¤ ¤
········//·���·�������·��������·���·�����,·���·���·������·�����.¤ ········//·���·�������·��������·���·�����,·���·���·������·�����.¤
········if·(!Res·&&·PrevTicket·&&·(::OrderGetInteger(ORDER_TICKET)·!=·PrevTicket))¤ ········if·(!Res·&&·PrevTicket·&&·(::OrderGetInteger(ORDER_TICKET)·!=·PrevTicket))¤
··········const·bool·AntiWarning·::OrderSelect(PrevTicket);¤ ··········const·bool·AntiWarning·::OrderSelect(PrevTicket);¤
······ ······
····while·(PrevTotal·!=·::OrdersTotal());·//·��·�����·��������·�����·����������·����������·�������¤ ····while·(PrevTotal·!=·::OrdersTotal());·//·��·�����·��������·�����·����������·����������·�������¤
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··//·�·�����·�·���·��·�������·���������·������·�������·����·������¤ ··//·�·�����·�·���·��·�������·���������·������·�������·����·������¤
··static·bool·SelectByPos(·const·int·Index· ··static·bool·SelectByPos(·const·int·Index·
·· ··
····const·int·Total·::PositionsTotal();¤ ····const·int·Total·::PositionsTotal();¤
····const·bool·Flag·(Index·Total);¤ ····const·bool·Flag·(Index·Total);¤
¤ ¤
····const·bool·Res·(Flag)·::PositionGetTicket(Index)· ····const·bool·Res·(Flag)·::PositionGetTicket(Index)·
·························································#ifdef·MT4ORDERS_SELECTFILTER_OFF¤ ·························································#ifdef·MT4ORDERS_SELECTFILTER_OFF¤
···························································::OrderGetTicket(Index·Total);¤ ···························································::OrderGetTicket(Index·Total);¤
·························································#else·//·MT4ORDERS_SELECTFILTER_OFF¤ ·························································#else·//·MT4ORDERS_SELECTFILTER_OFF¤
···························································(MT4ORDERS::IsTester·::OrderGetTicket(Index·Total)·MT4ORDERS::OrderGetTicket(Index·Total));¤ ···························································(MT4ORDERS::IsTester·::OrderGetTicket(Index·Total)·MT4ORDERS::OrderGetTicket(Index·Total));¤
·························································#endif·//MT4ORDERS_SELECTFILTER_OFF¤ ·························································#endif·//MT4ORDERS_SELECTFILTER_OFF¤
¤ ¤
····if·(Res)¤ ····if·(Res)¤
···· ····
······if·(Flag)¤ ······if·(Flag)¤
········MT4ORDERS::GetPositionData();¤ ········MT4ORDERS::GetPositionData();¤
······else¤ ······else¤
········MT4ORDERS::GetOrderData();¤ ········MT4ORDERS::GetOrderData();¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·bool·SelectByHistoryTicket(·const·long·&Ticket· ··static·bool·SelectByHistoryTicket(·const·long·&Ticket·
·· ··
····bool·Res·false;¤ ····bool·Res·false;¤
¤ ¤
····if·(!Ticket)·//·�����·��·OrderTicketID·(��·��������·��������·����������·��������).¤ ····if·(!Ticket)·//·�����·��·OrderTicketID·(��·��������·��������·����������·��������).¤
···· ····
······const·ulong·TicketDealOut·MT4ORDERS::History.GetPositionDealOut(Ticket);¤ ······const·ulong·TicketDealOut·MT4ORDERS::History.GetPositionDealOut(Ticket);¤
¤ ¤
······if·(Res·::HistoryDealSelect(TicketDealOut))¤ ······if·(Res·::HistoryDealSelect(TicketDealOut))¤
········MT4ORDERS::GetHistoryPositionData(TicketDealOut);¤ ········MT4ORDERS::GetHistoryPositionData(TicketDealOut);¤
···· ····
····else·if·(::HistoryDealSelect(Ticket))¤ ····else·if·(::HistoryDealSelect(Ticket))¤
···· ····
······if·(Res·MT4HISTORY::IsMT4Deal(Ticket))¤ ······if·(Res·MT4HISTORY::IsMT4Deal(Ticket))¤
········MT4ORDERS::GetHistoryPositionData(Ticket);¤ ········MT4ORDERS::GetHistoryPositionData(Ticket);¤
······else¤ ······else¤
······ ······
········const·ulong·TicketDealOut·MT4ORDERS::History.GetPositionDealOut(HistoryDealGetInteger(Ticket,·DEAL_POSITION_ID));·//·�����·��·DealIn¤ ········const·ulong·TicketDealOut·MT4ORDERS::History.GetPositionDealOut(HistoryDealGetInteger(Ticket,·DEAL_POSITION_ID));·//·�����·��·DealIn¤
¤ ¤
········if·(Res·::HistoryDealSelect(TicketDealOut))¤ ········if·(Res·::HistoryDealSelect(TicketDealOut))¤
··········MT4ORDERS::GetHistoryPositionData(TicketDealOut);¤ ··········MT4ORDERS::GetHistoryPositionData(TicketDealOut);¤
······ ······
···· ····
····else·if·(::HistoryOrderSelect(Ticket))¤ ····else·if·(::HistoryOrderSelect(Ticket))¤
···· ····
······if·(Res·MT4HISTORY::IsMT4Order(Ticket))¤ ······if·(Res·MT4HISTORY::IsMT4Order(Ticket))¤
········MT4ORDERS::GetHistoryOrderData(Ticket);¤ ········MT4ORDERS::GetHistoryOrderData(Ticket);¤
······else¤ ······else¤
······ ······
········//·�����·��·OrderTicketID·���·������·�����������·�������·���������·���·��������.¤ ········//·�����·��·OrderTicketID·���·������·�����������·�������·���������·���·��������.¤
········const·ulong·TicketDealOut·MT4ORDERS::History.GetPositionDealOut(HistoryOrderGetInteger(Ticket,·ORDER_POSITION_ID));¤ ········const·ulong·TicketDealOut·MT4ORDERS::History.GetPositionDealOut(HistoryOrderGetInteger(Ticket,·ORDER_POSITION_ID));¤
¤ ¤
········if·(Res·::HistoryDealSelect(TicketDealOut))¤ ········if·(Res·::HistoryDealSelect(TicketDealOut))¤
··········MT4ORDERS::GetHistoryPositionData(TicketDealOut);¤ ··········MT4ORDERS::GetHistoryPositionData(TicketDealOut);¤
······ ······
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·bool·SelectByExistingTicket(·const·long·&Ticket· ··static·bool·SelectByExistingTicket(·const·long·&Ticket·
·· ··
····bool·Res·true;¤ ····bool·Res·true;¤
¤ ¤
····if·(::PositionSelectByTicket(Ticket))¤ ····if·(::PositionSelectByTicket(Ticket))¤
······MT4ORDERS::GetPositionData();¤ ······MT4ORDERS::GetPositionData();¤
····else·if·(::OrderSelect(Ticket))¤ ····else·if·(::OrderSelect(Ticket))¤
······MT4ORDERS::GetOrderData();¤ ······MT4ORDERS::GetOrderData();¤
····else·if·(::HistoryDealSelect(Ticket))¤ ····else·if·(::HistoryDealSelect(Ticket))¤
···· ····
······if·(MT4HISTORY::IsMT4Deal(Ticket))·//·����·������·�����·��·DealOut.¤ ······if·(MT4HISTORY::IsMT4Deal(Ticket))·//·����·������·�����·��·DealOut.¤
········MT4ORDERS::GetHistoryPositionData(Ticket);¤ ········MT4ORDERS::GetHistoryPositionData(Ticket);¤
······else·if·(::PositionSelectByTicket(::HistoryDealGetInteger(Ticket,·DEAL_POSITION_ID)))·//·�����·��·DealIn¤ ······else·if·(::PositionSelectByTicket(::HistoryDealGetInteger(Ticket,·DEAL_POSITION_ID)))·//·�����·��·DealIn¤
········MT4ORDERS::GetPositionData();¤ ········MT4ORDERS::GetPositionData();¤
······else¤ ······else¤
········Res·false;¤ ········Res·false;¤
···· ····
····else·if·(::HistoryOrderSelect(Ticket)·&&·::PositionSelectByTicket(::HistoryOrderGetInteger(Ticket,·ORDER_POSITION_ID)))·//·�����·��·������·MT5-������¤ ····else·if·(::HistoryOrderSelect(Ticket)·&&·::PositionSelectByTicket(::HistoryOrderGetInteger(Ticket,·ORDER_POSITION_ID)))·//·�����·��·������·MT5-������¤
······MT4ORDERS::GetPositionData();¤ ······MT4ORDERS::GetPositionData();¤
····else¤ ····else¤
······Res·false;¤ ······Res·false;¤
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··//·�·�����·�·���·��·�������·����������·������:¤ ··//·�·�����·�·���·��·�������·����������·������:¤
··//·MODE_TRADES:··������������·�������·������������·�����·������·����������·�����¤ ··//·MODE_TRADES:··������������·�������·������������·�����·������·����������·�����¤
··//·MODE_HISTORY:·������·����������·�����·������������·�������·������������·�����¤ ··//·MODE_HISTORY:·������·����������·�����·������������·�������·������������·�����¤
··static·bool·SelectByTicket(·const·long·&Ticket,·const·int·&Pool· ··static·bool·SelectByTicket(·const·long·&Ticket,·const·int·&Pool·
·· ··
····return((Pool·==·MODE_TRADES)· ····return((Pool·==·MODE_TRADES)·
···········(MT4ORDERS::SelectByExistingTicket(Ticket)·true·MT4ORDERS::SelectByHistoryTicket(Ticket))· ···········(MT4ORDERS::SelectByExistingTicket(Ticket)·true·MT4ORDERS::SelectByHistoryTicket(Ticket))·
···········(MT4ORDERS::SelectByHistoryTicket(Ticket)·true·MT4ORDERS::SelectByExistingTicket(Ticket)));¤ ···········(MT4ORDERS::SelectByHistoryTicket(Ticket)·true·MT4ORDERS::SelectByExistingTicket(Ticket)));¤
·· ··
¤ ¤
#ifdef·MT4ORDERS_SLTP_OLD¤ #ifdef·MT4ORDERS_SLTP_OLD¤
··static·void·CheckPrices(·double·&MinPrice,·double·&MaxPrice,·const·double·Min,·const·double·Max· ··static·void·CheckPrices(·double·&MinPrice,·double·&MaxPrice,·const·double·Min,·const·double·Max·
·· ··
····if·(MinPrice·&&·(MinPrice·>=·Min))¤ ····if·(MinPrice·&&·(MinPrice·>=·Min))¤
······MinPrice·0;¤ ······MinPrice·0;¤
¤ ¤
····if·(MaxPrice·&&·(MaxPrice·<=·Max))¤ ····if·(MaxPrice·&&·(MaxPrice·<=·Max))¤
······MaxPrice·0;¤ ······MaxPrice·0;¤
¤ ¤
····return;¤ ····return;¤
·· ··
#endif·//·MT4ORDERS_SLTP_OLD¤ #endif·//·MT4ORDERS_SLTP_OLD¤
¤ ¤
··static·int·OrdersTotal(·void· ··static·int·OrdersTotal(·void·
·· ··
····int·Res·0;¤ ····int·Res·0;¤
····const·long·PrevTicket·::OrderGetInteger(ORDER_TICKET);¤ ····const·long·PrevTicket·::OrderGetInteger(ORDER_TICKET);¤
····int·PrevTotal;¤ ····int·PrevTotal;¤
¤ ¤
····do¤ ····do¤
···· ····
······PrevTotal·::OrdersTotal();¤ ······PrevTotal·::OrdersTotal();¤
¤ ¤
······for·(int·PrevTotal·1;·>=·0;·i--)¤ ······for·(int·PrevTotal·1;·>=·0;·i--)¤
······ ······
········const·int·Total·::OrdersTotal();¤ ········const·int·Total·::OrdersTotal();¤
¤ ¤
········//·��·�����·��������·�����·����������·����������·�������¤ ········//·��·�����·��������·�����·����������·����������·�������¤
········if·(Total·!=·PrevTotal)¤ ········if·(Total·!=·PrevTotal)¤
········ ········
··········PrevTotal·Total;¤ ··········PrevTotal·Total;¤
¤ ¤
··········Res·0;¤ ··········Res·0;¤
··········PrevTotal;¤ ··········PrevTotal;¤
········ ········
········else·if·(::OrderGetTicket(i)·&&·MT4ORDERS::OrderVisible())¤ ········else·if·(::OrderGetTicket(i)·&&·MT4ORDERS::OrderVisible())¤
··········Res++;¤ ··········Res++;¤
······ ······
····while·(PrevTotal·!=·::OrdersTotal());·//·��·�����·��������·�����·����������·����������·�������¤ ····while·(PrevTotal·!=·::OrdersTotal());·//·��·�����·��������·�����·����������·����������·�������¤
¤ ¤
····if·(PrevTicket·&&·(::OrderGetInteger(ORDER_TICKET)·!=·PrevTicket))¤ ····if·(PrevTicket·&&·(::OrderGetInteger(ORDER_TICKET)·!=·PrevTicket))¤
······const·bool·AntiWarning·::OrderSelect(PrevTicket);¤ ······const·bool·AntiWarning·::OrderSelect(PrevTicket);¤
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
public:¤ public:¤
··static·uint·OrderSend_MaxPause;·//·������������·�����·��·�������������·�·���.¤ ··static·uint·OrderSend_MaxPause;·//·������������·�����·��·�������������·�·���.¤
¤ ¤
··static·MqlTradeResult·LastTradeResult;¤ ··static·MqlTradeResult·LastTradeResult;¤
··static·MqlTradeRequest·LastTradeRequest;¤ ··static·MqlTradeRequest·LastTradeRequest;¤
··static·MqlTradeCheckResult·LastTradeCheckResult;¤ ··static·MqlTradeCheckResult·LastTradeCheckResult;¤
¤ ¤
··static·bool·MT4OrderSelect(·const·long·&Index,·const·int·&Select,·const·int·&Pool· ··static·bool·MT4OrderSelect(·const·long·&Index,·const·int·&Select,·const·int·&Pool·
·· ··
····return((Select·==·SELECT_BY_POS)· ····return((Select·==·SELECT_BY_POS)·
···········((Pool·==·MODE_TRADES)·MT4ORDERS::SelectByPos((int)Index)·MT4ORDERS::SelectByPosHistory((int)Index))· ···········((Pool·==·MODE_TRADES)·MT4ORDERS::SelectByPos((int)Index)·MT4ORDERS::SelectByPosHistory((int)Index))·
···········MT4ORDERS::SelectByTicket(Index,·Pool));¤ ···········MT4ORDERS::SelectByTicket(Index,·Pool));¤
·· ··
¤ ¤
··//·�����·"����������"·���������·��������������·���������·�·MT5-�������·OrderSelect¤ ··//·�����·"����������"·���������·��������������·���������·�·MT5-�������·OrderSelect¤
··static·bool·MT4OrderSelect(·const·ulong·&Ticket· ··static·bool·MT4OrderSelect(·const·ulong·&Ticket·
·· ··
····return(::OrderSelect(Ticket));¤ ····return(::OrderSelect(Ticket));¤
·· ··
¤ ¤
··static·int·MT4OrdersTotal(·void· ··static·int·MT4OrdersTotal(·void·
·· ··
··#ifdef·MT4ORDERS_SELECTFILTER_OFF¤ ··#ifdef·MT4ORDERS_SELECTFILTER_OFF¤
····return(::OrdersTotal()·::PositionsTotal());¤ ····return(::OrdersTotal()·::PositionsTotal());¤
··#else·//·MT4ORDERS_SELECTFILTER_OFF¤ ··#else·//·MT4ORDERS_SELECTFILTER_OFF¤
····int·Res;¤ ····int·Res;¤
¤ ¤
····if·(MT4ORDERS::IsTester)¤ ····if·(MT4ORDERS::IsTester)¤
······return(::OrdersTotal()·::PositionsTotal());¤ ······return(::OrdersTotal()·::PositionsTotal());¤
····else¤ ····else¤
···· ····
······int·PrevTotal;¤ ······int·PrevTotal;¤
¤ ¤
······do¤ ······do¤
······ ······
········PrevTotal·::PositionsTotal();¤ ········PrevTotal·::PositionsTotal();¤
¤ ¤
········Res·MT4ORDERS::OrdersTotal()·PrevTotal;¤ ········Res·MT4ORDERS::OrdersTotal()·PrevTotal;¤
¤ ¤
······while·(PrevTotal·!=·::PositionsTotal());·//·�����������·������·���������·�������,·�.�.·������·�������������·�·MT4ORDERS::OrdersTotal()¤ ······while·(PrevTotal·!=·::PositionsTotal());·//·�����������·������·���������·�������,·�.�.·������·�������������·�·MT4ORDERS::OrdersTotal()¤
···· ····
¤ ¤
····return(Res);·//·https://www.mql5.com/ru/forum/290673#comment_9493241¤ ····return(Res);·//·https://www.mql5.com/ru/forum/290673#comment_9493241¤
··#endif·//MT4ORDERS_SELECTFILTER_OFF¤ ··#endif·//MT4ORDERS_SELECTFILTER_OFF¤
·· ··
¤ ¤
··//·�����·"����������"·���������·��������������·���������·�·MT5-�������·OrdersTotal¤ ··//·�����·"����������"·���������·��������������·���������·�·MT5-�������·OrdersTotal¤
··static·int·MT4OrdersTotal(·const·bool· ··static·int·MT4OrdersTotal(·const·bool·
·· ··
····return(::OrdersTotal());¤ ····return(::OrdersTotal());¤
·· ··
¤ ¤
··static·int·MT4OrdersHistoryTotal(·void· ··static·int·MT4OrdersHistoryTotal(·void·
·· ··
····return(MT4ORDERS::History.GetAmount());¤ ····return(MT4ORDERS::History.GetAmount());¤
·· ··
¤ ¤
··static·long·MT4OrderSend(·const·string·&Symb,·const·int·&Type,·const·double·&dVolume,·const·double·&Price,·const·int·&SlipPage,·const·double·&SL,·const·double·&TP,¤ ··static·long·MT4OrderSend(·const·string·&Symb,·const·int·&Type,·const·double·&dVolume,·const·double·&Price,·const·int·&SlipPage,·const·double·&SL,·const·double·&TP,¤
····························const·string·&comment,·const·MAGIC_TYPE·&magic,·const·datetime·&dExpiration,·const·color·&arrow_color· ····························const·string·&comment,·const·MAGIC_TYPE·&magic,·const·datetime·&dExpiration,·const·color·&arrow_color·
¤ ¤
·· ··
····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤ ····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤
¤ ¤
····MT4ORDERS::LastTradeRequest.action·(((Type·==·OP_BUY)·||·(Type·==·OP_SELL))·TRADE_ACTION_DEAL·TRADE_ACTION_PENDING);¤ ····MT4ORDERS::LastTradeRequest.action·(((Type·==·OP_BUY)·||·(Type·==·OP_SELL))·TRADE_ACTION_DEAL·TRADE_ACTION_PENDING);¤
····MT4ORDERS::LastTradeRequest.magic·magic;¤ ····MT4ORDERS::LastTradeRequest.magic·magic;¤
¤ ¤
····MT4ORDERS::LastTradeRequest.symbol·((Symb·==·NULL)·::Symbol()·Symb);¤ ····MT4ORDERS::LastTradeRequest.symbol·((Symb·==·NULL)·::Symbol()·Symb);¤
····MT4ORDERS::LastTradeRequest.volume·dVolume;¤ ····MT4ORDERS::LastTradeRequest.volume·dVolume;¤
····MT4ORDERS::LastTradeRequest.price·Price;¤ ····MT4ORDERS::LastTradeRequest.price·Price;¤
¤ ¤
····MT4ORDERS::LastTradeRequest.tp·TP;¤ ····MT4ORDERS::LastTradeRequest.tp·TP;¤
····MT4ORDERS::LastTradeRequest.sl·SL;¤ ····MT4ORDERS::LastTradeRequest.sl·SL;¤
····MT4ORDERS::LastTradeRequest.deviation·SlipPage;¤ ····MT4ORDERS::LastTradeRequest.deviation·SlipPage;¤
····MT4ORDERS::LastTradeRequest.type·(ENUM_ORDER_TYPE)Type;¤ ····MT4ORDERS::LastTradeRequest.type·(ENUM_ORDER_TYPE)Type;¤
¤ ¤
····MT4ORDERS::LastTradeRequest.type_filling·MT4ORDERS::GetFilling(MT4ORDERS::LastTradeRequest.symbol,·(uint)MT4ORDERS::LastTradeRequest.deviation);¤ ····MT4ORDERS::LastTradeRequest.type_filling·MT4ORDERS::GetFilling(MT4ORDERS::LastTradeRequest.symbol,·(uint)MT4ORDERS::LastTradeRequest.deviation);¤
¤ ¤
····if·(MT4ORDERS::LastTradeRequest.action·==·TRADE_ACTION_PENDING)¤ ····if·(MT4ORDERS::LastTradeRequest.action·==·TRADE_ACTION_PENDING)¤
···· ····
······MT4ORDERS::LastTradeRequest.type_time·MT4ORDERS::GetExpirationType(MT4ORDERS::LastTradeRequest.symbol,·(uint)dExpiration);¤ ······MT4ORDERS::LastTradeRequest.type_time·MT4ORDERS::GetExpirationType(MT4ORDERS::LastTradeRequest.symbol,·(uint)dExpiration);¤
¤ ¤
······if·(dExpiration·ORDER_TIME_DAY)¤ ······if·(dExpiration·ORDER_TIME_DAY)¤
········MT4ORDERS::LastTradeRequest.expiration·dExpiration;¤ ········MT4ORDERS::LastTradeRequest.expiration·dExpiration;¤
···· ····
¤ ¤
····if·(comment·!=·NULL)¤ ····if·(comment·!=·NULL)¤
······MT4ORDERS::LastTradeRequest.comment·comment;¤ ······MT4ORDERS::LastTradeRequest.comment·comment;¤
¤ ¤
····return((arrow_color·==·INT_MAX)·(MT4ORDERS::NewOrderCheck()·-1)· ····return((arrow_color·==·INT_MAX)·(MT4ORDERS::NewOrderCheck()·-1)·
···········((((int)arrow_color·!=·INT_MIN)·||·MT4ORDERS::NewOrderCheck())·&&¤ ···········((((int)arrow_color·!=·INT_MIN)·||·MT4ORDERS::NewOrderCheck())·&&¤
············MT4ORDERS::OrderSend(MT4ORDERS::LastTradeRequest,·MT4ORDERS::LastTradeResult)· ············MT4ORDERS::OrderSend(MT4ORDERS::LastTradeRequest,·MT4ORDERS::LastTradeResult)·
············(MT4ORDERS::IsHedging·(long)MT4ORDERS::LastTradeResult.order·//·PositionID·==·Result.order·�����������·MT5-Hedge¤ ············(MT4ORDERS::IsHedging·(long)MT4ORDERS::LastTradeResult.order·//·PositionID·==·Result.order·�����������·MT5-Hedge¤
·············((MT4ORDERS::LastTradeRequest.action·==·TRADE_ACTION_DEAL)· ·············((MT4ORDERS::LastTradeRequest.action·==·TRADE_ACTION_DEAL)·
··············(MT4ORDERS::IsTester·(::PositionSelect(MT4ORDERS::LastTradeRequest.symbol)·PositionGetInteger(POSITION_TICKET)·0)· ··············(MT4ORDERS::IsTester·(::PositionSelect(MT4ORDERS::LastTradeRequest.symbol)·PositionGetInteger(POSITION_TICKET)·0)·
······································//·HistoryDealSelect·�·MT4ORDERS::OrderSend¤ ······································//·HistoryDealSelect·�·MT4ORDERS::OrderSend¤
······································::HistoryDealGetInteger(MT4ORDERS::LastTradeResult.deal,·DEAL_POSITION_ID))· ······································::HistoryDealGetInteger(MT4ORDERS::LastTradeResult.deal,·DEAL_POSITION_ID))·
··············(long)MT4ORDERS::LastTradeResult.order))·-1));¤ ··············(long)MT4ORDERS::LastTradeResult.order))·-1));¤
·· ··
¤ ¤
··static·bool·MT4OrderModify(·const·long·&Ticket,·const·double·&Price,·const·double·&SL,·const·double·&TP,·const·datetime·&Expiration,·const·color·&Arrow_Color· ··static·bool·MT4OrderModify(·const·long·&Ticket,·const·double·&Price,·const·double·&SL,·const·double·&TP,·const·datetime·&Expiration,·const·color·&Arrow_Color·
·· ··
····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤ ····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤
¤ ¤
···············//·�����������·������,·�����·������������·�����·�·�������·�·�����·�·���·��·�������¤ ···············//·�����������·������,·�����·������������·�����·�·�������·�·�����·�·���·��·�������¤
····bool·Res·((Ticket·!=·MT4ORDERS::Order.Ticket)·||·(MT4ORDERS::Order.Ticket·<=·OP_SELL))· ····bool·Res·((Ticket·!=·MT4ORDERS::Order.Ticket)·||·(MT4ORDERS::Order.Ticket·<=·OP_SELL))·
···············(MT4ORDERS::ModifyPosition(Ticket,·MT4ORDERS::LastTradeRequest)·true·MT4ORDERS::ModifyOrder(Ticket,·Price,·Expiration,·MT4ORDERS::LastTradeRequest))· ···············(MT4ORDERS::ModifyPosition(Ticket,·MT4ORDERS::LastTradeRequest)·true·MT4ORDERS::ModifyOrder(Ticket,·Price,·Expiration,·MT4ORDERS::LastTradeRequest))·
···············(MT4ORDERS::ModifyOrder(Ticket,·Price,·Expiration,·MT4ORDERS::LastTradeRequest)·true·MT4ORDERS::ModifyPosition(Ticket,·MT4ORDERS::LastTradeRequest));¤ ···············(MT4ORDERS::ModifyOrder(Ticket,·Price,·Expiration,·MT4ORDERS::LastTradeRequest)·true·MT4ORDERS::ModifyPosition(Ticket,·MT4ORDERS::LastTradeRequest));¤
¤ ¤
//····if·(Res)·//·����������·��������·����·OrderCheck¤ //····if·(Res)·//·����������·��������·����·OrderCheck¤
···· ····
······MT4ORDERS::LastTradeRequest.tp·TP;¤ ······MT4ORDERS::LastTradeRequest.tp·TP;¤
······MT4ORDERS::LastTradeRequest.sl·SL;¤ ······MT4ORDERS::LastTradeRequest.sl·SL;¤
¤ ¤
······Res·MT4ORDERS::NewOrderSend(Arrow_Color);¤ ······Res·MT4ORDERS::NewOrderSend(Arrow_Color);¤
···· ····
¤ ¤
····return(Res);¤ ····return(Res);¤
·· ··
¤ ¤
··static·bool·MT4OrderClose(·const·long·&Ticket,·const·double·&dLots,·const·double·&Price,·const·int·&SlipPage,·const·color·&Arrow_Color,·const·string·&comment· ··static·bool·MT4OrderClose(·const·long·&Ticket,·const·double·&dLots,·const·double·&Price,·const·int·&SlipPage,·const·color·&Arrow_Color,·const·string·&comment·
·· ··
····//·����·MT4ORDERS::LastTradeRequest·�·MT4ORDERS::LastTradeResult,·�������·��·���������·��·������,·��·�����·���·PositionGetString·����¤ ····//·����·MT4ORDERS::LastTradeRequest·�·MT4ORDERS::LastTradeResult,·�������·��·���������·��·������,·��·�����·���·PositionGetString·����¤
····::PositionSelectByTicket(Ticket);¤ ····::PositionSelectByTicket(Ticket);¤
¤ ¤
····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤ ····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤
¤ ¤
····MT4ORDERS::LastTradeRequest.action·TRADE_ACTION_DEAL;¤ ····MT4ORDERS::LastTradeRequest.action·TRADE_ACTION_DEAL;¤
····MT4ORDERS::LastTradeRequest.position·Ticket;¤ ····MT4ORDERS::LastTradeRequest.position·Ticket;¤
¤ ¤
····MT4ORDERS::LastTradeRequest.symbol·::PositionGetString(POSITION_SYMBOL);¤ ····MT4ORDERS::LastTradeRequest.symbol·::PositionGetString(POSITION_SYMBOL);¤
¤ ¤
····//·���������·�����������·���·���������·��������·�������¤ ····//·���������·�����������·���·���������·��������·�������¤
//····if·(dLots·::PositionGetDouble(POSITION_VOLUME))¤ //····if·(dLots·::PositionGetDouble(POSITION_VOLUME))¤
······MT4ORDERS::LastTradeRequest.comment·(comment·==·NULL)·::PositionGetString(POSITION_COMMENT)·comment;¤ ······MT4ORDERS::LastTradeRequest.comment·(comment·==·NULL)·::PositionGetString(POSITION_COMMENT)·comment;¤
¤ ¤
····//·���������·��·��·��������·������·���·��������?·-���������!¤ ····//·���������·��·��·��������·������·���·��������?·-���������!¤
····MT4ORDERS::LastTradeRequest.volume·dLots;¤ ····MT4ORDERS::LastTradeRequest.volume·dLots;¤
····MT4ORDERS::LastTradeRequest.price·Price;¤ ····MT4ORDERS::LastTradeRequest.price·Price;¤
¤ ¤
··#ifdef·MT4ORDERS_SLTP_OLD¤ ··#ifdef·MT4ORDERS_SLTP_OLD¤
····//·�����·���·�����������·SL/TP-�������·�·��������·�������.·�����������·��·������¤ ····//·�����·���·�����������·SL/TP-�������·�·��������·�������.·�����������·��·������¤
····//·SYMBOL_SESSION_PRICE_LIMIT_MIN·�·SYMBOL_SESSION_PRICE_LIMIT_MAX·���������·��·���������,·�.�.·��������·SL/TP·���·�����������¤ ····//·SYMBOL_SESSION_PRICE_LIMIT_MIN·�·SYMBOL_SESSION_PRICE_LIMIT_MAX·���������·��·���������,·�.�.·��������·SL/TP·���·�����������¤
····MT4ORDERS::LastTradeRequest.tp·::PositionGetDouble(POSITION_SL);¤ ····MT4ORDERS::LastTradeRequest.tp·::PositionGetDouble(POSITION_SL);¤
····MT4ORDERS::LastTradeRequest.sl·::PositionGetDouble(POSITION_TP);¤ ····MT4ORDERS::LastTradeRequest.sl·::PositionGetDouble(POSITION_TP);¤
¤ ¤
····if·(MT4ORDERS::LastTradeRequest.tp·||·MT4ORDERS::LastTradeRequest.sl)¤ ····if·(MT4ORDERS::LastTradeRequest.tp·||·MT4ORDERS::LastTradeRequest.sl)¤
···· ····
······const·double·__StopLevel·::SymbolInfoInteger(MT4ORDERS::LastTradeRequest.symbol,·SYMBOL_TRADE_STOPS_LEVEL)· ······const·double·StopLevel·::SymbolInfoInteger(MT4ORDERS::LastTradeRequest.symbol,·SYMBOL_TRADE_STOPS_LEVEL)·
·································::SymbolInfoDouble(MT4ORDERS::LastTradeRequest.symbol,·SYMBOL_POINT);¤ ·······························::SymbolInfoDouble(MT4ORDERS::LastTradeRequest.symbol,·SYMBOL_POINT);¤
¤ ¤
······const·bool·FlagBuy·(::PositionGetInteger(POSITION_TYPE)·==·POSITION_TYPE_BUY);¤ ······const·bool·FlagBuy·(::PositionGetInteger(POSITION_TYPE)·==·POSITION_TYPE_BUY);¤
······const·double·CurrentPrice·SymbolInfoDouble(MT4ORDERS::LastTradeRequest.symbol,·FlagBuy·SYMBOL_ASK·SYMBOL_BID);¤ ······const·double·CurrentPrice·SymbolInfoDouble(MT4ORDERS::LastTradeRequest.symbol,·FlagBuy·SYMBOL_ASK·SYMBOL_BID);¤
¤ ¤
······if·(CurrentPrice)¤ ······if·(CurrentPrice)¤
······ ······
········if·(FlagBuy)¤ ········if·(FlagBuy)¤
··········MT4ORDERS::CheckPrices(MT4ORDERS::LastTradeRequest.tp,·MT4ORDERS::LastTradeRequest.sl,·CurrentPrice·__StopLevel,·CurrentPrice·__StopLevel);¤ ··········MT4ORDERS::CheckPrices(MT4ORDERS::LastTradeRequest.tp,·MT4ORDERS::LastTradeRequest.sl,·CurrentPrice·StopLevel,·CurrentPrice·StopLevel);¤
········else¤ ········else¤
··········MT4ORDERS::CheckPrices(MT4ORDERS::LastTradeRequest.sl,·MT4ORDERS::LastTradeRequest.tp,·CurrentPrice·__StopLevel,·CurrentPrice·__StopLevel);¤ ··········MT4ORDERS::CheckPrices(MT4ORDERS::LastTradeRequest.sl,·MT4ORDERS::LastTradeRequest.tp,·CurrentPrice·StopLevel,·CurrentPrice·StopLevel);¤
······ ······
······else¤ ······else¤
······ ······
········MT4ORDERS::LastTradeRequest.tp·0;¤ ········MT4ORDERS::LastTradeRequest.tp·0;¤
········MT4ORDERS::LastTradeRequest.sl·0;¤ ········MT4ORDERS::LastTradeRequest.sl·0;¤
······ ······
···· ····
··#endif·//·MT4ORDERS_SLTP_OLD¤ ··#endif·//·MT4ORDERS_SLTP_OLD¤
¤ ¤
····MT4ORDERS::LastTradeRequest.deviation·SlipPage;¤ ····MT4ORDERS::LastTradeRequest.deviation·SlipPage;¤
¤ ¤
····MT4ORDERS::LastTradeRequest.type·(ENUM_ORDER_TYPE)(1·::PositionGetInteger(POSITION_TYPE));¤ ····MT4ORDERS::LastTradeRequest.type·(ENUM_ORDER_TYPE)(1·::PositionGetInteger(POSITION_TYPE));¤
¤ ¤
····MT4ORDERS::LastTradeRequest.type_filling·MT4ORDERS::GetFilling(MT4ORDERS::LastTradeRequest.symbol,·(uint)MT4ORDERS::LastTradeRequest.deviation);¤ ····MT4ORDERS::LastTradeRequest.type_filling·MT4ORDERS::GetFilling(MT4ORDERS::LastTradeRequest.symbol,·(uint)MT4ORDERS::LastTradeRequest.deviation);¤
¤ ¤
····return(MT4ORDERS::NewOrderSend(Arrow_Color));¤ ····return(MT4ORDERS::NewOrderSend(Arrow_Color));¤
·· ··
¤ ¤
··static·bool·MT4OrderCloseBy(·const·long·&Ticket,·const·long·&Opposite,·const·color·&Arrow_Color· ··static·bool·MT4OrderCloseBy(·const·long·&Ticket,·const·long·&Opposite,·const·color·&Arrow_Color·
·· ··
····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤ ····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤
¤ ¤
····MT4ORDERS::LastTradeRequest.action·TRADE_ACTION_CLOSE_BY;¤ ····MT4ORDERS::LastTradeRequest.action·TRADE_ACTION_CLOSE_BY;¤
····MT4ORDERS::LastTradeRequest.position·Ticket;¤ ····MT4ORDERS::LastTradeRequest.position·Ticket;¤
····MT4ORDERS::LastTradeRequest.position_by·Opposite;¤ ····MT4ORDERS::LastTradeRequest.position_by·Opposite;¤
¤ ¤
····if·((!MT4ORDERS::IsTester)·&&·::PositionSelectByTicket(Ticket))·//·�����·���·MT4ORDERS::SymbolTrade()¤ ····if·((!MT4ORDERS::IsTester)·&&·::PositionSelectByTicket(Ticket))·//·�����·���·MT4ORDERS::SymbolTrade()¤
······MT4ORDERS::LastTradeRequest.symbol·::PositionGetString(POSITION_SYMBOL);¤ ······MT4ORDERS::LastTradeRequest.symbol·::PositionGetString(POSITION_SYMBOL);¤
¤ ¤
····return(MT4ORDERS::NewOrderSend(Arrow_Color));¤ ····return(MT4ORDERS::NewOrderSend(Arrow_Color));¤
·· ··
¤ ¤
··static·bool·MT4OrderDelete(·const·long·&Ticket,·const·color·&Arrow_Color· ··static·bool·MT4OrderDelete(·const·long·&Ticket,·const·color·&Arrow_Color·
·· ··
//····bool·Res·::OrderSelect(Ticket);·//·����·��·���,·�����·�����·MT4ORDERS::LastTradeRequest·�·MT4ORDERS::LastTradeResult· //····bool·Res·::OrderSelect(Ticket);·//·����·��·���,·�����·�����·MT4ORDERS::LastTradeRequest·�·MT4ORDERS::LastTradeResult·
¤ ¤
····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤ ····::ZeroMemory(MT4ORDERS::LastTradeRequest);¤
¤ ¤
····MT4ORDERS::LastTradeRequest.action·TRADE_ACTION_REMOVE;¤ ····MT4ORDERS::LastTradeRequest.action·TRADE_ACTION_REMOVE;¤
····MT4ORDERS::LastTradeRequest.order·Ticket;¤ ····MT4ORDERS::LastTradeRequest.order·Ticket;¤
¤ ¤
····if·((!MT4ORDERS::IsTester)·&&·::OrderSelect(Ticket))·//·�����·���·MT4ORDERS::SymbolTrade()¤ ····if·((!MT4ORDERS::IsTester)·&&·::OrderSelect(Ticket))·//·�����·���·MT4ORDERS::SymbolTrade()¤
······MT4ORDERS::LastTradeRequest.symbol·::OrderGetString(ORDER_SYMBOL);¤ ······MT4ORDERS::LastTradeRequest.symbol·::OrderGetString(ORDER_SYMBOL);¤
¤ ¤
····return(MT4ORDERS::NewOrderSend(Arrow_Color));¤ ····return(MT4ORDERS::NewOrderSend(Arrow_Color));¤
·· ··
¤ ¤
#define·MT4_ORDERFUNCTION(NAME,T,A,B,C)······························· #define·MT4_ORDERFUNCTION(NAME,T,A,B,C)·······························
··static·MT4Order##NAME(·void····································· ··static·MT4Order##NAME(·void·····································
···································································· ····································································
····return(POSITION_ORDER((T)(A),·(T)(B),·MT4ORDERS::Order.NAME,·C));· ····return(POSITION_ORDER((T)(A),·(T)(B),·MT4ORDERS::Order.NAME,·C));·
·· ··
¤ ¤
#define·POSITION_ORDER(A,B,C,D)·(((MT4ORDERS::Order.Ticket·==·POSITION_SELECT)·&&·(D))·(A)·((MT4ORDERS::Order.Ticket·==·ORDER_SELECT)·(B)·(C)))¤ #define·POSITION_ORDER(A,B,C,D)·(((MT4ORDERS::Order.Ticket·==·POSITION_SELECT)·&&·(D))·(A)·((MT4ORDERS::Order.Ticket·==·ORDER_SELECT)·(B)·(C)))¤
¤ ¤
··MT4_ORDERFUNCTION(Ticket,·long,·::PositionGetInteger(POSITION_TICKET),·::OrderGetInteger(ORDER_TICKET),·true)¤ ··MT4_ORDERFUNCTION(Ticket,·long,·::PositionGetInteger(POSITION_TICKET),·::OrderGetInteger(ORDER_TICKET),·true)¤
··MT4_ORDERFUNCTION(Type,·int,·::PositionGetInteger(POSITION_TYPE),·::OrderGetInteger(ORDER_TYPE),·true)¤ ··MT4_ORDERFUNCTION(Type,·int,·::PositionGetInteger(POSITION_TYPE),·::OrderGetInteger(ORDER_TYPE),·true)¤
··MT4_ORDERFUNCTION(Lots,·double,·::PositionGetDouble(POSITION_VOLUME),·::OrderGetDouble(ORDER_VOLUME_CURRENT),·true)¤ ··MT4_ORDERFUNCTION(Lots,·double,·::PositionGetDouble(POSITION_VOLUME),·::OrderGetDouble(ORDER_VOLUME_CURRENT),·true)¤
··MT4_ORDERFUNCTION(OpenPrice,·double,·::PositionGetDouble(POSITION_PRICE_OPEN),·(::OrderGetDouble(ORDER_PRICE_OPEN)·::OrderGetDouble(ORDER_PRICE_OPEN)·::OrderGetDouble(ORDER_PRICE_CURRENT)),·true)¤ ··MT4_ORDERFUNCTION(OpenPrice,·double,·::PositionGetDouble(POSITION_PRICE_OPEN),·(::OrderGetDouble(ORDER_PRICE_OPEN)·::OrderGetDouble(ORDER_PRICE_OPEN)·::OrderGetDouble(ORDER_PRICE_CURRENT)),·true)¤
··MT4_ORDERFUNCTION(OpenTimeMsc,·long,·::PositionGetInteger(POSITION_TIME_MSC),·::OrderGetInteger(ORDER_TIME_SETUP_MSC),·true)¤ ··MT4_ORDERFUNCTION(OpenTimeMsc,·long,·::PositionGetInteger(POSITION_TIME_MSC),·::OrderGetInteger(ORDER_TIME_SETUP_MSC),·true)¤
··MT4_ORDERFUNCTION(OpenTime,·datetime,·::PositionGetInteger(POSITION_TIME),·::OrderGetInteger(ORDER_TIME_SETUP),·true)¤ ··MT4_ORDERFUNCTION(OpenTime,·datetime,·::PositionGetInteger(POSITION_TIME),·::OrderGetInteger(ORDER_TIME_SETUP),·true)¤
··MT4_ORDERFUNCTION(StopLoss,·double,·::PositionGetDouble(POSITION_SL),·::OrderGetDouble(ORDER_SL),·true)¤ ··MT4_ORDERFUNCTION(StopLoss,·double,·::PositionGetDouble(POSITION_SL),·::OrderGetDouble(ORDER_SL),·true)¤
··MT4_ORDERFUNCTION(TakeProfit,·double,·::PositionGetDouble(POSITION_TP),·::OrderGetDouble(ORDER_TP),·true)¤ ··MT4_ORDERFUNCTION(TakeProfit,·double,·::PositionGetDouble(POSITION_TP),·::OrderGetDouble(ORDER_TP),·true)¤
··MT4_ORDERFUNCTION(ClosePrice,·double,·::PositionGetDouble(POSITION_PRICE_CURRENT),·::OrderGetDouble(ORDER_PRICE_CURRENT),·true)¤ ··MT4_ORDERFUNCTION(ClosePrice,·double,·::PositionGetDouble(POSITION_PRICE_CURRENT),·::OrderGetDouble(ORDER_PRICE_CURRENT),·true)¤
··MT4_ORDERFUNCTION(CloseTimeMsc,·long,·0,·0,·true)¤ ··MT4_ORDERFUNCTION(CloseTimeMsc,·long,·0,·0,·true)¤
··MT4_ORDERFUNCTION(CloseTime,·datetime,·0,·0,·true)¤ ··MT4_ORDERFUNCTION(CloseTime,·datetime,·0,·0,·true)¤
··MT4_ORDERFUNCTION(Expiration,·datetime,·0,·::OrderGetInteger(ORDER_TIME_EXPIRATION),·true)¤ ··MT4_ORDERFUNCTION(Expiration,·datetime,·0,·::OrderGetInteger(ORDER_TIME_EXPIRATION),·true)¤
··MT4_ORDERFUNCTION(MagicNumber,·long,·::PositionGetInteger(POSITION_MAGIC),·::OrderGetInteger(ORDER_MAGIC),·true)¤ ··MT4_ORDERFUNCTION(MagicNumber,·long,·::PositionGetInteger(POSITION_MAGIC),·::OrderGetInteger(ORDER_MAGIC),·true)¤
··MT4_ORDERFUNCTION(Profit,·double,·::PositionGetDouble(POSITION_PROFIT),·0,·true)¤ ··MT4_ORDERFUNCTION(Profit,·double,·::PositionGetDouble(POSITION_PROFIT),·0,·true)¤
··MT4_ORDERFUNCTION(Swap,·double,·::PositionGetDouble(POSITION_SWAP),·0,·true)¤ ··MT4_ORDERFUNCTION(Swap,·double,·::PositionGetDouble(POSITION_SWAP),·0,·true)¤
··MT4_ORDERFUNCTION(Symbol,·string,·::PositionGetString(POSITION_SYMBOL),·::OrderGetString(ORDER_SYMBOL),·true)¤ ··MT4_ORDERFUNCTION(Symbol,·string,·::PositionGetString(POSITION_SYMBOL),·::OrderGetString(ORDER_SYMBOL),·true)¤
··MT4_ORDERFUNCTION(Comment,·string,·MT4ORDERS::Order.Comment,·::OrderGetString(ORDER_COMMENT),·MT4ORDERS::CheckPositionCommissionComment())¤ ··MT4_ORDERFUNCTION(Comment,·string,·MT4ORDERS::Order.Comment,·::OrderGetString(ORDER_COMMENT),·MT4ORDERS::CheckPositionCommissionComment())¤
··MT4_ORDERFUNCTION(Commission,·double,·MT4ORDERS::Order.Commission,·0,·MT4ORDERS::CheckPositionCommissionComment())¤ ··MT4_ORDERFUNCTION(Commission,·double,·MT4ORDERS::Order.Commission,·0,·MT4ORDERS::CheckPositionCommissionComment())¤
¤ ¤
··MT4_ORDERFUNCTION(OpenPriceRequest,·double,·MT4ORDERS::Order.OpenPriceRequest,·::OrderGetDouble(ORDER_PRICE_OPEN),·MT4ORDERS::CheckPositionOpenPriceRequest())¤ ··MT4_ORDERFUNCTION(OpenPriceRequest,·double,·MT4ORDERS::Order.OpenPriceRequest,·::OrderGetDouble(ORDER_PRICE_OPEN),·MT4ORDERS::CheckPositionOpenPriceRequest())¤
··MT4_ORDERFUNCTION(ClosePriceRequest,·double,·::PositionGetDouble(POSITION_PRICE_CURRENT),·::OrderGetDouble(ORDER_PRICE_CURRENT),·true)¤ ··MT4_ORDERFUNCTION(ClosePriceRequest,·double,·::PositionGetDouble(POSITION_PRICE_CURRENT),·::OrderGetDouble(ORDER_PRICE_CURRENT),·true)¤
¤ ¤
··MT4_ORDERFUNCTION(TicketOpen,·long,·MT4ORDERS::Order.TicketOpen,·::OrderGetInteger(ORDER_TICKET),·MT4ORDERS::CheckPositionTicketOpen())¤ ··MT4_ORDERFUNCTION(TicketOpen,·long,·MT4ORDERS::Order.TicketOpen,·::OrderGetInteger(ORDER_TICKET),·MT4ORDERS::CheckPositionTicketOpen())¤
//··MT4_ORDERFUNCTION(OpenReason,·ENUM_DEAL_REASON,·MT4ORDERS::Order.OpenReason,·::OrderGetInteger(ORDER_REASON),·MT4ORDERS::CheckPositionOpenReason())¤ //··MT4_ORDERFUNCTION(OpenReason,·ENUM_DEAL_REASON,·MT4ORDERS::Order.OpenReason,·::OrderGetInteger(ORDER_REASON),·MT4ORDERS::CheckPositionOpenReason())¤
··MT4_ORDERFUNCTION(OpenReason,·ENUM_DEAL_REASON,·::PositionGetInteger(POSITION_REASON),·::OrderGetInteger(ORDER_REASON),·true)¤ ··MT4_ORDERFUNCTION(OpenReason,·ENUM_DEAL_REASON,·::PositionGetInteger(POSITION_REASON),·::OrderGetInteger(ORDER_REASON),·true)¤
··MT4_ORDERFUNCTION(CloseReason,·ENUM_DEAL_REASON,·0,·::OrderGetInteger(ORDER_REASON),·true)¤ ··MT4_ORDERFUNCTION(CloseReason,·ENUM_DEAL_REASON,·0,·::OrderGetInteger(ORDER_REASON),·true)¤
··MT4_ORDERFUNCTION(TicketID,·long,·::PositionGetInteger(POSITION_IDENTIFIER),·::OrderGetInteger(ORDER_TICKET),·true)¤ ··MT4_ORDERFUNCTION(TicketID,·long,·::PositionGetInteger(POSITION_IDENTIFIER),·::OrderGetInteger(ORDER_TICKET),·true)¤
¤ ¤
#undef·POSITION_ORDER¤ #undef·POSITION_ORDER¤
#undef·MT4_ORDERFUNCTION¤ #undef·MT4_ORDERFUNCTION¤
¤ ¤
··static·void·MT4OrderPrint(·void· ··static·void·MT4OrderPrint(·void·
·· ··
····if·(MT4ORDERS::Order.Ticket·==·POSITION_SELECT)¤ ····if·(MT4ORDERS::Order.Ticket·==·POSITION_SELECT)¤
······MT4ORDERS::CheckPositionCommissionComment();¤ ······MT4ORDERS::CheckPositionCommissionComment();¤
¤ ¤
····::Print(MT4ORDERS::Order.ToString());¤ ····::Print(MT4ORDERS::Order.ToString());¤
¤ ¤
····return;¤ ····return;¤
·· ··
¤ ¤
#undef·ORDER_SELECT¤ #undef·ORDER_SELECT¤
#undef·POSITION_SELECT¤ #undef·POSITION_SELECT¤
};¤ };¤
¤ ¤
//·#define·OrderToString·MT4ORDERS::MT4OrderToString¤ //·#define·OrderToString·MT4ORDERS::MT4OrderToString¤
¤ ¤
static·MT4_ORDER·MT4ORDERS::Order·{0};¤ static·MT4_ORDER·MT4ORDERS::Order·{0};¤
¤ ¤
static·MT4HISTORY·MT4ORDERS::History;¤ static·MT4HISTORY·MT4ORDERS::History;¤
¤ ¤
static·const·bool·MT4ORDERS::IsTester·::MQLInfoInteger(MQL_TESTER);¤ static·const·bool·MT4ORDERS::IsTester·::MQLInfoInteger(MQL_TESTER);¤
¤ ¤
//·����·�����������·����,·���·��������·�·����������·���·�����·�������������¤ //·����·�����������·����,·���·��������·�·����������·���·�����·�������������¤
//·https://www.mql5.com/ru/forum/170952/page61#comment_6132824¤ //·https://www.mql5.com/ru/forum/170952/page61#comment_6132824¤
static·const·bool·MT4ORDERS::IsHedging·((ENUM_ACCOUNT_MARGIN_MODE)::AccountInfoInteger(ACCOUNT_MARGIN_MODE)·==¤ static·const·bool·MT4ORDERS::IsHedging·((ENUM_ACCOUNT_MARGIN_MODE)::AccountInfoInteger(ACCOUNT_MARGIN_MODE)·==¤
··········································ACCOUNT_MARGIN_MODE_RETAIL_HEDGING);¤ ··········································ACCOUNT_MARGIN_MODE_RETAIL_HEDGING);¤
¤ ¤
static·int·MT4ORDERS::OrderSendBug·0;¤ static·int·MT4ORDERS::OrderSendBug·0;¤
¤ ¤
static·uint·MT4ORDERS::OrderSend_MaxPause·1000000;·//·������������·�����·��·�������������·�·���.¤ static·uint·MT4ORDERS::OrderSend_MaxPause·1000000;·//·������������·�����·��·�������������·�·���.¤
¤ ¤
static·MqlTradeResult·MT4ORDERS::LastTradeResult·{0};¤ static·MqlTradeResult·MT4ORDERS::LastTradeResult·{0};¤
static·MqlTradeRequest·MT4ORDERS::LastTradeRequest·{0};¤ static·MqlTradeRequest·MT4ORDERS::LastTradeRequest·{0};¤
static·MqlTradeCheckResult·MT4ORDERS::LastTradeCheckResult·{0};¤ static·MqlTradeCheckResult·MT4ORDERS::LastTradeCheckResult·{0};¤
¤ ¤
bool·OrderClose(·const·long·Ticket,·const·double·dLots,·const·double·Price,·const·int·SlipPage,·const·color·Arrow_Color·clrNONE,·const·string·comment·NULL· bool·OrderClose(·const·long·Ticket,·const·double·dLots,·const·double·Price,·const·int·SlipPage,·const·color·Arrow_Color·clrNONE,·const·string·comment·NULL·
··return(MT4ORDERS::MT4OrderClose(Ticket,·dLots,·Price,·SlipPage,·Arrow_Color,·comment));¤ ··return(MT4ORDERS::MT4OrderClose(Ticket,·dLots,·Price,·SlipPage,·Arrow_Color,·comment));¤
¤ ¤
bool·OrderModify(·const·long·Ticket,·const·double·Price,·const·double·SL,·const·double·TP,·const·datetime·Expiration,·const·color·Arrow_Color·clrNONE· bool·OrderModify(·const·long·Ticket,·const·double·Price,·const·double·SL,·const·double·TP,·const·datetime·Expiration,·const·color·Arrow_Color·clrNONE·
··return(MT4ORDERS::MT4OrderModify(Ticket,·Price,·SL,·TP,·Expiration,·Arrow_Color));¤ ··return(MT4ORDERS::MT4OrderModify(Ticket,·Price,·SL,·TP,·Expiration,·Arrow_Color));¤
¤ ¤
bool·OrderCloseBy(·const·long·Ticket,·const·long·Opposite,·const·color·Arrow_Color·clrNONE· bool·OrderCloseBy(·const·long·Ticket,·const·long·Opposite,·const·color·Arrow_Color·clrNONE·
··return(MT4ORDERS::MT4OrderCloseBy(Ticket,·Opposite,·Arrow_Color));¤ ··return(MT4ORDERS::MT4OrderCloseBy(Ticket,·Opposite,·Arrow_Color));¤
¤ ¤
bool·OrderDelete(·const·long·Ticket,·const·color·Arrow_Color·clrNONE· bool·OrderDelete(·const·long·Ticket,·const·color·Arrow_Color·clrNONE·
··return(MT4ORDERS::MT4OrderDelete(Ticket,·Arrow_Color));¤ ··return(MT4ORDERS::MT4OrderDelete(Ticket,·Arrow_Color));¤
¤ ¤
void·OrderPrint(·void· void·OrderPrint(·void·
··MT4ORDERS::MT4OrderPrint();¤ ··MT4ORDERS::MT4OrderPrint();¤
¤ ¤
··return;¤ ··return;¤
¤ ¤
#define·MT4_ORDERGLOBALFUNCTION(NAME,T)····· #define·MT4_ORDERGLOBALFUNCTION(NAME,T)·····
··Order##NAME(·void····················· ··Order##NAME(·void·····················
·········································· ··········································
····return((T)MT4ORDERS::MT4Order##NAME());· ····return((T)MT4ORDERS::MT4Order##NAME());·
·· ··
¤ ¤
MT4_ORDERGLOBALFUNCTION(sHistoryTotal,·int)¤ MT4_ORDERGLOBALFUNCTION(sHistoryTotal,·int)¤
MT4_ORDERGLOBALFUNCTION(Ticket,·TICKET_TYPE)¤ MT4_ORDERGLOBALFUNCTION(Ticket,·TICKET_TYPE)¤
MT4_ORDERGLOBALFUNCTION(Type,·int)¤ MT4_ORDERGLOBALFUNCTION(Type,·int)¤
MT4_ORDERGLOBALFUNCTION(Lots,·double)¤ MT4_ORDERGLOBALFUNCTION(Lots,·double)¤
MT4_ORDERGLOBALFUNCTION(OpenPrice,·double)¤ MT4_ORDERGLOBALFUNCTION(OpenPrice,·double)¤
MT4_ORDERGLOBALFUNCTION(OpenTimeMsc,·long)¤ MT4_ORDERGLOBALFUNCTION(OpenTimeMsc,·long)¤
MT4_ORDERGLOBALFUNCTION(OpenTime,·datetime)¤ MT4_ORDERGLOBALFUNCTION(OpenTime,·datetime)¤
MT4_ORDERGLOBALFUNCTION(StopLoss,·double)¤ MT4_ORDERGLOBALFUNCTION(StopLoss,·double)¤
MT4_ORDERGLOBALFUNCTION(TakeProfit,·double)¤ MT4_ORDERGLOBALFUNCTION(TakeProfit,·double)¤
MT4_ORDERGLOBALFUNCTION(ClosePrice,·double)¤ MT4_ORDERGLOBALFUNCTION(ClosePrice,·double)¤
MT4_ORDERGLOBALFUNCTION(CloseTimeMsc,·long)¤ MT4_ORDERGLOBALFUNCTION(CloseTimeMsc,·long)¤
MT4_ORDERGLOBALFUNCTION(CloseTime,·datetime)¤ MT4_ORDERGLOBALFUNCTION(CloseTime,·datetime)¤
MT4_ORDERGLOBALFUNCTION(Expiration,·datetime)¤ MT4_ORDERGLOBALFUNCTION(Expiration,·datetime)¤
MT4_ORDERGLOBALFUNCTION(MagicNumber,·MAGIC_TYPE)¤ MT4_ORDERGLOBALFUNCTION(MagicNumber,·MAGIC_TYPE)¤
MT4_ORDERGLOBALFUNCTION(Profit,·double)¤ MT4_ORDERGLOBALFUNCTION(Profit,·double)¤
MT4_ORDERGLOBALFUNCTION(Commission,·double)¤ MT4_ORDERGLOBALFUNCTION(Commission,·double)¤
MT4_ORDERGLOBALFUNCTION(Swap,·double)¤ MT4_ORDERGLOBALFUNCTION(Swap,·double)¤
MT4_ORDERGLOBALFUNCTION(Symbol,·string)¤ MT4_ORDERGLOBALFUNCTION(Symbol,·string)¤
MT4_ORDERGLOBALFUNCTION(Comment,·string)¤ MT4_ORDERGLOBALFUNCTION(Comment,·string)¤
¤ ¤
MT4_ORDERGLOBALFUNCTION(OpenPriceRequest,·double)¤ MT4_ORDERGLOBALFUNCTION(OpenPriceRequest,·double)¤
MT4_ORDERGLOBALFUNCTION(ClosePriceRequest,·double)¤ MT4_ORDERGLOBALFUNCTION(ClosePriceRequest,·double)¤
¤ ¤
MT4_ORDERGLOBALFUNCTION(TicketOpen,·long)¤ MT4_ORDERGLOBALFUNCTION(TicketOpen,·long)¤
MT4_ORDERGLOBALFUNCTION(OpenReason,·ENUM_DEAL_REASON)¤ MT4_ORDERGLOBALFUNCTION(OpenReason,·ENUM_DEAL_REASON)¤
MT4_ORDERGLOBALFUNCTION(CloseReason,·ENUM_DEAL_REASON)¤ MT4_ORDERGLOBALFUNCTION(CloseReason,·ENUM_DEAL_REASON)¤
MT4_ORDERGLOBALFUNCTION(TicketID,·long)¤ MT4_ORDERGLOBALFUNCTION(TicketID,·long)¤
¤ ¤
#undef·MT4_ORDERGLOBALFUNCTION¤ #undef·MT4_ORDERGLOBALFUNCTION¤
¤ ¤
//·�������������·�����������·�������¤ //·�������������·�����������·�������¤
#define·OrdersTotal·MT4ORDERS::MT4OrdersTotal·//·�����·Expert/Expert.mqh·����·�����·MT5-OrdersTotal()¤ #define·OrdersTotal·MT4ORDERS::MT4OrdersTotal·//·�����·Expert/Expert.mqh·����·�����·MT5-OrdersTotal()¤
¤ ¤
bool·OrderSelect(·const·long·Index,·const·int·Select,·const·int·Pool·MODE_TRADES· bool·OrderSelect(·const·long·Index,·const·int·Select,·const·int·Pool·MODE_TRADES·
··return(MT4ORDERS::MT4OrderSelect(Index,·Select,·Pool));¤ ··return(MT4ORDERS::MT4OrderSelect(Index,·Select,·Pool));¤
¤ ¤
TICKET_TYPE·OrderSend(·const·string·Symb,·const·int·Type,·const·double·dVolume,·const·double·Price,·const·int·SlipPage,·const·double·SL,·const·double·TP,¤ TICKET_TYPE·OrderSend(·const·string·Symb,·const·int·Type,·const·double·dVolume,·const·double·Price,·const·int·SlipPage,·const·double·SL,·const·double·TP,¤
·······················const·string·comment·NULL,·const·MAGIC_TYPE·magic·0,·const·datetime·dExpiration·0,·color·arrow_color·clrNONE· ·······················const·string·comment·NULL,·const·MAGIC_TYPE·magic·0,·const·datetime·dExpiration·0,·color·arrow_color·clrNONE·
··return((TICKET_TYPE)MT4ORDERS::MT4OrderSend(Symb,·Type,·dVolume,·Price,·SlipPage,·SL,·TP,·comment,·magic,·dExpiration,·arrow_color));¤ ··return((TICKET_TYPE)MT4ORDERS::MT4OrderSend(Symb,·Type,·dVolume,·Price,·SlipPage,·SL,·TP,·comment,·magic,·dExpiration,·arrow_color));¤
¤ ¤
#define·RETURN_ASYNC(A)·return((A)·&&·::OrderSendAsync(MT4ORDERS::LastTradeRequest,·MT4ORDERS::LastTradeResult)·&&························ #define·RETURN_ASYNC(A)·return((A)·&&·::OrderSendAsync(MT4ORDERS::LastTradeRequest,·MT4ORDERS::LastTradeResult)·&&························
·······························(MT4ORDERS::LastTradeResult.retcode·==·TRADE_RETCODE_PLACED)·MT4ORDERS::LastTradeResult.request_id·0);¤ ·······························(MT4ORDERS::LastTradeResult.retcode·==·TRADE_RETCODE_PLACED)·MT4ORDERS::LastTradeResult.request_id·0);¤
¤ ¤
uint·OrderCloseAsync(·const·long·Ticket,·const·double·dLots,·const·double·Price,·const·int·SlipPage,·const·color·Arrow_Color·clrNONE· uint·OrderCloseAsync(·const·long·Ticket,·const·double·dLots,·const·double·Price,·const·int·SlipPage,·const·color·Arrow_Color·clrNONE·
··RETURN_ASYNC(OrderClose(Ticket,·dLots,·Price,·SlipPage,·INT_MAX))¤ ··RETURN_ASYNC(OrderClose(Ticket,·dLots,·Price,·SlipPage,·INT_MAX))¤
¤ ¤
uint·OrderModifyAsync(·const·long·Ticket,·const·double·Price,·const·double·SL,·const·double·TP,·const·datetime·Expiration,·const·color·Arrow_Color·clrNONE· uint·OrderModifyAsync(·const·long·Ticket,·const·double·Price,·const·double·SL,·const·double·TP,·const·datetime·Expiration,·const·color·Arrow_Color·clrNONE·
··RETURN_ASYNC(OrderModify(Ticket,·Price,·SL,·TP,·Expiration,·INT_MAX))¤ ··RETURN_ASYNC(OrderModify(Ticket,·Price,·SL,·TP,·Expiration,·INT_MAX))¤
¤ ¤
uint·OrderDeleteAsync(·const·long·Ticket,·const·color·Arrow_Color·clrNONE· uint·OrderDeleteAsync(·const·long·Ticket,·const·color·Arrow_Color·clrNONE·
··RETURN_ASYNC(OrderDelete(Ticket,·INT_MAX))¤ ··RETURN_ASYNC(OrderDelete(Ticket,·INT_MAX))¤
¤ ¤
uint·OrderSendAsync(·const·string·Symb,·const·int·Type,·const·double·dVolume,·const·double·Price,·const·int·SlipPage,·const·double·SL,·const·double·TP,¤ uint·OrderSendAsync(·const·string·Symb,·const·int·Type,·const·double·dVolume,·const·double·Price,·const·int·SlipPage,·const·double·SL,·const·double·TP,¤
····················const·string·comment·NULL,·const·MAGIC_TYPE·magic·0,·const·datetime·dExpiration·0,·color·arrow_color·clrNONE· ····················const·string·comment·NULL,·const·MAGIC_TYPE·magic·0,·const·datetime·dExpiration·0,·color·arrow_color·clrNONE·
··RETURN_ASYNC(!OrderSend(Symb,·Type,·dVolume,·Price,·SlipPage,·SL,·TP,·comment,·magic,·dExpiration,·INT_MAX))¤ ··RETURN_ASYNC(!OrderSend(Symb,·Type,·dVolume,·Price,·SlipPage,·SL,·TP,·comment,·magic,·dExpiration,·INT_MAX))¤
¤ ¤
#undef·RETURN_ASYNC¤ #undef·RETURN_ASYNC¤
¤ ¤
#undef·MT4ORDERS_SLTP_OLD¤ #undef·MT4ORDERS_SLTP_OLD¤
¤ ¤
//·#undef·TICKET_TYPE¤ //·#undef·TICKET_TYPE¤
#endif·//·__MT4ORDERS__¤ #endif·//·__MT4ORDERS__¤
#else··//·__MQL5__¤ #else··//·__MQL5__¤
··#define·TICKET_TYPE·int¤ ··#define·TICKET_TYPE·int¤
··#define·MAGIC_TYPE··int¤ ··#define·MAGIC_TYPE··int¤
#endif·//·__MQL5__¤ #endif·//·__MQL5__¤
¤ ¤
////////////////////////////¤ ////////////////////////////¤
//Strategy¤ //Strategy¤
///////////////////////////¤ ///////////////////////////¤
//#include·<stdlib.mqh>¤ //#include·<stdlib.mqh>¤
#include·<StdLibErr.mqh>¤ #include·<StdLibErr.mqh>¤
//#include·<WinUser32.mqh>¤ //#include·<WinUser32.mqh>¤
¤ ¤
#define·····················//All·(Basket·Hedge)¤ #define·····················//All·(Basket·Hedge)¤
#define·····················//Basket¤ #define·····················//Basket¤
#define·····················//Hedge¤ #define·····················//Hedge¤
#define·····················//Ticket¤ #define·····················//Ticket¤
#define·····················//Pending¤ #define·····················//Pending¤
¤ ¤
enum·portChgs· enum·portChgs·
····no_change·0,··············//·No·changes¤ ····no_change·0,··············//·No·changes¤
····increase·1,···············//·Increase·only¤ ····increase·1,···············//·Increase·only¤
····any·-1,···················//·Increase·decrease¤ ····any·-1,···················//·Increase·decrease¤
};¤ };¤
¤ ¤
enum·mktCond· enum·mktCond·
····uptrend·0,················//·Long·only¤ ····uptrend·0,················//·Long·only¤
····downtrend·1,··············//·Short·only¤ ····downtrend·1,··············//·Short·only¤
····range·2,··················//·Long·short¤ ····range·2,··················//·Long·short¤
····automatic···············//·Automatic¤ ····automatic···············//·Automatic¤
};¤ };¤
¤ ¤
enum·entType· enum·entType·
····disable·0,················//·Disabled¤ ····disable·0,················//·Disabled¤
····enable·1,·················//·Enabled¤ ····enable·1,·················//·Enabled¤
····reverse·················//·Reverse¤ ····reverse·················//·Reverse¤
};¤ };¤
¤ ¤
enum·tFrame· enum·tFrame·
····current·0,················//·Current¤ ····current·0,················//·Current¤
····m1·1,·····················//·M1¤ ····m1·1,·····················//·M1¤
····m5·2,·····················//·M5¤ ····m5·2,·····················//·M5¤
····m15·3,····················//·M15¤ ····m15·3,····················//·M15¤
····m30·4,····················//·M30¤ ····m30·4,····················//·M30¤
····h1·5,·····················//·H1¤ ····h1·5,·····················//·H1¤
····h4·6,·····················//·H4¤ ····h4·6,·····················//·H4¤
····d1·7,·····················//·Daily¤ ····d1·7,·····················//·Daily¤
····w1·8,·····················//·Weekly¤ ····w1·8,·····················//·Weekly¤
····mn1·····················//·Monthly¤ ····mn1·····················//·Monthly¤
};¤ };¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·External·Parameters·Set········································· //|·External·Parameters·Set·········································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
¤ ¤
input·string·Version_3_9_6_17·"EA·Settings:";¤ input·string·Version_3_9_6_15·"EA·Settings:";¤
input·string·TradeComment·"b3_v396.17";¤ input·string·TradeComment·"b3_v396.15";¤
input·string·Notes·"";¤ input·string·Notes·"";¤
input·int·EANumber·1;·········//·EA·Magic·Number¤ input·int·EANumber·1;·········//·EA·Magic·Number¤
input·bool·EmergencyCloseAll·false;···//·***·CLOSE·ALL·NOW·***¤ input·bool·EmergencyCloseAll·false;···//·***·CLOSE·ALL·NOW·***¤
//·input·bool»  kludge_fix·true;¤ //·input·bool»  kludge_fix·true;¤
¤ ¤
input·string·s1·"";···········//.¤ input·string·s1·"";···········//.¤
input·bool·ShutDown·false;····//·***·NO·NEW·TRADES·***¤ input·bool·ShutDown·false;····//·***·NO·NEW·TRADES·***¤
input·string·s2·"";···········//.¤ input·string·s2·"";···········//.¤
¤ ¤
input·string·LabelAcc·"";·····//·==···ACCOUNT·SETTINGS···==¤ input·string·LabelAcc·"";·····//·==···ACCOUNT·SETTINGS···==¤
input·double·StopTradePercent·10;;····//·Percentage·of·balance·lost·before·trading·stops¤ input·double·StopTradePercent·10;;····//·Percentage·of·balance·lost·before·trading·stops¤
¤ ¤
input·bool·NanoAccount·false;;········//·Small·Lot·Account·(0.01)¤ input·bool·NanoAccount·false;;········//·Small·Lot·Account·(0.01)¤
input·string·s3·"...·PortionPC·100·forces·effective·balance·to·that·amount·(e.g.·1000)";·//.¤ input·string·s3·"...·PortionPC·100·forces·effective·balance·to·that·amount·(e.g.·1000)";·//.¤
input·double·PortionPC·100;;··//·Percentage·of·account·you·want·to·trade·on·this·pair¤ input·double·PortionPC·100;;··//·Percentage·of·account·you·want·to·trade·on·this·pair¤
input·portChgs·PortionChange·increase;;·······//·Permitted·Portion·change·with·open·basket¤ input·portChgs·PortionChange·increase;;·······//·Permitted·Portion·change·with·open·basket¤
//·If·basket·open:·0=no·Portion·change;1=allow·portion·to·increase;·-1=allow·increase·and·decrease¤ //·If·basket·open:·0=no·Portion·change;1=allow·portion·to·increase;·-1=allow·increase·and·decrease¤
input·double·MaxDDPercent·50;;········//·Percent·of·portion·for·max·drawdown·level.¤ input·double·MaxDDPercent·50;;········//·Percent·of·portion·for·max·drawdown·level.¤
input·double·MaxSpread·5;;····//·Maximum·allowed·spread·while·placing·trades¤ input·double·MaxSpread·5;;····//·Maximum·allowed·spread·while·placing·trades¤
input·bool·UseHolidayShutdown·true;;··//·Enable·holiday·shut-downs¤ input·bool·UseHolidayShutdown·true;;··//·Enable·holiday·shut-downs¤
input·string·Holidays·"18/12-01/01";;·//·Comma-separated·holiday·list·(format:·[day]/[mth]-[day]/[mth])¤ input·string·Holidays·"18/12-01/01";;·//·Comma-separated·holiday·list·(format:·[day]/[mth]-[day]/[mth])¤
input·bool·PlaySounds·false;;·//·Audible·alerts¤ input·bool·PlaySounds·false;;·//·Audible·alerts¤
input·string·AlertSound·"Alert.wav";;·//·Alert·sound¤ input·string·AlertSound·"Alert.wav";;·//·Alert·sound¤
¤ ¤
input·string·eopb·"";·········//·--·Opt.·with·'Open·prices·only'·--¤ input·string·eopb·"";·········//·--·Opt.·with·'Open·prices·only'·--¤
//·input·string···eopb0···················"Filters·out·ticks";·//. ¤ //·input·string···eopb0···················"Filters·out·ticks";·//. ¤
input·bool·EnableOncePerBar·true;¤ input·bool·EnableOncePerBar·true;¤
input·bool·UseMinMarginPercent·false;¤ input·bool·UseMinMarginPercent·false;¤
input·double·MinMarginPercent·1500;¤ input·double·MinMarginPercent·1500;¤
input·string·eopb1·"";········//. ¤ input·string·eopb1·"";········//. ¤
¤ ¤
input·bool·B3Traditional·true;;·······//·Stop/Limits·for·entry·if·true,·Buys/Sells·if·false¤ input·bool·B3Traditional·true;;·······//·Stop/Limits·for·entry·if·true,·Buys/Sells·if·false¤
input·mktCond·ForceMarketCond·3;;·····//·Market·condition¤ input·mktCond·ForceMarketCond·3;;·····//·Market·condition¤
//·0=uptrend·1=downtrend·2=range·3=automatic¤ //·0=uptrend·1=downtrend·2=range·3=automatic¤
input·bool·UseAnyEntry·false;;········//·true·ANY·entry·can·be·used·to·open·orders,·false·ALL·entries·used·to·open·orders¤ input·bool·UseAnyEntry·false;;········//·true·ANY·entry·can·be·used·to·open·orders,·false·ALL·entries·used·to·open·orders¤
//·input·entType··MAEntry············1;·//·MA·_Entry¤ //·input·entType··MAEntry············1;·//·MA·_Entry¤
//·input·entType··CCIEntry···········0;·//·CCI·_Entry¤ //·input·entType··CCIEntry···········0;·//·CCI·_Entry¤
//·input·entType··BollingerEntry·····0;·//·Bollinger·_Entry¤ //·input·entType··BollingerEntry·····0;·//·Bollinger·_Entry¤
//·input·entType··StochEntry·········0;·//·Stochastic·_Entry¤ //·input·entType··StochEntry·········0;·//·Stochastic·_Entry¤
//·input·entType··MACDEntry··········0;·//·MACD·_Entry¤ //·input·entType··MACDEntry··········0;·//·MACD·_Entry¤
//·0=disable·1=enable·2=reverse¤ //·0=disable·1=enable·2=reverse¤
¤ ¤
input·string·LabelLS·"";······//·-----------···LOT·SIZE···-----------¤ input·string·LabelLS·"";······//·-----------···LOT·SIZE···-----------¤
input·bool·UseMM·true;········//·UseMM···(Money·Management)¤ input·bool·UseMM·true;········//·UseMM···(Money·Management)¤
input·double·LAF·0.5;;········//·Adjusts·MM·base·lot·for·large·accounts¤ input·double·LAF·0.5;;········//·Adjusts·MM·base·lot·for·large·accounts¤
input·double·Lot·0.01;;·······//·Starting·lots·if·Money·Management·is·off¤ input·double·Lot·0.01;;·······//·Starting·lots·if·Money·Management·is·off¤
input·double·Multiplier·1.4;;·//·Multiplier·on·each·level¤ input·double·Multiplier·1.4;;·//·Multiplier·on·each·level¤
¤ ¤
input·string·LabelGS·"";······//·------·····GRID·SETTINGS····------¤ input·string·LabelGS·"";······//·------·····GRID·SETTINGS····------¤
input·bool·AutoCal·false;;····//·Auto·calculation·of·TakeProfit·and·Grid·size;¤ input·bool·AutoCal·false;;····//·Auto·calculation·of·TakeProfit·and·Grid·size;¤
input·ENUM_TIMEFRAMES·ATRTF·0;;········//·TimeFrame·for·ATR·calculation¤ input·ENUM_TIMEFRAMES·ATRTF·0;;········//·TimeFrame·for·ATR·calculation¤
input·int·ATRPeriods·21;;·····//·Number·of·periods·for·the·ATR·calculation¤ input·int·ATRPeriods·21;;·····//·Number·of·periods·for·the·ATR·calculation¤
input·double·GAF·1.0;;········//·Widens/Squishes·Grid·in·increments/decrements·of·.1¤ input·double·GAF·1.0;;········//·Widens/Squishes·Grid·in·increments/decrements·of·.1¤
input·int·EntryDelay·2400;;···//·Time·Grid·in·seconds,·avoid·opening·lots·of·levels·in·fast·market¤ input·int·EntryDelay·2400;;···//·Time·Grid·in·seconds,·avoid·opening·lots·of·levels·in·fast·market¤
input·double·EntryOffset·5;;··//·In·pips,·used·in·conjunction·with·logic·to·offset·first·trade·entry¤ input·double·EntryOffset·5;;··//·In·pips,·used·in·conjunction·with·logic·to·offset·first·trade·entry¤
input·bool·UseSmartGrid·true;;········//·True·use·RSI/MA·calculation·for·next·grid·order¤ input·bool·UseSmartGrid·true;;········//·True·use·RSI/MA·calculation·for·next·grid·order¤
¤ ¤
input·string·LabelTS·"";······//·=====····TRADING····=====¤ input·string·LabelTS·"";······//·=====····TRADING····=====¤
input·int·MaxTrades·15;;······//·Maximum·number·of·trades·to·place·(stops·placing·orders·when·reaches·MaxTrades)¤ input·int·MaxTrades·15;;······//·Maximum·number·of·trades·to·place·(stops·placing·orders·when·reaches·MaxTrades)¤
input·int·BreakEvenTrade·12;;·//·Close·All·level,·when·reaches·this·level,·doesn't·wait·for·TP·to·be·hit¤ input·int·BreakEvenTrade·12;;·//·Close·All·level,·when·reaches·this·level,·doesn't·wait·for·TP·to·be·hit¤
input·double·BEPlusPips·2;;···//·Pips·added·to·Break·Even·Point·before·BE·closure¤ input·double·BEPlusPips·2;;···//·Pips·added·to·Break·Even·Point·before·BE·closure¤
input·bool·UseCloseOldest·false;;·····//·True·will·close·the·oldest·open·trade·after·CloseTradesLevel·is·reached¤ input·bool·UseCloseOldest·false;;·····//·True·will·close·the·oldest·open·trade·after·CloseTradesLevel·is·reached¤
input·int·CloseTradesLevel·5;;········//·will·start·closing·oldest·open·trade·at·this·level¤ input·int·CloseTradesLevel·5;;········//·will·start·closing·oldest·open·trade·at·this·level¤
input·bool·ForceCloseOldest·true;;····//·Will·close·the·oldest·trade·whether·it·has·potential·profit·or·not¤ input·bool·ForceCloseOldest·true;;····//·Will·close·the·oldest·trade·whether·it·has·potential·profit·or·not¤
input·int·MaxCloseTrades·4;;··//·Maximum·number·of·oldest·trades·to·close¤ input·int·MaxCloseTrades·4;;··//·Maximum·number·of·oldest·trades·to·close¤
input·double·CloseTPPips·10;;·//·After·Oldest·Trades·have·closed,·Forces·Take·Profit·to·BE·+/-·xx·Pips¤ input·double·CloseTPPips·10;;·//·After·Oldest·Trades·have·closed,·Forces·Take·Profit·to·BE·+/-·xx·Pips¤
input·double·ForceTPPips·0;;··//·Force·Take·Profit·to·BE·+/-·xx·Pips¤ input·double·ForceTPPips·0;;··//·Force·Take·Profit·to·BE·+/-·xx·Pips¤
input·double·MinTPPips·0;;····//·Ensure·Take·Profit·is·at·least·BE·+/-·xx·Pips¤ input·double·MinTPPips·0;;····//·Ensure·Take·Profit·is·at·least·BE·+/-·xx·Pips¤
¤ ¤
¤ ¤
input·string·LabelES·"";······//·-----------·····EXITS····-----------¤ input·string·LabelES·"";······//·-----------·····EXITS····-----------¤
input·bool·MaximizeProfit·false;;·····//·Turns·on·TP·move·and·Profit·Trailing·Stop·Feature¤ input·bool·MaximizeProfit·false;;·····//·Turns·on·TP·move·and·Profit·Trailing·Stop·Feature¤
input·double·ProfitSet·70;;···//·Profit·trailing·stop:·Lock·in·profit·at·set·percent·of·Total·Profit·Potential¤ input·double·ProfitSet·70;;···//·Profit·trailing·stop:·Lock·in·profit·at·set·percent·of·Total·Profit·Potential¤
input·double·MoveTP·30;;······//·Moves·TP·this·amount·in·pips¤ input·double·MoveTP·30;;······//·Moves·TP·this·amount·in·pips¤
input·int·TotalMoves·2;;······//·Number·of·times·you·want·TP·to·move·before·stopping·movement¤ input·int·TotalMoves·2;;······//·Number·of·times·you·want·TP·to·move·before·stopping·movement¤
input·bool·UseStopLoss·false;;········//·Use·Stop·Loss·and/or·Trailing·Stop·Loss¤ input·bool·UseStopLoss·false;;········//·Use·Stop·Loss·and/or·Trailing·Stop·Loss¤
input·double·SLPips·30;;······//·Pips·for·fixed·StopLoss·from·BE,·0=off¤ input·double·SLPips·30;;······//·Pips·for·fixed·StopLoss·from·BE,·0=off¤
input·double·TSLPips·10;;·····//·Pips·for·trailing·stop·loss·from·BE·TSLPips:·+ve·fixed·trail;·-ve·reducing·trail;·0=off¤ input·double·TSLPips·10;;·····//·Pips·for·trailing·stop·loss·from·BE·TSLPips:·+ve·fixed·trail;·-ve·reducing·trail;·0=off¤
input·double·TSLPipsMin·3;;···//·Minimum·trailing·stop·pips·if·using·reducing·TS¤ input·double·TSLPipsMin·3;;···//·Minimum·trailing·stop·pips·if·using·reducing·TS¤
input·bool·UsePowerOutSL·false;;······//·Transmits·SL·in·case·of·internet·loss¤ input·bool·UsePowerOutSL·false;;······//·Transmits·SL·in·case·of·internet·loss¤
input·double·POSLPips·600;;···//·Power·Out·Stop·Loss·in·pips¤ input·double·POSLPips·600;;···//·Power·Out·Stop·Loss·in·pips¤
input·bool·UseFIFO·false;;····//·Close·trades·in·FIFO·order¤ input·bool·UseFIFO·false;;····//·Close·trades·in·FIFO·order¤
¤ ¤
input·string·LabelEE·"";······//·---------···EARLY·EXITS···---------¤ input·string·LabelEE·"";······//·---------···EARLY·EXITS···---------¤
input·bool·UseEarlyExit·false;;·······//·Reduces·ProfitTarget·by·percentage·over·time·and·number·of·levels·open¤ input·bool·UseEarlyExit·false;;·······//·Reduces·ProfitTarget·by·percentage·over·time·and·number·of·levels·open¤
input·double·EEStartHours·3;;·//·Number·of·Hours·to·wait·before·EE·over·time·starts¤ input·double·EEStartHours·3;;·//·Number·of·Hours·to·wait·before·EE·over·time·starts¤
input·bool·EEFirstTrade·true;;········//·true·StartHours·from·FIRST·trade:·false·StartHours·from·LAST·trade¤ input·bool·EEFirstTrade·true;;········//·true·StartHours·from·FIRST·trade:·false·StartHours·from·LAST·trade¤
input·double·EEHoursPC·0.5;;··//·Percentage·reduction·per·hour·(0·OFF)¤ input·double·EEHoursPC·0.5;;··//·Percentage·reduction·per·hour·(0·OFF)¤
input·int·EEStartLevel·5;;····//·Number·of·Open·Trades·before·EE·over·levels·starts¤ input·int·EEStartLevel·5;;····//·Number·of·Open·Trades·before·EE·over·levels·starts¤
input·double·EELevelPC·10;;···//·Percentage·reduction·at·each·level·(0·OFF)¤ input·double·EELevelPC·10;;···//·Percentage·reduction·at·each·level·(0·OFF)¤
input·bool·EEAllowLoss·false;;········//·true·Will·allow·the·basket·to·close·at·loss·false·Minimum·profit·is·Break·Even¤ input·bool·EEAllowLoss·false;;········//·true·Will·allow·the·basket·to·close·at·loss·false·Minimum·profit·is·Break·Even¤
¤ ¤
input·string·LabelAdv·"";·····//.¤ input·string·LabelAdv·"";·····//.¤
input·string·LabelGrid·"";····//·---------····GRID·SIZE···---------¤ input·string·LabelGrid·"";····//·---------····GRID·SIZE···---------¤
input·string·SetCountArray·"4,4";;····//·Specifies·number·of·open·trades·in·each·block·(separated·by·comma)¤ input·string·SetCountArray·"4,4";;····//·Specifies·number·of·open·trades·in·each·block·(separated·by·comma)¤
input·string·GridSetArray·"25,50,100";;·······//·Specifies·number·of·pips·away·to·issue·limit·order·(separated·by·comma)¤ input·string·GridSetArray·"25,50,100";;·······//·Specifies·number·of·pips·away·to·issue·limit·order·(separated·by·comma)¤
input·string·TP_SetArray·"50,100,200";;·······//·Take·profit·for·each·block·(separated·by·comma)¤ input·string·TP_SetArray·"50,100,200";;·······//·Take·profit·for·each·block·(separated·by·comma)¤
¤ ¤
input·string·LabelEST0·"";····//· input·string·LabelEST0·"";····//·
input·string·LabelEST·"";·····//·==··ENTRY·PARAMETERS··==¤ input·string·LabelEST·"";·····//·==··ENTRY·PARAMETERS··==¤
input·string·LabelMA·"";······//·-------------·····MA·····-------------···¤ input·string·LabelMA·"";······//·-------------·····MA·····-------------···¤
input·entType·MAEntry·1;;·····//·MA·_Entry¤ input·entType·MAEntry·1;;·····//·MA·_Entry¤
input·int·MAPeriod·100;;······//·Period·of·MA·(H4·100,·H1·400)¤ input·int·MAPeriod·100;;······//·Period·of·MA·(H4·100,·H1·400)¤
input·double·MADistance·10;;··//·Distance·from·MA·to·be·treated·as·Ranging·Market¤ input·double·MADistance·10;;··//·Distance·from·MA·to·be·treated·as·Ranging·Market¤
¤ ¤
input·string·LabelCCI·"";·····//·-------------·····CCI·····-------------¤ input·string·LabelCCI·"";·····//·-------------·····CCI·····-------------¤
input·entType·CCIEntry·0;;····//·CCI·_Entry¤ input·entType·CCIEntry·0;;····//·CCI·_Entry¤
input·int·CCIPeriod·14;;······//·Period·for·CCI·calculation¤ input·int·CCIPeriod·14;;······//·Period·for·CCI·calculation¤
¤ ¤
input·string·LabelBBS·"";·····//·-----···BOLLINGER·BANDS···-----¤ input·string·LabelBBS·"";·····//·-----···BOLLINGER·BANDS···-----¤
input·entType·BollingerEntry·0;;······//·Bollinger·_Entry¤ input·entType·BollingerEntry·0;;······//·Bollinger·_Entry¤
input·int·BollPeriod·10;;·····//·Period·for·Bollinger¤ input·int·BollPeriod·10;;·····//·Period·for·Bollinger¤
input·double·BollDistance·10;;········//·Up/Down·spread¤ input·double·BollDistance·10;;········//·Up/Down·spread¤
input·double·BollDeviation·2.0;;······//·Standard·deviation·multiplier·for·channel¤ input·double·BollDeviation·2.0;;······//·Standard·deviation·multiplier·for·channel¤
¤ ¤
input·string·LabelSto·"";·····//·---------···STOCHASTIC···--------¤ input·string·LabelSto·"";·····//·---------···STOCHASTIC···--------¤
input·entType·StochEntry·0;;··//·Stochastic·_Entry¤ input·entType·StochEntry·0;;··//·Stochastic·_Entry¤
input·int·BuySellStochZone·20;;·······//·Determines·Overbought·and·Oversold·Zones¤ input·int·BuySellStochZone·20;;·······//·Determines·Overbought·and·Oversold·Zones¤
input·int·KPeriod·10;;········//·Stochastic·KPeriod¤ input·int·KPeriod·10;;········//·Stochastic·KPeriod¤
input·int·DPeriod·2;;·········//·Stochastic·DPeriod¤ input·int·DPeriod·2;;·········//·Stochastic·DPeriod¤
input·int·Slowing·2;;·········//·Stochastic·Slowing¤ input·int·Slowing·2;;·········//·Stochastic·Slowing¤
¤ ¤
input·string·LabelMACD·"";····//··------------····MACD····------------¤ input·string·LabelMACD·"";····//··------------····MACD····------------¤
input·entType·MACDEntry·0;;···//·MACD·_Entry¤ input·entType·MACDEntry·0;;···//·MACD·_Entry¤
input·ENUM_TIMEFRAMES·MACD_TF·0;;······//·Time·frame·for·MACD·calculation¤ input·ENUM_TIMEFRAMES·MACD_TF·0;;······//·Time·frame·for·MACD·calculation¤
//·0:Chart,·1:M1,·2:M5,·3:M15,·4:M30,·5:H1,·6:H4,·7:D1,·8:W1,·9:MN1¤ //·0:Chart,·1:M1,·2:M5,·3:M15,·4:M30,·5:H1,·6:H4,·7:D1,·8:W1,·9:MN1¤
input·int·FastPeriod·12;;·····//·MACD·EMA·Fast·Period¤ input·int·FastPeriod·12;;·····//·MACD·EMA·Fast·Period¤
input·int·SlowPeriod·26;;·····//·MACD·EMA·Slow·Period¤ input·int·SlowPeriod·26;;·····//·MACD·EMA·Slow·Period¤
input·int·SignalPeriod·9;;····//·MACD·EMA·Signal·Period¤ input·int·SignalPeriod·9;;····//·MACD·EMA·Signal·Period¤
input·ENUM_APPLIED_PRICE·MACDPrice·PRICE_CLOSE;;········//·MACD·Applied·Price¤ input·ENUM_APPLIED_PRICE·MACDPrice·PRICE_CLOSE;;········//·MACD·Applied·Price¤
//·0=close,·1=open,·2=high,·3=low,·4=HL/2,·5=HLC/3·6=HLCC/4¤ //·0=close,·1=open,·2=high,·3=low,·4=HL/2,·5=HLC/3·6=HLCC/4¤
¤ ¤
input·string·LabelSG·"";······//·---------···SMART·GRID···---------¤ input·string·LabelSG·"";······//·---------···SMART·GRID···---------¤
input·ENUM_TIMEFRAMES·RSI_TF·3;;·······//·Timeframe·for·RSI·calculation·(should·be·lower·than·chart·TF)¤ input·ENUM_TIMEFRAMES·RSI_TF·3;;·······//·Timeframe·for·RSI·calculation·(should·be·lower·than·chart·TF)¤
input·int·RSI_Period·14;;·····//·Period·for·RSI·calculation¤ input·int·RSI_Period·14;;·····//·Period·for·RSI·calculation¤
input·ENUM_APPLIED_PRICE·RSI_Price·PRICE_CLOSE;;········//·RSI·Applied·Price¤ input·ENUM_APPLIED_PRICE·RSI_Price·PRICE_CLOSE;;········//·RSI·Applied·Price¤
input·int·RSI_MA_Period·10;;··//·Period·for·MA·of·RSI·calculation¤ input·int·RSI_MA_Period·10;;··//·Period·for·MA·of·RSI·calculation¤
input·ENUM_MA_METHOD·RSI_MA_Method·MODE_SMA;;········//·RSI·MA·Method¤ input·ENUM_MA_METHOD·RSI_MA_Method·MODE_SMA;;········//·RSI·MA·Method¤
¤ ¤
¤ ¤
//·***********************************************************¤ //·***********************************************************¤
input·string·LabelHS0·"";·····//.¤ input·string·LabelHS0·"";·····//.¤
input·string·LabelHS·"";······//·------···HEDGE·SETTINGS···-----¤ input·string·LabelHS·"";······//·------···HEDGE·SETTINGS···-----¤
//·input·string···LabelHS1········"";··//.¤ //·input·string···LabelHS1········"";··//.¤
input·string·HedgeSymbol·"";;·//·Enter·the·Symbol·of·the·same/correlated·pair·EXACTLY·as·used·by·your·broker.¤ input·string·HedgeSymbol·"";;·//·Enter·the·Symbol·of·the·same/correlated·pair·EXACTLY·as·used·by·your·broker.¤
input·int·CorrPeriod·30;;·····//·Number·of·days·for·checking·Hedge·Correlation¤ input·int·CorrPeriod·30;;·····//·Number·of·days·for·checking·Hedge·Correlation¤
input·bool·UseHedge·false;;···//·Turns·DD·hedge·on/off¤ input·bool·UseHedge·false;;···//·Turns·DD·hedge·on/off¤
input·string·DDorLevel·"DD";;·//·DD·start·hedge·at·set·DD;Level·Start·at·set·level¤ input·string·DDorLevel·"DD";;·//·DD·start·hedge·at·set·DD;Level·Start·at·set·level¤
input·double·HedgeStart·20;;··//·DD·Percent·or·Level·at·which·Hedge·starts¤ input·double·HedgeStart·20;;··//·DD·Percent·or·Level·at·which·Hedge·starts¤
input·double·hLotMult·0.8;;···//·Hedge·Lots·Open·Lots·hLotMult¤ input·double·hLotMult·0.8;;···//·Hedge·Lots·Open·Lots·hLotMult¤
input·double·hMaxLossPips·30;;········//·DD·Hedge·maximum·pip·loss·also·hedge·trailing·stop¤ input·double·hMaxLossPips·30;;········//·DD·Hedge·maximum·pip·loss·also·hedge·trailing·stop¤
input·bool·hFixedSL·false;;···//·true·fixed·SL·at·hMaxLossPips¤ input·bool·hFixedSL·false;;···//·true·fixed·SL·at·hMaxLossPips¤
input·double·hTakeProfit·30;;·//·Hedge·Take·Profit¤ input·double·hTakeProfit·30;;·//·Hedge·Take·Profit¤
input·double·hReEntryPC·5;;···//·Increase·to·HedgeStart·to·stop·early·re-entry·of·the·hedge¤ input·double·hReEntryPC·5;;···//·Increase·to·HedgeStart·to·stop·early·re-entry·of·the·hedge¤
input·bool·StopTrailAtBE·true;;·······//·True·Trailing·Stop·will·stop·at·BE;False·Hedge·will·continue·into·profit¤ input·bool·StopTrailAtBE·true;;·······//·True·Trailing·Stop·will·stop·at·BE;False·Hedge·will·continue·into·profit¤
input·bool·ReduceTrailStop·true;;·····//·False·Trailing·Stop·is·Fixed;True·Trailing·Stop·will·reduce·after·BE·is·reached¤ input·bool·ReduceTrailStop·true;;·····//·False·Trailing·Stop·is·Fixed;True·Trailing·Stop·will·reduce·after·BE·is·reached¤
//·***********************************************************¤ //·***********************************************************¤
¤ ¤
input·string·LabelOS0·"";·····//.¤ input·string·LabelOS0·"";·····//.¤
input·string·LabelOS·"";······//·------------···OTHER···-----------¤ input·string·LabelOS·"";······//·------------···OTHER···-----------¤
input·bool·RecoupClosedLoss·true;;····//·true·Recoup·any·Hedge/CloseOldest·losses:·false·Use·original·profit·target.¤ input·bool·RecoupClosedLoss·true;;····//·true·Recoup·any·Hedge/CloseOldest·losses:·false·Use·original·profit·target.¤
input·int·Level·7;;···········//·Largest·Assumed·Basket·size.··Lower·number·higher·start·lots¤ input·int·Level·7;;···········//·Largest·Assumed·Basket·size.··Lower·number·higher·start·lots¤
int·slip·99;;¤ int·slip·99;;¤
input·bool·SaveStats·false;;··//·true·will·save·equity·statistics¤ input·bool·SaveStats·false;;··//·true·will·save·equity·statistics¤
input·int·StatsPeriod·3600;;··//·seconds·between·stats·entries·off·by·default¤ input·int·StatsPeriod·3600;;··//·seconds·between·stats·entries·off·by·default¤
input·bool·StatsInitialise·true;;·····//·true·for·backtest·false·for·forward/live·to·ACCUMULATE·equity·traces¤ input·bool·StatsInitialise·true;;·····//·true·for·backtest·false·for·forward/live·to·ACCUMULATE·equity·traces¤
¤ ¤
input·string·LabelUE·"";······//·------------···EMAIL···------------¤ input·string·LabelUE·"";······//·------------···EMAIL···------------¤
input·bool·UseEmail·false;;¤ input·bool·UseEmail·false;;¤
input·string·LabelEDD·"At·what·DD%·would·you·like·Email·warnings·(Max:·49,·Disable:·0)?";·····//.¤ input·string·LabelEDD·"At·what·DD%·would·you·like·Email·warnings·(Max:·49,·Disable:·0)?";·····//.¤
input·double·EmailDD1·20;;¤ input·double·EmailDD1·20;;¤
input·double·EmailDD2·30;;¤ input·double·EmailDD2·30;;¤
input·double·EmailDD3·40;;¤ input·double·EmailDD3·40;;¤
¤ ¤
input·string·LabelEH·"Hours·before·DD·timer·resets";··//.¤ input·string·LabelEH·"Hours·before·DD·timer·resets";··//.¤
input·double·EmailHours·24;;··//·Minimum·number·of·hours·between·emails¤ input·double·EmailHours·24;;··//·Minimum·number·of·hours·between·emails¤
¤ ¤
input·string·LabelDisplay·"";·//·------------···DISPLAY···-----------¤ input·string·LabelDisplay·"";·//·------------···DISPLAY···-----------¤
//·input·string···LabelDisplay·······"Used·to·Adjust·Overlay";·//.¤ //·input·string···LabelDisplay·······"Used·to·Adjust·Overlay";·//.¤
input·bool·background·false;·//·Show·Background¤ input·bool·background·false;·//·Show·Background¤
input·color·bgColor·Black;·//·Background·Color¤ input·color·bgColor·Black;·//·Background·Color¤
input·bool·displayOverlay·true;;······//·Enable·display¤ input·bool·displayOverlay·true;;······//·Enable·display¤
input·bool·displayLogo·true;;·//·Display·copyright·and·icon¤ input·bool·displayLogo·true;;·//·Display·copyright·and·icon¤
input·bool·displayCCI·true;;··//·Enable·CCI·display¤ input·bool·displayCCI·true;;··//·Enable·CCI·display¤
input·bool·displayLines·true;;········//·Show·BE,·TP·and·TS·lines¤ input·bool·displayLines·true;;········//·Show·BE,·TP·and·TS·lines¤
input·int·displayXcord·100;;··//·Left·right·offset¤ input·int·displayXcord·100;;··//·Left·right·offset¤
input·int·displayYcord·30;;···//·Up·down·offset¤ input·int·displayYcord·30;;···//·Up·down·offset¤
input·int·displayCCIxCord·10;;········//·Moves·CCI·display·left·and·right¤ input·int·displayCCIxCord·10;;········//·Moves·CCI·display·left·and·right¤
input·string·displayFont·"Arial·Bold";········//Display·font¤ input·string·displayFont·"Arial·Bold";········//Display·font¤
input·int·displayFontSize·9;;·//·Changes·size·of·display·characters¤ input·int·displayFontSize·9;;·//·Changes·size·of·display·characters¤
input·int·displaySpacing·14;;·//·Changes·space·between·lines¤ input·int·displaySpacing·14;;·//·Changes·space·between·lines¤
//·input·double···displayRatio·······1;;·//·Ratio·to·increase·label·width·spacing¤ //·input·double···displayRatio·······1;;·//·Ratio·to·increase·label·width·spacing¤
input·double·displayRatio·1.3;;·······//·Ratio·to·increase·label·width·spacing¤ input·double·displayRatio·1.3;;·······//·Ratio·to·increase·label·width·spacing¤
input·color·displayColor·DeepSkyBlue;;········//·default·color·of·display·characters¤ input·color·displayColor·DeepSkyBlue;;········//·default·color·of·display·characters¤
input·color·displayColorProfit·Green;;········//·default·color·of·profit·display·characters¤ input·color·displayColorProfit·Green;;········//·default·color·of·profit·display·characters¤
input·color·displayColorLoss·Red;;····//·default·color·of·loss·display·characters¤ input·color·displayColorLoss·Red;;····//·default·color·of·loss·display·characters¤
//·input·color·displayColorFGnd·White;;··//·default·color·of·ForeGround·Text·display·characters¤ //·input·color·displayColorFGnd·White;;··//·default·color·of·ForeGround·Text·display·characters¤
input·color·displayColorFGnd·Black;;··//·default·color·of·ForeGround·Text·display·characters¤ input·color·displayColorFGnd·Black;;··//·default·color·of·ForeGround·Text·display·characters¤
¤ ¤
input·bool·HideTestIndicators·true;¤  
input·bool·Debug·false;;¤ input·bool·Debug·false;;¤
¤ ¤
input·string·LabelGridOpt·"";·//·----···GRID·OPTIMIZATION···----¤ input·string·LabelGridOpt·"";·//·----···GRID·OPTIMIZATION···----¤
input·string·LabelOpt·"These·values·can·only·be·used·while·optimizing";·······//.¤ input·string·LabelOpt·"These·values·can·only·be·used·while·optimizing";·······//.¤
input·bool·UseGridOpt·false;;·//·Set·True·in·order·to·optimize·the·grid·settings.¤ input·bool·UseGridOpt·false;;·//·Set·True·in·order·to·optimize·the·grid·settings.¤
//·These·values·will·replace·the·normal·SetCountArray,¤ //·These·values·will·replace·the·normal·SetCountArray,¤
//·GridSetArray·and·TP_SetArray·during·optimization.¤ //·GridSetArray·and·TP_SetArray·during·optimization.¤
//·The·default·values·are·the·same·as·the·normal·array·defaults¤ //·The·default·values·are·the·same·as·the·normal·array·defaults¤
//·REMEMBER:¤ //·REMEMBER:¤
//·There·must·be·one·more·value·for·GridArray·and·TPArray¤ //·There·must·be·one·more·value·for·GridArray·and·TPArray¤
//·than·there·is·for·SetArray¤ //·than·there·is·for·SetArray¤
input·int·SetArray1·4;¤ input·int·SetArray1·4;¤
input·int·SetArray2·4;¤ input·int·SetArray2·4;¤
input·int·SetArray3·0;¤ input·int·SetArray3·0;¤
input·int·SetArray4·0;¤ input·int·SetArray4·0;¤
input·int·GridArray1·25;¤ input·int·GridArray1·25;¤
input·int·GridArray2·50;¤ input·int·GridArray2·50;¤
input·int·GridArray3·100;¤ input·int·GridArray3·100;¤
input·int·GridArray4·0;¤ input·int·GridArray4·0;¤
input·int·GridArray5·0;¤ input·int·GridArray5·0;¤
input·int·TPArray1·50;¤ input·int·TPArray1·50;¤
input·int·TPArray2·100;¤ input·int·TPArray2·100;¤
input·int·TPArray3·200;¤ input·int·TPArray3·200;¤
input·int·TPArray4·0;¤ input·int·TPArray4·0;¤
input·int·TPArray5·0;¤ input·int·TPArray5·0;¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Internal·Parameters·Set········································· //|·Internal·Parameters·Set·········································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
int·ca;¤ int·ca;¤
int·Magic,·hMagic;¤ int·Magic,·hMagic;¤
int·CbT,·CpT,·ChT;··············//·Count·basket·Total,Count·pending·Total,Count·hedge·Total¤ int·CbT,·CpT,·ChT;··············//·Count·basket·Total,Count·pending·Total,Count·hedge·Total¤
double·Pip,·hPip;¤ double·Pip,·hPip;¤
int·POSLCount;¤ int·POSLCount;¤
double·SLbL;····················//·Stop·Loss·basket·Last¤ double·SLbL;····················//·Stop·Loss·basket·Last¤
int·Moves;¤ int·Moves;¤
double·MaxDD;¤ double·MaxDD;¤
double·SLb;·····················//·Stop·Loss¤ double·SLb;·····················//·Stop·Loss¤
int·AccountType;¤ int·AccountType;¤
double·StopTradeBalance;¤ double·StopTradeBalance;¤
double·InitialAB;···············//·Initial·Account·Balance¤ double·InitialAB;···············//·Initial·Account·Balance¤
bool·Testing,·Visual;¤ bool·Testing,·Visual;¤
bool·AllowTrading;¤ bool·AllowTrading;¤
bool·EmergencyWarning;¤ bool·EmergencyWarning;¤
double·MaxDDPer;¤ double·MaxDDPer;¤
int·Error;¤ int·Error;¤
int·Set1Level,·Set2Level,·Set3Level,·Set4Level;¤ int·Set1Level,·Set2Level,·Set3Level,·Set4Level;¤
int·EmailCount;¤ int·EmailCount;¤
string·sTF;¤ string·sTF;¤
datetime·EmailSent;¤ datetime·EmailSent;¤
int·GridArray[,·2];¤ int·GridArray[,·2];¤
double·Lots[],·MinLotSize,·LotStep;¤ double·Lots[],·MinLotSize,·LotStep;¤
int·LotDecimal,·LotMult,·MinMult;¤ int·LotDecimal,·LotMult,·MinMult;¤
bool·PendLot;¤ bool·PendLot;¤
string·CS,·UAE;¤ string·CS,·UAE;¤
int·HolShutDown;¤ int·HolShutDown;¤
//·datetime·HolArray[,·4];¤ //·datetime·HolArray[,·4];¤
int·HolArray[,·4];¤ int·HolArray[,·4];¤
datetime·HolFirst,·HolLast,·NextStats,·OTbF;¤ datetime·HolFirst,·HolLast,·NextStats,·OTbF;¤
double·RSI[];¤ double·RSI[];¤
int·Digit[,·2],·TF[10]·0,·1,·5,·15,·30,·60,·240,·1440,·10080,·43200·};¤ int·Digit[,·2],·TF[10]·0,·1,·5,·15,·30,·60,·240,·1440,·10080,·43200·};¤
¤ ¤
double·Email[3];¤ double·Email[3];¤
double·PbC,·PhC,·hDDStart,·PbMax,·PbMin,·PhMax,·PhMin,·LastClosedPL,·ClosedPips,·SLh,·hLvlStart,·StatLowEquity,·StatHighEquity;¤ double·PbC,·PhC,·hDDStart,·PbMax,·PbMin,·PhMax,·PhMin,·LastClosedPL,·ClosedPips,·SLh,·hLvlStart,·StatLowEquity,·StatHighEquity;¤
datetime·EETime;¤ datetime·EETime;¤
int·hActive,·EECount,·TbF,·CbC,·CaL,·FileHandle;¤ int·hActive,·EECount,·TbF,·CbC,·CaL,·FileHandle;¤
bool·TradesOpen,·FileClosed,·HedgeTypeDD,·hThisChart,·hPosCorr,·dLabels,·FirstRun;¤ bool·TradesOpen,·FileClosed,·HedgeTypeDD,·hThisChart,·hPosCorr,·dLabels,·FirstRun;¤
string·FileName,·ID,·StatFile;¤ string·FileName,·ID,·StatFile;¤
double·TPb,·StopLevel,·TargetPips,·LbF,·bTS,·PortionBalance;¤ double·TPb,·StopLevel,·TargetPips,·LbF,·bTS,·PortionBalance;¤
bool·checkResult;¤ bool·checkResult;¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Input·Parameters·Requiring·Modifications·To·Entered·Values······ //|·Input·Parameters·Requiring·Modifications·To·Entered·Values······
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
int·EANumber_;¤ int·EANumber_;¤
double·EntryOffset_;¤ double·EntryOffset_;¤
double·MoveTP_;¤ double·MoveTP_;¤
double·MADistance_;¤ double·MADistance_;¤
double·BollDistance_;¤ double·BollDistance_;¤
double·POSLPips_;¤ double·POSLPips_;¤
double·hMaxLossPips_;¤ double·hMaxLossPips_;¤
double·hTakeProfit_;¤ double·hTakeProfit_;¤
double·CloseTPPips_;¤ double·CloseTPPips_;¤
double·ForceTPPips_;¤ double·ForceTPPips_;¤
double·MinTPPips_;¤ double·MinTPPips_;¤
double·BEPlusPips_;¤ double·BEPlusPips_;¤
double·SLPips_;¤ double·SLPips_;¤
double·TSLPips_;¤ double·TSLPips_;¤
double·TSLPipsMin_;¤ double·TSLPipsMin_;¤
string·HedgeSymbol_;¤ string·HedgeSymbol_;¤
bool·UseHedge_;¤ bool·UseHedge_;¤
double·HedgeStart_;¤ double·HedgeStart_;¤
double·StopTradePercent_;¤ double·StopTradePercent_;¤
double·ProfitSet_;¤ double·ProfitSet_;¤
double·EEHoursPC_;¤ double·EEHoursPC_;¤
double·EELevelPC_;¤ double·EELevelPC_;¤
double·hReEntryPC_;¤ double·hReEntryPC_;¤
double·PortionPC_;¤ double·PortionPC_;¤
double·Lot_;¤ double·Lot_;¤
bool·Debug_;¤ bool·Debug_;¤
mktCond·ForceMarketCond_;¤ mktCond·ForceMarketCond_;¤
entType·MAEntry_;¤ entType·MAEntry_;¤
entType·CCIEntry_;¤ entType·CCIEntry_;¤
entType·BollingerEntry_;¤ entType·BollingerEntry_;¤
entType·StochEntry_;¤ entType·StochEntry_;¤
entType·MACDEntry_;¤ entType·MACDEntry_;¤
int·MaxCloseTrades_;¤ int·MaxCloseTrades_;¤
double·Multiplier_;¤ double·Multiplier_;¤
string·SetCountArray_;¤ string·SetCountArray_;¤
string·GridSetArray_;¤ string·GridSetArray_;¤
string·TP_SetArray_;¤ string·TP_SetArray_;¤
bool·EmergencyCloseAll_;¤ bool·EmergencyCloseAll_;¤
bool·ShutDown_;¤ bool·ShutDown_;¤
¤ ¤
¤ ¤
int·ma_01_handle;¤ long·ma_01_handle;¤
int·gridATRHandle;¤ long·gridATRHandle;¤
int·cci_01_handle;¤ long·cci_01_handle;¤
int·cci_02_handle;¤ long·cci_02_handle;¤
int·cci_03_handle;¤ long·cci_03_handle;¤
int·cci_04_handle;¤ long·cci_04_handle;¤
¤ ¤
¤ ¤
int·ma1handle;¤ long·ma1handle;¤
int·stddevhandle;¤ long·stddevhandle;¤
int·stoch_0_handle;¤ long·stoch_0_handle;¤
¤ ¤
int·macd1_handle;¤ long·macd1_handle;¤
int·imaOnArrayHandle;¤ long·imaOnArrayHandle;¤
int·rsi1handle;¤ long·rsi1handle;¤
int·dailyMA1handle;¤ long·dailyMA1handle;¤
int·dailyMA2handle;¤ long·dailyMA2handle;¤
¤ ¤
string·pref·"requst2178";¤ string·pref·"requst2178";¤
string··········InpLoadedSymbol="NZDUSD";···//·Symbol·to·be·load¤ string··········InpLoadedSymbol="NZDUSD";···//·Symbol·to·be·load¤
ENUM_TIMEFRAMES·InpLoadedPeriod=PERIOD_H1;··//·Period·to·be·loaded¤ ENUM_TIMEFRAMES·InpLoadedPeriod=PERIOD_H1;··//·Period·to·be·loaded¤
datetime········InpStartDate=D'2006.01.01';·//·Start·date¤ datetime········InpStartDate=D'2006.01.01';·//·Start·date¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·expert·initialization·function·································· //|·expert·initialization·function··································
//+-----------------------------------------------------------------+·¤ //+-----------------------------------------------------------------+·¤
bool·firstStart·false;¤ bool·firstStart·false;¤
int·OnInit()· int·OnInit()·
TesterHideIndicators(HideTestIndicators);¤  
firstStart·false;¤ firstStart·false;¤
····EANumber_·EANumber;¤ ····EANumber_·EANumber;¤
····EntryOffset_·EntryOffset;¤ ····EntryOffset_·EntryOffset;¤
····MoveTP_·MoveTP;¤ ····MoveTP_·MoveTP;¤
····MADistance_·MADistance;¤ ····MADistance_·MADistance;¤
····BollDistance_·BollDistance;¤ ····BollDistance_·BollDistance;¤
····POSLPips_·POSLPips;¤ ····POSLPips_·POSLPips;¤
····hMaxLossPips_·hMaxLossPips;¤ ····hMaxLossPips_·hMaxLossPips;¤
····hTakeProfit_·hTakeProfit;¤ ····hTakeProfit_·hTakeProfit;¤
····CloseTPPips_·CloseTPPips;¤ ····CloseTPPips_·CloseTPPips;¤
····ForceTPPips_·ForceTPPips;¤ ····ForceTPPips_·ForceTPPips;¤
····MinTPPips_·MinTPPips;¤ ····MinTPPips_·MinTPPips;¤
····BEPlusPips_·BEPlusPips;¤ ····BEPlusPips_·BEPlusPips;¤
····SLPips_·SLPips;¤ ····SLPips_·SLPips;¤
····TSLPips_·TSLPips;¤ ····TSLPips_·TSLPips;¤
····TSLPipsMin_·TSLPipsMin;¤ ····TSLPipsMin_·TSLPipsMin;¤
····HedgeSymbol_·HedgeSymbol;¤ ····HedgeSymbol_·HedgeSymbol;¤
····UseHedge_·UseHedge;¤ ····UseHedge_·UseHedge;¤
····HedgeStart_·HedgeStart;¤ ····HedgeStart_·HedgeStart;¤
····StopTradePercent_·StopTradePercent;¤ ····StopTradePercent_·StopTradePercent;¤
····ProfitSet_·ProfitSet;¤ ····ProfitSet_·ProfitSet;¤
····EEHoursPC_·EEHoursPC;¤ ····EEHoursPC_·EEHoursPC;¤
····EELevelPC_·EELevelPC;¤ ····EELevelPC_·EELevelPC;¤
····hReEntryPC_·hReEntryPC;¤ ····hReEntryPC_·hReEntryPC;¤
····PortionPC_·PortionPC;¤ ····PortionPC_·PortionPC;¤
»   if·(PortionPC·100)·PortionPC_·100;·//·r.f.¤ »   if·(PortionPC·100)·PortionPC_·100;·//·r.f.¤
····Lot_·Lot;¤ ····Lot_·Lot;¤
····Debug_·Debug;¤ ····Debug_·Debug;¤
····ForceMarketCond_·ForceMarketCond;¤ ····ForceMarketCond_·ForceMarketCond;¤
····MAEntry_·MAEntry;¤ ····MAEntry_·MAEntry;¤
····CCIEntry_·CCIEntry;¤ ····CCIEntry_·CCIEntry;¤
····BollingerEntry_·BollingerEntry;¤ ····BollingerEntry_·BollingerEntry;¤
····StochEntry_·StochEntry;¤ ····StochEntry_·StochEntry;¤
····MACDEntry_·MACDEntry;¤ ····MACDEntry_·MACDEntry;¤
····MaxCloseTrades_·MaxCloseTrades;¤ ····MaxCloseTrades_·MaxCloseTrades;¤
····Multiplier_·Multiplier;¤ ····Multiplier_·Multiplier;¤
····SetCountArray_·SetCountArray;¤ ····SetCountArray_·SetCountArray;¤
····GridSetArray_·GridSetArray;¤ ····GridSetArray_·GridSetArray;¤
····TP_SetArray_·TP_SetArray;¤ ····TP_SetArray_·TP_SetArray;¤
····EmergencyCloseAll_·EmergencyCloseAll;¤ ····EmergencyCloseAll_·EmergencyCloseAll;¤
····ShutDown_·ShutDown;¤ ····ShutDown_·ShutDown;¤
//TesterHideIndicators(true);¤ //TesterHideIndicators(true);¤
¤ ¤
¤ ¤
¤ ¤
····ChartSetInteger(0,·CHART_SHOW_GRID,·false);¤ ····ChartSetInteger(0,·CHART_SHOW_GRID,·false);¤
····CS·"Waiting·for·next·tick·.";·····//·To·display·comments·while·testing,·simply·use·CS·....·and¤ ····CS·"Waiting·for·next·tick·.";·····//·To·display·comments·while·testing,·simply·use·CS·....·and¤
····Comment(CS);················//·it·will·be·displayed·by·the·line·at·the·end·of·the·start()·block.¤ ····Comment(CS);················//·it·will·be·displayed·by·the·line·at·the·end·of·the·start()·block.¤
····CS·"";¤ ····CS·"";¤
····Testing·MQLInfoInteger(MQL_TESTER);¤ ····Testing·MQLInfoInteger(MQL_TESTER);¤
····Visual·MQLInfoInteger(MQL_VISUAL_MODE);¤ ····Visual·MQLInfoInteger(MQL_VISUAL_MODE);¤
····FirstRun·true;¤ ····FirstRun·true;¤
····AllowTrading·true;¤ ····AllowTrading·true;¤
¤ ¤
····if·(EANumber_·1)¤ ····if·(EANumber_·1)¤
········EANumber_·1;¤ ········EANumber_·1;¤
¤ ¤
····if·(Testing)¤ ····if·(Testing)¤
········EANumber_·0;¤ ········EANumber_·0;¤
¤ ¤
····Magic·GenerateMagicNumber();¤ ····Magic·GenerateMagicNumber();¤
····hMagic·JenkinsHash((string)·Magic);¤ ····hMagic·JenkinsHash((string)·Magic);¤
····FileName·"B3_"·(string)·Magic·".dat";¤ ····FileName·"B3_"·(string)·Magic·".dat";¤
¤ ¤
····if·(Debug_)· ····if·(Debug_)·
········Print("Magic·Number:·",·DTS(Magic,·0));¤ ········Print("Magic·Number:·",·DTS(Magic,·0));¤
········Print("Hedge·Number:·",·DTS(hMagic,·0));¤ ········Print("Hedge·Number:·",·DTS(hMagic,·0));¤
········Print("FileName:·",·FileName);¤ ········Print("FileName:·",·FileName);¤
···· ····
¤ ¤
····Pip·Point();¤ ····Pip·Point();¤
¤ ¤
····if·(Digits()·==·1)¤ ····if·(Digits()·==·1)¤
········Pip·*=·10;¤ ········Pip·*=·10;¤
¤ ¤
····if·(NanoAccount)¤ ····if·(NanoAccount)¤
········AccountType·10;¤ ········AccountType·10;¤
····else¤ ····else¤
········AccountType·1;¤ ········AccountType·1;¤
¤ ¤
····MoveTP_·ND(MoveTP_·Pip,·Digits());¤ ····MoveTP_·ND(MoveTP_·Pip,·Digits());¤
····EntryOffset_·ND(EntryOffset_·Pip,·Digits());¤ ····EntryOffset_·ND(EntryOffset_·Pip,·Digits());¤
····MADistance_·ND(MADistance_·Pip,·Digits());¤ ····MADistance_·ND(MADistance_·Pip,·Digits());¤
····BollDistance_·ND(BollDistance_·Pip,·Digits());¤ ····BollDistance_·ND(BollDistance_·Pip,·Digits());¤
····POSLPips_·ND(POSLPips_·Pip,·Digits());¤ ····POSLPips_·ND(POSLPips_·Pip,·Digits());¤
····hMaxLossPips_·ND(hMaxLossPips_·Pip,·Digits());¤ ····hMaxLossPips_·ND(hMaxLossPips_·Pip,·Digits());¤
····hTakeProfit_·ND(hTakeProfit_·Pip,·Digits());¤ ····hTakeProfit_·ND(hTakeProfit_·Pip,·Digits());¤
····CloseTPPips_·ND(CloseTPPips_·Pip,·Digits());¤ ····CloseTPPips_·ND(CloseTPPips_·Pip,·Digits());¤
····ForceTPPips_·ND(ForceTPPips_·Pip,·Digits());¤ ····ForceTPPips_·ND(ForceTPPips_·Pip,·Digits());¤
····MinTPPips_·ND(MinTPPips_·Pip,·Digits());¤ ····MinTPPips_·ND(MinTPPips_·Pip,·Digits());¤
····BEPlusPips_·ND(BEPlusPips_·Pip,·Digits());¤ ····BEPlusPips_·ND(BEPlusPips_·Pip,·Digits());¤
····SLPips_·ND(SLPips_·Pip,·Digits());¤ ····SLPips_·ND(SLPips_·Pip,·Digits());¤
····TSLPips_·ND(TSLPips·Pip,·Digits());¤ ····TSLPips_·ND(TSLPips·Pip,·Digits());¤
····TSLPipsMin_·ND(TSLPipsMin_·Pip,·Digits());¤ ····TSLPipsMin_·ND(TSLPipsMin_·Pip,·Digits());¤
¤ ¤
····if·(UseHedge_)· ····if·(UseHedge_)·
········if·(HedgeSymbol_·==·"")¤ ········if·(HedgeSymbol_·==·"")¤
············HedgeSymbol_·Symbol();¤ ············HedgeSymbol_·Symbol();¤
¤ ¤
········if·(HedgeSymbol_·==·Symbol())¤ ········if·(HedgeSymbol_·==·Symbol())¤
············hThisChart·true;¤ ············hThisChart·true;¤
········else¤ ········else¤
············hThisChart·false;¤ ············hThisChart·false;¤
¤ ¤
········hPip·SymbolInfoDouble(HedgeSymbol_,·SYMBOL_POINT);¤ ········hPip·SymbolInfoDouble(HedgeSymbol_,·SYMBOL_POINT);¤
········int·hDigits·(int)·SymbolInfoInteger(HedgeSymbol_,·SYMBOL_DIGITS);¤ ········int·hDigits·(int)·SymbolInfoInteger(HedgeSymbol_,·SYMBOL_DIGITS);¤
¤ ¤
········if·(hDigits·==·1)¤ ········if·(hDigits·==·1)¤
············hPip·*=·10;¤ ············hPip·*=·10;¤
¤ ¤
········if·(CheckCorr()·0.9·||·hThisChart)¤ ········if·(CheckCorr()·0.9·||·hThisChart)¤
············hPosCorr·true;¤ ············hPosCorr·true;¤
········else·if·(CheckCorr()·-0.9)¤ ········else·if·(CheckCorr()·-0.9)¤
············hPosCorr·false;¤ ············hPosCorr·false;¤
········else· ········else·
············AllowTrading·false;¤ ············AllowTrading·false;¤
············UseHedge_·false;¤ ············UseHedge_·false;¤
············Print("The·specified·Hedge·symbol·(",·HedgeSymbol_,·")·is·not·closely·correlated·with·",·Symbol());¤ ············Print("The·specified·Hedge·symbol·(",·HedgeSymbol_,·")·is·not·closely·correlated·with·",·Symbol());¤
········ ········
¤ ¤
········if·(StringSubstr(DDorLevel,·0,·1)·==·"D"·||·StringSubstr(DDorLevel,·0,·1)·==·"d")¤ ········if·(StringSubstr(DDorLevel,·0,·1)·==·"D"·||·StringSubstr(DDorLevel,·0,·1)·==·"d")¤
············HedgeTypeDD·true;¤ ············HedgeTypeDD·true;¤
········else·if·(StringSubstr(DDorLevel,·0,·1)·==·"L"·||·StringSubstr(DDorLevel,·0,·1)·==·"l")¤ ········else·if·(StringSubstr(DDorLevel,·0,·1)·==·"L"·||·StringSubstr(DDorLevel,·0,·1)·==·"l")¤
············HedgeTypeDD·false;¤ ············HedgeTypeDD·false;¤
········else¤ ········else¤
············UseHedge_·false;¤ ············UseHedge_·false;¤
¤ ¤
········if·(HedgeTypeDD)· ········if·(HedgeTypeDD)·
············HedgeStart_·/=·100;¤ ············HedgeStart_·/=·100;¤
············hDDStart·HedgeStart_;¤ ············hDDStart·HedgeStart_;¤
········ ········
···· ····
¤ ¤
····StopTradePercent_·/=·100;¤ ····StopTradePercent_·/=·100;¤
····ProfitSet_·/=·100;¤ ····ProfitSet_·/=·100;¤
····EEHoursPC_·/=·100;¤ ····EEHoursPC_·/=·100;¤
····EELevelPC_·/=·100;¤ ····EELevelPC_·/=·100;¤
····hReEntryPC_·/=·100;¤ ····hReEntryPC_·/=·100;¤
····PortionPC_·/=·100;¤ ····PortionPC_·/=·100;¤
¤ ¤
····InitialAB·AccountInfoDouble(ACCOUNT_BALANCE);¤ ····InitialAB·AccountInfoDouble(ACCOUNT_BALANCE);¤
»   //·PortionPC·now·does·double·duty.··If·100·serves·as·forced·balance¤ »   //·PortionPC·now·does·double·duty.··If·100·serves·as·forced·balance¤
»   //··assuming·the·real·balance·is·greater·than·PortionPC¤ »   //··assuming·the·real·balance·is·greater·than·PortionPC¤
»   if·(PortionPC·100·&&·InitialAB·PortionPC)· »   if·(PortionPC·100·&&·InitialAB·PortionPC)·
»   »   InitialAB·PortionPC;¤ »   »   InitialAB·PortionPC;¤
»   }¤ »   }¤
»   Print("***·Account·balance:··DTS(InitialAB,·0));¤ »   Print("***·Account·balance:··DTS(InitialAB,·0));¤
····StopTradeBalance·InitialAB·(1·StopTradePercent_);¤ ····StopTradeBalance·InitialAB·(1·StopTradePercent_);¤
¤ ¤
····if·(Testing)¤ ····if·(Testing)¤
········ID·"B3Test.";¤ ········ID·"B3Test.";¤
····else¤ ····else¤
········ID·DTS(Magic,·0)·".";¤ ········ID·DTS(Magic,·0)·".";¤
¤ ¤
····//HideTestIndicators(true);¤ ····//HideTestIndicators(true);¤
¤ ¤
····MinLotSize·SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);¤ ····MinLotSize·SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);¤
¤ ¤
····if·(MinLotSize·Lot_)· ····if·(MinLotSize·Lot_)·
········Print("Lot·is·less·than·minimum·lot·size·permitted·for·this·account");¤ ········Print("Lot·is·less·than·minimum·lot·size·permitted·for·this·account");¤
········AllowTrading·false;¤ ········AllowTrading·false;¤
···· ····
¤ ¤
····LotStep·SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_STEP);¤ ····LotStep·SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_STEP);¤
····double·MinLot·MathMin(MinLotSize,·LotStep);¤ ····double·MinLot·MathMin(MinLotSize,·LotStep);¤
····LotMult·(int)·ND(MathMax(Lot_,·MinLotSize)·MinLot,·0);¤ ····LotMult·(int)·ND(MathMax(Lot_,·MinLotSize)·MinLot,·0);¤
····MinMult·LotMult;¤ ····MinMult·LotMult;¤
····Lot_·MinLot;¤ ····Lot_·MinLot;¤
¤ ¤
····if·(MinLot·0.01)¤ ····if·(MinLot·0.01)¤
········LotDecimal·3;¤ ········LotDecimal·3;¤
····else·if·(MinLot·0.1)¤ ····else·if·(MinLot·0.1)¤
········LotDecimal·2;¤ ········LotDecimal·2;¤
····else·if·(MinLot·1)¤ ····else·if·(MinLot·1)¤
········LotDecimal·1;¤ ········LotDecimal·1;¤
····else¤ ····else¤
········LotDecimal·0;¤ ········LotDecimal·0;¤
¤ ¤
····FileHandle·FileOpen(FileName,·FILE_BIN·FILE_READ);¤ ····FileHandle·FileOpen(FileName,·FILE_BIN·FILE_READ);¤
¤ ¤
····if·(FileHandle·!=·-1)· ····if·(FileHandle·!=·-1)·
········TbF·FileReadInteger(FileHandle,·INT_VALUE);¤ ········TbF·FileReadInteger(FileHandle,·INT_VALUE);¤
········FileClose(FileHandle);¤ ········FileClose(FileHandle);¤
········Error·GetLastError();¤ ········Error·GetLastError();¤
¤ ¤
········if·(OrderSelect(TbF))· ········if·(OrderSelect(TbF))·
············OTbF·(datetime)OrderGetInteger(ORDER_TIME_SETUP);¤ ············OTbF·OrderGetInteger(ORDER_TIME_SETUP);¤
············LbF·OrderGetDouble(ORDER_VOLUME_CURRENT);¤ ············LbF·OrderGetDouble(ORDER_VOLUME_CURRENT);¤
············LotMult·(int)·MathMax(1,·LbF·MinLot);¤ ············LotMult·(int)·MathMax(1,·LbF·MinLot);¤
············PbC·FindClosedPL(B);¤ ············PbC·FindClosedPL(B);¤
············PhC·FindClosedPL(H);¤ ············PhC·FindClosedPL(H);¤
············TradesOpen·true;¤ ············TradesOpen·true;¤
¤ ¤
············if·(Debug_)¤ ············if·(Debug_)¤
················Print(FileName,·File·Read:·",·TbF,·Lots:·",·DTS(LbF,·LotDecimal));¤ ················Print(FileName,·File·Read:·",·TbF,·Lots:·",·DTS(LbF,·LotDecimal));¤
········else· ········else·
············FileDelete(FileName);¤ ············FileDelete(FileName);¤
············TbF·0;¤ ············TbF·0;¤
············OTbF·0;¤ ············OTbF·0;¤
············LbF·0;¤ ············LbF·0;¤
············Error·GetLastError();¤ ············Error·GetLastError();¤
¤ ¤
············if·(Error·==·0)· ············if·(Error·==·0)·
················if·(Debug_)¤ ················if·(Debug_)¤
····················Print(FileName,·File·Deleted");¤ ····················Print(FileName,·File·Deleted");¤
············else¤ ············else¤
················Print("Error·",·Error,·deleting·file·",·FileName);¤ ················Print("Error·",·Error,·deleting·file·",·FileName);¤
········ ········
···· ····
¤ ¤
····GlobalVariableSet(ID·"LotMult",·LotMult);¤ ····GlobalVariableSet(ID·"LotMult",·LotMult);¤
¤ ¤
····if·(Debug_)¤ ····if·(Debug_)¤
········Print("MinLotSize:·",·DTS(MinLotSize,·2),·LotStep:·",·DTS(LotStep,·2),·MinLot:·",·DTS(MinLot,·2),·StartLot:·",·DTS(Lot_,·2),·LotMult:·",·DTS(LotMult,·0),·Lot·Decimal:·",·DTS(LotDecimal,·0));¤ ········Print("MinLotSize:·",·DTS(MinLotSize,·2),·LotStep:·",·DTS(LotStep,·2),·MinLot:·",·DTS(MinLot,·2),·StartLot:·",·DTS(Lot_,·2),·LotMult:·",·DTS(LotMult,·0),·Lot·Decimal:·",·DTS(LotDecimal,·0));¤
¤ ¤
····EmergencyWarning·EmergencyCloseAll_;¤ ····EmergencyWarning·EmergencyCloseAll_;¤
¤ ¤
····if·MQLInfoInteger(MQL_OPTIMIZATION))¤ ····if·MQLInfoInteger(MQL_OPTIMIZATION))¤
········Debug_·false;¤ ········Debug_·false;¤
¤ ¤
····if·(UseAnyEntry)¤ ····if·(UseAnyEntry)¤
········UAE·"||";¤ ········UAE·"||";¤
····else¤ ····else¤
········UAE·"&&";¤ ········UAE·"&&";¤
¤ ¤
····if·(ForceMarketCond_·||·ForceMarketCond_·3)¤ ····if·(ForceMarketCond_·||·ForceMarketCond_·3)¤
········ForceMarketCond_·3;¤ ········ForceMarketCond_·3;¤
¤ ¤
····if·(MAEntry_·||·MAEntry_·2)¤ ····if·(MAEntry_·||·MAEntry_·2)¤
········MAEntry_·0;¤ ········MAEntry_·0;¤
¤ ¤
····if·(CCIEntry_·||·CCIEntry_·2)¤ ····if·(CCIEntry_·||·CCIEntry_·2)¤
········CCIEntry_·0;¤ ········CCIEntry_·0;¤
¤ ¤
····if·(BollingerEntry_·||·BollingerEntry_·2)¤ ····if·(BollingerEntry_·||·BollingerEntry_·2)¤
········BollingerEntry_·0;¤ ········BollingerEntry_·0;¤
¤ ¤
····if·(StochEntry_·||·StochEntry_·2)¤ ····if·(StochEntry_·||·StochEntry_·2)¤
········StochEntry_·0;¤ ········StochEntry_·0;¤
¤ ¤
····if·(MACDEntry_·||·MACDEntry_·2)¤ ····if·(MACDEntry_·||·MACDEntry_·2)¤
········MACDEntry_·0;¤ ········MACDEntry_·0;¤
¤ ¤
····if·(MaxCloseTrades_·==·0)¤ ····if·(MaxCloseTrades_·==·0)¤
········MaxCloseTrades_·MaxTrades;¤ ········MaxCloseTrades_·MaxTrades;¤
¤ ¤
····ArrayResize(Digit,·6);¤ ····ArrayResize(Digit,·6);¤
¤ ¤
····for·(int·Index·0;·Index·ArrayRange(Digit,·0);·Index++)· ····for·(int·Index·0;·Index·ArrayRange(Digit,·0);·Index++)·
········if·(Index·0)¤ ········if·(Index·0)¤
············Digit[Index,·0]·(int)·MathPow(10,·Index);¤ ············Digit[Index,·0]·(int)·MathPow(10,·Index);¤
¤ ¤
········Digit[Index,·1]·Index;¤ ········Digit[Index,·1]·Index;¤
¤ ¤
········if·(Debug_)¤ ········if·(Debug_)¤
············Print("Digit:·",·Index,·[",·Digit[Index,·0],·",·",·Digit[Index,·1],·"]");¤ ············Print("Digit:·",·Index,·[",·Digit[Index,·0],·",·",·Digit[Index,·1],·"]");¤
···· ····
¤ ¤
···¤ ···¤
······if(background)¤ ······if(background)¤
··· ···
···for(int·x=0;x<21;x++)·//·¤ ···for(int·x=0;x<21;x++)·//·¤
···for(int·w=0;w<15;w++)¤ ···for(int·w=0;w<15;w++)¤
······ ······
·········ObjectCreate(ChartID(),pref+"Bkgrd"+(string)x+(string)w,OBJ_LABEL,0,0,0,0,0);¤ ·········ObjectCreate(ChartID(),pref+"Bkgrd"+x+w,OBJ_LABEL,0,0,0,0,0);¤
·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+(string)x+(string)w,OBJPROP_CORNER,0);¤ ·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_CORNER,0);¤
·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+(string)x+(string)w,OBJPROP_XDISTANCE,x*24+displayXcord-4);¤ ·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_XDISTANCE,x*24+displayXcord-4);¤
·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+(string)x+(string)w,OBJPROP_YDISTANCE,w*24+displayYcord-10);¤ ·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_YDISTANCE,w*24+displayYcord-10);¤
·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+(string)x+(string)w,OBJPROP_ZORDER,0);¤ ·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_ZORDER,0);¤
·········ObjectSetText("Bkgrd"+(string)x+(string)w,CharToString(110),32,"Wingdings",bgColor);¤ ·········ObjectSetText("Bkgrd"+x+w,CharToString(110),32,"Wingdings",bgColor);¤
······ ······
···¤ ···¤
ChartRedraw();¤ ChartRedraw();¤
¤ ¤
····LabelCreate();¤ ····LabelCreate();¤
····dLabels·false;¤ ····dLabels·false;¤
¤ ¤
¤ ¤
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Set·Lot·Array··················································· ····//|·Set·Lot·Array···················································
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····ArrayResize(Lots,·MaxTrades);¤ ····ArrayResize(Lots,·MaxTrades);¤
¤ ¤
····for·(int·Index·0;·Index·MaxTrades;·Index++)· ····for·(int·Index·0;·Index·MaxTrades;·Index++)·
········if·(Index·==·||·Multiplier_·1)¤ ········if·(Index·==·||·Multiplier_·1)¤
············Lots[Index]·Lot_;¤ ············Lots[Index]·Lot_;¤
········else¤ ········else¤
············Lots[Index]·ND(MathMax(Lots[Index·1]·Multiplier_,·Lots[Index·1]·LotStep),·LotDecimal);¤ ············Lots[Index]·ND(MathMax(Lots[Index·1]·Multiplier_,·Lots[Index·1]·LotStep),·LotDecimal);¤
¤ ¤
········if·(Debug_)¤ ········if·(Debug_)¤
············Print("Lot·Size·for·level·",·DTS(Index·1,·0),·",·DTS(Lots[Index]·MathMax(LotMult,·1),·LotDecimal));¤ ············Print("Lot·Size·for·level·",·DTS(Index·1,·0),·",·DTS(Lots[Index]·MathMax(LotMult,·1),·LotDecimal));¤
···· ····
¤ ¤
····if·(Multiplier_·1)¤ ····if·(Multiplier_·1)¤
········Multiplier_·1;¤ ········Multiplier_·1;¤
¤ ¤
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Set·Grid·and·TP·array··········································· ····//|·Set·Grid·and·TP·array···········································
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····int·GridSet·0,·GridTemp,·GridTP,·GridIndex·0,·GridLevel·0,·GridError·0;¤ ····int·GridSet·0,·GridTemp,·GridTP,·GridIndex·0,·GridLevel·0,·GridError·0;¤
¤ ¤
····if·(!AutoCal)· ····if·(!AutoCal)·
········ArrayResize(GridArray,·MaxTrades);¤ ········ArrayResize(GridArray,·MaxTrades);¤
¤ ¤
········if·(MQLInfoInteger(MQL_OPTIMIZATION)·&&·UseGridOpt)· ········if·(MQLInfoInteger(MQL_OPTIMIZATION)·&&·UseGridOpt)·
············if·(SetArray1·0)· ············if·(SetArray1·0)·
················SetCountArray_·DTS(SetArray1,·0);¤ ················SetCountArray_·DTS(SetArray1,·0);¤
················GridSetArray_·DTS(GridArray1,·0);¤ ················GridSetArray_·DTS(GridArray1,·0);¤
················TP_SetArray_·DTS(TPArray1,·0);¤ ················TP_SetArray_·DTS(TPArray1,·0);¤
············ ············
¤ ¤
············if·(SetArray2·||·(SetArray1·&&·GridArray2·0))· ············if·(SetArray2·||·(SetArray1·&&·GridArray2·0))·
················if·(SetArray2·0)¤ ················if·(SetArray2·0)¤
····················SetCountArray_·SetCountArray_·","·DTS(SetArray2,·0);¤ ····················SetCountArray_·SetCountArray_·","·DTS(SetArray2,·0);¤
¤ ¤
················GridSetArray_·GridSetArray_·","·DTS(GridArray2,·0);¤ ················GridSetArray_·GridSetArray_·","·DTS(GridArray2,·0);¤
················TP_SetArray_·TP_SetArray_·","·DTS(TPArray2,·0);¤ ················TP_SetArray_·TP_SetArray_·","·DTS(TPArray2,·0);¤
············ ············
¤ ¤
············if·(SetArray3·||·(SetArray2·&&·GridArray3·0))· ············if·(SetArray3·||·(SetArray2·&&·GridArray3·0))·
················if·(SetArray3·0)¤ ················if·(SetArray3·0)¤
····················SetCountArray_·SetCountArray_·","·DTS(SetArray3,·0);¤ ····················SetCountArray_·SetCountArray_·","·DTS(SetArray3,·0);¤
¤ ¤
················GridSetArray_·GridSetArray_·","·DTS(GridArray3,·0);¤ ················GridSetArray_·GridSetArray_·","·DTS(GridArray3,·0);¤
················TP_SetArray_·TP_SetArray_·","·DTS(TPArray3,·0);¤ ················TP_SetArray_·TP_SetArray_·","·DTS(TPArray3,·0);¤
············ ············
¤ ¤
············if·(SetArray4·||·(SetArray3·&&·GridArray4·0))· ············if·(SetArray4·||·(SetArray3·&&·GridArray4·0))·
················if·(SetArray4·0)¤ ················if·(SetArray4·0)¤
····················SetCountArray_·SetCountArray_·","·DTS(SetArray4,·0);¤ ····················SetCountArray_·SetCountArray_·","·DTS(SetArray4,·0);¤
¤ ¤
················GridSetArray_·GridSetArray_·","·DTS(GridArray4,·0);¤ ················GridSetArray_·GridSetArray_·","·DTS(GridArray4,·0);¤
················TP_SetArray_·TP_SetArray_·","·DTS(TPArray4,·0);¤ ················TP_SetArray_·TP_SetArray_·","·DTS(TPArray4,·0);¤
············ ············
¤ ¤
············if·(SetArray4·&&·GridArray5·0)· ············if·(SetArray4·&&·GridArray5·0)·
················GridSetArray_·GridSetArray_·","·DTS(GridArray5,·0);¤ ················GridSetArray_·GridSetArray_·","·DTS(GridArray5,·0);¤
················TP_SetArray_·TP_SetArray_·","·DTS(TPArray5,·0);¤ ················TP_SetArray_·TP_SetArray_·","·DTS(TPArray5,·0);¤
············ ············
········ ········
¤ ¤
········while·(GridIndex·MaxTrades)· ········while·(GridIndex·MaxTrades)·
············if·(StringFind(SetCountArray_,·",")·==·-1·&&·GridIndex·==·0)· ············if·(StringFind(SetCountArray_,·",")·==·-1·&&·GridIndex·==·0)·
················GridError·1;¤ ················GridError·1;¤
················break;¤ ················break;¤
············else¤ ············else¤
················GridSet·(int)(StringSubstr(SetCountArray_,·0,·StringFind(SetCountArray_,·",")));¤ ················GridSet·StringToInteger(StringSubstr(SetCountArray_,·0,·StringFind(SetCountArray_,·",")));¤
¤ ¤
············if·(GridSet·0)· ············if·(GridSet·0)·
················SetCountArray_·StringSubstr(SetCountArray_,·StringFind(SetCountArray_,·",")·1);¤ ················SetCountArray_·StringSubstr(SetCountArray_,·StringFind(SetCountArray_,·",")·1);¤
················GridTemp·(int)(StringSubstr(GridSetArray_,·0,·StringFind(GridSetArray_,·",")));¤ ················GridTemp·StringToInteger(StringSubstr(GridSetArray_,·0,·StringFind(GridSetArray_,·",")));¤
················GridSetArray_·StringSubstr(GridSetArray_,·StringFind(GridSetArray_,·",")·1);¤ ················GridSetArray_·StringSubstr(GridSetArray_,·StringFind(GridSetArray_,·",")·1);¤
················GridTP·(int)(StringSubstr(TP_SetArray_,·0,·StringFind(TP_SetArray_,·",")));¤ ················GridTP·StringToInteger(StringSubstr(TP_SetArray_,·0,·StringFind(TP_SetArray_,·",")));¤
················TP_SetArray_·StringSubstr(TP_SetArray_,·StringFind(TP_SetArray_,·",")·1);¤ ················TP_SetArray_·StringSubstr(TP_SetArray_,·StringFind(TP_SetArray_,·",")·1);¤
············else¤ ············else¤
················GridSet·MaxTrades;¤ ················GridSet·MaxTrades;¤
¤ ¤
············if·(GridTemp·==·||·GridTP·==·0)· ············if·(GridTemp·==·||·GridTP·==·0)·
················GridError·2;¤ ················GridError·2;¤
················break;¤ ················break;¤
············ ············
¤ ¤
············for·(GridLevel·GridIndex;·GridLevel·<=·MathMin(GridIndex·GridSet·1,·MaxTrades·1);·GridLevel++)· ············for·(GridLevel·GridIndex;·GridLevel·<=·MathMin(GridIndex·GridSet·1,·MaxTrades·1);·GridLevel++)·
················GridArray[GridLevel,·0]·GridTemp;¤ ················GridArray[GridLevel,·0]·GridTemp;¤
················GridArray[GridLevel,·1]·GridTP;¤ ················GridArray[GridLevel,·1]·GridTP;¤
¤ ¤
················if·(Debug_)¤ ················if·(Debug_)¤
····················Print("GridArray·",·(GridLevel·1),·":·[",·GridArray[GridLevel,·0],·",·",·GridArray[GridLevel,·1],·"]");¤ ····················Print("GridArray·",·(GridLevel·1),·":·[",·GridArray[GridLevel,·0],·",·",·GridArray[GridLevel,·1],·"]");¤
············ ············
¤ ¤
············GridIndex·GridLevel;¤ ············GridIndex·GridLevel;¤
········ ········
¤ ¤
········if·(GridError·||·GridArray[0,·0]·==·||·GridArray[0,·1]·==·0)· ········if·(GridError·||·GridArray[0,·0]·==·||·GridArray[0,·1]·==·0)·
············if·(GridError·==·1)¤ ············if·(GridError·==·1)¤
················Print("Grid·Array·Error.·Each·value·should·be·separated·by·comma.");¤ ················Print("Grid·Array·Error.·Each·value·should·be·separated·by·comma.");¤
············else¤ ············else¤
················Print("Grid·Array·Error.·Check·that·there·is·one·more·'Grid'·and·'TP'·entry·than·there·are·'Set'·numbers·separated·by·commas.");¤ ················Print("Grid·Array·Error.·Check·that·there·is·one·more·'Grid'·and·'TP'·entry·than·there·are·'Set'·numbers·separated·by·commas.");¤
¤ ¤
············AllowTrading·false;¤ ············AllowTrading·false;¤
········ ········
····else· ····else·
········while·(GridIndex·4)· ········while·(GridIndex·4)·
············GridSet·(int)(StringSubstr(SetCountArray_,·0,·StringFind(SetCountArray_,·",")));¤ ············GridSet·StringToInteger(StringSubstr(SetCountArray_,·0,·StringFind(SetCountArray_,·",")));¤
············SetCountArray_·StringSubstr(SetCountArray_,·StringFind(SetCountArray_,·DTS(GridSet,·0))·2);¤ ············SetCountArray_·StringSubstr(SetCountArray_,·StringFind(SetCountArray_,·DTS(GridSet,·0))·2);¤
¤ ¤
············if·(GridIndex·==·&&·GridSet·1)· ············if·(GridIndex·==·&&·GridSet·1)·
················GridError·1;¤ ················GridError·1;¤
················break;¤ ················break;¤
············ ············
¤ ¤
············if·(GridSet·0)¤ ············if·(GridSet·0)¤
················GridLevel·+=·GridSet;¤ ················GridLevel·+=·GridSet;¤
············else·if·(GridLevel·MaxTrades)¤ ············else·if·(GridLevel·MaxTrades)¤
················GridLevel·MaxTrades;¤ ················GridLevel·MaxTrades;¤
············else¤ ············else¤
················GridLevel·MaxTrades·1;¤ ················GridLevel·MaxTrades·1;¤
¤ ¤
············if·(GridIndex·==·0)¤ ············if·(GridIndex·==·0)¤
················Set1Level·GridLevel;¤ ················Set1Level·GridLevel;¤
············else·if·(GridIndex·==·&&·GridLevel·<=·MaxTrades)¤ ············else·if·(GridIndex·==·&&·GridLevel·<=·MaxTrades)¤
················Set2Level·GridLevel;¤ ················Set2Level·GridLevel;¤
············else·if·(GridIndex·==·&&·GridLevel·<=·MaxTrades)¤ ············else·if·(GridIndex·==·&&·GridLevel·<=·MaxTrades)¤
················Set3Level·GridLevel;¤ ················Set3Level·GridLevel;¤
············else·if·(GridIndex·==·&&·GridLevel·<=·MaxTrades)¤ ············else·if·(GridIndex·==·&&·GridLevel·<=·MaxTrades)¤
················Set4Level·GridLevel;¤ ················Set4Level·GridLevel;¤
¤ ¤
············GridIndex++;¤ ············GridIndex++;¤
········ ········
¤ ¤
········if·(GridError·==·||·Set1Level·==·0)· ········if·(GridError·==·||·Set1Level·==·0)·
············Print("Error·setting·up·Grid·Levels.·Check·that·the·SetCountArray·contains·valid·numbers·separated·by·commas.");¤ ············Print("Error·setting·up·Grid·Levels.·Check·that·the·SetCountArray·contains·valid·numbers·separated·by·commas.");¤
············AllowTrading·false;¤ ············AllowTrading·false;¤
········ ········
···· ····
¤ ¤
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Set·holidays·array·············································· ····//|·Set·holidays·array··············································
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····if·(UseHolidayShutdown)· ····if·(UseHolidayShutdown)·
········int·HolTemp·0,·NumHols,·NumBS·0,·HolCounter·0;¤ ········int·HolTemp·0,·NumHols,·NumBS·0,·HolCounter·0;¤
········string·HolTempStr;¤ ········string·HolTempStr;¤
¤ ¤
»   »   //·holidays·are·separated·by·commas¤ »   »   //·holidays·are·separated·by·commas¤
»   »   //·18/12-01/01¤ »   »   //·18/12-01/01¤
········if·(StringFind(Holidays,·",",·0)·==·-1)·//·no·comma·if·just·one·holiday¤ ········if·(StringFind(Holidays,·",",·0)·==·-1)·//·no·comma·if·just·one·holiday¤
············NumHols·1;¤ ············NumHols·1;¤
········else· ········else·
············NumHols·1;¤ ············NumHols·1;¤
············while·(HolTemp·!=·-1)· ············while·(HolTemp·!=·-1)·
················HolTemp·StringFind(Holidays,·",",·HolTemp·1);¤ ················HolTemp·StringFind(Holidays,·",",·HolTemp·1);¤
················if·(HolTemp·!=·-1)·NumHols++;¤ ················if·(HolTemp·!=·-1)·NumHols++;¤
············ ············
········ ········
········HolTemp·0;¤ ········HolTemp·0;¤
········while·(HolTemp·!=·-1)· ········while·(HolTemp·!=·-1)·
············HolTemp·StringFind(Holidays,·"/",·HolTemp·1);¤ ············HolTemp·StringFind(Holidays,·"/",·HolTemp·1);¤
············if·(HolTemp·!=·-1)·NumBS++;¤ ············if·(HolTemp·!=·-1)·NumBS++;¤
········ ········
¤ ¤
········if·(NumBS·!=·NumHols·2)· ········if·(NumBS·!=·NumHols·2)·
············Print("Holidays·Error,·number·of·back-slashes·(",·NumBS,·")·should·be·equal·to·2*·number·of·Holidays·(",¤ ············Print("Holidays·Error,·number·of·back-slashes·(",·NumBS,·")·should·be·equal·to·2*·number·of·Holidays·(",¤
»   »   »   »   NumHols,·",·and·separators·should·be·commas.");¤ »   »   »   »   NumHols,·",·and·separators·should·be·commas.");¤
············AllowTrading·false;¤ ············AllowTrading·false;¤
········else· ········else·
············HolTemp·0;¤ ············HolTemp·0;¤
············string·hol·Holidays;¤ ············string·hol·Holidays;¤
············ArrayResize(HolArray,·NumHols);¤ ············ArrayResize(HolArray,·NumHols);¤
············while·(HolTemp·!=·-1)· ············while·(HolTemp·!=·-1)·
················string·StringSubstr(hol,·0,·StringFind(hol,·",",·HolTemp));¤ ················string·StringSubstr(hol,·0,·StringFind(hol,·",",·HolTemp));¤
················StringTrimRight(a);¤ ················string·=·StringTrimRight(a);¤
················if·(HolTemp·==·0)¤ ················if·(HolTemp·==·0)¤
················  
····················StringTrimLeft(a);¤  
····················HolTempStr·a ····················HolTempStr·StringTrimLeft(b)
················  
················else¤ ················else¤
················ ················
··················string·b·StringSubstr(hol,·HolTemp·1,·StringFind(hol,·",",·HolTemp·1)·StringFind(hol,·",",·HolTemp)·1);¤ ··················string·c·StringSubstr(hol,·HolTemp·1,¤
  »   »   »   »   »   »   StringFind(hol,·",",·HolTemp·1)·StringFind(hol,·",",·HolTemp)·1);¤
»   »   »   »   »   »   StringTrimRight(b);¤ »   »   »   »   »   »   string·StringTrimRight(c);¤
··················StringTrimLeft(b);¤  
··················HolTempStr·b ····················HolTempStr·StringTrimLeft(d)
················ ················
················HolTemp·StringFind(hol,·",",·HolTemp·1);¤ ················HolTemp·StringFind(hol,·",",·HolTemp·1);¤
················HolArray[HolCounter,·0]·(int)(StringSubstr(StringSubstr(HolTempStr,·0,·StringFind(HolTempStr,·"-",·0)),¤ ················HolArray[HolCounter,·0]·StringToInteger(StringSubstr(StringSubstr(HolTempStr,·0,·StringFind(HolTempStr,·"-",·0)),¤
»   »   »   »   »   ············································StringFind(StringSubstr(HolTempStr,·0,·StringFind(HolTempStr,·"-",·0)),·"/")·1));¤ »   »   »   »   »   StringFind(StringSubstr(HolTempStr,·0,·StringFind(HolTempStr,·"-",·0)),·"/")·1));¤
················HolArray[HolCounter,·1]·(int)(StringSubstr(StringSubstr(HolTempStr,·0,·StringFind(HolTempStr,·"-",·0)),·0,¤ ················HolArray[HolCounter,·1]·StringToInteger(StringSubstr(StringSubstr(HolTempStr,·0,·StringFind(HolTempStr,·"-",·0)),·0,¤
»   »   »   »   »   StringFind(StringSubstr(HolTempStr,·0,·StringFind(HolTempStr,·"-",·0)),·"/")));¤ »   »   »   »   »   StringFind(StringSubstr(HolTempStr,·0,·StringFind(HolTempStr,·"-",·0)),·"/")));¤
················HolArray[HolCounter,·2]·(int)(StringSubstr(StringSubstr(HolTempStr,·StringFind(HolTempStr,·"-",·0)·1),¤ ················HolArray[HolCounter,·2]·StringToInteger(StringSubstr(StringSubstr(HolTempStr,·StringFind(HolTempStr,·"-",·0)·1),¤
»   »   »   »   »   StringFind(StringSubstr(HolTempStr,·StringFind(HolTempStr,·"-",·0)·1),·"/")·1));¤ »   »   »   »   »   StringFind(StringSubstr(HolTempStr,·StringFind(HolTempStr,·"-",·0)·1),·"/")·1));¤
················HolArray[HolCounter,·3]·(int)(StringSubstr(StringSubstr(HolTempStr,·StringFind(HolTempStr,·"-",·0)·1),·0,¤ ················HolArray[HolCounter,·3]·StringToInteger(StringSubstr(StringSubstr(HolTempStr,·StringFind(HolTempStr,·"-",·0)·1),·0,¤
»   »   »   »   »   StringFind(StringSubstr(HolTempStr,·StringFind(HolTempStr,·"-",·0)·1),·"/")));¤ »   »   »   »   »   StringFind(StringSubstr(HolTempStr,·StringFind(HolTempStr,·"-",·0)·1),·"/")));¤
················HolCounter++;¤ ················HolCounter++;¤
············ ············
········ ········
¤ ¤
········for·(HolTemp·0;·HolTemp·HolCounter;·HolTemp++)· ········for·(HolTemp·0;·HolTemp·HolCounter;·HolTemp++)·
············datetime·Start1,·Start2;¤ ············datetime·Start1,·Start2;¤
»   »   »   int·Temp0,·Temp1,·Temp2,·Temp3;¤ »   »   »   int·Temp0,·Temp1,·Temp2,·Temp3;¤
············for·(int·Item1·HolTemp·1;·Item1·HolCounter;·Item1++)· ············for·(int·Item1·HolTemp·1;·Item1·HolCounter;·Item1++)·
················Start1·(datetime)·HolArray[HolTemp,·0]·100·HolArray[HolTemp,·1];¤ ················Start1·(datetime)·HolArray[HolTemp,·0]·100·HolArray[HolTemp,·1];¤
················Start2·(datetime)·HolArray[Item1,·0]·100·HolArray[Item1,·1];¤ ················Start2·(datetime)·HolArray[Item1,·0]·100·HolArray[Item1,·1];¤
················if·(Start1·Start2)· ················if·(Start1·Start2)·
····················Temp0·HolArray[Item1,·0];¤ ····················Temp0·HolArray[Item1,·0];¤
····················Temp1·HolArray[Item1,·1];¤ ····················Temp1·HolArray[Item1,·1];¤
····················Temp2·HolArray[Item1,·2];¤ ····················Temp2·HolArray[Item1,·2];¤
····················Temp3·HolArray[Item1,·3];¤ ····················Temp3·HolArray[Item1,·3];¤
····················HolArray[Item1,·0]·HolArray[HolTemp,·0];¤ ····················HolArray[Item1,·0]·HolArray[HolTemp,·0];¤
····················HolArray[Item1,·1]·HolArray[HolTemp,·1];¤ ····················HolArray[Item1,·1]·HolArray[HolTemp,·1];¤
····················HolArray[Item1,·2]·HolArray[HolTemp,·2];¤ ····················HolArray[Item1,·2]·HolArray[HolTemp,·2];¤
····················HolArray[Item1,·3]·HolArray[HolTemp,·3];¤ ····················HolArray[Item1,·3]·HolArray[HolTemp,·3];¤
····················HolArray[HolTemp,·0]·Temp0;¤ ····················HolArray[HolTemp,·0]·Temp0;¤
····················HolArray[HolTemp,·1]·Temp1;¤ ····················HolArray[HolTemp,·1]·Temp1;¤
····················HolArray[HolTemp,·2]·Temp2;¤ ····················HolArray[HolTemp,·2]·Temp2;¤
····················HolArray[HolTemp,·3]·Temp3;¤ ····················HolArray[HolTemp,·3]·Temp3;¤
················ ················
············ ············
········ ········
¤ ¤
········if·(Debug_)· ········if·(Debug_)·
············for·(HolTemp·0;·HolTemp·HolCounter;·HolTemp++)¤ ············for·(HolTemp·0;·HolTemp·HolCounter;·HolTemp++)¤
················Print("Holidays·From:·",·HolArray[HolTemp,·1],·"/",·HolArray[HolTemp,·0],·",¤ ················Print("Holidays·From:·",·HolArray[HolTemp,·1],·"/",·HolArray[HolTemp,·0],·",¤
»   »   »   »   »   HolArray[HolTemp,·3],·"/",·HolArray[HolTemp,·2]);¤ »   »   »   »   »   HolArray[HolTemp,·3],·"/",·HolArray[HolTemp,·2]);¤
········ ········
···· ····
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Set·email·parameters············································ ····//|·Set·email·parameters············································
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····if·(UseEmail)· ····if·(UseEmail)·
········if·(Period()·==·43200)¤ ········if·(Period()·==·43200)¤
············sTF·"MN1";¤ ············sTF·"MN1";¤
········else·if·(Period()·==·10800)¤ ········else·if·(Period()·==·10800)¤
············sTF·"W1";¤ ············sTF·"W1";¤
········else·if·(Period()·==·1440)¤ ········else·if·(Period()·==·1440)¤
············sTF·"D1";¤ ············sTF·"D1";¤
········else·if·(Period()·==·240)¤ ········else·if·(Period()·==·240)¤
············sTF·"H4";¤ ············sTF·"H4";¤
········else·if·(Period()·==·60)¤ ········else·if·(Period()·==·60)¤
············sTF·"H1";¤ ············sTF·"H1";¤
········else·if·(Period()·==·30)¤ ········else·if·(Period()·==·30)¤
············sTF·"M30";¤ ············sTF·"M30";¤
········else·if·(Period()·==·15)¤ ········else·if·(Period()·==·15)¤
············sTF·"M15";¤ ············sTF·"M15";¤
········else·if·(Period()·==·5)¤ ········else·if·(Period()·==·5)¤
············sTF·"M5";¤ ············sTF·"M5";¤
········else·if·(Period()·==·1)¤ ········else·if·(Period()·==·1)¤
············sTF·"M1";¤ ············sTF·"M1";¤
¤ ¤
········Email[0]·MathMax(MathMin(EmailDD1,·MaxDDPercent·1),·0)·100;¤ ········Email[0]·MathMax(MathMin(EmailDD1,·MaxDDPercent·1),·0)·100;¤
········Email[1]·MathMax(MathMin(EmailDD2,·MaxDDPercent·1),·0)·100;¤ ········Email[1]·MathMax(MathMin(EmailDD2,·MaxDDPercent·1),·0)·100;¤
········Email[2]·MathMax(MathMin(EmailDD3,·MaxDDPercent·1),·0)·100;¤ ········Email[2]·MathMax(MathMin(EmailDD3,·MaxDDPercent·1),·0)·100;¤
········ArraySort(Email);¤ ········ArraySort(Email);¤
¤ ¤
········for·(int·0;·<=·2;·z++)· ········for·(int·0;·<=·2;·z++)·
············for·(int·Index·0;·Index·<=·2;·Index++)· ············for·(int·Index·0;·Index·<=·2;·Index++)·
················if·(Email[Index]·==·0)· ················if·(Email[Index]·==·0)·
····················Email[Index]·Email[Index·1];¤ ····················Email[Index]·Email[Index·1];¤
····················Email[Index·1]·0;¤ ····················Email[Index·1]·0;¤
················ ················
············ ············
¤ ¤
············if·(Debug_)¤ ············if·(Debug_)¤
················Print("Email·[",·(z·1),·"]·",·Email[z]);¤ ················Print("Email·[",·(z·1),·"]·",·Email[z]);¤
········ ········
···· ····
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Set·SmartGrid·parameters········································ ····//|·Set·SmartGrid·parameters········································
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····if·(UseSmartGrid)· ····if·(UseSmartGrid)·
········ArrayResize(RSI,·RSI_Period·RSI_MA_Period);¤ ········ArrayResize(RSI,·RSI_Period·RSI_MA_Period);¤
········ArraySetAsSeries(RSI,·true);¤ ········ArraySetAsSeries(RSI,·true);¤
···· ····
····//+---------------------------------------------------------------+¤ ····//+---------------------------------------------------------------+¤
····//|·Initialize·Statistics········································· ····//|·Initialize·Statistics·········································
····//+---------------------------------------------------------------+¤ ····//+---------------------------------------------------------------+¤
····if·(SaveStats)· ····if·(SaveStats)·
········StatFile·"B3"·Symbol()·"_"·(string)·Period()·"_"·(string)·EANumber_·".csv";¤ ········StatFile·"B3"·Symbol()·"_"·(string)·Period()·"_"·(string)·EANumber_·".csv";¤
········NextStats·TimeCurrent();¤ ········NextStats·TimeCurrent();¤
»   »   //·new·PortionPC·behavior·...·r.f.¤ »   »   //·new·PortionPC·behavior·...·r.f.¤
»   »   double·temp_account_balance·AccountInfoDouble(ACCOUNT_BALANCE);¤ »   »   double·temp_account_balance·AccountInfoDouble(ACCOUNT_BALANCE);¤
»   »   if·(PortionPC·100·&&·temp_account_balance·PortionPC)· »   »   if·(PortionPC·100·&&·temp_account_balance·PortionPC)·
»   »   »   Stats(StatsInitialise,·false,·PortionPC,·0);¤ »   »   »   Stats(StatsInitialise,·false,·PortionPC,·0);¤
»   »   }·else· »   »   }·else·
»   »   »   Stats(StatsInitialise,·false,·temp_account_balance·PortionPC_,·0);¤ »   »   »   Stats(StatsInitialise,·false,·temp_account_balance·PortionPC_,·0);¤
»   »   }¤ »   »   }¤
···· ····
¤ ¤
¤ ¤
····return·(0);¤ ····return·(0);¤
····//+---------------------------------------------------------------+¤ ····//+---------------------------------------------------------------+¤
····//|·Initialize·Custom·Optimization·Criteria······················· ····//|·Initialize·Custom·Optimization·Criteria·······················
····//+---------------------------------------------------------------+¤ ····//+---------------------------------------------------------------+¤
···double·OnTester()¤ ···double·OnTester()¤
···double··param·0.0;¤ ···double··param·0.0;¤
¤ ¤
//··Balance·max·min·Drawdown·Trades·Number:¤ //··Balance·max·min·Drawdown·Trades·Number:¤
··double··balance·TesterStatistics(STAT_PROFIT);¤ ··double··balance·TesterStatistics(STAT_PROFIT);¤
··double··min_dd·TesterStatistics(STAT_BALANCE_DD);¤ ··double··min_dd·TesterStatistics(STAT_BALANCE_DD);¤
··if(min_dd·0.0)¤ ··if(min_dd·0.0)¤
·· ··
····min_dd·1.0·min_dd;¤ ····min_dd·1.0·min_dd;¤
·· ··
··double··trades_number·TesterStatistics(STAT_TRADES);¤ ··double··trades_number·TesterStatistics(STAT_TRADES);¤
··param·balance·balance·trades_number·min_dd;¤ ··param·balance·balance·trades_number·min_dd;¤
¤ ¤
··return(param);¤ ··return(param);¤
¤ ¤
¤ ¤
¤ ¤
¤ ¤
¤ ¤
¤ ¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·expert·deinitialization·function································ //|·expert·deinitialization·function································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
void·OnDeinit(const·int·reason)· void·OnDeinit(const·int·reason)·
if·(!Testing)¤  
for(int·ObjectsTotal(ChartID());·i>=0;·i--)¤ for(int·ObjectsTotal(ChartID());·i>=0;·i--)¤
···if(StringFind(ObjectName(ChartID(),i),pref)!=-1)¤ ···if(StringFind(ObjectName(ChartID(),i),pref)!=-1)¤
··· ···
······ObjectDelete(ChartID(),ObjectName(ChartID(),i));¤ ······ObjectDelete(ChartID(),ObjectName(ChartID(),i));¤
··· ···
····switch·(UninitializeReason())· ····switch·(UninitializeReason())·
····case·REASON_REMOVE:¤ ····case·REASON_REMOVE:¤
····case·REASON_CHARTCLOSE:¤ ····case·REASON_CHARTCLOSE:¤
····case·REASON_CHARTCHANGE:¤ ····case·REASON_CHARTCHANGE:¤
········if·(CpT·0)· ········if·(CpT·0)·
············while·(CpT·0)¤ ············while·(CpT·0)¤
················CpT·-=·ExitTrades(P,·displayColorLoss,·"Blessing·Removed");¤ ················CpT·-=·ExitTrades(P,·displayColorLoss,·"Blessing·Removed");¤
········ ········
¤ ¤
········GlobalVariablesDeleteAll(ID);¤ ········GlobalVariablesDeleteAll(ID);¤
····case·REASON_RECOMPILE:¤ ····case·REASON_RECOMPILE:¤
····case·REASON_PARAMETERS:¤ ····case·REASON_PARAMETERS:¤
····case·REASON_ACCOUNT:¤ ····case·REASON_ACCOUNT:¤
········if·(!Testing)¤ ········if·(!Testing)¤
············LabelDelete();¤ ············LabelDelete();¤
¤ ¤
········Comment("");¤ ········Comment("");¤
···· ····
¤ ¤
····return;¤ ····return;¤
¤ ¤
¤ ¤
datetime·OncePerBarTime·0;¤ datetime·OncePerBarTime·0;¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Once·Per·Bar·function····returns·true·once·per·bar·············· //|·Once·Per·Bar·function····returns·true·once·per·bar··············
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
bool·OncePerBar()· bool·OncePerBar()·
····if·(!EnableOncePerBar·||·FirstRun)¤ ····if·(!EnableOncePerBar·||·FirstRun)¤
········return·(true);··········//·always·return·true·if·disabled¤ ········return·(true);··········//·always·return·true·if·disabled¤
¤ ¤
····if·(OncePerBarTime·!=·iTime(Symbol(),Period(),0))· ····if·(OncePerBarTime·!=·iTime(Symbol(),Period(),0))·
········OncePerBarTime·iTime(Symbol(),Period(),0);¤ ········OncePerBarTime·iTime(Symbol(),Period(),0);¤
········return·(true);··········//·true,·our·first·time·this·bar¤ ········return·(true);··········//·true,·our·first·time·this·bar¤
···· ····
¤ ¤
····return·(false);¤ ····return·(false);¤
¤ ¤
double·LbT·0;·················//·total·lots·out¤ double·LbT·0;·················//·total·lots·out¤
¤ ¤
double·previous_stop_trade_amount;¤ double·previous_stop_trade_amount;¤
double·stop_trade_amount;¤ double·stop_trade_amount;¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·expert·start·function··········································· //|·expert·start·function···········································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
¤ ¤
void·OnTick()· void·OnTick()·
if(!firstStart)¤ if(!firstStart)¤
···firstStart·true;¤ ···firstStart·true;¤
···ma_01_handle·iMA(Symbol(),·PERIOD_CURRENT,·MAPeriod,·0,·MODE_EMA,·PRICE_CLOSE);¤ ···ma_01_handle·iMA(Symbol(),·PERIOD_CURRENT,·MAPeriod,·0,·MODE_EMA,·PRICE_CLOSE);¤
¤ ¤
gridATRHandle·iATR(Symbol(),·ATRTF,·ATRPeriods);¤ gridATRHandle·iATR(Symbol(),·ATRTF,·ATRPeriods);¤
¤ ¤
cci_01_handle·iCCI(Symbol(),·PERIOD_M5,·CCIPeriod,·PRICE_CLOSE);¤ cci_01_handle·iCCI(Symbol(),·PERIOD_M5,·CCIPeriod,·PRICE_CLOSE);¤
cci_02_handle·iCCI(Symbol(),·PERIOD_M15,·CCIPeriod,·PRICE_CLOSE);¤ cci_02_handle·iCCI(Symbol(),·PERIOD_M15,·CCIPeriod,·PRICE_CLOSE);¤
cci_03_handle·iCCI(Symbol(),·PERIOD_M30,·CCIPeriod,·PRICE_CLOSE);¤ cci_03_handle·iCCI(Symbol(),·PERIOD_M30,·CCIPeriod,·PRICE_CLOSE);¤
cci_04_handle·iCCI(Symbol(),·PERIOD_H1,·CCIPeriod,·PRICE_CLOSE);¤ cci_04_handle·iCCI(Symbol(),·PERIOD_H1,·CCIPeriod,·PRICE_CLOSE);¤
¤ ¤
ma1handle·iMA(Symbol(),·PERIOD_CURRENT,·BollPeriod,·0,·MODE_SMA,·PRICE_OPEN);¤ ma1handle·iMA(Symbol(),·PERIOD_CURRENT,·BollPeriod,·0,·MODE_SMA,·PRICE_OPEN);¤
stddevhandle·iStdDev(Symbol(),·PERIOD_CURRENT,·BollPeriod,·0,·MODE_SMA,·PRICE_OPEN);¤ stddevhandle·iStdDev(Symbol(),·PERIOD_CURRENT,·BollPeriod,·0,·MODE_SMA,·PRICE_OPEN);¤
stoch_0_handle·iStochastic(Symbol(),·PERIOD_CURRENT,·KPeriod,·DPeriod,·Slowing,·MODE_LWMA,·1);¤ stoch_0_handle·iStochastic(Symbol(),·PERIOD_CURRENT,·KPeriod,·DPeriod,·Slowing,·MODE_LWMA,·1);¤
¤ ¤
macd1_handle·iMACD(Symbol(),·MACD_TF,·FastPeriod,·SlowPeriod,·SignalPeriod,·MACDPrice);¤ macd1_handle·iMACD(Symbol(),·MACD_TF,·FastPeriod,·SlowPeriod,·SignalPeriod,·MACDPrice);¤
Print(macd1_handle);¤ Print(macd1_handle);¤
rsi1handle·iRSI(Symbol(),·RSI_TF,·RSI_Period,·RSI_Price);¤ rsi1handle·iRSI(Symbol(),·RSI_TF,·RSI_Period,·RSI_Price);¤
¤ ¤
dailyMA1handle·=iMA(Symbol(),·PERIOD_D1,·CorrPeriod,·0,·MODE_SMA,·PRICE_CLOSE);¤ dailyMA1handle·=iMA(Symbol(),·PERIOD_D1,·CorrPeriod,·0,·MODE_SMA,·PRICE_CLOSE);¤
if(HedgeSymbol_!="")¤ if(HedgeSymbol_!="")¤
dailyMA2handle·iMA(HedgeSymbol_,·PERIOD_D1,·CorrPeriod,·0,·MODE_SMA,·PRICE_CLOSE);¤ dailyMA2handle·iMA(HedgeSymbol_,·PERIOD_D1,·CorrPeriod,·0,·MODE_SMA,·PRICE_CLOSE);¤
//LoadHistory();¤ //LoadHistory();¤
····int·CbB·0;················//·Count·buy¤ ····int·CbB·0;················//·Count·buy¤
····int·CbS·0;················//·Count·sell¤ ····int·CbS·0;················//·Count·sell¤
····int·CpBL·0;···············//·Count·buy·limit¤ ····int·CpBL·0;···············//·Count·buy·limit¤
····int·CpSL·0;···············//·Count·sell·limit¤ ····int·CpSL·0;···············//·Count·sell·limit¤
····int·CpBS·0;···············//·Count·buy·stop¤ ····int·CpBS·0;···············//·Count·buy·stop¤
····int·CpSS·0;···············//·Count·sell·stop¤ ····int·CpSS·0;···············//·Count·sell·stop¤
····double·LbB·0;·············//·Count·buy·lots¤ ····double·LbB·0;·············//·Count·buy·lots¤
····double·LbS·0;·············//·Count·sell·lots¤ ····double·LbS·0;·············//·Count·sell·lots¤
//·double···LbT··········=0;·····//·total·lots·out¤ //·double···LbT··········=0;·····//·total·lots·out¤
····double·OPpBL·0;···········//·Buy·limit·open·price¤ ····double·OPpBL·0;···········//·Buy·limit·open·price¤
····double·OPpSL·0;···········//·Sell·limit·open·price¤ ····double·OPpSL·0;···········//·Sell·limit·open·price¤
····double·SLbB·0;············//·stop·losses·are·set·to·zero·if·POSL·off¤ ····double·SLbB·0;············//·stop·losses·are·set·to·zero·if·POSL·off¤
····double·SLbS·0;············//·stop·losses·are·set·to·zero·if·POSL·off¤ ····double·SLbS·0;············//·stop·losses·are·set·to·zero·if·POSL·off¤
····double·BCb·0,·BCh·0,·BCa;·······//·Broker·costs·(swap·commission)¤ ····double·BCb·0,·BCh·0,·BCa;·······//·Broker·costs·(swap·commission)¤
····double·ProfitPot·0;·······//·The·Potential·Profit·of·basket·of·Trades¤ ····double·ProfitPot·0;·······//·The·Potential·Profit·of·basket·of·Trades¤
····double·PipValue,·PipVal2,·ASK,·BID;¤ ····double·PipValue,·PipVal2,·ASK,·BID;¤
····double·OrderLot;¤ ····double·OrderLot;¤
····double·OPbL·0,·OPhO·0;··//·last·open·price¤ ····double·OPbL·0,·OPhO·0;··//·last·open·price¤
····datetime·OTbL·0;··········//·last·open·time¤ ····datetime·OTbL·0;··········//·last·open·time¤
····datetime·OTbO·0,·OThO·0;¤ ····datetime·OTbO·0,·OThO·0;¤
····double·g2,·tp2,·_Entry,·RSI_MA·0,·LhB·0,·LhS·0,·LhT,·OPbO·0;¤ ····double·g2,·tp2,·_Entry,·RSI_MA·0,·LhB·0,·LhS·0,·LhT,·OPbO·0;¤
····int·Ticket·0,·ChB·0,·ChS·0,·IndEntry·0,·TbO·0,·ThO·0;¤ ····int·Ticket·0,·ChB·0,·ChS·0,·IndEntry·0,·TbO·0,·ThO·0;¤
····double·Pb·0,·Ph·0,·PaC·0,·PbPips·0,·PbTarget·0,·DrawDownPC·0,·BEb·0,·BEh·0,·BEa·0;¤ ····double·Pb·0,·Ph·0,·PaC·0,·PbPips·0,·PbTarget·0,·DrawDownPC·0,·BEb·0,·BEh·0,·BEa·0;¤
····bool·BuyMe·false,·SellMe·false,·Success,·SetPOSL;¤ ····bool·BuyMe·false,·SellMe·false,·Success,·SetPOSL;¤
····string·IndicatorUsed;¤ ····string·IndicatorUsed;¤
····double·EEpc·0,·OPbN·0,·nLots·0;¤ ····double·EEpc·0,·OPbN·0,·nLots·0;¤
····double·bSL·0,·TPa·0,·TPbMP·0;¤ ····double·bSL·0,·TPa·0,·TPbMP·0;¤
····int·Trend·0;¤ ····int·Trend·0;¤
····string·ATrend;¤ ····string·ATrend;¤
····double·cci_01[2],·cci_02[2],·cci_03[2],·cci_04[2];¤ ····double·cci_01[2],·cci_02[2],·cci_03[2],·cci_04[2];¤
¤ ¤
····ArrayInitialize(cci_01,·0);¤  
····ArrayInitialize(cci_02,·0);¤  
····ArrayInitialize(cci_03,·0);¤  
····ArrayInitialize(cci_04,·0);¤  
¤ ¤
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Count·Open·Orders,·Lots·and·Totals······························ ····//|·Count·Open·Orders,·Lots·and·Totals······························
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····PipVal2·SymbolInfoDouble(Symbol(),·SYMBOL_TRADE_TICK_VALUE)·SymbolInfoDouble(Symbol(),·SYMBOL_TRADE_TICK_SIZE);¤ ····PipVal2·SymbolInfoDouble(Symbol(),·SYMBOL_TRADE_TICK_VALUE)·SymbolInfoDouble(Symbol(),·SYMBOL_TRADE_TICK_SIZE);¤
····PipValue·PipVal2·Pip;¤ ····PipValue·PipVal2·Pip;¤
····StopLevel·SymbolInfoInteger(Symbol(),·SYMBOL_TRADE_STOPS_LEVEL)·Point();¤ ····StopLevel·SymbolInfoInteger(Symbol(),·SYMBOL_TRADE_STOPS_LEVEL)·Point();¤
····ASK·ND(SymbolInfoDouble(Symbol(),·SYMBOL_ASK),·(int)·SymbolInfoInteger(Symbol(),·SYMBOL_DIGITS));¤ ····ASK·ND(SymbolInfoDouble(Symbol(),·SYMBOL_ASK),·(int)·SymbolInfoInteger(Symbol(),·SYMBOL_DIGITS));¤
····BID·ND(SymbolInfoDouble(Symbol(),·SYMBOL_BID),·(int)·SymbolInfoInteger(Symbol(),·SYMBOL_DIGITS));¤ ····BID·ND(SymbolInfoDouble(Symbol(),·SYMBOL_BID),·(int)·SymbolInfoInteger(Symbol(),·SYMBOL_DIGITS));¤
¤ ¤
¤ ¤
···¤ ···¤
····if·(ASK·==·||·BID·==·0)¤ ····if·(ASK·==·||·BID·==·0)¤
········return;¤ ········return;¤
········¤ ········¤
···//·Заменить¤ ···//·Заменить¤
····for·(int·Order·0;·Order·OrdersTotal();·Order++)· ····for·(int·Order·0;·Order·OrdersTotal();·Order++)·
········if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤ ········if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤
············continue;¤ ············continue;¤
¤ ¤
········int·Type·OrderType();¤ ········int·Type·OrderType();¤
¤ ¤
········if·(OrderMagicNumber()·==·hMagic)· ········if·(OrderMagicNumber()·==·hMagic)·
············Ph·+=·OrderProfit();¤ ············Ph·+=·OrderProfit();¤
············BCh·+=·OrderSwap()·OrderCommission();¤ ············BCh·+=·OrderSwap()·OrderCommission();¤
············BEh·+=·OrderLots()·OrderOpenPrice();¤ ············BEh·+=·OrderLots()·OrderOpenPrice();¤
¤ ¤
············if·(OrderOpenTime()·OThO·||·OThO·==·0)· ············if·(OrderOpenTime()·OThO·||·OThO·==·0)·
················OThO·OrderOpenTime();¤ ················OThO·OrderOpenTime();¤
················ThO·OrderTicket();¤ ················ThO·OrderTicket();¤
················OPhO·OrderOpenPrice();¤ ················OPhO·OrderOpenPrice();¤
············ ············
¤ ¤
············if·(Type·==·OP_BUY)· ············if·(Type·==·OP_BUY)·
················ChB++;¤ ················ChB++;¤
················LhB·+=·OrderLots();¤ ················LhB·+=·OrderLots();¤
············else·if·(Type·==·OP_SELL)· ············else·if·(Type·==·OP_SELL)·
················ChS++;¤ ················ChS++;¤
················LhS·+=·OrderLots();¤ ················LhS·+=·OrderLots();¤
············ ············
¤ ¤
············continue;¤ ············continue;¤
········ ········
¤ ¤
········if·(OrderMagicNumber()·!=·Magic·||·OrderSymbol()·!=·Symbol())¤ ········if·(OrderMagicNumber()·!=·Magic·||·OrderSymbol()·!=·Symbol())¤
············continue;¤ ············continue;¤
¤ ¤
········if·(OrderTakeProfit()·0)¤ ········if·(OrderTakeProfit()·0)¤
············ModifyOrder(OrderOpenPrice(),·OrderStopLoss());¤ ············ModifyOrder(OrderOpenPrice(),·OrderStopLoss());¤
¤ ¤
········if·(Type·<=·OP_SELL)· ········if·(Type·<=·OP_SELL)·
············Pb·+=·OrderProfit();¤ ············Pb·+=·OrderProfit();¤
············BCb·+=·OrderSwap()·OrderCommission();¤ ············BCb·+=·OrderSwap()·OrderCommission();¤
············BEb·+=·OrderLots()·OrderOpenPrice();¤ ············BEb·+=·OrderLots()·OrderOpenPrice();¤
¤ ¤
············if·(OrderOpenTime()·>=·OTbL)· ············if·(OrderOpenTime()·>=·OTbL)·
················OTbL·OrderOpenTime();¤ ················OTbL·OrderOpenTime();¤
················OPbL·OrderOpenPrice();¤ ················OPbL·OrderOpenPrice();¤
············ ············
¤ ¤
············if·(OrderOpenTime()·OTbF·||·TbF·==·0)· ············if·(OrderOpenTime()·OTbF·||·TbF·==·0)·
················OTbF·OrderOpenTime();¤ ················OTbF·OrderOpenTime();¤
················TbF·OrderTicket();¤ ················TbF·OrderTicket();¤
················LbF·OrderLots();¤ ················LbF·OrderLots();¤
············ ············
¤ ¤
············if·(OrderOpenTime()·OTbO·||·OTbO·==·0)· ············if·(OrderOpenTime()·OTbO·||·OTbO·==·0)·
················OTbO·OrderOpenTime();¤ ················OTbO·OrderOpenTime();¤
················TbO·OrderTicket();¤ ················TbO·OrderTicket();¤
················OPbO·OrderOpenPrice();¤ ················OPbO·OrderOpenPrice();¤
············ ············
¤ ¤
············if·(UsePowerOutSL·&&·((POSLPips_·&&·OrderStopLoss()·==·0)·||·(POSLPips_·==·&&·OrderStopLoss()·0)))¤ ············if·(UsePowerOutSL·&&·((POSLPips_·&&·OrderStopLoss()·==·0)·||·(POSLPips_·==·&&·OrderStopLoss()·0)))¤
················SetPOSL·true;¤ ················SetPOSL·true;¤
¤ ¤
············if·(Type·==·OP_BUY)· ············if·(Type·==·OP_BUY)·
················CbB++;¤ ················CbB++;¤
················LbB·+=·OrderLots();¤ ················LbB·+=·OrderLots();¤
················continue;¤ ················continue;¤
············else· ············else·
················CbS++;¤ ················CbS++;¤
················LbS·+=·OrderLots();¤ ················LbS·+=·OrderLots();¤
················continue;¤ ················continue;¤
············ ············
········else· ········else·
············if·(Type·==·OP_BUYLIMIT)· ············if·(Type·==·OP_BUYLIMIT)·
················CpBL++;¤ ················CpBL++;¤
················OPpBL·OrderOpenPrice();¤ ················OPpBL·OrderOpenPrice();¤
················continue;¤ ················continue;¤
············else·if·(Type·==·OP_SELLLIMIT)· ············else·if·(Type·==·OP_SELLLIMIT)·
················CpSL++;¤ ················CpSL++;¤
················OPpSL·OrderOpenPrice();¤ ················OPpSL·OrderOpenPrice();¤
················continue;¤ ················continue;¤
············else·if·(Type·==·OP_BUYSTOP)¤ ············else·if·(Type·==·OP_BUYSTOP)¤
················CpBS++;¤ ················CpBS++;¤
············else¤ ············else¤
················CpSS++;¤ ················CpSS++;¤
········ ········
···· ····
¤ ¤
····CbT·CbB·CbS;¤ ····CbT·CbB·CbS;¤
····LbT·LbB·LbS;¤ ····LbT·LbB·LbS;¤
····Pb·ND(Pb·BCb,·2);¤ ····Pb·ND(Pb·BCb,·2);¤
····ChT·ChB·ChS;¤ ····ChT·ChB·ChS;¤
····LhT·LhB·LhS;¤ ····LhT·LhB·LhS;¤
····Ph·ND(Ph·BCh,·2);¤ ····Ph·ND(Ph·BCh,·2);¤
····CpT·CpBL·CpSL·CpBS·CpSS;¤ ····CpT·CpBL·CpSL·CpBS·CpSS;¤
····BCa·BCb·BCh;¤ ····BCa·BCb·BCh;¤
¤ ¤
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Calculate·Min/Max·Profit·and·Break·Even·Points·················· ····//|·Calculate·Min/Max·Profit·and·Break·Even·Points··················
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····if·(LbT·0)· ····if·(LbT·0)·
········BEb·ND(BEb·LbT,·Digits());¤ ········BEb·ND(BEb·LbT,·Digits());¤
¤ ¤
········if·(BCa·0)· //·broker·costs¤ ········if·(BCa·0)· //·broker·costs¤
»   »   »   if·(LbB·LbS·!=·0)·//·r.f.,·fix·divide·by·zero·on·following·line¤ »   »   »   if·(LbB·LbS·!=·0)·//·r.f.,·fix·divide·by·zero·on·following·line¤
»   »   »   »   BEb·-=·ND(BCa·PipVal2·(LbB·LbS),·Digits());¤ »   »   »   »   BEb·-=·ND(BCa·PipVal2·(LbB·LbS),·Digits());¤
»   »   }¤ »   »   }¤
¤ ¤
········if·(Pb·PbMax·||·PbMax·==·0)¤ ········if·(Pb·PbMax·||·PbMax·==·0)¤
············PbMax·Pb;¤ ············PbMax·Pb;¤
¤ ¤
········if·(Pb·PbMin·||·PbMin·==·0)¤ ········if·(Pb·PbMin·||·PbMin·==·0)¤
············PbMin·Pb;¤ ············PbMin·Pb;¤
¤ ¤
········if·(!TradesOpen)· ········if·(!TradesOpen)·
············FileHandle·FileOpen(FileName,·FILE_BIN·FILE_WRITE);¤ ············FileHandle·FileOpen(FileName,·FILE_BIN·FILE_WRITE);¤
¤ ¤
············if·(FileHandle·-1)· ············if·(FileHandle·-1)·
················FileWriteInteger(FileHandle,·TbF);¤ ················FileWriteInteger(FileHandle,·TbF);¤
················FileClose(FileHandle);¤ ················FileClose(FileHandle);¤
················TradesOpen·true;¤ ················TradesOpen·true;¤
¤ ¤
················if·(Debug_)¤ ················if·(Debug_)¤
····················Print(FileName,·File·Written:·",·TbF);¤ ····················Print(FileName,·File·Written:·",·TbF);¤
············ ············
········ ········
····else·if·(TradesOpen)· ····else·if·(TradesOpen)·
········TPb·0;¤ ········TPb·0;¤
········PbMax·0;¤ ········PbMax·0;¤
········PbMin·0;¤ ········PbMin·0;¤
········OTbF·0;¤ ········OTbF·0;¤
········TbF·0;¤ ········TbF·0;¤
········LbF·0;¤ ········LbF·0;¤
········PbC·0;¤ ········PbC·0;¤
········PhC·0;¤ ········PhC·0;¤
········PaC·0;¤ ········PaC·0;¤
········ClosedPips·0;¤ ········ClosedPips·0;¤
········CbC·0;¤ ········CbC·0;¤
········CaL·0;¤ ········CaL·0;¤
········bTS·0;¤ ········bTS·0;¤
¤ ¤
········if·(HedgeTypeDD)¤ ········if·(HedgeTypeDD)¤
············hDDStart·HedgeStart_;¤ ············hDDStart·HedgeStart_;¤
········else¤ ········else¤
············hLvlStart·HedgeStart_;¤ ············hLvlStart·HedgeStart_;¤
¤ ¤
········EmailCount·0;¤ ········EmailCount·0;¤
········EmailSent·0;¤ ········EmailSent·0;¤
········FileHandle·FileOpen(FileName,·FILE_BIN·FILE_READ);¤ ········FileHandle·FileOpen(FileName,·FILE_BIN·FILE_READ);¤
¤ ¤
········if·(FileHandle·-1)· ········if·(FileHandle·-1)·
············FileClose(FileHandle);¤ ············FileClose(FileHandle);¤
············Error·GetLastError();¤ ············Error·GetLastError();¤
············FileDelete(FileName);¤ ············FileDelete(FileName);¤
············Error·GetLastError();¤ ············Error·GetLastError();¤
¤ ¤
············if·(Error·==·0)· ············if·(Error·==·0)·
················if·(Debug_)¤ ················if·(Debug_)¤
····················Print(FileName·File·Deleted");¤ ····················Print(FileName·File·Deleted");¤
¤ ¤
················TradesOpen·false;¤ ················TradesOpen·false;¤
············else¤ ············else¤
················Print("Error·",·Error,·deleting·file·",·FileName);¤ ················Print("Error·",·Error,·deleting·file·",·FileName);¤
········else¤ ········else¤
············TradesOpen·false;¤ ············TradesOpen·false;¤
···· ····
¤ ¤
····if·(LhT·0)· ····if·(LhT·0)·
········BEh·ND(BEh·LhT,·Digits());¤ ········BEh·ND(BEh·LhT,·Digits());¤
¤ ¤
········if·(Ph·PhMax·||·PhMax·==·0)¤ ········if·(Ph·PhMax·||·PhMax·==·0)¤
············PhMax·Ph;¤ ············PhMax·Ph;¤
¤ ¤
········if·(Ph·PhMin·||·PhMin·==·0)¤ ········if·(Ph·PhMin·||·PhMin·==·0)¤
············PhMin·Ph;¤ ············PhMin·Ph;¤
····else· ····else·
········PhMax·0;¤ ········PhMax·0;¤
········PhMin·0;¤ ········PhMin·0;¤
········SLh·0;¤ ········SLh·0;¤
···· ····
¤ ¤
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Check·if·trading·is·allowed····································· ····//|·Check·if·trading·is·allowed·····································
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····if·(CbT·==·&&·ChT·==·&&·ShutDown_)· ····if·(CbT·==·&&·ChT·==·&&·ShutDown_)·
········if·(CpT·0)· ········if·(CpT·0)·
············ExitTrades(P,·displayColorLoss,·"Blessing·is·shutting·down");¤ ············ExitTrades(P,·displayColorLoss,·"Blessing·is·shutting·down");¤
¤ ¤
············return;¤ ············return;¤
········ ········
¤ ¤
········if·(AllowTrading)· ········if·(AllowTrading)·
············Print("Blessing·has·shut·down.·Set·ShutDown·'false'·to·resume·trading");¤ ············Print("Blessing·has·shut·down.·Set·ShutDown·'false'·to·resume·trading");¤
¤ ¤
············if·(PlaySounds)¤ ············if·(PlaySounds)¤
················PlaySound(AlertSound);¤ ················PlaySound(AlertSound);¤
¤ ¤
············AllowTrading·false;¤ ············AllowTrading·false;¤
········ ········
¤ ¤
········if·(UseEmail·&&·EmailCount·&&·!Testing)· ········if·(UseEmail·&&·EmailCount·&&·!Testing)·
············SendMail("Blessing·EA",·"Blessing·has·shut·down·on·Symbol()·sTF·".·To·resume·trading,·change·ShutDown·to·false.");¤ ············SendMail("Blessing·EA",·"Blessing·has·shut·down·on·Symbol()·sTF·".·To·resume·trading,·change·ShutDown·to·false.");¤
············Error·GetLastError();¤ ············Error·GetLastError();¤
¤ ¤
············if·(Error·0)¤ ············if·(Error·0)¤
················Print("Error·",·Error,·sending·email");¤ ················Print("Error·",·Error,·sending·email");¤
············else¤ ············else¤
················EmailCount·4;¤ ················EmailCount·4;¤
········ ········
···· ····
¤ ¤
····static·bool·LDelete;¤ ····static·bool·LDelete;¤
¤ ¤
····if·(!AllowTrading)· ····if·(!AllowTrading)·
········if·(!LDelete)· ········if·(!LDelete)·
············LDelete·true;¤ ············LDelete·true;¤
············LabelDelete();¤ ············LabelDelete();¤
¤ ¤
············if·(ObjectFind(ChartID(),pref+"B3LStop")·==·-1)· ············if·(ObjectFind(ChartID(),pref+"B3LStop")·==·-1)·
················CreateLabel("B3LStop",·"Trading·has·stopped·on·this·pair.",·10,·0,·0,·3,·displayColorLoss);¤ ················CreateLabel("B3LStop",·"Trading·has·stopped·on·this·pair.",·10,·0,·0,·3,·displayColorLoss);¤
················CreateLabel("B3LLogo",·"I",·27,·3,·10,·10,·0,·Red,·"Wingdings");···//·open·hand·(stop)¤ ················CreateLabel("B3LLogo",·"I",·27,·3,·10,·10,·Red,·"Wingdings");···//·open·hand·(stop)¤
············ ············
¤ ¤
············string·Tab·"Tester·Journal";¤ ············string·Tab·"Tester·Journal";¤
¤ ¤
············if·(!Testing)¤ ············if·(!Testing)¤
················Tab·"Terminal·Experts";¤ ················Tab·"Terminal·Experts";¤
¤ ¤
············if·(ObjectFind(ChartID(),pref+"B3LExpt")·==·-1)¤ ············if·(ObjectFind(ChartID(),pref+"B3LExpt")·==·-1)¤
················CreateLabel("B3LExpt",·"Check·the·Tab·tab·for·the·reason.",·10,·0,·0,·6,·displayColorLoss);¤ ················CreateLabel("B3LExpt",·"Check·the·Tab·tab·for·the·reason.",·10,·0,·0,·6,·displayColorLoss);¤
¤ ¤
············if·(ObjectFind(ChartID(),pref+"B3LResm")·==·-1)¤ ············if·(ObjectFind(ChartID(),pref+"B3LResm")·==·-1)¤
················CreateLabel("B3LResm",·"Reset·Blessing·to·resume·trading.",·10,·0,·0,·9,·displayColorLoss);¤ ················CreateLabel("B3LResm",·"Reset·Blessing·to·resume·trading.",·10,·0,·0,·9,·displayColorLoss);¤
········ ········
¤ ¤
········return;¤ ········return;¤
····else· ····else·
········LDelete·false;¤ ········LDelete·false;¤
········ObjDel("B3LStop");¤ ········ObjDel("B3LStop");¤
········ObjDel("B3LExpt");¤ ········ObjDel("B3LExpt");¤
········ObjDel("B3LResm");¤ ········ObjDel("B3LResm");¤
···· ····
¤ ¤
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Calculate·Drawdown·and·Equity·Protection························ ····//|·Calculate·Drawdown·and·Equity·Protection························
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
»   double·temp_account_balance·AccountInfoDouble(ACCOUNT_BALANCE);¤ »   double·temp_account_balance·AccountInfoDouble(ACCOUNT_BALANCE);¤
»   double·NewPortionBalance;¤ »   double·NewPortionBalance;¤
»   if·(PortionPC·100·&&·temp_account_balance·PortionPC)· »   if·(PortionPC·100·&&·temp_account_balance·PortionPC)·
»   »   NewPortionBalance·ND(PortionPC,·2);¤ »   »   NewPortionBalance·ND(PortionPC,·2);¤
»   }·else· »   }·else·
»   »   NewPortionBalance·ND(temp_account_balance·PortionPC_,·2);¤ »   »   NewPortionBalance·ND(temp_account_balance·PortionPC_,·2);¤
»   }¤ »   }¤
¤ ¤
····if·(CbT·==·||·PortionChange·||·(PortionChange·&&·NewPortionBalance·PortionBalance))¤ ····if·(CbT·==·||·PortionChange·||·(PortionChange·&&·NewPortionBalance·PortionBalance))¤
········PortionBalance·NewPortionBalance;¤ ········PortionBalance·NewPortionBalance;¤
¤ ¤
····if·(OncePerBar())· ····if·(OncePerBar())·
········if·(Pb·Ph·0)¤ ········if·(Pb·Ph·0)¤
············DrawDownPC·-(Pb·Ph)·PortionBalance;···//·opb¤ ············DrawDownPC·-(Pb·Ph)·PortionBalance;···//·opb¤
¤ ¤
········if·(!FirstRun·&&·DrawDownPC·>=·MaxDDPercent·100)· ········if·(!FirstRun·&&·DrawDownPC·>=·MaxDDPercent·100)·
············ExitTrades(A,·displayColorLoss,·"Equity·StopLoss·Reached");¤ ············ExitTrades(A,·displayColorLoss,·"Equity·StopLoss·Reached");¤
¤ ¤
············if·(PlaySounds)¤ ············if·(PlaySounds)¤
················PlaySound(AlertSound);¤ ················PlaySound(AlertSound);¤
¤ ¤
············return;¤ ············return;¤
········ ········
¤ ¤
········if·(-(Pb·Ph)·MaxDD)¤ ········if·(-(Pb·Ph)·MaxDD)¤
············MaxDD·-(Pb·Ph);¤ ············MaxDD·-(Pb·Ph);¤
¤ ¤
········MaxDDPer·MathMax(MaxDDPer,·DrawDownPC·100);¤ ········MaxDDPer·MathMax(MaxDDPer,·DrawDownPC·100);¤
¤ ¤
········if·(SaveStats)¤ ········if·(SaveStats)¤
············Stats(false,·TimeCurrent()·NextStats,·PortionBalance,·Pb·Ph);¤ ············Stats(false,·TimeCurrent()·NextStats,·PortionBalance,·Pb·Ph);¤
¤ ¤
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Calculate··Stop·Trade·Percent··································· ········//|·Calculate··Stop·Trade·Percent···································
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········double·StepAB·InitialAB·(1·StopTradePercent_);¤ ········double·StepAB·InitialAB·(1·StopTradePercent_);¤
»   »   double·StepSTB;¤ »   »   double·StepSTB;¤
»   »   double·temp_ab·AccountInfoDouble(ACCOUNT_BALANCE);¤ »   »   double·temp_ab·AccountInfoDouble(ACCOUNT_BALANCE);¤
»   »   if·(PortionPC·100·&&·temp_ab·PortionPC)· »   »   if·(PortionPC·100·&&·temp_ab·PortionPC)·
»   »   »   StepSTB·PortionPC·(1·StopTradePercent_);¤ »   »   »   StepSTB·PortionPC·(1·StopTradePercent_);¤
»   »   }·else· »   »   }·else·
»   »   »   StepSTB·temp_ab·(1·StopTradePercent_);¤ »   »   »   StepSTB·temp_ab·(1·StopTradePercent_);¤
»   »   }¤ »   »   }¤
········double·NextISTB·StepAB·(1·StopTradePercent_);¤ ········double·NextISTB·StepAB·(1·StopTradePercent_);¤
¤ ¤
········if·(StepSTB·NextISTB)· ········if·(StepSTB·NextISTB)·
············InitialAB·StepAB;¤ ············InitialAB·StepAB;¤
············StopTradeBalance·StepSTB;¤ ············StopTradeBalance·StepSTB;¤
········ ········
········//·Stop·Trade·Amount:¤ ········//·Stop·Trade·Amount:¤
········double·InitialAccountMultiPortion·StopTradeBalance·PortionPC_;¤ ········double·InitialAccountMultiPortion·StopTradeBalance·PortionPC_;¤
········stop_trade_amount·InitialAccountMultiPortion;¤ ········stop_trade_amount·InitialAccountMultiPortion;¤
¤ ¤
········if·(PortionBalance·InitialAccountMultiPortion)· ········if·(PortionBalance·InitialAccountMultiPortion)·
············if·(CbT·==·0)· ············if·(CbT·==·0)·
················AllowTrading·false;¤ ················AllowTrading·false;¤
¤ ¤
················if·(PlaySounds)¤ ················if·(PlaySounds)¤
····················PlaySound(AlertSound);¤ ····················PlaySound(AlertSound);¤
¤ ¤
················Print("Portion·Balance·dropped·below·stop-trading·percentage");¤ ················Print("Portion·Balance·dropped·below·stop-trading·percentage");¤
················MessageBox("Reset·required·account·balance·dropped·below·stop-trading·percentage·on·AccountInfoString(ACCOUNT_NAME)·Symbol()·(string)·Period(),·"Blessing·3:·Warning",·48);¤ ················MessageBox("Reset·required·account·balance·dropped·below·stop-trading·percentage·on·AccountInfoString(ACCOUNT_NAME)·Symbol()·(string)·Period(),·"Blessing·3:·Warning",·48);¤
¤ ¤
················return;¤ ················return;¤
············else·if·(!ShutDown_·&&·!RecoupClosedLoss)· ············else·if·(!ShutDown_·&&·!RecoupClosedLoss)·
················ShutDown_·true;¤ ················ShutDown_·true;¤
¤ ¤
················if·(PlaySounds)¤ ················if·(PlaySounds)¤
····················PlaySound(AlertSound);¤ ····················PlaySound(AlertSound);¤
¤ ¤
················Print("Portion·Balance·dropped·below·stop-trading·percentage");¤ ················Print("Portion·Balance·dropped·below·stop-trading·percentage");¤
¤ ¤
················return;¤ ················return;¤
············ ············
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Calculation·of·Trend·Direction·································· ········//|·Calculation·of·Trend·Direction··································
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········double·ima_0[1];·¤ ········double·ima_0[1];·¤
CopyBuffer(ma_01_handle,·0,·0,·1,·ima_0);¤ CopyBuffer(ma_01_handle,·0,·0,·1,·ima_0);¤
········if·(ForceMarketCond_·==·3)· ········if·(ForceMarketCond_·==·3)·
············if·(BID·ima_0[0]·MADistance_)¤ ············if·(BID·ima_0[0]·MADistance_)¤
················Trend·0;¤ ················Trend·0;¤
············else·if·(ASK·ima_0[0]·MADistance_)¤ ············else·if·(ASK·ima_0[0]·MADistance_)¤
················Trend·1;¤ ················Trend·1;¤
············else¤ ············else¤
················Trend·2;¤ ················Trend·2;¤
········else· ········else·
············Trend·ForceMarketCond_;¤ ············Trend·ForceMarketCond_;¤
¤ ¤
············if·(Trend·!=·&&·BID·ima_0[0]·MADistance_)¤ ············if·(Trend·!=·&&·BID·ima_0[0]·MADistance_)¤
················ATrend·"U";¤ ················ATrend·"U";¤
¤ ¤
············if·(Trend·!=·&&·ASK·ima_0[0]·MADistance_)¤ ············if·(Trend·!=·&&·ASK·ima_0[0]·MADistance_)¤
················ATrend·"D";¤ ················ATrend·"D";¤
¤ ¤
············if·(Trend·!=·&&·(BID·ima_0[0]·MADistance_·&&·ASK·ima_0[0]·MADistance_))¤ ············if·(Trend·!=·&&·(BID·ima_0[0]·MADistance_·&&·ASK·ima_0[0]·MADistance_))¤
················ATrend·"R";¤ ················ATrend·"R";¤
········ ········
¤ ¤
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Hedge/Basket/ClosedTrades·Profit·Management····················· ········//|·Hedge/Basket/ClosedTrades·Profit·Management·····················
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········double·Pa·Pb;¤ ········double·Pa·Pb;¤
········PaC·PbC·PhC;¤ ········PaC·PbC·PhC;¤
¤ ¤
········if·(hActive·==·&&·ChT·==·0)· ········if·(hActive·==·&&·ChT·==·0)·
············PhC·FindClosedPL(H);¤ ············PhC·FindClosedPL(H);¤
············hActive·0;¤ ············hActive·0;¤
¤ ¤
············return;¤ ············return;¤
········else·if·(hActive·==·&&·ChT·0)¤ ········else·if·(hActive·==·&&·ChT·0)¤
············hActive·1;¤ ············hActive·1;¤
¤ ¤
········if·(LbT·0)· ········if·(LbT·0)·
············if·(PbC·||·(PbC·&&·RecoupClosedLoss))· ············if·(PbC·||·(PbC·&&·RecoupClosedLoss))·
················Pa·+=·PbC;¤ ················Pa·+=·PbC;¤
················BEb·-=·ND(PbC·PipVal2·(LbB·LbS),·Digits());¤ ················BEb·-=·ND(PbC·PipVal2·(LbB·LbS),·Digits());¤
············ ············
¤ ¤
············if·(PhC·||·(PhC·&&·RecoupClosedLoss))· ············if·(PhC·||·(PhC·&&·RecoupClosedLoss))·
················Pa·+=·PhC;¤ ················Pa·+=·PhC;¤
················BEb·-=·ND(PhC·PipVal2·(LbB·LbS),·Digits());¤ ················BEb·-=·ND(PhC·PipVal2·(LbB·LbS),·Digits());¤
············ ············
¤ ¤
············if·(Ph·||·(Ph·&&·RecoupClosedLoss))¤ ············if·(Ph·||·(Ph·&&·RecoupClosedLoss))¤
················Pa·+=·Ph;¤ ················Pa·+=·Ph;¤
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Close·oldest·open·trade·after·CloseTradesLevel·reached·········· ········//|·Close·oldest·open·trade·after·CloseTradesLevel·reached··········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········if·(UseCloseOldest·&&·CbT·>=·CloseTradesLevel·&&·CbC·MaxCloseTrades_)· ········if·(UseCloseOldest·&&·CbT·>=·CloseTradesLevel·&&·CbC·MaxCloseTrades_)·
············if·(!FirstRun·&&·TPb·&&·(ForceCloseOldest·||·(CbB·&&·OPbO·TPb)·||·(CbS·&&·OPbO·TPb)))· ············if·(!FirstRun·&&·TPb·&&·(ForceCloseOldest·||·(CbB·&&·OPbO·TPb)·||·(CbS·&&·OPbO·TPb)))·
················int·Index·ExitTrades(T,·DarkViolet,·"Close·Oldest·Trade",·TbO);¤ ················int·Index·ExitTrades(T,·DarkViolet,·"Close·Oldest·Trade",·TbO);¤
//Заменить¤ //Заменить¤
················if·(Index·==·1)· ················if·(Index·==·1)·
····················if·(OrderSelect(TbO,·SELECT_BY_TICKET))···//·yoh·check·return¤ ····················if·(OrderSelect(TbO,·SELECT_BY_TICKET))···//·yoh·check·return¤
························PbC·+=·OrderProfit()·OrderSwap()·OrderCommission();¤ ························PbC·+=·OrderProfit()·OrderSwap()·OrderCommission();¤
························ca·0;¤ ························ca·0;¤
························CbC++;¤ ························CbC++;¤
····················else¤ ····················else¤
························Print("OrderSelect·error·",·GetLastError());····//·yoh¤ ························Print("OrderSelect·error·",·GetLastError());····//·yoh¤
¤ ¤
····················return;¤ ····················return;¤
················ ················
············ ············
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·ATR·for·Auto·Grid·Calculation·and·Grid·Set·Block················ ········//|·ATR·for·Auto·Grid·Calculation·and·Grid·Set·Block················
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········double·GridTP;¤ ········double·GridTP;¤
¤ ¤
········if·(AutoCal)· ········if·(AutoCal)·
············double·GridATR[1];¤ ············double·GridATR[1];¤
············CopyBuffer(gridATRHandle,·0,·0,·1,·GridATR);¤ ············CopyBuffer(gridATRHandle,·0,·0,·1,·GridATR);¤
············GridATR[0]·GridATR[0]/Pip;¤ ············GridATR[0]·GridATR[0]/Pip;¤
¤ ¤
············if·((CbT·CbC·Set4Level)·&&·Set4Level·0)· ············if·((CbT·CbC·Set4Level)·&&·Set4Level·0)·
················g2·GridATR[0]·12;······//GS*2*2*2*1.5¤ ················g2·GridATR[0]·12;······//GS*2*2*2*1.5¤
················tp2·GridATR[0]·18;·····//GS*2*2*2*1.5*1.5¤ ················tp2·GridATR[0]·18;·····//GS*2*2*2*1.5*1.5¤
············else·if·((CbT·CbC·Set3Level)·&&·Set3Level·0)· ············else·if·((CbT·CbC·Set3Level)·&&·Set3Level·0)·
················g2·GridATR[0]·8;·······//GS*2*2*2¤ ················g2·GridATR[0]·8;·······//GS*2*2*2¤
················tp2·GridATR[0]·12;·····//GS*2*2*2*1.5¤ ················tp2·GridATR[0]·12;·····//GS*2*2*2*1.5¤
············else·if·((CbT·CbC·Set2Level)·&&·Set2Level·0)· ············else·if·((CbT·CbC·Set2Level)·&&·Set2Level·0)·
················g2·GridATR[0]·4;·······//GS*2*2¤ ················g2·GridATR[0]·4;·······//GS*2*2¤
················tp2·GridATR[0]·8;······//GS*2*2*2¤ ················tp2·GridATR[0]·8;······//GS*2*2*2¤
············else·if·((CbT·CbC·Set1Level)·&&·Set1Level·0)· ············else·if·((CbT·CbC·Set1Level)·&&·Set1Level·0)·
················g2·GridATR[0]·2;·······//GS*2¤ ················g2·GridATR[0]·2;·······//GS*2¤
················tp2·GridATR[0]·4;······//GS*2*2¤ ················tp2·GridATR[0]·4;······//GS*2*2¤
············else· ············else·
················g2·GridATR[0];¤ ················g2·GridATR[0];¤
················tp2·GridATR[0]·2;¤ ················tp2·GridATR[0]·2;¤
············ ············
¤ ¤
············GridTP·GridATR[0]·2;¤ ············GridTP·GridATR[0]·2;¤
········else· ········else·
············int·Index·(int)·MathMax(MathMin(CbT·CbC,·MaxTrades)·1,·0);¤ ············int·Index·(int)·MathMax(MathMin(CbT·CbC,·MaxTrades)·1,·0);¤
············g2·GridArray[Index,·0];¤ ············g2·GridArray[Index,·0];¤
············tp2·GridArray[Index,·1];¤ ············tp2·GridArray[Index,·1];¤
············GridTP·GridArray[0,·1];¤ ············GridTP·GridArray[0,·1];¤
········ ········
¤ ¤
········g2·ND(MathMax(g2·GAF·Pip,·Pip),·Digits());¤ ········g2·ND(MathMax(g2·GAF·Pip,·Pip),·Digits());¤
········tp2·ND(tp2·GAF·Pip,·Digits());¤ ········tp2·ND(tp2·GAF·Pip,·Digits());¤
········GridTP·ND(GridTP·GAF·Pip,·Digits());¤ ········GridTP·ND(GridTP·GAF·Pip,·Digits());¤
¤ ¤
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Money·Management·and·Lot·size·coding···························· ········//|·Money·Management·and·Lot·size·coding····························
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········if·(UseMM)· ········if·(UseMM)·
············if·(CbT·0)········//·Count·basket·Total¤ ············if·(CbT·0)········//·Count·basket·Total¤
············ ············
················if·(GlobalVariableCheck(ID·"LotMult"))¤ ················if·(GlobalVariableCheck(ID·"LotMult"))¤
····················LotMult·(int)·GlobalVariableGet(ID·"LotMult");¤ ····················LotMult·(int)·GlobalVariableGet(ID·"LotMult");¤
¤ ¤
················if·(LbF·!=·LotSize(Lots[0]·LotMult))· ················if·(LbF·!=·LotSize(Lots[0]·LotMult))·
····················LotMult·(int)·(LbF·Lots[0]);¤ ····················LotMult·(int)·(LbF·Lots[0]);¤
····················GlobalVariableSet(ID·"LotMult",·LotMult);¤ ····················GlobalVariableSet(ID·"LotMult",·LotMult);¤
····················Print("LotMult·reset·to·DTS(LotMult,·0));¤ ····················Print("LotMult·reset·to·DTS(LotMult,·0));¤
················ ················
············else·if·(CbT·==·0)· ············else·if·(CbT·==·0)·
················double·Contracts,·Factor,·Lotsize;¤ ················double·Contracts,·Factor,·Lotsize;¤
················Contracts·PortionBalance·10000;·····//·MarketInfo(Symbol(),·MODE_LOTSIZE);·??¤ ················Contracts·PortionBalance·10000;·····//·MarketInfo(Symbol(),·MODE_LOTSIZE);·??¤
¤ ¤
················if·(Multiplier_·<=·1)¤ ················if·(Multiplier_·<=·1)¤
····················Factor·Level;¤ ····················Factor·Level;¤
················else¤ ················else¤
····················Factor·(MathPow(Multiplier_,·Level)·Multiplier_)·(Multiplier_·1);¤ ····················Factor·(MathPow(Multiplier_,·Level)·Multiplier_)·(Multiplier_·1);¤
¤ ¤
················Lotsize·LAF·AccountType·Contracts·(1·Factor);¤ ················Lotsize·LAF·AccountType·Contracts·(1·Factor);¤
················LotMult·(int)·MathMax(MathFloor(Lotsize·Lot_),·MinMult);¤ ················LotMult·(int)·MathMax(MathFloor(Lotsize·Lot_),·MinMult);¤
················GlobalVariableSet(ID·"LotMult",·LotMult);¤ ················GlobalVariableSet(ID·"LotMult",·LotMult);¤
············ ············
········else·if·(CbT·==·0)¤ ········else·if·(CbT·==·0)¤
············LotMult·MinMult;¤ ············LotMult·MinMult;¤
¤ ¤
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Calculate·Take·Profit··········································· ········//|·Calculate·Take·Profit···········································
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········static·double·BCaL,·BEbL;¤ ········static·double·BCaL,·BEbL;¤
········nLots·LbB·LbS;¤ ········nLots·LbB·LbS;¤
¤ ¤
········if·(CbT·&&·(TPb·==·||·CbT·ChT·!=·CaL·||·BEbL·!=·BEb·||·BCa·!=·BCaL·||·FirstRun))· ········if·(CbT·&&·(TPb·==·||·CbT·ChT·!=·CaL·||·BEbL·!=·BEb·||·BCa·!=·BCaL·||·FirstRun))·
············string·sCalcTP·"Set·New·TP:··BE:·DTS(BEb,·Digits());¤ ············string·sCalcTP·"Set·New·TP:··BE:·DTS(BEb,·Digits());¤
············double·NewTP·0,·BasePips;¤ ············double·NewTP·0,·BasePips;¤
············CaL·CbT·ChT;¤ ············CaL·CbT·ChT;¤
············BCaL·BCa;¤ ············BCaL·BCa;¤
············BEbL·BEb;¤ ············BEbL·BEb;¤
············if·(nLots·==·0)· ············if·(nLots·==·0)·
················nLots·1;¤ ················nLots·1;¤
······························//·divide·by·zero·error·fix·...·r.f.¤ ······························//·divide·by·zero·error·fix·...·r.f.¤
············BasePips·ND(Lot_·LotMult·GridTP·(CbT·CbC)·nLots,·Digits());¤ ············BasePips·ND(Lot_·LotMult·GridTP·(CbT·CbC)·nLots,·Digits());¤
¤ ¤
············if·(CbB·0)· ············if·(CbB·0)·
················if·(ForceTPPips_·0)· ················if·(ForceTPPips_·0)·
····················NewTP·BEb·ForceTPPips_;¤ ····················NewTP·BEb·ForceTPPips_;¤
····················sCalcTP·sCalcTP·+Force·TP·("·DTS(ForceTPPips_,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·+Force·TP·("·DTS(ForceTPPips_,·Digits())·")·";¤
················else·if·(CbC·&&·CloseTPPips_·0)· ················else·if·(CbC·&&·CloseTPPips_·0)·
····················NewTP·BEb·CloseTPPips_;¤ ····················NewTP·BEb·CloseTPPips_;¤
····················sCalcTP·sCalcTP·+Close·TP·("·DTS(CloseTPPips_,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·+Close·TP·("·DTS(CloseTPPips_,·Digits())·")·";¤
················else·if·(BEb·BasePips·OPbL·tp2)· ················else·if·(BEb·BasePips·OPbL·tp2)·
····················NewTP·BEb·BasePips;¤ ····················NewTP·BEb·BasePips;¤
····················sCalcTP·sCalcTP·+Base·TP:·("·DTS(BasePips,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·+Base·TP:·("·DTS(BasePips,·Digits())·")·";¤
················else· ················else·
····················NewTP·OPbL·tp2;¤ ····················NewTP·OPbL·tp2;¤
····················sCalcTP·sCalcTP·+Grid·TP:·("·DTS(tp2,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·+Grid·TP:·("·DTS(tp2,·Digits())·")·";¤
················ ················
¤ ¤
················if·(MinTPPips_·0)· ················if·(MinTPPips_·0)·
····················NewTP·MathMax(NewTP,·BEb·MinTPPips_);¤ ····················NewTP·MathMax(NewTP,·BEb·MinTPPips_);¤
····················sCalcTP·sCalcTP·>Minimum·TP:·";¤ ····················sCalcTP·sCalcTP·>Minimum·TP:·";¤
················ ················
¤ ¤
················NewTP·+=·MoveTP_·Moves;¤ ················NewTP·+=·MoveTP_·Moves;¤
¤ ¤
················if·(BreakEvenTrade·&&·CbT·CbC·>=·BreakEvenTrade)· ················if·(BreakEvenTrade·&&·CbT·CbC·>=·BreakEvenTrade)·
····················NewTP·BEb·BEPlusPips_;¤ ····················NewTP·BEb·BEPlusPips_;¤
····················sCalcTP·sCalcTP·>BreakEven:·("·DTS(BEPlusPips_,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·>BreakEven:·("·DTS(BEPlusPips_,·Digits())·")·";¤
················ ················
¤ ¤
················sCalcTP·(sCalcTP·"Buy:·TakeProfit:·");¤ ················sCalcTP·(sCalcTP·"Buy:·TakeProfit:·");¤
············else·if·(CbS·0)· ············else·if·(CbS·0)·
················if·(ForceTPPips_·0)· ················if·(ForceTPPips_·0)·
····················NewTP·BEb·ForceTPPips_;¤ ····················NewTP·BEb·ForceTPPips_;¤
····················sCalcTP·sCalcTP·-Force·TP·("·DTS(ForceTPPips_,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·-Force·TP·("·DTS(ForceTPPips_,·Digits())·")·";¤
················else·if·(CbC·&&·CloseTPPips_·0)· ················else·if·(CbC·&&·CloseTPPips_·0)·
····················NewTP·BEb·CloseTPPips_;¤ ····················NewTP·BEb·CloseTPPips_;¤
····················sCalcTP·sCalcTP·-Close·TP·("·DTS(CloseTPPips_,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·-Close·TP·("·DTS(CloseTPPips_,·Digits())·")·";¤
················else·if·(BEb·BasePips·OPbL·tp2)· ················else·if·(BEb·BasePips·OPbL·tp2)·
····················NewTP·BEb·BasePips;¤ ····················NewTP·BEb·BasePips;¤
····················sCalcTP·sCalcTP·-Base·TP:·("·DTS(BasePips,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·-Base·TP:·("·DTS(BasePips,·Digits())·")·";¤
················else· ················else·
····················NewTP·OPbL·tp2;¤ ····················NewTP·OPbL·tp2;¤
····················sCalcTP·sCalcTP·-Grid·TP:·("·DTS(tp2,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·-Grid·TP:·("·DTS(tp2,·Digits())·")·";¤
················ ················
¤ ¤
················if·(MinTPPips_·0)· ················if·(MinTPPips_·0)·
····················NewTP·MathMin(NewTP,·BEb·MinTPPips_);¤ ····················NewTP·MathMin(NewTP,·BEb·MinTPPips_);¤
····················sCalcTP·sCalcTP·>Minimum·TP:·";¤ ····················sCalcTP·sCalcTP·>Minimum·TP:·";¤
················ ················
¤ ¤
················NewTP·-=·MoveTP_·Moves;¤ ················NewTP·-=·MoveTP_·Moves;¤
¤ ¤
················if·(BreakEvenTrade·&&·CbT·CbC·>=·BreakEvenTrade)· ················if·(BreakEvenTrade·&&·CbT·CbC·>=·BreakEvenTrade)·
····················NewTP·BEb·BEPlusPips_;¤ ····················NewTP·BEb·BEPlusPips_;¤
····················sCalcTP·sCalcTP·>BreakEven:·("·DTS(BEPlusPips_,·Digits())·")·";¤ ····················sCalcTP·sCalcTP·>BreakEven:·("·DTS(BEPlusPips_,·Digits())·")·";¤
················ ················
¤ ¤
················sCalcTP·(sCalcTP·"Sell:·TakeProfit:·");¤ ················sCalcTP·(sCalcTP·"Sell:·TakeProfit:·");¤
············ ············
¤ ¤
············if·(TPb·!=·NewTP)· ············if·(TPb·!=·NewTP)·
················TPb·NewTP;¤ ················TPb·NewTP;¤
¤ ¤
················if·(nLots·0)¤ ················if·(nLots·0)¤
····················TargetPips·ND(TPb·BEb,·Digits());¤ ····················TargetPips·ND(TPb·BEb,·Digits());¤
················else¤ ················else¤
····················TargetPips·ND(BEb·TPb,·Digits());¤ ····················TargetPips·ND(BEb·TPb,·Digits());¤
¤ ¤
················Print(sCalcTP·DTS(NewTP,·Digits()));¤ ················Print(sCalcTP·DTS(NewTP,·Digits()));¤
¤ ¤
················return;¤ ················return;¤
············ ············
········ ········
¤ ¤
········PbTarget·TargetPips·Pip;¤ ········PbTarget·TargetPips·Pip;¤
········ProfitPot·ND(TargetPips·PipVal2·MathAbs(nLots),·2);¤ ········ProfitPot·ND(TargetPips·PipVal2·MathAbs(nLots),·2);¤
¤ ¤
········if·(CbB·0)¤ ········if·(CbB·0)¤
············PbPips·ND((BID·BEb)·Pip,·1);¤ ············PbPips·ND((BID·BEb)·Pip,·1);¤
¤ ¤
········if·(CbS·0)¤ ········if·(CbS·0)¤
············PbPips·ND((BEb·ASK)·Pip,·1);¤ ············PbPips·ND((BEb·ASK)·Pip,·1);¤
¤ ¤
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Adjust·BEb/TakeProfit·if·Hedge·is·active························ ········//|·Adjust·BEb/TakeProfit·if·Hedge·is·active························
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········double·hAsk·SymbolInfoDouble(HedgeSymbol_,·SYMBOL_ASK);¤ ········double·hAsk·SymbolInfoDouble(HedgeSymbol_,·SYMBOL_ASK);¤
········double·hBid·SymbolInfoDouble(HedgeSymbol_,·SYMBOL_BID);¤ ········double·hBid·SymbolInfoDouble(HedgeSymbol_,·SYMBOL_BID);¤
········double·hSpread·hAsk·hBid;¤ ········double·hSpread·hAsk·hBid;¤
¤ ¤
········if·(hThisChart)¤ ········if·(hThisChart)¤
············nLots·+=·LhB·LhS;¤ ············nLots·+=·LhB·LhS;¤
¤ ¤
········double·PhPips;¤ ········double·PhPips;¤
¤ ¤
········if·(hActive·==·1)· ········if·(hActive·==·1)·
············if·(nLots·==·0)· ············if·(nLots·==·0)·
················BEa·0;¤ ················BEa·0;¤
················TPa·0;¤ ················TPa·0;¤
············else·if·(hThisChart)· ············else·if·(hThisChart)·
················if·(nLots·0)· ················if·(nLots·0)·
····················if·(CbB·0)¤ ····················if·(CbB·0)¤
························BEa·ND((BEb·LbT·(BEh·hSpread)·LhT)·(LbT·LhT),·Digits());¤ ························BEa·ND((BEb·LbT·(BEh·hSpread)·LhT)·(LbT·LhT),·Digits());¤
····················else¤ ····················else¤
························BEa·ND(((BEb·(ASK·BID))·LbT·BEh·LhT)·(LbT·LhT),·Digits());¤ ························BEa·ND(((BEb·(ASK·BID))·LbT·BEh·LhT)·(LbT·LhT),·Digits());¤
¤ ¤
····················TPa·ND(BEa·TargetPips,·Digits());¤ ····················TPa·ND(BEa·TargetPips,·Digits());¤
················else· ················else·
····················if·(CbS·0)¤ ····················if·(CbS·0)¤
························BEa·ND((BEb·LbT·(BEh·hSpread)·LhT)·(LbT·LhT),·Digits());¤ ························BEa·ND((BEb·LbT·(BEh·hSpread)·LhT)·(LbT·LhT),·Digits());¤
····················else¤ ····················else¤
························BEa·ND(((BEb·ASK·BID)·LbT·BEh·LhT)·(LbT·LhT),·Digits());¤ ························BEa·ND(((BEb·ASK·BID)·LbT·BEh·LhT)·(LbT·LhT),·Digits());¤
¤ ¤
····················TPa·ND(BEa·TargetPips,·Digits());¤ ····················TPa·ND(BEa·TargetPips,·Digits());¤
················ ················
············ ············
¤ ¤
············if·(ChB·0)¤ ············if·(ChB·0)¤
················PhPips·ND((hBid·BEh)·hPip,·1);¤ ················PhPips·ND((hBid·BEh)·hPip,·1);¤
¤ ¤
············if·(ChS·0)¤ ············if·(ChS·0)¤
················PhPips·ND((BEh·hAsk)·hPip,·1);¤ ················PhPips·ND((BEh·hAsk)·hPip,·1);¤
········else· ········else·
············BEa·BEb;¤ ············BEa·BEb;¤
············TPa·TPb;¤ ············TPa·TPb;¤
········ ········
¤ ¤
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Calculate·Early·Exit·Percentage································· ········//|·Calculate·Early·Exit·Percentage·································
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········double·EEStartTime·0,·TPaF;¤ ········double·EEStartTime·0,·TPaF;¤
¤ ¤
········if·(UseEarlyExit·&&·CbT·0)· ········if·(UseEarlyExit·&&·CbT·0)·
············datetime·EEopt;¤ ············datetime·EEopt;¤
¤ ¤
············if·(EEFirstTrade)¤ ············if·(EEFirstTrade)¤
················EEopt·OTbF;¤ ················EEopt·OTbF;¤
············else¤ ············else¤
················EEopt·OTbL;¤ ················EEopt·OTbL;¤
··MqlDateTime·date;¤ ··MqlDateTime·date;¤
··TimeToStruct(TimeCurrent(),date);¤ ··TimeToStruct(TimeCurrent(),date);¤
··MqlDateTime·dateEEopt;¤ ··MqlDateTime·dateEEopt;¤
··TimeToStruct(EEopt,dateEEopt);¤ ··TimeToStruct(EEopt,dateEEopt);¤
············if·(date.day_of_week·dateEEopt.day_of_week)¤ ············if·(date.day_of_week·dateEEopt.day_of_week)¤
················EEStartTime·24·3600;¤ ················EEStartTime·24·3600;¤
¤ ¤
············EEStartTime·+=·EEopt·EEStartHours·3600;¤ ············EEStartTime·+=·EEopt·EEStartHours·3600;¤
¤ ¤
············if·(EEHoursPC_·&&·TimeCurrent()·>=·EEStartTime)¤ ············if·(EEHoursPC_·&&·TimeCurrent()·>=·EEStartTime)¤
················EEpc·EEHoursPC_·(TimeCurrent()·EEStartTime)·3600;¤ ················EEpc·EEHoursPC_·(TimeCurrent()·EEStartTime)·3600;¤
¤ ¤
············if·(EELevelPC_·&&·(CbT·CbC)·>=·EEStartLevel)¤ ············if·(EELevelPC_·&&·(CbT·CbC)·>=·EEStartLevel)¤
················EEpc·+=·EELevelPC_·(CbT·CbC·EEStartLevel·1);¤ ················EEpc·+=·EELevelPC_·(CbT·CbC·EEStartLevel·1);¤
¤ ¤
············EEpc·EEpc;¤ ············EEpc·EEpc;¤
¤ ¤
············if·(!EEAllowLoss·&&·EEpc·0)¤ ············if·(!EEAllowLoss·&&·EEpc·0)¤
················EEpc·0;¤ ················EEpc·0;¤
¤ ¤
············PbTarget·*=·EEpc;¤ ············PbTarget·*=·EEpc;¤
············TPaF·ND((TPa·BEa)·EEpc·BEa,·Digits());¤ ············TPaF·ND((TPa·BEa)·EEpc·BEa,·Digits());¤
¤ ¤
············if·(displayOverlay·&&·displayLines·&&·(hActive·!=·||·(hActive·==·&&·hThisChart))·&&·(!Testing·||·(Testing·&&·Visual))·&&¤ ············if·(displayOverlay·&&·displayLines·&&·(hActive·!=·||·(hActive·==·&&·hThisChart))·&&·(!Testing·||·(Testing·&&·Visual))·&&¤
················EEpc·&&·(CbT·CbC·ChT·EECount·||·EETime·!=·iTime(Symbol(),Period(),0))·&&·((EEHoursPC_·&&·EEopt·EEStartHours·3600·iTime(Symbol(),Period(),0))·||·(EELevelPC_·&&·CbT·CbC·>=·EEStartLevel)))· ················EEpc·&&·(CbT·CbC·ChT·EECount·||·EETime·!=·iTime(Symbol(),Period(),0))·&&·((EEHoursPC_·&&·EEopt·EEStartHours·3600·iTime(Symbol(),Period(),0))·||·(EELevelPC_·&&·CbT·CbC·>=·EEStartLevel)))·
················EETime·iTime(Symbol(),Period(),0);¤ ················EETime·iTime(Symbol(),Period(),0);¤
················EECount·CbT·CbC·ChT;¤ ················EECount·CbT·CbC·ChT;¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3LEELn")·0)· ················if·(ObjectFind(ChartID(),pref+"B3LEELn")·0)·
····················ObjectCreate(ChartID(),pref+"B3LEELn",·OBJ_TREND,·0,·0,·0);¤ ····················ObjectCreate(ChartID(),pref+"B3LEELn",·OBJ_TREND,·0,·0,·0);¤
····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_COLOR,·Yellow);¤ ····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_COLOR,·Yellow);¤
····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_WIDTH,·1);¤ ····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_WIDTH,·1);¤
····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_STYLE,·0);¤ ····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_STYLE,·0);¤
····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_RAY,·false);¤ ····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_RAY,·false);¤
····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_BACK,·false);¤ ····················ObjectSetInteger(ChartID(),pref+"B3LEELn",·OBJPROP_BACK,·false);¤
················ ················
¤ ¤
················if·(EEHoursPC_·0)¤ ················if·(EEHoursPC_·0)¤
····················ObjectMove(ChartID(),pref+"B3LEELn",·0,·(datetime)·(MathFloor(EEopt·3600·EEStartHours)·3600),·TPa);¤ ····················ObjectMove(ChartID(),pref+"B3LEELn",·0,·(datetime)·(MathFloor(EEopt·3600·EEStartHours)·3600),·TPa);¤
················else¤ ················else¤
····················ObjectMove(ChartID(),pref+"B3LEELn",·0,·(datetime)·(MathFloor(EEopt·3600)·3600),·TPaF);¤ ····················ObjectMove(ChartID(),pref+"B3LEELn",·0,·(datetime)·(MathFloor(EEopt·3600)·3600),·TPaF);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LEELn",·1,·iTime(Symbol(),Period(),1),·TPaF);¤ ················ObjectMove(ChartID(),pref+"B3LEELn",·1,·iTime(Symbol(),Period(),1),·TPaF);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3VEELn")·0)· ················if·(ObjectFind(ChartID(),pref+"B3VEELn")·0)·
····················ObjectCreate(ChartID(),pref+"B3VEELn",·OBJ_TEXT,·0,·0,·0);¤ ····················ObjectCreate(ChartID(),pref+"B3VEELn",·OBJ_TEXT,·0,·0,·0);¤
····················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_COLOR,·Yellow);¤ ····················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_COLOR,·Yellow);¤
····················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_WIDTH,·1);¤ ····················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_WIDTH,·1);¤
····················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_STYLE,·0);¤ ····················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_STYLE,·0);¤
····················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_BACK,·false);¤ ····················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_BACK,·false);¤
················ ················
¤ ¤
················ObjSetTxt("B3VEELn",··············DTS(TPaF,·Digits()),·-1,·Yellow);¤ ················ObjSetTxt("B3VEELn",··············DTS(TPaF,·Digits()),·-1,·Yellow);¤
················ObjectSetDouble(ChartID(),pref+"B3VEELn",·OBJPROP_PRICE,·TPaF·Pip);¤ ················ObjectSetDouble(ChartID(),pref+"B3VEELn",·OBJPROP_PRICE,·TPaF·Pip);¤
················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_TIME,·iTime(Symbol(),Period(),1));¤ ················ObjectSetInteger(ChartID(),pref+"B3VEELn",·OBJPROP_TIME,·iTime(Symbol(),Period(),1));¤
············else·if·((!displayLines·||·EEpc·==·||·(!EEAllowLoss·&&·EEpc·==·0)·||·(EEHoursPC_·&&·EEopt·EEStartHours·3600·>=·iTime(Symbol(),Period(),0))))· ············else·if·((!displayLines·||·EEpc·==·||·(!EEAllowLoss·&&·EEpc·==·0)·||·(EEHoursPC_·&&·EEopt·EEStartHours·3600·>=·iTime(Symbol(),Period(),0))))·
················ObjDel("B3LEELn");¤ ················ObjDel("B3LEELn");¤
················ObjDel("B3VEELn");¤ ················ObjDel("B3VEELn");¤
············ ············
········else· ········else·
············TPaF·TPa;¤ ············TPaF·TPa;¤
············EETime·0;¤ ············EETime·0;¤
············EECount·0;¤ ············EECount·0;¤
············ObjDel("B3LEELn");¤ ············ObjDel("B3LEELn");¤
············ObjDel("B3VEELn");¤ ············ObjDel("B3VEELn");¤
········ ········
¤ ¤
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Maximize·Profit·with·Moving·TP·and·setting·Trailing·Profit·Stop· ········//|·Maximize·Profit·with·Moving·TP·and·setting·Trailing·Profit·Stop·
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········if·(MaximizeProfit)· ········if·(MaximizeProfit)·
············if·(CbT·==·0)· ············if·(CbT·==·0)·
················SLbL·0;¤ ················SLbL·0;¤
················Moves·0;¤ ················Moves·0;¤
················SLb·0;¤ ················SLb·0;¤
············ ············
¤ ¤
············if·(!FirstRun·&&·CbT·0)· ············if·(!FirstRun·&&·CbT·0)·
················if·(Pb·Ph·&&·SLb·0)¤ ················if·(Pb·Ph·&&·SLb·0)¤
····················SLb·0;¤ ····················SLb·0;¤
¤ ¤
················if·(SLb·&&·((nLots·&&·BID·SLb)·||·(nLots·&&·ASK·SLb)))· ················if·(SLb·&&·((nLots·&&·BID·SLb)·||·(nLots·&&·ASK·SLb)))·
····················ExitTrades(A,·displayColorProfit,·"Profit·Trailing·Stop·Reached·("·DTS(ProfitSet_·100,·2)·"%)");¤ ····················ExitTrades(A,·displayColorProfit,·"Profit·Trailing·Stop·Reached·("·DTS(ProfitSet_·100,·2)·"%)");¤
¤ ¤
····················return;¤ ····················return;¤
················ ················
¤ ¤
················if·(PbTarget·0)· ················if·(PbTarget·0)·
····················TPbMP·ND(BEa·(TPa·BEa)·ProfitSet_,·Digits());¤ ····················TPbMP·ND(BEa·(TPa·BEa)·ProfitSet_,·Digits());¤
¤ ¤
····················if·((nLots·&&·BID·TPbMP)·||·(nLots·&&·ASK·TPbMP))¤ ····················if·((nLots·&&·BID·TPbMP)·||·(nLots·&&·ASK·TPbMP))¤
························SLb·TPbMP;¤ ························SLb·TPbMP;¤
················ ················
¤ ¤
················if·(SLb·&&·SLb·!=·SLbL·&&·MoveTP_·&&·TotalMoves·Moves)· ················if·(SLb·&&·SLb·!=·SLbL·&&·MoveTP_·&&·TotalMoves·Moves)·
····················TPb·0;¤ ····················TPb·0;¤
····················Moves++;¤ ····················Moves++;¤
¤ ¤
····················if·(Debug_)¤ ····················if·(Debug_)¤
························Print("MoveTP");¤ ························Print("MoveTP");¤
¤ ¤
····················SLbL·SLb;¤ ····················SLbL·SLb;¤
¤ ¤
····················if·(PlaySounds)¤ ····················if·(PlaySounds)¤
························PlaySound(AlertSound);¤ ························PlaySound(AlertSound);¤
¤ ¤
····················return;¤ ····················return;¤
················ ················
············ ············
········ ········
¤ ¤
········if·(!FirstRun·&&·TPaF·0)· ········if·(!FirstRun·&&·TPaF·0)·
············if·((nLots·&&·BID·>=·TPaF)·||·(nLots·&&·ASK·<=·TPaF))· ············if·((nLots·&&·BID·>=·TPaF)·||·(nLots·&&·ASK·<=·TPaF))·
················ExitTrades(A,·displayColorProfit,·"Profit·Target·Reached·DTS(TPaF,·Digits()));¤ ················ExitTrades(A,·displayColorProfit,·"Profit·Target·Reached·DTS(TPaF,·Digits()));¤
¤ ¤
················return;¤ ················return;¤
············ ············
········ ········
¤ ¤
········if·(!FirstRun·&&·UseStopLoss)· ········if·(!FirstRun·&&·UseStopLoss)·
············if·(SLPips_·0)· ············if·(SLPips_·0)·
················if·(nLots·0)· ················if·(nLots·0)·
····················bSL·BEa·SLPips_;¤ ····················bSL·BEa·SLPips_;¤
¤ ¤
····················if·(BID·<=·bSL)· ····················if·(BID·<=·bSL)·
························ExitTrades(A,·displayColorProfit,·"Stop·Loss·Reached");¤ ························ExitTrades(A,·displayColorProfit,·"Stop·Loss·Reached");¤
¤ ¤
························return;¤ ························return;¤
···················· ····················
················else·if·(nLots·0)· ················else·if·(nLots·0)·
····················bSL·BEa·SLPips_;¤ ····················bSL·BEa·SLPips_;¤
¤ ¤
····················if·(ASK·>=·bSL)· ····················if·(ASK·>=·bSL)·
························ExitTrades(A,·displayColorProfit,·"Stop·Loss·Reached");¤ ························ExitTrades(A,·displayColorProfit,·"Stop·Loss·Reached");¤
¤ ¤
························return;¤ ························return;¤
···················· ····················
················ ················
············ ············
¤ ¤
············if·(TSLPips_·!=·0)· ············if·(TSLPips_·!=·0)·
················if·(nLots·0)· ················if·(nLots·0)·
····················if·(TSLPips_·&&·BID·BEa·TSLPips_)¤ ····················if·(TSLPips_·&&·BID·BEa·TSLPips_)¤
························bTS·MathMax(bTS,·BID·TSLPips_);¤ ························bTS·MathMax(bTS,·BID·TSLPips_);¤
¤ ¤
····················if·(TSLPips_·&&·BID·BEa·TSLPips_)¤ ····················if·(TSLPips_·&&·BID·BEa·TSLPips_)¤
························bTS·MathMax(bTS,·BID·MathMax(TSLPipsMin_,·-TSLPips_·(1·(BID·BEa·TSLPips_)·(-TSLPips_·2))));¤ ························bTS·MathMax(bTS,·BID·MathMax(TSLPipsMin_,·-TSLPips_·(1·(BID·BEa·TSLPips_)·(-TSLPips_·2))));¤
¤ ¤
····················if·(bTS·&&·BID·<=·bTS)· ····················if·(bTS·&&·BID·<=·bTS)·
························ExitTrades(A,·displayColorProfit,·"Trailing·Stop·Reached");¤ ························ExitTrades(A,·displayColorProfit,·"Trailing·Stop·Reached");¤
¤ ¤
························return;¤ ························return;¤
···················· ····················
················else·if·(nLots·0)· ················else·if·(nLots·0)·
····················if·(TSLPips_·&&·ASK·BEa·TSLPips_)· ····················if·(TSLPips_·&&·ASK·BEa·TSLPips_)·
························if·(bTS·0)¤ ························if·(bTS·0)¤
····························bTS·MathMin(bTS,·ASK·TSLPips_);¤ ····························bTS·MathMin(bTS,·ASK·TSLPips_);¤
························else¤ ························else¤
····························bTS·ASK·TSLPips_;¤ ····························bTS·ASK·TSLPips_;¤
···················· ····················
¤ ¤
····················if·(TSLPips_·&&·ASK·BEa·TSLPips_)¤ ····················if·(TSLPips_·&&·ASK·BEa·TSLPips_)¤
························bTS·MathMin(bTS,·ASK·MathMax(TSLPipsMin_,·-TSLPips_·(1·(BEa·ASK·TSLPips_)·(-TSLPips_·2))));¤ ························bTS·MathMin(bTS,·ASK·MathMax(TSLPipsMin_,·-TSLPips_·(1·(BEa·ASK·TSLPips_)·(-TSLPips_·2))));¤
¤ ¤
····················if·(bTS·&&·ASK·>=·bTS)· ····················if·(bTS·&&·ASK·>=·bTS)·
························ExitTrades(A,·displayColorProfit,·"Trailing·Stop·Reached");¤ ························ExitTrades(A,·displayColorProfit,·"Trailing·Stop·Reached");¤
¤ ¤
························return;¤ ························return;¤
···················· ····················
················ ················
············ ············
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Check·for·and·Delete·hanging·pending·orders····················· ········//|·Check·for·and·Delete·hanging·pending·orders·····················
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········if·(CbT·==·&&·!PendLot)· ········if·(CbT·==·&&·!PendLot)·
············PendLot·true;¤ ············PendLot·true;¤
//Заменить¤ //Заменить¤
············for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)· ············for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)·
················if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤ ················if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤
····················continue;¤ ····················continue;¤
¤ ¤
················if·(OrderMagicNumber()·!=·Magic·||·OrderType()·<=·OP_SELL)¤ ················if·(OrderMagicNumber()·!=·Magic·||·OrderType()·<=·OP_SELL)¤
····················continue;¤ ····················continue;¤
¤ ¤
················if·(ND(OrderLots(),·LotDecimal)·ND(Lots[0]·LotMult,·LotDecimal))· ················if·(ND(OrderLots(),·LotDecimal)·ND(Lots[0]·LotMult,·LotDecimal))·
····················PendLot·false;¤ ····················PendLot·false;¤
¤ ¤
····················//while·(IsTradeContextBusy())¤ ····················//while·(IsTradeContextBusy())¤
····················//····Sleep(100);¤ ····················//····Sleep(100);¤
¤ ¤
····················if·(IsStopped())¤ ····················if·(IsStopped())¤
························return;¤ ························return;¤
¤ ¤
····················Success·OrderDelete(OrderTicket());¤ ····················Success·OrderDelete(OrderTicket());¤
¤ ¤
····················if·(Success)· ····················if·(Success)·
························PendLot·true;¤ ························PendLot·true;¤
¤ ¤
························if·(Debug_)¤ ························if·(Debug_)¤
····························Print("Delete·pending·Lot");¤ ····························Print("Delete·pending·Lot");¤
···················· ····················
················ ················
············ ············
¤ ¤
············return;¤ ············return;¤
········else·if·((CbT·||·(CbT·==·&&·CpT·&&·!B3Traditional))·&&·PendLot)· ········else·if·((CbT·||·(CbT·==·&&·CpT·&&·!B3Traditional))·&&·PendLot)·
············PendLot·false;¤ ············PendLot·false;¤
//Заменить¤ //Заменить¤
············for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)· ············for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)·
················if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤ ················if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤
····················continue;¤ ····················continue;¤
¤ ¤
················if·(OrderMagicNumber()·!=·Magic·||·OrderType()·<=·OP_SELL)¤ ················if·(OrderMagicNumber()·!=·Magic·||·OrderType()·<=·OP_SELL)¤
····················continue;¤ ····················continue;¤
¤ ¤
················if·(ND(OrderLots(),·LotDecimal)·==·ND(Lots[0]·LotMult,·LotDecimal))· ················if·(ND(OrderLots(),·LotDecimal)·==·ND(Lots[0]·LotMult,·LotDecimal))·
····················PendLot·true;¤ ····················PendLot·true;¤
¤ ¤
····················//while·(IsTradeContextBusy())¤ ····················//while·(IsTradeContextBusy())¤
····················//····Sleep(100);¤ ····················//····Sleep(100);¤
¤ ¤
····················if·(IsStopped())¤ ····················if·(IsStopped())¤
························return;¤ ························return;¤
¤ ¤
····················Success·OrderDelete(OrderTicket());¤ ····················Success·OrderDelete(OrderTicket());¤
¤ ¤
····················if·(Success)· ····················if·(Success)·
························PendLot·false;¤ ························PendLot·false;¤
¤ ¤
························if·(Debug_)¤ ························if·(Debug_)¤
····························Print("Delete·pending·Lot");¤ ····························Print("Delete·pending·Lot");¤
···················· ····················
················ ················
············ ············
¤ ¤
············return;¤ ············return;¤
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Check·ca,·Breakeven·Trades·and·Emergency·Close·All·············· ········//|·Check·ca,·Breakeven·Trades·and·Emergency·Close·All··············
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········switch·(ca)· ········switch·(ca)·
········case·B:¤ ········case·B:¤
············if·(CbT·==·&&·CpT·==·0)¤ ············if·(CbT·==·&&·CpT·==·0)¤
················ca·0;¤ ················ca·0;¤
¤ ¤
············break;¤ ············break;¤
········case·H:¤ ········case·H:¤
············if·(ChT·==·0)¤ ············if·(ChT·==·0)¤
················ca·0;¤ ················ca·0;¤
¤ ¤
············break;¤ ············break;¤
········case·A:¤ ········case·A:¤
············if·(CbT·==·&&·CpT·==·&&·ChT·==·0)¤ ············if·(CbT·==·&&·CpT·==·&&·ChT·==·0)¤
················ca·0;¤ ················ca·0;¤
¤ ¤
············break;¤ ············break;¤
········case·P:¤ ········case·P:¤
············if·(CpT·==·0)¤ ············if·(CpT·==·0)¤
················ca·0;¤ ················ca·0;¤
¤ ¤
············break;¤ ············break;¤
········case·T:¤ ········case·T:¤
············break;¤ ············break;¤
········default:¤ ········default:¤
············break;¤ ············break;¤
········ ········
¤ ¤
········if·(ca·0)· ········if·(ca·0)·
············ExitTrades(ca,·displayColorLoss,·"Close·All·("·DTS(ca,·0)·")");¤ ············ExitTrades(ca,·displayColorLoss,·"Close·All·("·DTS(ca,·0)·")");¤
¤ ¤
············return;¤ ············return;¤
········else·if·(CbT·==·&&·ChT·0)· ········else·if·(CbT·==·&&·ChT·0)·
············ExitTrades(H,·displayColorLoss,·"Basket·Closed");¤ ············ExitTrades(H,·displayColorLoss,·"Basket·Closed");¤
¤ ¤
············return;¤ ············return;¤
········else·if·(EmergencyCloseAll_)· ········else·if·(EmergencyCloseAll_)·
············ExitTrades(A,·displayColorLoss,·"Emergency·Close-All-Trades");¤ ············ExitTrades(A,·displayColorLoss,·"Emergency·Close-All-Trades");¤
············EmergencyCloseAll_·false;¤ ············EmergencyCloseAll_·false;¤
¤ ¤
············return;¤ ············return;¤
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Check·Holiday·Shutdown·········································· ········//|·Check·Holiday·Shutdown··········································
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········if·(UseHolidayShutdown)· ········if·(UseHolidayShutdown)·
············if·(HolShutDown·&&·TimeCurrent()·>=·HolLast·&&·HolLast·0)· ············if·(HolShutDown·&&·TimeCurrent()·>=·HolLast·&&·HolLast·0)·
················Print("Trading·has·resumed·after·the·",·TimeToString(HolFirst,·TIME_DATE),·",·TimeToString(HolLast,·TIME_DATE),·holidays.");¤ ················Print("Trading·has·resumed·after·the·",·TimeToString(HolFirst,·TIME_DATE),·",·TimeToString(HolLast,·TIME_DATE),·holidays.");¤
················HolShutDown·0;¤ ················HolShutDown·0;¤
················LabelDelete();¤ ················LabelDelete();¤
················LabelCreate();¤ ················LabelCreate();¤
¤ ¤
················if·(PlaySounds)¤ ················if·(PlaySounds)¤
····················PlaySound(AlertSound);¤ ····················PlaySound(AlertSound);¤
············ ············
¤ ¤
············if·(HolShutDown·==·3)· ············if·(HolShutDown·==·3)·
················if·(ObjectFind(ChartID(),pref+"B3LStop")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LStop")·==·-1)¤
····················CreateLabel("B3LStop",·"Trading·has·been·paused·on·this·pair·for·the·holidays.",·10,·0,·0,·3,·displayColorLoss);¤ ····················CreateLabel("B3LStop",·"Trading·has·been·paused·on·this·pair·for·the·holidays.",·10,·0,·0,·3,·displayColorLoss);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3LResm")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LResm")·==·-1)¤
····················CreateLabel("B3LResm",·"Trading·will·resume·trading·after·TimeToString(HolLast,·TIME_DATE)·".",·10,·0,·0,·9,·displayColorLoss);¤ ····················CreateLabel("B3LResm",·"Trading·will·resume·trading·after·TimeToString(HolLast,·TIME_DATE)·".",·10,·0,·0,·9,·displayColorLoss);¤
¤ ¤
················return;¤ ················return;¤
············else·if·((HolShutDown·==·&&·TimeCurrent()·>=·HolLast)·||·HolFirst·==·0)· ············else·if·((HolShutDown·==·&&·TimeCurrent()·>=·HolLast)·||·HolFirst·==·0)·
················for·(int·Index·0;·Index·ArraySize(HolArray);·Index++)· ················for·(int·Index·0;·Index·ArraySize(HolArray);·Index++)·
····················if(ArrayRange(HolArray,0)<=Index)¤ ····················if(ArrayRange(HolArray,0)<=Index)¤
····················break;¤ ····················break;¤
····················//·HolFirst·StrToTime((string)·Year()·"."·(string)·HolArray[Index,·0]·"."·(string)·HolArray[Index,·1]);¤ ····················//·HolFirst·StrToTime((string)·Year()·"."·(string)·HolArray[Index,·0]·"."·(string)·HolArray[Index,·1]);¤
······················MqlDateTime·date;¤ ······················MqlDateTime·date;¤
·····················TimeToStruct(TimeCurrent(),date);¤ ·····················TimeToStruct(TimeCurrent(),date);¤
»   »   »   »   »   string·tts·(string)·date.year·"."·(string)·HolArray[Index,·0]·"."·(string)·HolArray[Index,·1];¤ »   »   »   »   »   string·tts·(string)·date.year·"."·(string)·HolArray[Index,·0]·"."·(string)·HolArray[Index,·1];¤
»   »   »   »   »   Print("tts:·tts··*******************************************************");¤ »   »   »   »   »   Print("tts:·tts··*******************************************************");¤
····················HolFirst·StringToTime(tts);¤ ····················HolFirst·StringToTime(tts);¤
¤ ¤
····················HolLast·StringToTime((string)·date.year·"."·(string)·HolArray[Index,·2]·"."·(string)·HolArray[Index,·3]·23:59:59");¤ ····················HolLast·StringToTime((string)·date.year·"."·(string)·HolArray[Index,·2]·"."·(string)·HolArray[Index,·3]·23:59:59");¤
¤ ¤
····················if·(TimeCurrent()·HolFirst)· ····················if·(TimeCurrent()·HolFirst)·
························if·(HolFirst·HolLast)¤ ························if·(HolFirst·HolLast)¤
····························HolLast·StringToTime((string)(date.year·1)·"."·(string)·HolArray[Index,·2]·"."·(string)·HolArray[Index,·3]·23:59:59");¤ ····························HolLast·StringToTime((date.year·1)·"."·(string)·HolArray[Index,·2]·"."·(string)·HolArray[Index,·3]·23:59:59");¤
¤ ¤
························break;¤ ························break;¤
···················· ····················
¤ ¤
····················if·(TimeCurrent()·HolLast)· ····················if·(TimeCurrent()·HolLast)·
························if·(HolFirst·HolLast)¤ ························if·(HolFirst·HolLast)¤
····························HolFirst·StringToTime((string)(date.year·1)·"."·(string)·HolArray[Index,·0]·"."·(string)·HolArray[Index,·1]);¤ ····························HolFirst·StringToTime((date.year·1)·"."·(string)·HolArray[Index,·0]·"."·(string)·HolArray[Index,·1]);¤
¤ ¤
························break;¤ ························break;¤
···················· ····················
¤ ¤
····················if·(TimeCurrent()·HolFirst·&&·HolFirst·HolLast)· ····················if·(TimeCurrent()·HolFirst·&&·HolFirst·HolLast)·
························HolLast·StringToTime((string)(date.year·1)·"."·(string)·HolArray[Index,·2]·"."·(string)·HolArray[Index,·3]·23:59:59");¤ ························HolLast·StringToTime((date.year·1)·"."·(string)·HolArray[Index,·2]·"."·(string)·HolArray[Index,·3]·23:59:59");¤
¤ ¤
························if·(TimeCurrent()·HolLast)¤ ························if·(TimeCurrent()·HolLast)¤
····························break;¤ ····························break;¤
···················· ····················
················ ················
¤ ¤
················if·(TimeCurrent()·>=·HolFirst·&&·TimeCurrent()·<=·HolLast)· ················if·(TimeCurrent()·>=·HolFirst·&&·TimeCurrent()·<=·HolLast)·
····················//·Comment("");·//·xxx¤ ····················//·Comment("");·//·xxx¤
····················HolShutDown·1;¤ ····················HolShutDown·1;¤
················ ················
············else·if·(HolShutDown·==·&&·TimeCurrent()·>=·HolFirst·&&·TimeCurrent()·HolLast)¤ ············else·if·(HolShutDown·==·&&·TimeCurrent()·>=·HolFirst·&&·TimeCurrent()·HolLast)¤
················HolShutDown·1;¤ ················HolShutDown·1;¤
¤ ¤
············if·(HolShutDown·==·&&·CbT·==·0)· ············if·(HolShutDown·==·&&·CbT·==·0)·
················Print("Trading·has·been·paused·for·holidays·(",·TimeToString(HolFirst,·TIME_DATE),·",·TimeToString(HolLast,·TIME_DATE),·")");¤ ················Print("Trading·has·been·paused·for·holidays·(",·TimeToString(HolFirst,·TIME_DATE),·",·TimeToString(HolLast,·TIME_DATE),·")");¤
¤ ¤
················if·(CpT·0)· ················if·(CpT·0)·
····················int·Index·ExitTrades(P,·displayColorLoss,·"Holiday·Shutdown");¤ ····················int·Index·ExitTrades(P,·displayColorLoss,·"Holiday·Shutdown");¤
¤ ¤
····················if·(Index·==·CpT)¤ ····················if·(Index·==·CpT)¤
························ca·0;¤ ························ca·0;¤
················ ················
¤ ¤
················HolShutDown·2;¤ ················HolShutDown·2;¤
················ObjDel("B3LClos");¤ ················ObjDel("B3LClos");¤
············else·if·(HolShutDown·==·1)· ············else·if·(HolShutDown·==·1)·
················if·(ObjectFind(ChartID(),pref+"B3LClos")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LClos")·==·-1)¤
····················CreateLabel("B3LClos",·"",·5,·0,·0,·23,·displayColorLoss);¤ ····················CreateLabel("B3LClos",·"",·5,·0,·0,·23,·displayColorLoss);¤
¤ ¤
················ObjSetTxt("B3LClos",·"Trading·will·pause·for·holidays·when·this·basket·closes",·5);¤ ················ObjSetTxt("B3LClos",·"Trading·will·pause·for·holidays·when·this·basket·closes",·5);¤
············ ············
¤ ¤
············if·(HolShutDown·==·2)· ············if·(HolShutDown·==·2)·
················LabelDelete();¤ ················LabelDelete();¤
¤ ¤
················if·(PlaySounds)¤ ················if·(PlaySounds)¤
····················PlaySound(AlertSound);¤ ····················PlaySound(AlertSound);¤
¤ ¤
················HolShutDown·3;¤ ················HolShutDown·3;¤
············ ············
¤ ¤
············if·(HolShutDown·==·3)· ············if·(HolShutDown·==·3)·
················if·(ObjectFind(ChartID(),pref+"B3LStop")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LStop")·==·-1)¤
····················CreateLabel("B3LStop",·"Trading·has·been·paused·on·this·pair·due·to·holidays.",·10,·0,·0,·3,·displayColorLoss);¤ ····················CreateLabel("B3LStop",·"Trading·has·been·paused·on·this·pair·due·to·holidays.",·10,·0,·0,·3,·displayColorLoss);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3LResm")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LResm")·==·-1)¤
····················CreateLabel("B3LResm",·"Trading·will·resume·after·TimeToString(HolLast,·TIME_DATE)·".",·10,·0,·0,·9,·displayColorLoss);¤ ····················CreateLabel("B3LResm",·"Trading·will·resume·after·TimeToString(HolLast,·TIME_DATE)·".",·10,·0,·0,·9,·displayColorLoss);¤
¤ ¤
················//·Comment("");·//·xxx¤ ················//·Comment("");·//·xxx¤
¤ ¤
················return;¤ ················return;¤
············ ············
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Power·Out·Stop·Loss·Protection·································· ········//|·Power·Out·Stop·Loss·Protection··································
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········if·(SetPOSL)· ········if·(SetPOSL)·
············if·(UsePowerOutSL·&&·POSLPips_·0)· ············if·(UsePowerOutSL·&&·POSLPips_·0)·
···············double·POSL·0;¤ ···············double·POSL·0;¤
···············if(·LbT!=0·&&·PipVal2·!=0·&&··PipVal2·LbT·!=0)¤ ···············if(·LbT!=0·&&·PipVal2·!=0·&&··PipVal2·LbT·!=0)¤
················POSL·MathMin(PortionBalance·(MaxDDPercent·1)·100·PipVal2·LbT,·POSLPips_);¤ ················POSL·MathMin(PortionBalance·(MaxDDPercent·1)·100·PipVal2·LbT,·POSLPips_);¤
················SLbB·ND(BEb·POSL,·Digits());¤ ················SLbB·ND(BEb·POSL,·Digits());¤
················SLbS·ND(BEb·POSL,·Digits());¤ ················SLbS·ND(BEb·POSL,·Digits());¤
············else· ············else·
················SLbB·0;¤ ················SLbB·0;¤
················SLbS·0;¤ ················SLbS·0;¤
············ ············
//Заменить¤ //Заменить¤
············for·(int·Order·0;·Order·OrdersTotal();·Order++)· ············for·(int·Order·0;·Order·OrdersTotal();·Order++)·
················if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤ ················if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤
····················continue;¤ ····················continue;¤
¤ ¤
················if·(OrderMagicNumber()·!=·Magic·||·OrderSymbol()·!=·Symbol()·||·OrderType()·OP_SELL)¤ ················if·(OrderMagicNumber()·!=·Magic·||·OrderSymbol()·!=·Symbol()·||·OrderType()·OP_SELL)¤
····················continue;¤ ····················continue;¤
¤ ¤
················if·(OrderType()·==·OP_BUY·&&·OrderStopLoss()·!=·SLbB)· ················if·(OrderType()·==·OP_BUY·&&·OrderStopLoss()·!=·SLbB)·
····················Success·ModifyOrder(OrderOpenPrice(),·SLbB,·Purple);¤ ····················Success·ModifyOrder(OrderOpenPrice(),·SLbB,·Purple);¤
¤ ¤
····················if·(Debug_·&&·Success)¤ ····················if·(Debug_·&&·Success)¤
························Print("Order·",·OrderTicket(),·":·Sync·POSL·Buy");¤ ························Print("Order·",·OrderTicket(),·":·Sync·POSL·Buy");¤
················else·if·(OrderType()·==·OP_SELL·&&·OrderStopLoss()·!=·SLbS)· ················else·if·(OrderType()·==·OP_SELL·&&·OrderStopLoss()·!=·SLbS)·
····················Success·ModifyOrder(OrderOpenPrice(),·SLbS,·Purple);¤ ····················Success·ModifyOrder(OrderOpenPrice(),·SLbS,·Purple);¤
¤ ¤
····················if·(Debug_·&&·Success)¤ ····················if·(Debug_·&&·Success)¤
························Print("Order·",·OrderTicket(),·":·Sync·POSL·Sell");¤ ························Print("Order·",·OrderTicket(),·":·Sync·POSL·Sell");¤
················ ················
············ ············
········ ········
········//+-----------------------------------------------------------------+··<<·This·must·be·the·first·_Entry·check.¤ ········//+-----------------------------------------------------------------+··<<·This·must·be·the·first·_Entry·check.¤
········//|·Moving·Average·Indicator·for·Order·_Entry·························<<·Add·your·own·Indicator·_Entry·checks¤ ········//|·Moving·Average·Indicator·for·Order·_Entry·························<<·Add·your·own·Indicator·_Entry·checks¤
········//+-----------------------------------------------------------------+··<<·after·the·Moving·Average·_Entry.¤ ········//+-----------------------------------------------------------------+··<<·after·the·Moving·Average·_Entry.¤
········if·(MAEntry_·&&·CbT·==·&&·CpT·2)· ········if·(MAEntry_·&&·CbT·==·&&·CpT·2)·
············if·(BID·ima_0[0]·MADistance_·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))· ············if·(BID·ima_0[0]·MADistance_·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))·
················if·(MAEntry_·==·1)· ················if·(MAEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················else·if·(MAEntry_·==·2)· ················else·if·(MAEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················ ················
············else·if·(ASK·ima_0[0]·MADistance_·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))· ············else·if·(ASK·ima_0[0]·MADistance_·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))·
················if·(MAEntry_·==·1)· ················if·(MAEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················else·if·(MAEntry_·==·2)· ················else·if·(MAEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················ ················
············else·if·(B3Traditional·&&·Trend·==·2)· ············else·if·(B3Traditional·&&·Trend·==·2)·
················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
····················BuyMe·true;¤ ····················BuyMe·true;¤
¤ ¤
················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
····················SellMe·true;¤ ····················SellMe·true;¤
············else· ············else·
················BuyMe·false;¤ ················BuyMe·false;¤
················SellMe·false;¤ ················SellMe·false;¤
············ ············
¤ ¤
············if·(IndEntry·0)¤ ············if·(IndEntry·0)¤
················IndicatorUsed·IndicatorUsed·UAE;¤ ················IndicatorUsed·IndicatorUsed·UAE;¤
¤ ¤
············IndEntry++;¤ ············IndEntry++;¤
············IndicatorUsed·IndicatorUsed·MA·";¤ ············IndicatorUsed·IndicatorUsed·MA·";¤
········ ········
········//+----------------------------------------------------------------+¤ ········//+----------------------------------------------------------------+¤
········//|·CCI·of·5M,·15M,·30M,·1H·for·Market·Condition·and·Order·_Entry······ ········//|·CCI·of·5M,·15M,·30M,·1H·for·Market·Condition·and·Order·_Entry······
········//+----------------------------------------------------------------+¤ ········//+----------------------------------------------------------------+¤
········if·(CCIEntry_·0)· ········if·(CCIEntry_·0)·
············CopyBuffer(cci_01_handle,·0,·0,·2,·cci_01);¤ ············CopyBuffer(cci_01_handle,·0,·0,·2,·cci_01);¤
············CopyBuffer(cci_02_handle,·0,·0,·2,·cci_02);¤ ············CopyBuffer(cci_02_handle,·0,·0,·2,·cci_02);¤
············CopyBuffer(cci_03_handle,·0,·0,·2,·cci_03);¤ ············CopyBuffer(cci_03_handle,·0,·0,·2,·cci_03);¤
············CopyBuffer(cci_04_handle,·0,·0,·2,·cci_04);¤ ············CopyBuffer(cci_04_handle,·0,·0,·2,·cci_04);¤
········ ········
¤ ¤
········if·(CCIEntry_·&&·CbT·==·&&·CpT·2)· ········if·(CCIEntry_·&&·CbT·==·&&·CpT·2)·
············if·(cci_01[1]·&&·cci_02[1]·&&·cci_03[1]·&&·cci_04[1]·&&·cci_01[0]·&&·cci_02[0]·&&·cci_03[0]·&&·cci_04[0]·0)· ············if·(cci_01[1]·&&·cci_02[1]·&&·cci_03[1]·&&·cci_04[1]·&&·cci_01[0]·&&·cci_02[0]·&&·cci_03[0]·&&·cci_04[0]·0)·
················if·(ForceMarketCond_·==·3)¤ ················if·(ForceMarketCond_·==·3)¤
····················Trend·0;¤ ····················Trend·0;¤
¤ ¤
················if·(CCIEntry_·==·1)· ················if·(CCIEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················else·if·(CCIEntry_·==·2)· ················else·if·(CCIEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················ ················
············else·if·(cci_01[1]·&&·cci_02[1]·&&·cci_03[1]·&&·cci_04[1]·&&·cci_01[0]·&&·cci_02[0]·&&·cci_03[0]·&&·cci_04[0]·0)· ············else·if·(cci_01[1]·&&·cci_02[1]·&&·cci_03[1]·&&·cci_04[1]·&&·cci_01[0]·&&·cci_02[0]·&&·cci_03[0]·&&·cci_04[0]·0)·
················if·(ForceMarketCond_·==·3)¤ ················if·(ForceMarketCond_·==·3)¤
····················Trend·1;¤ ····················Trend·1;¤
¤ ¤
················if·(CCIEntry_·==·1)· ················if·(CCIEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················else·if·(CCIEntry_·==·2)· ················else·if·(CCIEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················ ················
············else·if·(!UseAnyEntry·&&·IndEntry·0)· ············else·if·(!UseAnyEntry·&&·IndEntry·0)·
················BuyMe·false;¤ ················BuyMe·false;¤
················SellMe·false;¤ ················SellMe·false;¤
············ ············
¤ ¤
············if·(IndEntry·0)¤ ············if·(IndEntry·0)¤
················IndicatorUsed·IndicatorUsed·UAE;¤ ················IndicatorUsed·IndicatorUsed·UAE;¤
¤ ¤
············IndEntry++;¤ ············IndEntry++;¤
············IndicatorUsed·IndicatorUsed·CCI·";¤ ············IndicatorUsed·IndicatorUsed·CCI·";¤
········ ········
········//+----------------------------------------------------------------+¤ ········//+----------------------------------------------------------------+¤
········//|·Bollinger·Band·Indicator·for·Order·_Entry······················· ········//|·Bollinger·Band·Indicator·for·Order·_Entry·······················
········//+----------------------------------------------------------------+¤ ········//+----------------------------------------------------------------+¤
········if·(BollingerEntry_·&&·CbT·==·&&·CpT·2)· ········if·(BollingerEntry_·&&·CbT·==·&&·CpT·2)·
············double·ma[1];¤ ············double·ma[1];¤
············CopyBuffer(ma1handle,0,0,1,ma);¤ ············CopyBuffer(ma1handle,0,0,1,ma);¤
············¤ ············¤
············double·stddev[1];¤ ············double·stddev[1];¤
············CopyBuffer(stddevhandle,0,0,1,stddev);¤ ············CopyBuffer(stddevhandle,0,0,1,stddev);¤
¤ ¤
············double·bup·ma[0]·(BollDeviation·stddev[0]);¤ ············double·bup·ma[0]·(BollDeviation·stddev[0]);¤
············double·bdn·ma[0]·(BollDeviation·stddev[0]);¤ ············double·bdn·ma[0]·(BollDeviation·stddev[0]);¤
············double·bux·bup·BollDistance_;¤ ············double·bux·bup·BollDistance_;¤
············double·bdx·bdn·BollDistance_;¤ ············double·bdx·bdn·BollDistance_;¤
¤ ¤
············if·(ASK·bdx)· ············if·(ASK·bdx)·
················if·(BollingerEntry_·==·1)· ················if·(BollingerEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················else·if·(BollingerEntry_·==·2)· ················else·if·(BollingerEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················ ················
············else·if·(BID·bux)· ············else·if·(BID·bux)·
················if·(BollingerEntry_·==·1)· ················if·(BollingerEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················else·if·(BollingerEntry_·==·2)· ················else·if·(BollingerEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················ ················
············else·if·(!UseAnyEntry·&&·IndEntry·0)· ············else·if·(!UseAnyEntry·&&·IndEntry·0)·
················BuyMe·false;¤ ················BuyMe·false;¤
················SellMe·false;¤ ················SellMe·false;¤
············ ············
¤ ¤
············if·(IndEntry·0)¤ ············if·(IndEntry·0)¤
················IndicatorUsed·IndicatorUsed·UAE;¤ ················IndicatorUsed·IndicatorUsed·UAE;¤
¤ ¤
············IndEntry++;¤ ············IndEntry++;¤
············IndicatorUsed·IndicatorUsed·BBands·";¤ ············IndicatorUsed·IndicatorUsed·BBands·";¤
········ ········
········//+----------------------------------------------------------------+¤ ········//+----------------------------------------------------------------+¤
········//|·Stochastic·Indicator·for·Order·_Entry··························· ········//|·Stochastic·Indicator·for·Order·_Entry···························
········//+----------------------------------------------------------------+¤ ········//+----------------------------------------------------------------+¤
········if·(StochEntry_·&&·CbT·==·&&·CpT·2)· ········if·(StochEntry_·&&·CbT·==·&&·CpT·2)·
············int·zoneBUY·BuySellStochZone;¤ ············int·zoneBUY·BuySellStochZone;¤
············int·zoneSELL·100·BuySellStochZone;¤ ············int·zoneSELL·100·BuySellStochZone;¤
············double·stoc_0[1];¤ ············double·stoc_0[1];¤
············CopyBuffer(stoch_0_handle,·0,·1,·1,·stoc_0);¤ ············CopyBuffer(stoch_0_handle,·0,·1,·1,·stoc_0);¤
¤ ¤
············double·stoc_1[1];¤ ············double·stoc_1[1];¤
············CopyBuffer(stoch_0_handle,·1,·1,·1,·stoc_1);¤ ············CopyBuffer(stoch_0_handle,·1,·1,·1,·stoc_1);¤
¤ ¤
¤ ¤
············if·(stoc_0[0]·zoneBUY·&&·stoc_1[0]·zoneBUY)· ············if·(stoc_0[0]·zoneBUY·&&·stoc_1[0]·zoneBUY)·
················if·(StochEntry_·==·1)· ················if·(StochEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················else·if·(StochEntry_·==·2)· ················else·if·(StochEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················ ················
············else·if·(stoc_0[0]·zoneSELL·&&·stoc_1[0]·zoneSELL)· ············else·if·(stoc_0[0]·zoneSELL·&&·stoc_1[0]·zoneSELL)·
················if·(StochEntry_·==·1)· ················if·(StochEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················else·if·(StochEntry_·==·2)· ················else·if·(StochEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················ ················
············else·if·(!UseAnyEntry·&&·IndEntry·0)· ············else·if·(!UseAnyEntry·&&·IndEntry·0)·
················BuyMe·false;¤ ················BuyMe·false;¤
················SellMe·false;¤ ················SellMe·false;¤
············ ············
¤ ¤
············if·(IndEntry·0)¤ ············if·(IndEntry·0)¤
················IndicatorUsed·IndicatorUsed·UAE;¤ ················IndicatorUsed·IndicatorUsed·UAE;¤
¤ ¤
············IndEntry++;¤ ············IndEntry++;¤
············IndicatorUsed·IndicatorUsed·Stoch·";¤ ············IndicatorUsed·IndicatorUsed·Stoch·";¤
········ ········
········//+----------------------------------------------------------------+¤ ········//+----------------------------------------------------------------+¤
········//|·MACD·Indicator·for·Order·_Entry································· ········//|·MACD·Indicator·for·Order·_Entry·································
········//+----------------------------------------------------------------+¤ ········//+----------------------------------------------------------------+¤
········if·(MACDEntry_·&&·CbT·==·&&·CpT·2)· ········if·(MACDEntry_·&&·CbT·==·&&·CpT·2)·
············double·MACDm[1];¤ ············double·MACDm[1];¤
············CopyBuffer(macd1_handle,·0,·0,·1,·MACDm);¤ ············CopyBuffer(macd1_handle,·0,·0,·1,·MACDm);¤
············double·MACDs[1];¤ ············double·MACDs[1];¤
············CopyBuffer(macd1_handle,·1,·0,·1,·MACDs);¤ ············CopyBuffer(macd1_handle,·1,·0,·1,·MACDs);¤
············if·(MACDm[0]·MACDs[0])· ············if·(MACDm[0]·MACDs[0])·
················if·(MACDEntry_·==·1)· ················if·(MACDEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················else·if·(MACDEntry_·==·2)· ················else·if·(MACDEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················ ················
············else·if·(MACDm[0]·MACDs[0])· ············else·if·(MACDm[0]·MACDs[0])·
················if·(MACDEntry_·==·1)· ················if·(MACDEntry_·==·1)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·SellMe)))¤
························SellMe·true;¤ ························SellMe·true;¤
····················else¤ ····················else¤
························SellMe·false;¤ ························SellMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························BuyMe·false;¤ ························BuyMe·false;¤
················else·if·(MACDEntry_·==·2)· ················else·if·(MACDEntry_·==·2)·
····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤ ····················if·(ForceMarketCond_·!=·&&·(UseAnyEntry·||·IndEntry·==·||·(!UseAnyEntry·&&·IndEntry·&&·BuyMe)))¤
························BuyMe·true;¤ ························BuyMe·true;¤
····················else¤ ····················else¤
························BuyMe·false;¤ ························BuyMe·false;¤
¤ ¤
····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤ ····················if·(!UseAnyEntry·&&·IndEntry·&&·SellMe·&&·(!B3Traditional·||·(B3Traditional·&&·Trend·!=·2)))¤
························SellMe·false;¤ ························SellMe·false;¤
················ ················
············else·if·(!UseAnyEntry·&&·IndEntry·0)· ············else·if·(!UseAnyEntry·&&·IndEntry·0)·
················BuyMe·false;¤ ················BuyMe·false;¤
················SellMe·false;¤ ················SellMe·false;¤
············ ············
¤ ¤
············if·(IndEntry·0)¤ ············if·(IndEntry·0)¤
················IndicatorUsed·IndicatorUsed·UAE;¤ ················IndicatorUsed·IndicatorUsed·UAE;¤
¤ ¤
············IndEntry++;¤ ············IndEntry++;¤
············IndicatorUsed·IndicatorUsed·MACD·";¤ ············IndicatorUsed·IndicatorUsed·MACD·";¤
········ ········
········//+-----------------------------------------------------------------+··<<·This·must·be·the·last·_Entry·check·before¤ ········//+-----------------------------------------------------------------+··<<·This·must·be·the·last·_Entry·check·before¤
········//|·UseAnyEntry·Check·&&·Force·Market·Condition·Buy/Sell·_Entry·······<<·the·Trade·Selection·Logic.·Add·checks·for¤ ········//|·UseAnyEntry·Check·&&·Force·Market·Condition·Buy/Sell·_Entry·······<<·the·Trade·Selection·Logic.·Add·checks·for¤
········//+-----------------------------------------------------------------+··<<·additional·indicators·before·this·block.¤ ········//+-----------------------------------------------------------------+··<<·additional·indicators·before·this·block.¤
········if·((!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·SellMe)·||·FirstRun)· ········if·((!UseAnyEntry·&&·IndEntry·&&·BuyMe·&&·SellMe)·||·FirstRun)·
············BuyMe·false;¤ ············BuyMe·false;¤
············SellMe·false;¤ ············SellMe·false;¤
········ ········
¤ ¤
········if·(ForceMarketCond_·&&·IndEntry·==·&&·CbT·==·&&·!FirstRun)· ········if·(ForceMarketCond_·&&·IndEntry·==·&&·CbT·==·&&·!FirstRun)·
············if·(ForceMarketCond_·==·0)¤ ············if·(ForceMarketCond_·==·0)¤
················BuyMe·true;¤ ················BuyMe·true;¤
············else·if·(ForceMarketCond_·==·1)¤ ············else·if·(ForceMarketCond_·==·1)¤
················SellMe·true;¤ ················SellMe·true;¤
¤ ¤
············IndicatorUsed·FMC·";¤ ············IndicatorUsed·FMC·";¤
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Trade·Selection·Logic··········································· ········//|·Trade·Selection·Logic···········································
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········OrderLot·LotSize(Lots[(int)MathMin(CbT·CbC,·MaxTrades·1)LotMult);¤ ········OrderLot·LotSize(Lots[StringToInteger(DTS(MathMin(CbT·CbC,·MaxTrades·1)0))LotMult);¤
¤ ¤
········if·(CbT·==·&&·CpT·&&·!FirstRun)· ········if·(CbT·==·&&·CpT·&&·!FirstRun)·
//Заменить¤ //Заменить¤
············if·(B3Traditional)· ············if·(B3Traditional)·
················if·(BuyMe)· ················if·(BuyMe)·
····················if·(CpBS·==·&&·CpSL·==·&&·((Trend·!=·||·MAEntry_·==·0)·||·(Trend·==·&&·MAEntry_·==·1)))· ····················if·(CpBS·==·&&·CpSL·==·&&·((Trend·!=·||·MAEntry_·==·0)·||·(Trend·==·&&·MAEntry_·==·1)))·
························_Entry·g2·MathMod(ASK,·g2)·EntryOffset_;¤ ························_Entry·g2·MathMod(ASK,·g2)·EntryOffset_;¤
¤ ¤
························if·(_Entry·StopLevel)· ························if·(_Entry·StopLevel)·
····························Ticket·SendOrder(Symbol(),·OP_BUYSTOP,·OrderLot,·_Entry,·0,·Magic,·CLR_NONE);¤ ····························Ticket·SendOrder(Symbol(),·OP_BUYSTOP,·OrderLot,·_Entry,·0,·Magic,·CLR_NONE);¤
¤ ¤
····························if·(Ticket·0)· ····························if·(Ticket·0)·
································if·(Debug_)¤ ································if·(Debug_)¤
····································Print("Indicator·_Entry·(",·IndicatorUsed,·")·BuyStop·MC·",·Trend);¤ ····································Print("Indicator·_Entry·(",·IndicatorUsed,·")·BuyStop·MC·",·Trend);¤
¤ ¤
································CpBS++;¤ ································CpBS++;¤
···························· ····························
························ ························
···················· ····················
¤ ¤
····················if·(CpBL·==·&&·CpSS·==·&&·((Trend·!=·||·MAEntry_·==·0)·||·(Trend·==·&&·MAEntry_·==·2)))· ····················if·(CpBL·==·&&·CpSS·==·&&·((Trend·!=·||·MAEntry_·==·0)·||·(Trend·==·&&·MAEntry_·==·2)))·
························_Entry·MathMod(ASK,·g2)·EntryOffset_;¤ ························_Entry·MathMod(ASK,·g2)·EntryOffset_;¤
¤ ¤
························if·(_Entry·StopLevel)· ························if·(_Entry·StopLevel)·
····························Ticket·SendOrder(Symbol(),·OP_BUYLIMIT,·OrderLot,·-_Entry,·0,·Magic,·CLR_NONE);¤ ····························Ticket·SendOrder(Symbol(),·OP_BUYLIMIT,·OrderLot,·-_Entry,·0,·Magic,·CLR_NONE);¤
¤ ¤
····························if·(Ticket·0)· ····························if·(Ticket·0)·
································if·(Debug_)¤ ································if·(Debug_)¤
····································Print("Indicator·_Entry·(",·IndicatorUsed,·")·BuyLimit·MC·",·Trend);¤ ····································Print("Indicator·_Entry·(",·IndicatorUsed,·")·BuyLimit·MC·",·Trend);¤
¤ ¤
································CpBL++;¤ ································CpBL++;¤
···························· ····························
························ ························
···················· ····················
················ ················
¤ ¤
················if·(SellMe)· ················if·(SellMe)·
····················if·(CpSL·==·&&·CpBS·==·&&·((Trend·!=·||·MAEntry_·==·0)·||·(Trend·==·&&·MAEntry_·==·2)))· ····················if·(CpSL·==·&&·CpBS·==·&&·((Trend·!=·||·MAEntry_·==·0)·||·(Trend·==·&&·MAEntry_·==·2)))·
························_Entry·g2·MathMod(BID,·g2)·EntryOffset_;¤ ························_Entry·g2·MathMod(BID,·g2)·EntryOffset_;¤
¤ ¤
························if·(_Entry·StopLevel)· ························if·(_Entry·StopLevel)·
····························Ticket·SendOrder(Symbol(),·OP_SELLLIMIT,·OrderLot,·_Entry,·0,·Magic,·CLR_NONE);¤ ····························Ticket·SendOrder(Symbol(),·OP_SELLLIMIT,·OrderLot,·_Entry,·0,·Magic,·CLR_NONE);¤
¤ ¤
····························if·(Ticket·&&·Debug_)¤ ····························if·(Ticket·&&·Debug_)¤
································Print("Indicator·_Entry·(",·IndicatorUsed,·")·SellLimit·MC·",·Trend);¤ ································Print("Indicator·_Entry·(",·IndicatorUsed,·")·SellLimit·MC·",·Trend);¤
························ ························
···················· ····················
¤ ¤
····················if·(CpSS·==·&&·CpBL·==·&&·((Trend·!=·||·MAEntry_·==·0)·||·(Trend·==·&&·MAEntry_·==·1)))· ····················if·(CpSS·==·&&·CpBL·==·&&·((Trend·!=·||·MAEntry_·==·0)·||·(Trend·==·&&·MAEntry_·==·1)))·
························_Entry·MathMod(BID,·g2)·EntryOffset_;¤ ························_Entry·MathMod(BID,·g2)·EntryOffset_;¤
¤ ¤
························if·(_Entry·StopLevel)· ························if·(_Entry·StopLevel)·
····························Ticket·SendOrder(Symbol(),·OP_SELLSTOP,·OrderLot,·-_Entry,·0,·Magic,·CLR_NONE);¤ ····························Ticket·SendOrder(Symbol(),·OP_SELLSTOP,·OrderLot,·-_Entry,·0,·Magic,·CLR_NONE);¤
¤ ¤
····························if·(Ticket·&&·Debug_)¤ ····························if·(Ticket·&&·Debug_)¤
································Print("Indicator·_Entry·(",·IndicatorUsed,·")·SellStop·MC·",·Trend);¤ ································Print("Indicator·_Entry·(",·IndicatorUsed,·")·SellStop·MC·",·Trend);¤
························ ························
···················· ····················
················ ················
············else· ············else·
················if·(BuyMe)· ················if·(BuyMe)·
····················Ticket·SendOrder(Symbol(),·OP_BUY,·OrderLot,·0,·slip,·Magic,·Blue);¤ ····················Ticket·SendOrder(Symbol(),·OP_BUY,·OrderLot,·0,·slip,·Magic,·Blue);¤
¤ ¤
····················if·(Ticket·&&·Debug_)¤ ····················if·(Ticket·&&·Debug_)¤
························Print("Indicator·_Entry·(",·IndicatorUsed,·")·Buy");¤ ························Print("Indicator·_Entry·(",·IndicatorUsed,·")·Buy");¤
················else·if·(SellMe)· ················else·if·(SellMe)·
····················Ticket·SendOrder(Symbol(),·OP_SELL,·OrderLot,·0,·slip,·Magic,·displayColorLoss);¤ ····················Ticket·SendOrder(Symbol(),·OP_SELL,·OrderLot,·0,·slip,·Magic,·displayColorLoss);¤
¤ ¤
····················if·(Ticket·&&·Debug_)¤ ····················if·(Ticket·&&·Debug_)¤
························Print("Indicator·_Entry·(",·IndicatorUsed,·")·Sell");¤ ························Print("Indicator·_Entry·(",·IndicatorUsed,·")·Sell");¤
················ ················
············ ············
¤ ¤
············if·(Ticket·0)¤ ············if·(Ticket·0)¤
················return;¤ ················return;¤
········else·if·(TimeCurrent()·EntryDelay·OTbL·&&·CbT·CbC·MaxTrades·&&·!FirstRun)· ········else·if·(TimeCurrent()·EntryDelay·OTbL·&&·CbT·CbC·MaxTrades·&&·!FirstRun)·
············if·(UseSmartGrid)· ············if·(UseSmartGrid)·
············double·rsi1[1];¤ ············double·rsi1[1];¤
············double·rsi2[1];¤ ············double·rsi2[1];¤
············double·rsi3[1];¤ ············double·rsi3[1];¤
············CopyBuffer(rsi1handle,·0,·1,·1,·rsi1);¤ ············CopyBuffer(rsi1handle,·0,·1,·1,·rsi1);¤
············¤ ············¤
················if·(RSI[1]·!=·rsi1[0])· ················if·(RSI[1]·!=·rsi1[0])·
····················for·(int·Index·0;·Index·RSI_Period·RSI_MA_Period;·Index++)¤ ····················for·(int·Index·0;·Index·RSI_Period·RSI_MA_Period;·Index++)¤
···················· ····················
·····················CopyBuffer(rsi1handle,·0,·Index,·1,·rsi2);¤ ·····················CopyBuffer(rsi1handle,·0,·Index,·1,·rsi2);¤
························RSI[Index]···rsi2[0];¤ ························RSI[Index]···rsi2[0];¤
························¤ ························¤
···················· ····················
················else¤ ················else¤
················ ················
·····················CopyBuffer(rsi1handle,·0,·0,·1,·rsi3);¤ ·····················CopyBuffer(rsi1handle,·0,·0,·1,·rsi3);¤
····················RSI[0]·rsi3[0];¤ ····················RSI[0]·rsi3[0];¤
················ ················
················RSI_MA·iMAOnArrayMQL4(RSI,·0,·RSI_MA_Period,·0,·RSI_MA_Method,·0);¤ ················RSI_MA·iMAOnArrayMQL4(RSI,·0,·RSI_MA_Period,·0,·RSI_MA_Method,·0);¤
················¤ ················¤
············ ············
¤ ¤
············if·(CbB·0)· ············if·(CbB·0)·
//Заменить¤ //Заменить¤
················if·(OPbL·ASK)¤ ················if·(OPbL·ASK)¤
····················_Entry·OPbL·(MathRound((OPbL·ASK)·g2)·1)·g2;¤ ····················_Entry·OPbL·(MathRound((OPbL·ASK)·g2)·1)·g2;¤
················else¤ ················else¤
····················_Entry·OPbL·g2;¤ ····················_Entry·OPbL·g2;¤
¤ ¤
················if·(UseSmartGrid)· ················if·(UseSmartGrid)·
····················if·(ASK·OPbL·g2)· ····················if·(ASK·OPbL·g2)·
························if·(RSI[0]·RSI_MA)· ························if·(RSI[0]·RSI_MA)·
····························Ticket·SendOrder(Symbol(),·OP_BUY,·OrderLot,·0,·slip,·Magic,·Blue);¤ ····························Ticket·SendOrder(Symbol(),·OP_BUY,·OrderLot,·0,·slip,·Magic,·Blue);¤
¤ ¤
····························if·(Ticket·&&·Debug_)¤ ····························if·(Ticket·&&·Debug_)¤
································Print("SmartGrid·Buy·RSI:·",·RSI[0],·MA:·",·RSI_MA);¤ ································Print("SmartGrid·Buy·RSI:·",·RSI[0],·MA:·",·RSI_MA);¤
························ ························
¤ ¤
························OPbN·0;¤ ························OPbN·0;¤
····················else¤ ····················else¤
························OPbN·OPbL·g2;¤ ························OPbN·OPbL·g2;¤
················else·if·(CpBL·==·0)· ················else·if·(CpBL·==·0)·
····················if·(ASK·_Entry·<=·StopLevel)¤ ····················if·(ASK·_Entry·<=·StopLevel)¤
························_Entry·OPbL·(MathFloor((OPbL·ASK·StopLevel)·g2)·1)·g2;¤ ························_Entry·OPbL·(MathFloor((OPbL·ASK·StopLevel)·g2)·1)·g2;¤
¤ ¤
····················Ticket·SendOrder(Symbol(),·OP_BUYLIMIT,·OrderLot,·_Entry·ASK,·0,·Magic,·SkyBlue);¤ ····················Ticket·SendOrder(Symbol(),·OP_BUYLIMIT,·OrderLot,·_Entry·ASK,·0,·Magic,·SkyBlue);¤
¤ ¤
····················if·(Ticket·&&·Debug_)¤ ····················if·(Ticket·&&·Debug_)¤
························Print("BuyLimit·grid");¤ ························Print("BuyLimit·grid");¤
················else·if·(CpBL·==·&&·_Entry·OPpBL·g2·&&·ASK·_Entry·StopLevel)· ················else·if·(CpBL·==·&&·_Entry·OPpBL·g2·&&·ASK·_Entry·StopLevel)·
····················for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)· ····················for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)·
························if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤ ························if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤
····························continue;¤ ····························continue;¤
¤ ¤
························if·(OrderMagicNumber()·!=·Magic·||·OrderSymbol()·!=·Symbol()·||·OrderType()·!=·OP_BUYLIMIT)¤ ························if·(OrderMagicNumber()·!=·Magic·||·OrderSymbol()·!=·Symbol()·||·OrderType()·!=·OP_BUYLIMIT)¤
····························continue;¤ ····························continue;¤
¤ ¤
························Success·ModifyOrder(_Entry,·0,·SkyBlue);¤ ························Success·ModifyOrder(_Entry,·0,·SkyBlue);¤
¤ ¤
························if·(Success·&&·Debug_)¤ ························if·(Success·&&·Debug_)¤
····························Print("Mod·BuyLimit·_Entry");¤ ····························Print("Mod·BuyLimit·_Entry");¤
···················· ····················
················ ················
············else·if·(CbS·0)· ············else·if·(CbS·0)·
················if·(BID·OPbL)¤ ················if·(BID·OPbL)¤
····················_Entry·OPbL·(MathRound((-OPbL·BID)·g2)·1)·g2;¤ ····················_Entry·OPbL·(MathRound((-OPbL·BID)·g2)·1)·g2;¤
················else¤ ················else¤
····················_Entry·OPbL·g2;¤ ····················_Entry·OPbL·g2;¤
¤ ¤
················if·(UseSmartGrid)· ················if·(UseSmartGrid)·
····················if·(BID·OPbL·g2)· ····················if·(BID·OPbL·g2)·
························if·(RSI[0]·RSI_MA)· ························if·(RSI[0]·RSI_MA)·
····························Ticket·SendOrder(Symbol(),·OP_SELL,·OrderLot,·0,·slip,·Magic,·displayColorLoss);¤ ····························Ticket·SendOrder(Symbol(),·OP_SELL,·OrderLot,·0,·slip,·Magic,·displayColorLoss);¤
¤ ¤
····························if·(Ticket·&&·Debug_)¤ ····························if·(Ticket·&&·Debug_)¤
································Print("SmartGrid·Sell·RSI:·",·RSI[0],·MA:·",·RSI_MA);¤ ································Print("SmartGrid·Sell·RSI:·",·RSI[0],·MA:·",·RSI_MA);¤
························ ························
¤ ¤
························OPbN·0;¤ ························OPbN·0;¤
····················else¤ ····················else¤
························OPbN·OPbL·g2;¤ ························OPbN·OPbL·g2;¤
················else·if·(CpSL·==·0)· ················else·if·(CpSL·==·0)·
····················if·(_Entry·BID·<=·StopLevel)¤ ····················if·(_Entry·BID·<=·StopLevel)¤
························_Entry·OPbL·(MathFloor((-OPbL·BID·StopLevel)·g2)·1)·g2;¤ ························_Entry·OPbL·(MathFloor((-OPbL·BID·StopLevel)·g2)·1)·g2;¤
¤ ¤
····················Ticket·SendOrder(Symbol(),·OP_SELLLIMIT,·OrderLot,·_Entry·BID,·0,·Magic,·Coral);¤ ····················Ticket·SendOrder(Symbol(),·OP_SELLLIMIT,·OrderLot,·_Entry·BID,·0,·Magic,·Coral);¤
¤ ¤
····················if·(Ticket·&&·Debug_)¤ ····················if·(Ticket·&&·Debug_)¤
························Print("SellLimit·grid");¤ ························Print("SellLimit·grid");¤
················else·if·(CpSL·==·&&·OPpSL·_Entry·g2·&&·_Entry·BID·StopLevel)· ················else·if·(CpSL·==·&&·OPpSL·_Entry·g2·&&·_Entry·BID·StopLevel)·
····················for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)· ····················for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)·
························if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤ ························if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤
····························continue;¤ ····························continue;¤
¤ ¤
························if·(OrderMagicNumber()·!=·Magic·||·OrderSymbol()·!=·Symbol()·||·OrderType()·!=·OP_SELLLIMIT)¤ ························if·(OrderMagicNumber()·!=·Magic·||·OrderSymbol()·!=·Symbol()·||·OrderType()·!=·OP_SELLLIMIT)¤
····························continue;¤ ····························continue;¤
¤ ¤
························Success·ModifyOrder(_Entry,·0,·Coral);¤ ························Success·ModifyOrder(_Entry,·0,·Coral);¤
¤ ¤
························if·(Success·&&·Debug_)¤ ························if·(Success·&&·Debug_)¤
····························Print("Mod·SellLimit·_Entry");¤ ····························Print("Mod·SellLimit·_Entry");¤
···················· ····················
················ ················
············ ············
¤ ¤
············if·(Ticket·0)¤ ············if·(Ticket·0)¤
················return;¤ ················return;¤
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Hedge·Trades·Set-Up·and·Monitoring······························ ········//|·Hedge·Trades·Set-Up·and·Monitoring······························
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········if·((UseHedge_·&&·CbT·0)·||·ChT·0)· ········if·((UseHedge_·&&·CbT·0)·||·ChT·0)·
············int·hLevel·CbT·CbC;¤ ············int·hLevel·CbT·CbC;¤
¤ ¤
············if·(HedgeTypeDD)· ············if·(HedgeTypeDD)·
················if·(hDDStart·==·&&·ChT·0)¤ ················if·(hDDStart·==·&&·ChT·0)¤
····················hDDStart·MathMax(HedgeStart_,·DrawDownPC·hReEntryPC_);¤ ····················hDDStart·MathMax(HedgeStart_,·DrawDownPC·hReEntryPC_);¤
¤ ¤
················if·(hDDStart·HedgeStart_·&&·hDDStart·DrawDownPC·hReEntryPC_)¤ ················if·(hDDStart·HedgeStart_·&&·hDDStart·DrawDownPC·hReEntryPC_)¤
····················hDDStart·DrawDownPC·hReEntryPC_;¤ ····················hDDStart·DrawDownPC·hReEntryPC_;¤
¤ ¤
················if·(hActive·==·2)· ················if·(hActive·==·2)·
····················hActive·0;¤ ····················hActive·0;¤
····················hDDStart·MathMax(HedgeStart_,·DrawDownPC·hReEntryPC_);¤ ····················hDDStart·MathMax(HedgeStart_,·DrawDownPC·hReEntryPC_);¤
················ ················
············ ············
¤ ¤
············if·(hActive·==·0)· ············if·(hActive·==·0)·
················if·(!hThisChart·&&·((hPosCorr·&&·CheckCorr()·0.9)·||·(!hPosCorr·&&·CheckCorr()·-0.9)))· ················if·(!hThisChart·&&·((hPosCorr·&&·CheckCorr()·0.9)·||·(!hPosCorr·&&·CheckCorr()·-0.9)))·
····················if·(ObjectFind(ChartID(),pref+"B3LhCor")·==·-1)¤ ····················if·(ObjectFind(ChartID(),pref+"B3LhCor")·==·-1)¤
························CreateLabel("B3LhCor",·"Correlation·with·the·hedge·pair·has·dropped·below·90%.",·0,·0,·190,·10,·displayColorLoss);¤ ························CreateLabel("B3LhCor",·"Correlation·with·the·hedge·pair·has·dropped·below·90%.",·0,·0,·190,·10,·displayColorLoss);¤
················else¤ ················else¤
····················ObjDel("B3LhCor");¤ ····················ObjDel("B3LhCor");¤
¤ ¤
················if·(hLvlStart·hLevel·||·(!HedgeTypeDD·&&·hLvlStart·==·0))¤ ················if·(hLvlStart·hLevel·||·(!HedgeTypeDD·&&·hLvlStart·==·0))¤
····················hLvlStart·MathMax(HedgeStart_,·hLevel·1);¤ ····················hLvlStart·MathMax(HedgeStart_,·hLevel·1);¤
¤ ¤
················if·((HedgeTypeDD·&&·DrawDownPC·hDDStart)·||·(!HedgeTypeDD·&&·hLevel·>=·hLvlStart))· ················if·((HedgeTypeDD·&&·DrawDownPC·hDDStart)·||·(!HedgeTypeDD·&&·hLevel·>=·hLvlStart))·
····················OrderLot·LotSize(LbT·hLotMult);¤ ····················OrderLot·LotSize(LbT·hLotMult);¤
¤ ¤
····················if·((CbB·&&·!hPosCorr)·||·(CbS·&&·hPosCorr))· ····················if·((CbB·&&·!hPosCorr)·||·(CbS·&&·hPosCorr))·
····················//Заменить¤ ····················//Заменить¤
························Ticket·SendOrder(HedgeSymbol_,·OP_BUY,·OrderLot,·0,·slip,·hMagic,·MidnightBlue);¤ ························Ticket·SendOrder(HedgeSymbol_,·OP_BUY,·OrderLot,·0,·slip,·hMagic,·MidnightBlue);¤
¤ ¤
························if·(Ticket·0)· ························if·(Ticket·0)·
····························if·(hMaxLossPips_·0)¤ ····························if·(hMaxLossPips_·0)¤
································SLh·hAsk·hMaxLossPips_;¤ ································SLh·hAsk·hMaxLossPips_;¤
¤ ¤
····························if·(Debug_)¤ ····························if·(Debug_)¤
································Print("Hedge·Buy:·Stoploss·",·DTS(SLh,·Digits()));¤ ································Print("Hedge·Buy:·Stoploss·",·DTS(SLh,·Digits()));¤
························ ························
···················· ····················
¤ ¤
····················if·((CbB·&&·hPosCorr)·||·(CbS·&&·!hPosCorr))· ····················if·((CbB·&&·hPosCorr)·||·(CbS·&&·!hPosCorr))·
·····················//Заменить¤ ·····················//Заменить¤
························Ticket·SendOrder(HedgeSymbol_,·OP_SELL,·OrderLot,·0,·slip,·hMagic,·Maroon);¤ ························Ticket·SendOrder(HedgeSymbol_,·OP_SELL,·OrderLot,·0,·slip,·hMagic,·Maroon);¤
¤ ¤
························if·(Ticket·0)· ························if·(Ticket·0)·
····························if·(hMaxLossPips_·0)¤ ····························if·(hMaxLossPips_·0)¤
································SLh·hBid·hMaxLossPips_;¤ ································SLh·hBid·hMaxLossPips_;¤
¤ ¤
····························if·(Debug_)¤ ····························if·(Debug_)¤
································Print("Hedge·Sell:·Stoploss·",·DTS(SLh,·Digits()));¤ ································Print("Hedge·Sell:·Stoploss·",·DTS(SLh,·Digits()));¤
························ ························
···················· ····················
¤ ¤
····················if·(Ticket·0)· ····················if·(Ticket·0)·
························hActive·1;¤ ························hActive·1;¤
¤ ¤
························if·(HedgeTypeDD)¤ ························if·(HedgeTypeDD)¤
····························hDDStart·+=·hReEntryPC_;¤ ····························hDDStart·+=·hReEntryPC_;¤
¤ ¤
························hLvlStart·hLevel·1;¤ ························hLvlStart·hLevel·1;¤
¤ ¤
························return;¤ ························return;¤
···················· ····················
················ ················
············else·if·(hActive·==·1)· ············else·if·(hActive·==·1)·
················if·(HedgeTypeDD·&&·hDDStart·HedgeStart_·&&·hDDStart·DrawDownPC·hReEntryPC_)¤ ················if·(HedgeTypeDD·&&·hDDStart·HedgeStart_·&&·hDDStart·DrawDownPC·hReEntryPC_)¤
····················hDDStart·DrawDownPC·hReEntryPC_;¤ ····················hDDStart·DrawDownPC·hReEntryPC_;¤
¤ ¤
················if·(hLvlStart·==·0)· ················if·(hLvlStart·==·0)·
····················if·(HedgeTypeDD)¤ ····················if·(HedgeTypeDD)¤
························hLvlStart·hLevel·1;¤ ························hLvlStart·hLevel·1;¤
····················else¤ ····················else¤
························hLvlStart·MathMax(HedgeStart_,·hLevel·1);¤ ························hLvlStart·MathMax(HedgeStart_,·hLevel·1);¤
················ ················
¤ ¤
················if·(hLevel·>=·hLvlStart)· ················if·(hLevel·>=·hLvlStart)·
····················OrderLot·LotSize(Lots[CbT·CbC·1]·LotMult·hLotMult);¤ ····················OrderLot·LotSize(Lots[CbT·CbC·1]·LotMult·hLotMult);¤
¤ ¤
····················if·(OrderLot·&&·((CbB·&&·!hPosCorr)·||·(CbS·&&·hPosCorr)))· ····················if·(OrderLot·&&·((CbB·&&·!hPosCorr)·||·(CbS·&&·hPosCorr)))·
····················//Заменить¤ ····················//Заменить¤
························Ticket·SendOrder(HedgeSymbol_,·OP_BUY,·OrderLot,·0,·slip,·hMagic,·MidnightBlue);¤ ························Ticket·SendOrder(HedgeSymbol_,·OP_BUY,·OrderLot,·0,·slip,·hMagic,·MidnightBlue);¤
¤ ¤
························if·(Ticket·&&·Debug_)¤ ························if·(Ticket·&&·Debug_)¤
····························Print("Hedge·Buy");¤ ····························Print("Hedge·Buy");¤
···················· ····················
¤ ¤
····················if·(OrderLot·&&·((CbB·&&·hPosCorr)·||·(CbS·&&·!hPosCorr)))· ····················if·(OrderLot·&&·((CbB·&&·hPosCorr)·||·(CbS·&&·!hPosCorr)))·
·······················//Заменить¤ ·······················//Заменить¤
························Ticket·SendOrder(HedgeSymbol_,·OP_SELL,·OrderLot,·0,·slip,·hMagic,·Maroon);¤ ························Ticket·SendOrder(HedgeSymbol_,·OP_SELL,·OrderLot,·0,·slip,·hMagic,·Maroon);¤
¤ ¤
························if·(Ticket·&&·Debug_)¤ ························if·(Ticket·&&·Debug_)¤
····························Print("Hedge·Sell");¤ ····························Print("Hedge·Sell");¤
···················· ····················
¤ ¤
····················if·(Ticket·0)· ····················if·(Ticket·0)·
························hLvlStart·hLevel·1;¤ ························hLvlStart·hLevel·1;¤
¤ ¤
························return;¤ ························return;¤
···················· ····················
················ ················
¤ ¤
················int·Index·0;¤ ················int·Index·0;¤
¤ ¤
················if·(!FirstRun·&&·hMaxLossPips_·0)· ················if·(!FirstRun·&&·hMaxLossPips_·0)·
····················if·(ChB·0)· ····················if·(ChB·0)·
························if·(hFixedSL)· ························if·(hFixedSL)·
····························if·(SLh·==·0)¤ ····························if·(SLh·==·0)¤
································SLh·hBid·hMaxLossPips_;¤ ································SLh·hBid·hMaxLossPips_;¤
························else· ························else·
····························if·(SLh·==·||·(SLh·BEh·&&·SLh·hBid·hMaxLossPips_))¤ ····························if·(SLh·==·||·(SLh·BEh·&&·SLh·hBid·hMaxLossPips_))¤
································SLh·hBid·hMaxLossPips_;¤ ································SLh·hBid·hMaxLossPips_;¤
····························else·if·(StopTrailAtBE·&&·hBid·hMaxLossPips_·>=·BEh)¤ ····························else·if·(StopTrailAtBE·&&·hBid·hMaxLossPips_·>=·BEh)¤
································SLh·BEh;¤ ································SLh·BEh;¤
····························else·if·(SLh·>=·BEh·&&·!StopTrailAtBE)· ····························else·if·(SLh·>=·BEh·&&·!StopTrailAtBE)·
································if·(!ReduceTrailStop)¤ ································if·(!ReduceTrailStop)¤
····································SLh·MathMax(SLh,·hBid·hMaxLossPips_);¤ ····································SLh·MathMax(SLh,·hBid·hMaxLossPips_);¤
································else¤ ································else¤
····································SLh·MathMax(SLh,·hBid·MathMax(StopLevel,·hMaxLossPips_·(1·(hBid·hMaxLossPips_·BEh)·(hMaxLossPips_·2))));¤ ····································SLh·MathMax(SLh,·hBid·MathMax(StopLevel,·hMaxLossPips_·(1·(hBid·hMaxLossPips_·BEh)·(hMaxLossPips_·2))));¤
···························· ····························
························ ························
¤ ¤
························if·(hBid·<=·SLh)¤ ························if·(hBid·<=·SLh)¤
····························Index·ExitTrades(H,·DarkViolet,·"Hedge·StopLoss");¤ ····························Index·ExitTrades(H,·DarkViolet,·"Hedge·StopLoss");¤
····················else·if·(ChS·0)· ····················else·if·(ChS·0)·
························if·(hFixedSL)· ························if·(hFixedSL)·
····························if·(SLh·==·0)¤ ····························if·(SLh·==·0)¤
································SLh·hAsk·hMaxLossPips_;¤ ································SLh·hAsk·hMaxLossPips_;¤
························else· ························else·
····························if·(SLh·==·||·(SLh·BEh·&&·SLh·hAsk·hMaxLossPips_))¤ ····························if·(SLh·==·||·(SLh·BEh·&&·SLh·hAsk·hMaxLossPips_))¤
································SLh·hAsk·hMaxLossPips_;¤ ································SLh·hAsk·hMaxLossPips_;¤
····························else·if·(StopTrailAtBE·&&·hAsk·hMaxLossPips_·<=·BEh)¤ ····························else·if·(StopTrailAtBE·&&·hAsk·hMaxLossPips_·<=·BEh)¤
································SLh·BEh;¤ ································SLh·BEh;¤
····························else·if·(SLh·<=·BEh·&&·!StopTrailAtBE)· ····························else·if·(SLh·<=·BEh·&&·!StopTrailAtBE)·
································if·(!ReduceTrailStop)¤ ································if·(!ReduceTrailStop)¤
····································SLh·MathMin(SLh,·hAsk·hMaxLossPips_);¤ ····································SLh·MathMin(SLh,·hAsk·hMaxLossPips_);¤
································else¤ ································else¤
····································SLh·MathMin(SLh,·hAsk·MathMax(StopLevel,·hMaxLossPips_·(1·(BEh·hAsk·hMaxLossPips_)·(hMaxLossPips_·2))));¤ ····································SLh·MathMin(SLh,·hAsk·MathMax(StopLevel,·hMaxLossPips_·(1·(BEh·hAsk·hMaxLossPips_)·(hMaxLossPips_·2))));¤
···························· ····························
························ ························
¤ ¤
························if·(hAsk·>=·SLh)¤ ························if·(hAsk·>=·SLh)¤
····························Index·ExitTrades(H,·DarkViolet,·"Hedge·StopLoss");¤ ····························Index·ExitTrades(H,·DarkViolet,·"Hedge·StopLoss");¤
···················· ····················
················ ················
¤ ¤
················if·(Index·==·&&·hTakeProfit_·0)· ················if·(Index·==·&&·hTakeProfit_·0)·
····················if·(ChB·&&·hBid·OPhO·hTakeProfit_)¤ ····················if·(ChB·&&·hBid·OPhO·hTakeProfit_)¤
························Index·ExitTrades(T,·DarkViolet,·"Hedge·TakeProfit·reached",·ThO);¤ ························Index·ExitTrades(T,·DarkViolet,·"Hedge·TakeProfit·reached",·ThO);¤
¤ ¤
····················if·(ChS·&&·hAsk·OPhO·hTakeProfit_)¤ ····················if·(ChS·&&·hAsk·OPhO·hTakeProfit_)¤
························Index·ExitTrades(T,·DarkViolet,·"Hedge·TakeProfit·reached",·ThO);¤ ························Index·ExitTrades(T,·DarkViolet,·"Hedge·TakeProfit·reached",·ThO);¤
················ ················
¤ ¤
················if·(Index·0)· ················if·(Index·0)·
····················PhC·FindClosedPL(H);¤ ····················PhC·FindClosedPL(H);¤
¤ ¤
····················if·(Index·==·ChT)· ····················if·(Index·==·ChT)·
························if·(HedgeTypeDD)¤ ························if·(HedgeTypeDD)¤
····························hActive·2;¤ ····························hActive·2;¤
························else¤ ························else¤
····························hActive·0;¤ ····························hActive·0;¤
···················· ····················
····················return;¤ ····················return;¤
················ ················
············ ············
········ ········
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········//|·Check·DD%·and·send·Email········································ ········//|·Check·DD%·and·send·Email········································
········//+-----------------------------------------------------------------+¤ ········//+-----------------------------------------------------------------+¤
········if·((UseEmail·||·PlaySounds)·&&·!Testing)· ········if·((UseEmail·||·PlaySounds)·&&·!Testing)·
············if·(EmailCount·&&·Email[EmailCount]·&&·DrawDownPC·Email[EmailCount])· ············if·(EmailCount·&&·Email[EmailCount]·&&·DrawDownPC·Email[EmailCount])·
················GetLastError();¤ ················GetLastError();¤
¤ ¤
················if·(UseEmail)· ················if·(UseEmail)·
····················SendMail("Drawdown·warning",·"Drawdown·has·exceeded·DTS(Email[EmailCount]·100,·2)·"%·on·Symbol()·sTF);¤ ····················SendMail("Drawdown·warning",·"Drawdown·has·exceeded·DTS(Email[EmailCount]·100,·2)·"%·on·Symbol()·sTF);¤
····················Error·GetLastError();¤ ····················Error·GetLastError();¤
¤ ¤
····················if·(Error·0)¤ ····················if·(Error·0)¤
························Print("Email·DD:·",·DTS(DrawDownPC·100,·2),·Error:·",·Error);¤ ························Print("Email·DD:·",·DTS(DrawDownPC·100,·2),·Error:·",·Error);¤
····················else·if·(Debug_)¤ ····················else·if·(Debug_)¤
························Print("DrawDown·Email·sent·for·",·Symbol(),·",·sTF,··DD:·",·DTS(DrawDownPC·100,·2));¤ ························Print("DrawDown·Email·sent·for·",·Symbol(),·",·sTF,··DD:·",·DTS(DrawDownPC·100,·2));¤
····················EmailSent·TimeCurrent();¤ ····················EmailSent·TimeCurrent();¤
····················EmailCount++;¤ ····················EmailCount++;¤
················ ················
¤ ¤
················if·(PlaySounds)¤ ················if·(PlaySounds)¤
····················PlaySound(AlertSound);¤ ····················PlaySound(AlertSound);¤
············else·if·(EmailCount·&&·EmailCount·&&·DrawDownPC·Email[EmailCount]·&&·TimeCurrent()·EmailSent·EmailHours·3600)¤ ············else·if·(EmailCount·&&·EmailCount·&&·DrawDownPC·Email[EmailCount]·&&·TimeCurrent()·EmailSent·EmailHours·3600)¤
················EmailCount--;¤ ················EmailCount--;¤
········ ········
···· ····
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····//|·Display·Overlay·Code············································ ····//|·Display·Overlay·Code············································
····//+-----------------------------------------------------------------+¤ ····//+-----------------------------------------------------------------+¤
····string·dMess·"";¤ ····string·dMess·"";¤
¤ ¤
····if·((Testing·&&·Visual)·||·!Testing)· ····if·((Testing·&&·Visual)·||·!Testing)·
········if·(displayOverlay)· ········if·(displayOverlay)·
············color·Colour;¤ ············color·Colour;¤
············int·dDigits;¤ ············int·dDigits;¤
¤ ¤
············ObjSetTxt("B3VTime",·TimeToString(TimeCurrent(),·TIME_DATE·TIME_SECONDS));¤ ············ObjSetTxt("B3VTime",·TimeToString(TimeCurrent(),·TIME_DATE·TIME_SECONDS));¤
············//·This·fixes·problem·with·OncePerBar·display·of·Stop·Trade·Amount·always¤ ············//·This·fixes·problem·with·OncePerBar·display·of·Stop·Trade·Amount·always¤
············//·showing·zero,·but·is·hack·...·Blessing·needs·to·be·re-engineered.¤ ············//·showing·zero,·but·is·hack·...·Blessing·needs·to·be·re-engineered.¤
············//·display·of·Stop·Trade·Amount:¤ ············//·display·of·Stop·Trade·Amount:¤
············//·double·stop_trade_amount·-(Pb·Ph)·PortionBalance;···//·opb¤ ············//·double·stop_trade_amount·-(Pb·Ph)·PortionBalance;···//·opb¤
············//·DrawLabel("B3VSTAm",·InitialAccountMultiPortion,·167,·2,·displayColorLoss);¤ ············//·DrawLabel("B3VSTAm",·InitialAccountMultiPortion,·167,·2,·displayColorLoss);¤
············//·static·double·previous_stop_trade_amount;¤ ············//·static·double·previous_stop_trade_amount;¤
¤ ¤
············if·(stop_trade_amount·!=·0)· ············if·(stop_trade_amount·!=·0)·
················previous_stop_trade_amount·stop_trade_amount;¤ ················previous_stop_trade_amount·stop_trade_amount;¤
················DrawLabel("B3VSTAm",·stop_trade_amount,·167,·2,·displayColorLoss);¤ ················DrawLabel("B3VSTAm",·stop_trade_amount,·167,·2,·displayColorLoss);¤
············else¤ ············else¤
················DrawLabel("B3VSTAm",·previous_stop_trade_amount,·167,·2,·displayColorLoss);¤ ················DrawLabel("B3VSTAm",·previous_stop_trade_amount,·167,·2,·displayColorLoss);¤
············//·DrawLabel("B3VSTAm",·stop_trade_amount,·167,·2,·displayColorLoss);¤ ············//·DrawLabel("B3VSTAm",·stop_trade_amount,·167,·2,·displayColorLoss);¤
············//·End·of·fix¤ ············//·End·of·fix¤
¤ ¤
············if·(UseHolidayShutdown)· ············if·(UseHolidayShutdown)·
················ObjSetTxt("B3VHolF",·TimeToString(HolFirst,·TIME_DATE));¤ ················ObjSetTxt("B3VHolF",·TimeToString(HolFirst,·TIME_DATE));¤
················ObjSetTxt("B3VHolT",·TimeToString(HolLast,·TIME_DATE));¤ ················ObjSetTxt("B3VHolT",·TimeToString(HolLast,·TIME_DATE));¤
············ ············
¤ ¤
············DrawLabel("B3VPBal",·PortionBalance,·167);¤ ············DrawLabel("B3VPBal",·PortionBalance,·167);¤
¤ ¤
············if·(DrawDownPC·0.4)¤ ············if·(DrawDownPC·0.4)¤
················Colour·displayColorLoss;¤ ················Colour·displayColorLoss;¤
············else·if·(DrawDownPC·0.3)¤ ············else·if·(DrawDownPC·0.3)¤
················Colour·Orange;¤ ················Colour·Orange;¤
············else·if·(DrawDownPC·0.2)¤ ············else·if·(DrawDownPC·0.2)¤
················Colour·Yellow;¤ ················Colour·Yellow;¤
············else·if·(DrawDownPC·0.1)¤ ············else·if·(DrawDownPC·0.1)¤
················Colour·displayColorProfit;¤ ················Colour·displayColorProfit;¤
············else¤ ············else¤
················Colour·displayColor;¤ ················Colour·displayColor;¤
¤ ¤
············DrawLabel("B3VDrDn",·DrawDownPC·100,·415,·2,·Colour);¤ ············DrawLabel("B3VDrDn",·DrawDownPC·100,·315,·2,·Colour);¤
¤ ¤
············if·(UseHedge_·&&·HedgeTypeDD)¤ ············if·(UseHedge_·&&·HedgeTypeDD)¤
················ObjSetTxt("B3VhDDm",·DTS(hDDStart·100,·2));¤ ················ObjSetTxt("B3VhDDm",·DTS(hDDStart·100,·2));¤
············else·if·(UseHedge_·&&·!HedgeTypeDD)· ············else·if·(UseHedge_·&&·!HedgeTypeDD)·
················DrawLabel("B3VhLvl",·CbT·CbC,·318,·0);¤ ················DrawLabel("B3VhLvl",·CbT·CbC,·318,·0);¤
················ObjSetTxt("B3VhLvT",·DTS(hLvlStart,·0));¤ ················ObjSetTxt("B3VhLvT",·DTS(hLvlStart,·0));¤
············ ············
¤ ¤
············ObjSetTxt("B3VSLot",·DTS(Lot_·LotMult,·2));¤ ············ObjSetTxt("B3VSLot",·DTS(Lot_·LotMult,·2));¤
¤ ¤
············if·(ProfitPot·>=·0)¤ ············if·(ProfitPot·>=·0)¤
················DrawLabel("B3VPPot",·ProfitPot,·190);¤ ················DrawLabel("B3VPPot",·ProfitPot,·190);¤
············else· ············else·
················ObjSetTxt("B3VPPot",·DTS(ProfitPot,·2),·0,·displayColorLoss);¤ ················ObjSetTxt("B3VPPot",·DTS(ProfitPot,·2),·0,·displayColorLoss);¤
················dDigits·Digit[ArrayBsearch(Digit,·(int)·-ProfitPot),·1];¤ ················dDigits·Digit[ArrayBsearch(Digit,·(int)·-ProfitPot),·1];¤
················ObjSet("B3VPPot",·186·dDigits·7);¤ ················ObjSet("B3VPPot",·186·dDigits·7);¤
············ ············
¤ ¤
············if·(UseEarlyExit·&&·EEpc·1)· ············if·(UseEarlyExit·&&·EEpc·1)·
················if·(ObjectFind(ChartID(),pref+"B3SEEPr")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3SEEPr")·==·-1)¤
····················CreateLabel("B3SEEPr",·"/",·0,·0,·220,·12,0);¤ ····················CreateLabel("B3SEEPr",·"/",·0,·0,·220,·12,0);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3VEEPr")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3VEEPr")·==·-1)¤
····················CreateLabel("B3VEEPr",·"",·0,·0,·229,·12,0);¤ ····················CreateLabel("B3VEEPr",·"",·0,·0,·229,·12,0);¤
¤ ¤
················ObjSetTxt("B3VEEPr",·DTS(PbTarget·PipValue·MathAbs(LbB·LbS),·2));¤ ················ObjSetTxt("B3VEEPr",·DTS(PbTarget·PipValue·MathAbs(LbB·LbS),·2));¤
············else· ············else·
················ObjDel("B3SEEPr");¤ ················ObjDel("B3SEEPr");¤
················ObjDel("B3VEEPr");¤ ················ObjDel("B3VEEPr");¤
············ ············
¤ ¤
············if·(SLb·0)¤ ············if·(SLb·0)¤
················DrawLabel("B3VPrSL",·SLb,·190,·Digits());¤ ················DrawLabel("B3VPrSL",·SLb,·190,·Digits());¤
············else·if·(bSL·0)¤ ············else·if·(bSL·0)¤
················DrawLabel("B3VPrSL",·bSL,·190,·Digits());¤ ················DrawLabel("B3VPrSL",·bSL,·190,·Digits());¤
············else·if·(bTS·0)¤ ············else·if·(bTS·0)¤
················DrawLabel("B3VPrSL",·bTS,·190,·Digits());¤ ················DrawLabel("B3VPrSL",·bTS,·190,·Digits());¤
············else¤ ············else¤
················DrawLabel("B3VPrSL",·0,·190,·2);¤ ················DrawLabel("B3VPrSL",·0,·190,·2);¤
¤ ¤
············if·(Pb·>=·0)· ············if·(Pb·>=·0)·
················DrawLabel("B3VPnPL",·Pb,·190,·2,·displayColorProfit);¤ ················DrawLabel("B3VPnPL",·Pb,·190,·2,·displayColorProfit);¤
················ObjSetTxt("B3VPPip",·DTS(PbPips,·1),·0,·displayColorProfit);¤ ················ObjSetTxt("B3VPPip",·DTS(PbPips,·1),·0,·displayColorProfit);¤
················ObjSet("B3VPPip",·229);¤ ················ObjSet("B3VPPip",·229);¤
············else· ············else·
················ObjSetTxt("B3VPnPL",·DTS(Pb,·2),·0,·displayColorLoss);¤ ················ObjSetTxt("B3VPnPL",·DTS(Pb,·2),·0,·displayColorLoss);¤
················dDigits·Digit[ArrayBsearch(Digit,·(int)·-Pb),·1];¤ ················dDigits·Digit[ArrayBsearch(Digit,·(int)·-Pb),·1];¤
················ObjSet("B3VPnPL",·186·dDigits·7);¤ ················ObjSet("B3VPnPL",·186·dDigits·7);¤
················ObjSetTxt("B3VPPip",·DTS(PbPips,·1),·0,·displayColorLoss);¤ ················ObjSetTxt("B3VPPip",·DTS(PbPips,·1),·0,·displayColorLoss);¤
················ObjSet("B3VPPip",·225);¤ ················ObjSet("B3VPPip",·225);¤
············ ············
¤ ¤
············if·(PbMax·>=·0)¤ ············if·(PbMax·>=·0)¤
················DrawLabel("B3VPLMx",·PbMax,·190,·2,·displayColorProfit);¤ ················DrawLabel("B3VPLMx",·PbMax,·190,·2,·displayColorProfit);¤
············else· ············else·
················ObjSetTxt("B3VPLMx",·DTS(PbMax,·2),·0,·displayColorLoss);¤ ················ObjSetTxt("B3VPLMx",·DTS(PbMax,·2),·0,·displayColorLoss);¤
················dDigits·Digit[ArrayBsearch(Digit,·(int)·-PbMax),·1];¤ ················dDigits·Digit[ArrayBsearch(Digit,·(int)·-PbMax),·1];¤
················ObjSet("B3VPLMx",·186·dDigits·7);¤ ················ObjSet("B3VPLMx",·186·dDigits·7);¤
············ ············
¤ ¤
············if·(PbMin·0)¤ ············if·(PbMin·0)¤
················ObjSet("B3VPLMn",·225);¤ ················ObjSet("B3VPLMn",·225);¤
············else¤ ············else¤
················ObjSet("B3VPLMn",·229);¤ ················ObjSet("B3VPLMn",·229);¤
¤ ¤
············ObjSetTxt("B3VPLMn",·DTS(PbMin,·2),·0,·displayColorLoss);¤ ············ObjSetTxt("B3VPLMn",·DTS(PbMin,·2),·0,·displayColorLoss);¤
¤ ¤
············if·(CbT·CbC·BreakEvenTrade·&&·CbT·CbC·MaxTrades)¤ ············if·(CbT·CbC·BreakEvenTrade·&&·CbT·CbC·MaxTrades)¤
················Colour·displayColor;¤ ················Colour·displayColor;¤
············else·if·(CbT·CbC·MaxTrades)¤ ············else·if·(CbT·CbC·MaxTrades)¤
················Colour·Orange;¤ ················Colour·Orange;¤
············else¤ ············else¤
················Colour·displayColorLoss;¤ ················Colour·displayColorLoss;¤
¤ ¤
············if·(CbB·0)· ············if·(CbB·0)·
················ObjSetTxt("B3LType",·"Buy:");¤ ················ObjSetTxt("B3LType",·"Buy:");¤
················DrawLabel("B3VOpen",·CbB,·207,·0,·Colour);¤ ················DrawLabel("B3VOpen",·CbB,·207,·0,·Colour);¤
············else·if·(CbS·0)· ············else·if·(CbS·0)·
················ObjSetTxt("B3LType",·"Sell:");¤ ················ObjSetTxt("B3LType",·"Sell:");¤
················DrawLabel("B3VOpen",·CbS,·207,·0,·Colour);¤ ················DrawLabel("B3VOpen",·CbS,·207,·0,·Colour);¤
············else· ············else·
················ObjSetTxt("B3LType",·"");¤ ················ObjSetTxt("B3LType",·"");¤
················ObjSetTxt("B3VOpen",·DTS(0,·0),·0,·Colour);¤ ················ObjSetTxt("B3VOpen",·DTS(0,·0),·0,·Colour);¤
················ObjSet("B3VOpen",·207);¤ ················ObjSet("B3VOpen",·207);¤
············ ············
¤ ¤
············ObjSetTxt("B3VLots",·DTS(LbT,·2));¤ ············ObjSetTxt("B3VLots",·DTS(LbT,·2));¤
············ObjSetTxt("B3VMove",·DTS(Moves,·0));¤ ············ObjSetTxt("B3VMove",·DTS(Moves,·0));¤
············DrawLabel("B3VMxDD",·MaxDD,·107);¤ ············DrawLabel("B3VMxDD",·MaxDD,·107);¤
············DrawLabel("B3VDDPC",·MaxDDPer,·279);¤ ············DrawLabel("B3VDDPC",·MaxDDPer,·229);¤
¤ ¤
············if·(Trend·==·0)· ············if·(Trend·==·0)·
················ObjSetTxt("B3LTrnd",·"Trend·is·UP",·10,·displayColorProfit);¤ ················ObjSetTxt("B3LTrnd",·"Trend·is·UP",·10,·displayColorProfit);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3ATrnd")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3ATrnd")·==·-1)¤
····················CreateLabel("B3ATrnd",·"",·0,·0,·160,·20,·0,·displayColorProfit,·"Wingdings");¤ ····················CreateLabel("B3ATrnd",·"",·0,·0,·160,·20,·displayColorProfit,·"Wingdings");¤
¤ ¤
················ObjectSetText("B3ATrnd",·CharToString(236),·displayFontSize·9,·"Wingdings",·displayColorProfit);¤ ················ObjectSetText("B3ATrnd",·CharToString(101),·displayFontSize·9,·"Wingdings",·displayColorProfit);¤
¤ ¤
················ObjSet("B3ATrnd",·160);¤ ················ObjSet("B3ATrnd",·160);¤
················ObjectSetInteger(ChartID(),"B3ATrnd",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤ ················ObjectSetInteger(ChartID(),"B3ATrnd",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤
¤ ¤
················if·(StringLen(ATrend)·0)· ················if·(StringLen(ATrend)·0)·
····················if·(ObjectFind(ChartID(),pref+"B3AATrn")·==·-1)¤ ····················if·(ObjectFind(ChartID(),pref+"B3AATrn")·==·-1)¤
························CreateLabel("B3AATrn",·"",·0,·0,·200,·20,·0,·displayColorProfit,·"Wingdings");¤ ························CreateLabel("B3AATrn",·"",·0,·0,·200,·20,·displayColorProfit,·"Wingdings");¤
¤ ¤
····················if·(ATrend·==·"D")· ····················if·(ATrend·==·"D")·
························ObjectSetText("B3AATrn",·CharToString(238),·displayFontSize·9,·"Wingdings",·displayColorLoss);¤ ························ObjectSetText("B3AATrn",·CharToString(101),·displayFontSize·9,·"Wingdings",·displayColorLoss);¤
························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20·5);¤ ························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20·5);¤
····················else·if·(ATrend·==·"R")· ····················else·if·(ATrend·==·"R")·
························ObjSetTxt("B3AATrn",·CharToString(232)10,·Orange);¤ ························ObjSetTxt("B3AATrn",·"R"10,·Orange);¤
························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤ ························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤
···················· ····················
················else¤ ················else¤
····················ObjDel("B3AATrn");¤ ····················ObjDel("B3AATrn");¤
············else·if·(Trend·==·1)· ············else·if·(Trend·==·1)·
················ObjSetTxt("B3LTrnd",·"Trend·is·DOWN",·10,·displayColorLoss);¤ ················ObjSetTxt("B3LTrnd",·"Trend·is·DOWN",·10,·displayColorLoss);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3ATrnd")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3ATrnd")·==·-1)¤
····················CreateLabel("B3ATrnd",·"",·0,·0,·210,·20,·0,·displayColorLoss,·"WingDings");¤ ····················CreateLabel("B3ATrnd",·"",·0,·0,·210,·20,·displayColorLoss,·"WingDings");¤
¤ ¤
················ObjectSetText("B3ATrnd",·CharToString(238),·displayFontSize·9,·"Wingdings",·displayColorLoss);¤ ················ObjectSetText("B3ATrnd",·CharToString(101),·displayFontSize·9,·"Wingdings",·displayColorLoss);¤
················¤ ················¤
················ObjSet("B3ATrnd",·210);¤ ················ObjSet("B3ATrnd",·210);¤
················ObjectSetInteger(ChartID(),"B3ATrnd",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20·5);¤ ················ObjectSetInteger(ChartID(),"B3ATrnd",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20·5);¤
¤ ¤
················if·(StringLen(ATrend)·0)· ················if·(StringLen(ATrend)·0)·
····················if·(ObjectFind(ChartID(),pref+"B3AATrn")·==·-1)¤ ····················if·(ObjectFind(ChartID(),pref+"B3AATrn")·==·-1)¤
························CreateLabel("B3AATrn",·"",·0,·0,·250,·20,·0,·displayColorProfit,·"Wingdings");¤ ························CreateLabel("B3AATrn",·"",·0,·0,·250,·20,·displayColorProfit,·"Wingdings");¤
¤ ¤
····················if·(ATrend·==·"U")· ····················if·(ATrend·==·"U")·
························ObjectSetText("B3AATrn",·CharToString(236),·displayFontSize·9,·"Wingdings",·displayColorProfit);¤ ························ObjectSetText("B3AATrn",·CharToString(101),·displayFontSize·9,·"Wingdings",·displayColorProfit);¤
························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤ ························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤
····················else·if·(ATrend·==·"R")· ····················else·if·(ATrend·==·"R")·
························ObjSetTxt("B3AATrn",·CharToString(232)10,·Orange);¤ ························ObjSetTxt("B3AATrn",·"R"10,·Orange);¤
························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤ ························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤
···················· ····················
················else¤ ················else¤
····················ObjDel("B3AATrn");¤ ····················ObjDel("B3AATrn");¤
············else·if·(Trend·==·2)· ············else·if·(Trend·==·2)·
················ObjSetTxt("B3LTrnd",·"Trend·is·Ranging",·10,·Orange);¤ ················ObjSetTxt("B3LTrnd",·"Trend·is·Ranging",·10,·Orange);¤
················ObjDel("B3ATrnd");¤ ················ObjDel("B3ATrnd");¤
¤ ¤
················if·(StringLen(ATrend)·0)· ················if·(StringLen(ATrend)·0)·
····················if·(ObjectFind(ChartID(),pref+"B3AATrn")·==·-1)¤ ····················if·(ObjectFind(ChartID(),pref+"B3AATrn")·==·-1)¤
························CreateLabel("B3AATrn",·"",·0,·0,·220,·20,·0,·displayColorProfit,·"Wingdings");¤ ························CreateLabel("B3AATrn",·"",·0,·0,·220,·20,·displayColorProfit,·"Wingdings");¤
¤ ¤
····················if·(ATrend·==·"U")· ····················if·(ATrend·==·"U")·
························ObjectSetText("B3AATrn",·CharToString(236),·displayFontSize·9,·"Wingdings",·displayColorProfit);¤ ························ObjectSetText("B3AATrn",·CharToString(101),·displayFontSize·9,·"Wingdings",·displayColorProfit);¤
························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤ ························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20);¤
····················else·if·(ATrend·==·"D")· ····················else·if·(ATrend·==·"D")·
························ObjectSetText("B3AATrn",·CharToString(238),·displayFontSize·8,·"Wingdings",·displayColorLoss);¤ ························ObjectSetText("B3AATrn",·CharToString(101),·displayFontSize·8,·"Wingdings",·displayColorLoss);¤
························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20·5);¤ ························ObjectSetInteger(ChartID(),"B3AATrn",·OBJPROP_YDISTANCE,·displayYcord·displaySpacing·20·5);¤
···················· ····················
················else¤ ················else¤
····················ObjDel("B3AATrn");¤ ····················ObjDel("B3AATrn");¤
············ ············
¤ ¤
············if·(PaC·!=·0)· ············if·(PaC·!=·0)·
················if·(ObjectFind(ChartID(),pref+"B3LClPL")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LClPL")·==·-1)¤
····················CreateLabel("B3LClPL",·"Closed·P/L",·0,·0,·312,·11,0);¤ ····················CreateLabel("B3LClPL",·"Closed·P/L",·0,·0,·312,·11,0);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3VClPL")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3VClPL")·==·-1)¤
····················CreateLabel("B3VClPL",·"",·0,·0,·327,·12,0);¤ ····················CreateLabel("B3VClPL",·"",·0,·0,·327,·12,0);¤
¤ ¤
················if·(PaC·>=·0)¤ ················if·(PaC·>=·0)¤
····················DrawLabel("B3VClPL",·PaC,·327,·2,·displayColorProfit);¤ ····················DrawLabel("B3VClPL",·PaC,·327,·2,·displayColorProfit);¤
················else· ················else·
····················ObjSetTxt("B3VClPL",·DTS(PaC,·2),·0,·displayColorLoss);¤ ····················ObjSetTxt("B3VClPL",·DTS(PaC,·2),·0,·displayColorLoss);¤
····················dDigits·Digit[ArrayBsearch(Digit,·(int)·-PaC),·1];¤ ····················dDigits·Digit[ArrayBsearch(Digit,·(int)·-PaC),·1];¤
····················ObjSet("B3VClPL",·323·dDigits·7);¤ ····················ObjSet("B3VClPL",·323·dDigits·7);¤
················ ················
············else· ············else·
················ObjDel("B3LClPL");¤ ················ObjDel("B3LClPL");¤
················ObjDel("B3VClPL");¤ ················ObjDel("B3VClPL");¤
············ ············
¤ ¤
············if·(hActive·==·1)· ············if·(hActive·==·1)·
················if·(ObjectFind(ChartID(),pref+"B3LHdge")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LHdge")·==·-1)¤
····················CreateLabel("B3LHdge",·"Hedge",·0,·0,·323,·13,0);¤ ····················CreateLabel("B3LHdge",·"Hedge",·0,·0,·323,·13,0);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3VhPro")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3VhPro")·==·-1)¤
····················CreateLabel("B3VhPro",·"",·0,·0,·312,·14,0);¤ ····················CreateLabel("B3VhPro",·"",·0,·0,·312,·14,0);¤
¤ ¤
················if·(Ph·>=·0)¤ ················if·(Ph·>=·0)¤
····················DrawLabel("B3VhPro",·Ph,·312,·2,·displayColorProfit);¤ ····················DrawLabel("B3VhPro",·Ph,·312,·2,·displayColorProfit);¤
················else· ················else·
····················ObjSetTxt("B3VhPro",·DTS(Ph,·2),·0,·displayColorLoss);¤ ····················ObjSetTxt("B3VhPro",·DTS(Ph,·2),·0,·displayColorLoss);¤
····················dDigits·Digit[ArrayBsearch(Digit,·(int)·-Ph),·1];¤ ····················dDigits·Digit[ArrayBsearch(Digit,·(int)·-Ph),·1];¤
····················ObjSet("B3VhPro",·308·dDigits·7);¤ ····················ObjSet("B3VhPro",·308·dDigits·7);¤
················ ················
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3VhPMx")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3VhPMx")·==·-1)¤
····················CreateLabel("B3VhPMx",·"",·0,·0,·312,·15,0);¤ ····················CreateLabel("B3VhPMx",·"",·0,·0,·312,·15,0);¤
¤ ¤
················if·(PhMax·>=·0)¤ ················if·(PhMax·>=·0)¤
····················DrawLabel("B3VhPMx",·PhMax,·312,·2,·displayColorProfit);¤ ····················DrawLabel("B3VhPMx",·PhMax,·312,·2,·displayColorProfit);¤
················else· ················else·
····················ObjSetTxt("B3VhPMx",·DTS(PhMax,·2),·0,·displayColorLoss);¤ ····················ObjSetTxt("B3VhPMx",·DTS(PhMax,·2),·0,·displayColorLoss);¤
····················dDigits·Digit[ArrayBsearch(Digit,·(int)·-PhMax),·1];¤ ····················dDigits·Digit[ArrayBsearch(Digit,·(int)·-PhMax),·1];¤
····················ObjSet("B3VhPMx",·308·dDigits·7);¤ ····················ObjSet("B3VhPMx",·308·dDigits·7);¤
················ ················
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3ShPro")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3ShPro")·==·-1)¤
····················CreateLabel("B3ShPro",·"/",·0,·0,·342,·15,0);¤ ····················CreateLabel("B3ShPro",·"/",·0,·0,·342,·15,0);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3VhPMn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3VhPMn")·==·-1)¤
····················CreateLabel("B3VhPMn",·"",·0,·0,·351,·15,0,·displayColorLoss);¤ ····················CreateLabel("B3VhPMn",·"",·0,·0,·351,·15,0,·displayColorLoss);¤
¤ ¤
················if·(PhMin·0)¤ ················if·(PhMin·0)¤
····················ObjSet("B3VhPMn",·347);¤ ····················ObjSet("B3VhPMn",·347);¤
················else¤ ················else¤
····················ObjSet("B3VhPMn",·351);¤ ····················ObjSet("B3VhPMn",·351);¤
¤ ¤
················ObjSetTxt("B3VhPMn",·DTS(PhMin,·2),·0,·displayColorLoss);¤ ················ObjSetTxt("B3VhPMn",·DTS(PhMin,·2),·0,·displayColorLoss);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3LhTyp")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LhTyp")·==·-1)¤
····················CreateLabel("B3LhTyp",·"",·0,·0,·292,·16,0);¤ ····················CreateLabel("B3LhTyp",·"",·0,·0,·292,·16,0);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3VhOpn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3VhOpn")·==·-1)¤
····················CreateLabel("B3VhOpn",·"",·0,·0,·329,·16,0);¤ ····················CreateLabel("B3VhOpn",·"",·0,·0,·329,·16,0);¤
¤ ¤
················if·(ChB·0)· ················if·(ChB·0)·
····················ObjSetTxt("B3LhTyp",·"Buy:");¤ ····················ObjSetTxt("B3LhTyp",·"Buy:");¤
····················DrawLabel("B3VhOpn",·ChB,·329,·0);¤ ····················DrawLabel("B3VhOpn",·ChB,·329,·0);¤
················else·if·(ChS·0)· ················else·if·(ChS·0)·
····················ObjSetTxt("B3LhTyp",·"Sell:");¤ ····················ObjSetTxt("B3LhTyp",·"Sell:");¤
····················DrawLabel("B3VhOpn",·ChS,·329,·0);¤ ····················DrawLabel("B3VhOpn",·ChS,·329,·0);¤
················else· ················else·
····················ObjSetTxt("B3LhTyp",·"");¤ ····················ObjSetTxt("B3LhTyp",·"");¤
····················ObjSetTxt("B3VhOpn",·DTS(0,·0));¤ ····················ObjSetTxt("B3VhOpn",·DTS(0,·0));¤
····················ObjSet("B3VhOpn",·329);¤ ····················ObjSet("B3VhOpn",·329);¤
················ ················
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3ShOpn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3ShOpn")·==·-1)¤
····················CreateLabel("B3ShOpn",·"/",·0,·0,·342,·16,0);¤ ····················CreateLabel("B3ShOpn",·"/",·0,·0,·342,·16,0);¤
¤ ¤
················if·(ObjectFind(ChartID(),pref+"B3VhLot")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3VhLot")·==·-1)¤
····················CreateLabel("B3VhLot",·"",·0,·0,·351,·16,0);¤ ····················CreateLabel("B3VhLot",·"",·0,·0,·351,·16,0);¤
¤ ¤
················ObjSetTxt("B3VhLot",·DTS(LhT,·2));¤ ················ObjSetTxt("B3VhLot",·DTS(LhT,·2));¤
············else· ············else·
················ObjDel("B3LHdge");¤ ················ObjDel("B3LHdge");¤
················ObjDel("B3VhPro");¤ ················ObjDel("B3VhPro");¤
················ObjDel("B3VhPMx");¤ ················ObjDel("B3VhPMx");¤
················ObjDel("B3ShPro");¤ ················ObjDel("B3ShPro");¤
················ObjDel("B3VhPMn");¤ ················ObjDel("B3VhPMn");¤
················ObjDel("B3LhTyp");¤ ················ObjDel("B3LhTyp");¤
················ObjDel("B3VhOpn");¤ ················ObjDel("B3VhOpn");¤
················ObjDel("B3ShOpn");¤ ················ObjDel("B3ShOpn");¤
················ObjDel("B3VhLot");¤ ················ObjDel("B3VhLot");¤
············ ············
········ ········
¤ ¤
········if·(displayLines)· ········if·(displayLines)·
············if·(BEb·0)· ············if·(BEb·0)·
················if·(ObjectFind(ChartID(),pref+"B3LBELn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LBELn")·==·-1)¤
····················CreateLine("B3LBELn",·DodgerBlue,·1,·0);¤ ····················CreateLine("B3LBELn",·DodgerBlue,·1,·0);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LBELn",·0,·iTime(Symbol(),Period(),1),·BEb);¤ ················ObjectMove(ChartID(),pref+"B3LBELn",·0,·iTime(Symbol(),Period(),1),·BEb);¤
············else¤ ············else¤
················ObjDel("B3LBELn");¤ ················ObjDel("B3LBELn");¤
¤ ¤
············if·(TPa·0)· ············if·(TPa·0)·
················if·(ObjectFind(ChartID(),pref+"B3LTPLn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LTPLn")·==·-1)¤
····················CreateLine("B3LTPLn",·Gold,·1,·0);¤ ····················CreateLine("B3LTPLn",·Gold,·1,·0);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LTPLn",·0,·iTime(Symbol(),Period(),1),·TPa);¤ ················ObjectMove(ChartID(),pref+"B3LTPLn",·0,·iTime(Symbol(),Period(),1),·TPa);¤
············else·if·(TPb·&&·nLots·!=·0)· ············else·if·(TPb·&&·nLots·!=·0)·
················if·(ObjectFind(ChartID(),pref+"B3LTPLn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LTPLn")·==·-1)¤
····················CreateLine("B3LTPLn",·Gold,·1,·0);¤ ····················CreateLine("B3LTPLn",·Gold,·1,·0);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LTPLn",·0,·iTime(Symbol(),Period(),1),·TPb);¤ ················ObjectMove(ChartID(),pref+"B3LTPLn",·0,·iTime(Symbol(),Period(),1),·TPb);¤
············else·if(TPa<=0·&&·TPb<=0)¤ ············else·if(TPa<=0·&&·TPb<=0)¤
················ObjDel("B3LTPLn");¤ ················ObjDel("B3LTPLn");¤
¤ ¤
············if·(OPbN·0)· ············if·(OPbN·0)·
················if·(ObjectFind(ChartID(),pref+"B3LOPLn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LOPLn")·==·-1)¤
····················CreateLine("B3LOPLn",·Red,·1,·4);¤ ····················CreateLine("B3LOPLn",·Red,·1,·4);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LOPLn",·0,·iTime(Symbol(),Period(),1),·OPbN);¤ ················ObjectMove(ChartID(),pref+"B3LOPLn",·0,·iTime(Symbol(),Period(),1),·OPbN);¤
············else¤ ············else¤
················ObjDel("B3LOPLn");¤ ················ObjDel("B3LOPLn");¤
¤ ¤
············if·(bSL·0)· ············if·(bSL·0)·
················if·(ObjectFind(ChartID(),pref+"B3LSLbT")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LSLbT")·==·-1)¤
····················CreateLine("B3LSLbT",·Red,·1,·3);¤ ····················CreateLine("B3LSLbT",·Red,·1,·3);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LSLbT",·0,·iTime(Symbol(),Period(),1),·bSL);¤ ················ObjectMove(ChartID(),pref+"B3LSLbT",·0,·iTime(Symbol(),Period(),1),·bSL);¤
············else·if(TPa<=0·&&·TPb<=0)¤ ············else·if(TPa<=0·&&·TPb<=0)¤
················ObjDel("B3LSLbT");¤ ················ObjDel("B3LSLbT");¤
¤ ¤
············if·(bTS·0)· ············if·(bTS·0)·
················if·(ObjectFind(ChartID(),pref+"B3LTSbT")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LTSbT")·==·-1)¤
····················CreateLine("B3LTSbT",·Gold,·1,·3);¤ ····················CreateLine("B3LTSbT",·Gold,·1,·3);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LTSbT",·0,·iTime(Symbol(),Period(),1),·bTS);¤ ················ObjectMove(ChartID(),pref+"B3LTSbT",·0,·iTime(Symbol(),Period(),1),·bTS);¤
············else¤ ············else¤
················ObjDel("B3LTSbT");¤ ················ObjDel("B3LTSbT");¤
¤ ¤
············if·(hActive·==·&&·BEa·0)· ············if·(hActive·==·&&·BEa·0)·
················if·(ObjectFind(ChartID(),pref+"B3LNBEL")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LNBEL")·==·-1)¤
····················CreateLine("B3LNBEL",·Crimson,·1,·0);¤ ····················CreateLine("B3LNBEL",·Crimson,·1,·0);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LNBEL",·0,·iTime(Symbol(),Period(),1),·BEa);¤ ················ObjectMove(ChartID(),pref+"B3LNBEL",·0,·iTime(Symbol(),Period(),1),·BEa);¤
············else¤ ············else¤
················ObjDel("B3LNBEL");¤ ················ObjDel("B3LNBEL");¤
¤ ¤
············if·(TPbMP·0)· ············if·(TPbMP·0)·
················if·(ObjectFind(ChartID(),pref+"B3LMPLn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LMPLn")·==·-1)¤
····················CreateLine("B3LMPLn",·Gold,·1,·4);¤ ····················CreateLine("B3LMPLn",·Gold,·1,·4);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LMPLn",·0,iTime(Symbol(),Period(),1),·TPbMP);¤ ················ObjectMove(ChartID(),pref+"B3LMPLn",·0,iTime(Symbol(),Period(),1),·TPbMP);¤
············else¤ ············else¤
················ObjDel("B3LMPLn");¤ ················ObjDel("B3LMPLn");¤
¤ ¤
············if·(SLb·0)· ············if·(SLb·0)·
················if·(ObjectFind(ChartID(),pref+"B3LTSLn")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LTSLn")·==·-1)¤
····················CreateLine("B3LTSLn",·Gold,·1,·2);¤ ····················CreateLine("B3LTSLn",·Gold,·1,·2);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LTSLn",·0,·iTime(Symbol(),Period(),1),·SLb);¤ ················ObjectMove(ChartID(),pref+"B3LTSLn",·0,·iTime(Symbol(),Period(),1),·SLb);¤
············else¤ ············else¤
················ObjDel("B3LTSLn");¤ ················ObjDel("B3LTSLn");¤
¤ ¤
············if·(hThisChart·&&·BEh·0)· ············if·(hThisChart·&&·BEh·0)·
················if·(ObjectFind(ChartID(),pref+"B3LhBEL")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LhBEL")·==·-1)¤
····················CreateLine("B3LhBEL",·SlateBlue,·1,·0);¤ ····················CreateLine("B3LhBEL",·SlateBlue,·1,·0);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LhBEL",·0,·iTime(Symbol(),Period(),1),·BEh);¤ ················ObjectMove(ChartID(),pref+"B3LhBEL",·0,·iTime(Symbol(),Period(),1),·BEh);¤
············else¤ ············else¤
················ObjDel("B3LhBEL");¤ ················ObjDel("B3LhBEL");¤
¤ ¤
············if·(hThisChart·&&·SLh·0)· ············if·(hThisChart·&&·SLh·0)·
················if·(ObjectFind(ChartID(),pref+"B3LhSLL")·==·-1)¤ ················if·(ObjectFind(ChartID(),pref+"B3LhSLL")·==·-1)¤
····················CreateLine("B3LhSLL",·SlateBlue,·1,·3);¤ ····················CreateLine("B3LhSLL",·SlateBlue,·1,·3);¤
¤ ¤
················ObjectMove(ChartID(),pref+"B3LhSLL",·0,·iTime(Symbol(),Period(),1),·SLh);¤ ················ObjectMove(ChartID(),pref+"B3LhSLL",·0,·iTime(Symbol(),Period(),1),·SLh);¤
············else¤ ············else¤
················ObjDel("B3LhSLL");¤ ················ObjDel("B3LhSLL");¤
········else· ········else·
············ObjDel("B3LBELn");¤ ············ObjDel("B3LBELn");¤
············ObjDel("B3LTPLn");¤ ············ObjDel("B3LTPLn");¤
············ObjDel("B3LOPLn");¤ ············ObjDel("B3LOPLn");¤
············ObjDel("B3LSLbT");¤ ············ObjDel("B3LSLbT");¤
············ObjDel("B3LTSbT");¤ ············ObjDel("B3LTSbT");¤
············ObjDel("B3LNBEL");¤ ············ObjDel("B3LNBEL");¤
············ObjDel("B3LMPLn");¤ ············ObjDel("B3LMPLn");¤
············ObjDel("B3LTSLn");¤ ············ObjDel("B3LTSLn");¤
············ObjDel("B3LhBEL");¤ ············ObjDel("B3LhBEL");¤
············ObjDel("B3LhSLL");¤ ············ObjDel("B3LhSLL");¤
········ ········
¤ ¤
········if·(CCIEntry_·&&·displayCCI)· ········if·(CCIEntry_·&&·displayCCI)·
············if·(cci_01[0]·&&·cci_01[1]·0)¤ ············if·(cci_01[0]·&&·cci_01[1]·0)¤
················ObjectSetText("B3VCm05",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorProfit);¤ ················ObjectSetText("B3VCm05",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorProfit);¤
············else·if·(cci_01[0]·&&·cci_01[1]·0)¤ ············else·if·(cci_01[0]·&&·cci_01[1]·0)¤
················ObjectSetText("B3VCm05",CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorLoss);¤ ················ObjectSetText("B3VCm05",CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorLoss);¤
············else¤ ············else¤
················ObjectSetText("B3VCm05",·CharToString(79),·displayFontSize·6,·"Wingdings",·Orange);¤ ················ObjectSetText("B3VCm05",·CharToString(79),·displayFontSize·6,·"Wingdings",·Orange);¤
¤ ¤
············if·(cci_02[0]·&&·cci_02[1]·0)¤ ············if·(cci_02[0]·&&·cci_02[1]·0)¤
················ObjectSetText("B3VCm15",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorProfit);¤ ················ObjectSetText("B3VCm15",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorProfit);¤
············else·if·(cci_02[0]·&&·cci_02[1]·0)¤ ············else·if·(cci_02[0]·&&·cci_02[1]·0)¤
················ObjectSetText("B3VCm15",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorLoss);¤ ················ObjectSetText("B3VCm15",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorLoss);¤
············else¤ ············else¤
················ObjectSetText("B3VCm15",·CharToString(79),·displayFontSize·6,·"Wingdings",·Orange);¤ ················ObjectSetText("B3VCm15",·CharToString(79),·displayFontSize·6,·"Wingdings",·Orange);¤
¤ ¤
············if·(cci_03[0]·&&·cci_03[1]·0)¤ ············if·(cci_03[0]·&&·cci_03[1]·0)¤
················ObjectSetText("B3VCm30",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorProfit);¤ ················ObjectSetText("B3VCm30",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorProfit);¤
············else·if·(cci_03[0]·&&·cci_03[1]·0)¤ ············else·if·(cci_03[0]·&&·cci_03[1]·0)¤
················ObjectSetText("B3VCm30",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorLoss);¤ ················ObjectSetText("B3VCm30",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorLoss);¤
············else¤ ············else¤
················ObjectSetText("B3VCm30",·CharToString(79),·displayFontSize·6,·"Wingdings",·Orange);¤ ················ObjectSetText("B3VCm30",·CharToString(79),·displayFontSize·6,·"Wingdings",·Orange);¤
¤ ¤
············if·(cci_04[0]·&&·cci_04[1]·0)¤ ············if·(cci_04[0]·&&·cci_04[1]·0)¤
················ObjectSetText("B3VCm60",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorProfit);¤ ················ObjectSetText("B3VCm60",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorProfit);¤
············else·if·(cci_04[0]·&&·cci_04[1]·0)¤ ············else·if·(cci_04[0]·&&·cci_04[1]·0)¤
················ObjectSetText("B3VCm60",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorLoss);¤ ················ObjectSetText("B3VCm60",·CharToString(85),·displayFontSize·6,·"Wingdings",·displayColorLoss);¤
············else¤ ············else¤
················ObjectSetText("B3VCm60",·CharToString(79),·displayFontSize·6,·"Wingdings",·Orange);¤ ················ObjectSetText("B3VCm60",·CharToString(79),·displayFontSize·6,·"Wingdings",·Orange);¤
········ ········
¤ ¤
········if·(Debug_)· ········if·(Debug_)·
············string·dSpace;¤ ············string·dSpace;¤
¤ ¤
············for·(int·Index·0;·Index·<=·175;·Index++)¤ ············for·(int·Index·0;·Index·<=·175;·Index++)¤
················dSpace·dSpace·";¤ ················dSpace·dSpace·";¤
¤ ¤
············dMess·"\n\n"·dSpace·"Ticket···Magic·····Type·Lots·OpenPrice··Costs··Profit··Potential";¤ ············dMess·"\n\n"·dSpace·"Ticket···Magic·····Type·Lots·OpenPrice··Costs··Profit··Potential";¤
//Заменить¤ //Заменить¤
············for·(int·Order·0;·Order·OrdersTotal();·Order++)· ············for·(int·Order·0;·Order·OrdersTotal();·Order++)·
················if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤ ················if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤
····················continue;¤ ····················continue;¤
¤ ¤
················if·(OrderMagicNumber()·!=·Magic·&&·OrderMagicNumber()·!=·hMagic)¤ ················if·(OrderMagicNumber()·!=·Magic·&&·OrderMagicNumber()·!=·hMagic)¤
····················continue;¤ ····················continue;¤
¤ ¤
················dMess·(dMess·"\n"·dSpace·(string)·OrderTicket()··DTS(OrderMagicNumber(),·0)···(string)·OrderType());¤ ················dMess·(dMess·"\n"·dSpace·(string)·OrderTicket()··DTS(OrderMagicNumber(),·0)···(string)·OrderType());¤
················dMess·(dMess···DTS(OrderLots(),·LotDecimal)··DTS(OrderOpenPrice(),·Digits()));¤ ················dMess·(dMess···DTS(OrderLots(),·LotDecimal)··DTS(OrderOpenPrice(),·Digits()));¤
················dMess·(dMess·····DTS(OrderSwap()·OrderCommission(),·2));¤ ················dMess·(dMess·····DTS(OrderSwap()·OrderCommission(),·2));¤
················dMess·(dMess····DTS(OrderProfit()·OrderSwap()·OrderCommission(),·2));¤ ················dMess·(dMess····DTS(OrderProfit()·OrderSwap()·OrderCommission(),·2));¤
¤ ¤
················if·(OrderMagicNumber()·!=·Magic)¤ ················if·(OrderMagicNumber()·!=·Magic)¤
····················continue;¤ ····················continue;¤
················else·if·(OrderType()·==·OP_BUY)¤ ················else·if·(OrderType()·==·OP_BUY)¤
····················dMess·(dMess······DTS(OrderLots()·(TPb·OrderOpenPrice())·PipVal2·OrderSwap()·OrderCommission(),·2));¤ ····················dMess·(dMess······DTS(OrderLots()·(TPb·OrderOpenPrice())·PipVal2·OrderSwap()·OrderCommission(),·2));¤
················else·if·(OrderType()·==·OP_SELL)¤ ················else·if·(OrderType()·==·OP_SELL)¤
····················dMess·(dMess······DTS(OrderLots()·(OrderOpenPrice()·TPb)·PipVal2·OrderSwap()·OrderCommission(),·2));¤ ····················dMess·(dMess······DTS(OrderLots()·(OrderOpenPrice()·TPb)·PipVal2·OrderSwap()·OrderCommission(),·2));¤
············ ············
¤ ¤
············if·(!dLabels)· ············if·(!dLabels)·
················dLabels·true;¤ ················dLabels·true;¤
················CreateLabel("B3LPipV",·"Pip·Value",·0,·2,·0,·0,0);¤ ················CreateLabel("B3LPipV",·"Pip·Value",·0,·2,·0,·0,0);¤
················CreateLabel("B3VPipV",·"",·0,·2,·100,·0,0);¤ ················CreateLabel("B3VPipV",·"",·0,·2,·100,·0,0);¤
················CreateLabel("B3LDigi",·"Digits·Value",·0,·2,·0,·1,0);¤ ················CreateLabel("B3LDigi",·"Digits·Value",·0,·2,·0,·1,0);¤
················CreateLabel("B3VDigi",·"",·0,·2,·100,·1,0);¤ ················CreateLabel("B3VDigi",·"",·0,·2,·100,·1,0);¤
················ObjSetTxt("B3VDigi",·DTS(Digits(),·0));¤ ················ObjSetTxt("B3VDigi",·DTS(Digits(),·0));¤
················CreateLabel("B3LPoin",·"Point·Value",·0,·2,·0,·2,0);¤ ················CreateLabel("B3LPoin",·"Point·Value",·0,·2,·0,·2,0);¤
················CreateLabel("B3VPoin",·"",·0,·2,·100,·2,0);¤ ················CreateLabel("B3VPoin",·"",·0,·2,·100,·2,0);¤
················ObjSetTxt("B3VPoin",·DTS(Point(),·Digits()));¤ ················ObjSetTxt("B3VPoin",·DTS(Point(),·Digits()));¤
················CreateLabel("B3LSprd",·"Spread·Value",·0,·2,·0,·3,0);¤ ················CreateLabel("B3LSprd",·"Spread·Value",·0,·2,·0,·3,0);¤
················CreateLabel("B3VSprd",·"",·0,·2,·100,·3,0);¤ ················CreateLabel("B3VSprd",·"",·0,·2,·100,·3,0);¤
················CreateLabel("B3LBid",·"Bid·Value",·0,·2,·0,·4,0);¤ ················CreateLabel("B3LBid",·"Bid·Value",·0,·2,·0,·4,0);¤
················CreateLabel("B3VBid",·"",·0,·2,·100,·4,0);¤ ················CreateLabel("B3VBid",·"",·0,·2,·100,·4,0);¤
················CreateLabel("B3LAsk",·"Ask·Value",·0,·2,·0,·5,0);¤ ················CreateLabel("B3LAsk",·"Ask·Value",·0,·2,·0,·5,0);¤
················CreateLabel("B3VAsk",·"",·0,·2,·100,·5,0);¤ ················CreateLabel("B3VAsk",·"",·0,·2,·100,·5,0);¤
················CreateLabel("B3LLotP",·"Lot·Step",·0,·2,·200,·0,0);¤ ················CreateLabel("B3LLotP",·"Lot·Step",·0,·2,·200,·0,0);¤
················CreateLabel("B3VLotP",·"",·0,·2,·300,·0,0);¤ ················CreateLabel("B3VLotP",·"",·0,·2,·300,·0,0);¤
················ObjSetTxt("B3VLotP",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_STEP),·LotDecimal));¤ ················ObjSetTxt("B3VLotP",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_STEP),·LotDecimal));¤
················CreateLabel("B3LLotX",·"Lot·Max",·0,·2,·200,·1,0);¤ ················CreateLabel("B3LLotX",·"Lot·Max",·0,·2,·200,·1,0);¤
················CreateLabel("B3VLotX",·"",·0,·2,·300,·1,0);¤ ················CreateLabel("B3VLotX",·"",·0,·2,·300,·1,0);¤
················ObjSetTxt("B3VLotX",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_MAX),·0));¤ ················ObjSetTxt("B3VLotX",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_MAX),·0));¤
················CreateLabel("B3LLotN",·"Lot·Min",·0,·2,·200,·2,0);¤ ················CreateLabel("B3LLotN",·"Lot·Min",·0,·2,·200,·2,0);¤
················CreateLabel("B3VLotN",·"",·0,·2,·300,·2,0);¤ ················CreateLabel("B3VLotN",·"",·0,·2,·300,·2,0);¤
················ObjSetTxt("B3VLotN",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_MIN),·LotDecimal));¤ ················ObjSetTxt("B3VLotN",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_MIN),·LotDecimal));¤
················CreateLabel("B3LLotD",·"Lot·Decimal",·0,·2,·200,·3,0);¤ ················CreateLabel("B3LLotD",·"Lot·Decimal",·0,·2,·200,·3,0);¤
················CreateLabel("B3VLotD",·"",·0,·2,·300,·3,0);¤ ················CreateLabel("B3VLotD",·"",·0,·2,·300,·3,0);¤
················ObjSetTxt("B3VLotD",·DTS(LotDecimal,·0));¤ ················ObjSetTxt("B3VLotD",·DTS(LotDecimal,·0));¤
················CreateLabel("B3LAccT",·"Account·Type",·0,·2,·200,·4,0);¤ ················CreateLabel("B3LAccT",·"Account·Type",·0,·2,·200,·4,0);¤
················CreateLabel("B3VAccT",·"",·0,·2,·300,·4,0);¤ ················CreateLabel("B3VAccT",·"",·0,·2,·300,·4,0);¤
················ObjSetTxt("B3VAccT",·DTS(AccountType,·0));¤ ················ObjSetTxt("B3VAccT",·DTS(AccountType,·0));¤
················CreateLabel("B3LPnts",·"Pip",·0,·2,·200,·5,0);¤ ················CreateLabel("B3LPnts",·"Pip",·0,·2,·200,·5,0);¤
················CreateLabel("B3VPnts",·"",·0,·2,·300,·5,0);¤ ················CreateLabel("B3VPnts",·"",·0,·2,·300,·5,0);¤
················ObjSetTxt("B3VPnts",·DTS(Pip,·Digits()));¤ ················ObjSetTxt("B3VPnts",·DTS(Pip,·Digits()));¤
················CreateLabel("B3LTicV",·"Tick·Value",·0,·2,·400,·0,0);¤ ················CreateLabel("B3LTicV",·"Tick·Value",·0,·2,·400,·0,0);¤
················CreateLabel("B3VTicV",·"",·0,·2,·500,·0,0);¤ ················CreateLabel("B3VTicV",·"",·0,·2,·500,·0,0);¤
················CreateLabel("B3LTicS",·"Tick·Size",·0,·2,·400,·1,0);¤ ················CreateLabel("B3LTicS",·"Tick·Size",·0,·2,·400,·1,0);¤
················CreateLabel("B3VTicS",·"",·0,·2,·500,·1,0);¤ ················CreateLabel("B3VTicS",·"",·0,·2,·500,·1,0);¤
················ObjSetTxt("B3VTicS",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_TRADE_TICK_SIZE),·Digits()));¤ ················ObjSetTxt("B3VTicS",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_TRADE_TICK_SIZE),·Digits()));¤
················CreateLabel("B3LLev",·"Leverage",·0,·2,·400,·2,0);¤ ················CreateLabel("B3LLev",·"Leverage",·0,·2,·400,·2,0);¤
················CreateLabel("B3VLev",·"",·0,·2,·500,·2,0);¤ ················CreateLabel("B3VLev",·"",·0,·2,·500,·2,0);¤
················ObjSetTxt("B3VLev",·DTS(AccountInfoInteger(ACCOUNT_LEVERAGE),·0)·":1");¤ ················ObjSetTxt("B3VLev",·DTS(AccountInfoInteger(ACCOUNT_LEVERAGE),·0)·":1");¤
················CreateLabel("B3LSGTF",·"SmartGrid",·0,·2,·400,·3,0);¤ ················CreateLabel("B3LSGTF",·"SmartGrid",·0,·2,·400,·3,0);¤
¤ ¤
················if·(UseSmartGrid)¤ ················if·(UseSmartGrid)¤
····················CreateLabel("B3VSGTF",·"True",·0,·2,·500,·3,0);¤ ····················CreateLabel("B3VSGTF",·"True",·0,·2,·500,·3,0);¤
················else¤ ················else¤
····················CreateLabel("B3VSGTF",·"False",·0,·2,·500,·3,0);¤ ····················CreateLabel("B3VSGTF",·"False",·0,·2,·500,·3,0);¤
¤ ¤
················CreateLabel("B3LCOTF",·"Close·Oldest",·0,·2,·400,·4,0);¤ ················CreateLabel("B3LCOTF",·"Close·Oldest",·0,·2,·400,·4,0);¤
¤ ¤
················if·(UseCloseOldest)¤ ················if·(UseCloseOldest)¤
····················CreateLabel("B3VCOTF",·"True",·0,·2,·500,·4,0);¤ ····················CreateLabel("B3VCOTF",·"True",·0,·2,·500,·4,0);¤
················else¤ ················else¤
····················CreateLabel("B3VCOTF",·"False",·0,·2,·500,·4,0);¤ ····················CreateLabel("B3VCOTF",·"False",·0,·2,·500,·4,0);¤
¤ ¤
················CreateLabel("B3LUHTF",·"Hedge",·0,·2,·400,·5,0);¤ ················CreateLabel("B3LUHTF",·"Hedge",·0,·2,·400,·5,0);¤
¤ ¤
················if·(UseHedge_·&&·HedgeTypeDD)¤ ················if·(UseHedge_·&&·HedgeTypeDD)¤
····················CreateLabel("B3VUHTF",·"DrawDown",·0,·2,·500,·5,0);¤ ····················CreateLabel("B3VUHTF",·"DrawDown",·0,·2,·500,·5,0);¤
················else·if·(UseHedge_·&&·!HedgeTypeDD)¤ ················else·if·(UseHedge_·&&·!HedgeTypeDD)¤
····················CreateLabel("B3VUHTF",·"Level",·0,·2,·500,·5,0);¤ ····················CreateLabel("B3VUHTF",·"Level",·0,·2,·500,·5,0);¤
················else¤ ················else¤
····················CreateLabel("B3VUHTF",·"False",·0,·2,·500,·5,0);¤ ····················CreateLabel("B3VUHTF",·"False",·0,·2,·500,·5,0);¤
············ ············
¤ ¤
············ObjSetTxt("B3VPipV",·DTS(PipValue,·2));¤ ············ObjSetTxt("B3VPipV",·DTS(PipValue,·2));¤
············ObjSetTxt("B3VSprd",·DTS(ASK·BID,·Digits()));¤ ············ObjSetTxt("B3VSprd",·DTS(ASK·BID,·Digits()));¤
············ObjSetTxt("B3VBid",·DTS(BID,·Digits()));¤ ············ObjSetTxt("B3VBid",·DTS(BID,·Digits()));¤
············ObjSetTxt("B3VAsk",·DTS(ASK,·Digits()));¤ ············ObjSetTxt("B3VAsk",·DTS(ASK,·Digits()));¤
············ObjSetTxt("B3VTicV",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_TRADE_TICK_VALUE),·Digits()));¤ ············ObjSetTxt("B3VTicV",·DTS(SymbolInfoDouble(Symbol(),·SYMBOL_TRADE_TICK_VALUE),·Digits()));¤
········ ········
¤ ¤
········if·(EmergencyWarning)· ········if·(EmergencyWarning)·
············if·(ObjectFind(ChartID(),pref+"B3LClos")·==·-1)¤ ············if·(ObjectFind(ChartID(),pref+"B3LClos")·==·-1)¤
················CreateLabel("B3LClos",·"",·5,·0,·0,·23,·displayColorLoss);¤ ················CreateLabel("B3LClos",·"",·5,·0,·0,·23,·displayColorLoss);¤
¤ ¤
············ObjSetTxt("B3LClos",·"WARNING:·EmergencyCloseAll·is·TRUE",·5,·displayColorLoss);¤ ············ObjSetTxt("B3LClos",·"WARNING:·EmergencyCloseAll·is·TRUE",·5,·displayColorLoss);¤
········else·if·(ShutDown_)· ········else·if·(ShutDown_)·
············if·(ObjectFind(ChartID(),pref+"B3LClos")·==·-1)¤ ············if·(ObjectFind(ChartID(),pref+"B3LClos")·==·-1)¤
················CreateLabel("B3LClos",·"",·5,·0,·0,·23,·displayColorLoss);¤ ················CreateLabel("B3LClos",·"",·5,·0,·0,·23,·displayColorLoss);¤
¤ ¤
············ObjSetTxt("B3LClos",·"Trading·will·stop·when·this·basket·closes.",·5,·displayColorLoss);¤ ············ObjSetTxt("B3LClos",·"Trading·will·stop·when·this·basket·closes.",·5,·displayColorLoss);¤
········else·if·(HolShutDown·!=·1)¤ ········else·if·(HolShutDown·!=·1)¤
············ObjDel("B3LClos");¤ ············ObjDel("B3LClos");¤
···· ····
//tyt¤ //tyt¤
//····¤ //····¤
//··········if(background)¤ //··········if(background)¤
//··· //···
//···Print("aaaaaaaaaaaaaaaaaaaaaaaaa");¤ //···Print("aaaaaaaaaaaaaaaaaaaaaaaaa");¤
//···for(int·x=0;x<21;x++)·//·¤ //···for(int·x=0;x<21;x++)·//·¤
//···for(int·w=0;w<15;w++)¤ //···for(int·w=0;w<15;w++)¤
//······ //······
//·········ObjectCreate(ChartID(),pref+"Bkgrd"+x+w,OBJ_LABEL,0,0,0,0,0);¤ //·········ObjectCreate(ChartID(),pref+"Bkgrd"+x+w,OBJ_LABEL,0,0,0,0,0);¤
//·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_CORNER,0);¤ //·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_CORNER,0);¤
//·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_XDISTANCE,x*24+displayXcord-4);¤ //·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_XDISTANCE,x*24+displayXcord-4);¤
//·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_YDISTANCE,w*24+displayYcord-10);¤ //·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_YDISTANCE,w*24+displayYcord-10);¤
//·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_ZORDER,0);¤ //·········ObjectSetInteger(ChartID(),pref+"Bkgrd"+x+w,OBJPROP_ZORDER,0);¤
//·········ObjectSetText(pref+"Bkgrd"+x+w,CharToString(110),32,"Wingdings",ChartGetInteger(ChartID(),CHART_COLOR_BACKGROUND));¤ //·········ObjectSetText(pref+"Bkgrd"+x+w,CharToString(110),32,"Wingdings",ChartGetInteger(ChartID(),CHART_COLOR_BACKGROUND));¤
//······ //······
//···¤ //···¤
//···ChartRedraw();¤ //···ChartRedraw();¤
····FirstRun·false;¤ ····FirstRun·false;¤
····Comment(CS,·dMess);¤ ····Comment(CS,·dMess);¤
¤ ¤
····return;¤ ····return;¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Check·Lot·Size·Function········································· //|·Check·Lot·Size·Function·········································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
double·LotSize(double·NewLot)· double·LotSize(double·NewLot)·
····NewLot·ND(NewLot,·LotDecimal);¤ ····NewLot·ND(NewLot,·LotDecimal);¤
····NewLot·MathMin(NewLot,·SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_MAX));¤ ····NewLot·MathMin(NewLot,·SymbolInfoDouble(Symbol(),·SYMBOL_VOLUME_MAX));¤
····NewLot·MathMax(NewLot,·MinLotSize);¤ ····NewLot·MathMax(NewLot,·MinLotSize);¤
¤ ¤
····return·(NewLot);¤ ····return·(NewLot);¤
¤ ¤
¤ ¤
double·margin_maxlots()· double·margin_maxlots()·
····return·(AccountInfoDouble(ACCOUNT_MARGIN_FREE)·GetMarginRequired(Symbol())·);¤ ····return·(AccountInfoDouble(ACCOUNT_MARGIN_FREE)·GetMarginRequired(Symbol())·);¤
¤ ¤
¤ ¤
double·portion_maxlots()· double·portion_maxlots()·
¤ ¤
····return·(PortionBalance·GetMarginRequired(Symbol()));¤ ····return·(PortionBalance·GetMarginRequired(Symbol()));¤
¤ ¤
double·GetMarginRequired(·const·string·Symb· double·GetMarginRequired(·const·string·Symb·
··MqlTick·Tick;¤ ··MqlTick·Tick;¤
··double·MarginInit,·MarginMain;¤ ··double·MarginInit,·MarginMain;¤
¤ ¤
··return((SymbolInfoTick(Symb,·Tick)·&&·SymbolInfoMarginRate(Symb,·ORDER_TYPE_BUY,·MarginInit,·MarginMain))·MarginInit·Tick.ask· ··return((SymbolInfoTick(Symb,·Tick)·&&·SymbolInfoMarginRate(Symb,·ORDER_TYPE_BUY,·MarginInit,·MarginMain))·MarginInit·Tick.ask·
··········SymbolInfoDouble(Symb,·SYMBOL_TRADE_TICK_VALUE)·(SymbolInfoDouble(Symb,·SYMBOL_TRADE_TICK_SIZE)·AccountInfoInteger(ACCOUNT_LEVERAGE))·0);¤ ··········SymbolInfoDouble(Symb,·SYMBOL_TRADE_TICK_VALUE)·(SymbolInfoDouble(Symb,·SYMBOL_TRADE_TICK_SIZE)·AccountInfoInteger(ACCOUNT_LEVERAGE))·0);¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Open·Order·Function············································· //|·Open·Order·Function·············································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
int·SendOrder(string·OSymbol,·int·OCmd,·double·OLot,·double·OPrice,·int·OSlip,·int·OMagic,·color·OColor·CLR_NONE)· int·SendOrder(string·OSymbol,·int·OCmd,·double·OLot,·double·OPrice,·int·OSlip,·int·OMagic,·color·OColor·CLR_NONE)·
····if·(FirstRun)¤ ····if·(FirstRun)¤
········return·(-1);¤ ········return·(-1);¤
¤ ¤
····int·Ticket·0;¤ ····int·Ticket·0;¤
····int·Tries·0;¤ ····int·Tries·0;¤
····int·OType·(int)·MathMod(OCmd,·2);¤ ····int·OType·(int)·MathMod(OCmd,·2);¤
····double·OrderPrice;¤ ····double·OrderPrice;¤
¤ ¤
»   //·check·margin·against·MinMarginPercent¤ »   //·check·margin·against·MinMarginPercent¤
»   if·(UseMinMarginPercent·&&·AccountInfoDouble(ACCOUNT_MARGIN)·0)· »   if·(UseMinMarginPercent·&&·AccountInfoDouble(ACCOUNT_MARGIN)·0)·
········//·double·ml·ND(AccountEquity()·AccountMargin()·100,·2);¤ ········//·double·ml·ND(AccountEquity()·AccountMargin()·100,·2);¤
········double·ml·ND(AccountInfoDouble(ACCOUNT_MARGIN_LEVEL),·2);¤ ········double·ml·ND(AccountInfoDouble(ACCOUNT_MARGIN_LEVEL),·2);¤
»   »   Print("Account·Margin·Level:·DTS(ml,2));¤ »   »   Print("Account·Margin·Level:·DTS(ml,2));¤
········if·(ml·MinMarginPercent)· ········if·(ml·MinMarginPercent)·
············Print("Margin·percent·(string)·ml·"%·too·low·to·open·new·trade");¤ ············Print("Margin·percent·(string)·ml·"%·too·low·to·open·new·trade");¤
············return·-1;¤ ············return·-1;¤
········ ········
···· ····
¤ ¤
»   //·Sanity·check·lots·vs.·portion·and·margin·...·r.f.¤ »   //·Sanity·check·lots·vs.·portion·and·margin·...·r.f.¤
····if·(OLot·(portion_maxlots()·LbT))·····//·Request·lots·vs·Portion·Current·lots·out¤ ····if·(OLot·(portion_maxlots()·LbT))·····//·Request·lots·vs·Portion·Current·lots·out¤
········Print("Insufficient·Portion·free·",·OSymbol,··Type:·",·OType,·Lots:·",·DTS(OLot,·2),¤ ········Print("Insufficient·Portion·free·",·OSymbol,··Type:·",·OType,·Lots:·",·DTS(OLot,·2),¤
···············Free·margin:·",·DTS(AccountInfoDouble(ACCOUNT_MARGIN_FREE),·2),··Margin·Maxlots:·",·DTS(margin_maxlots(),·2),··Portion·Maxlots:·",·DTS(portion_maxlots(),·2),··Current·Lots:·",·DTS(LbT,·2));¤ ···············Free·margin:·",·DTS(AccountInfoDouble(ACCOUNT_MARGIN_FREE),·2),··Margin·Maxlots:·",·DTS(margin_maxlots(),·2),··Portion·Maxlots:·",·DTS(portion_maxlots(),·2),··Current·Lots:·",·DTS(LbT,·2));¤
········return·(-1);¤ ········return·(-1);¤
¤ ¤
········//·OLot·portion_maxlots()·LbT·MinLotSize;¤ ········//·OLot·portion_maxlots()·LbT·MinLotSize;¤
········//·Print("Reducing·order·to:·",·DTS(OLot,·2));¤ ········//·Print("Reducing·order·to:·",·DTS(OLot,·2));¤
···· ····
//Заменить¤ //Заменить¤
//····if·(AccountFreeMarginCheck(OSymbol,·OType,·OLot)·<=·||·GetLastError()·==·ERR_NOT_ENOUGH_MONEY)· //····if·(AccountFreeMarginCheck(OSymbol,·OType,·OLot)·<=·||·GetLastError()·==·ERR_NOT_ENOUGH_MONEY)·
//········Print("Not·enough·margin·",·OSymbol,··Type:·",·OType,·Lots:·",·DTS(OLot,·2),¤ //········Print("Not·enough·margin·",·OSymbol,··Type:·",·OType,·Lots:·",·DTS(OLot,·2),¤
//···············Free·margin:·",·DTS(AccountInfoDouble(ACCOUNT_MARGIN_FREE),·2),··Margin·Maxlots:·",·DTS(margin_maxlots(),·2),··Portion·Maxlots:·",·DTS(portion_maxlots(),·2),··Current·Lots:·",·DTS(LbT,·2));¤ //···············Free·margin:·",·DTS(AccountInfoDouble(ACCOUNT_MARGIN_FREE),·2),··Margin·Maxlots:·",·DTS(margin_maxlots(),·2),··Portion·Maxlots:·",·DTS(portion_maxlots(),·2),··Current·Lots:·",·DTS(LbT,·2));¤
//¤ //¤
//········return·(-1);¤ //········return·(-1);¤
//···· //····
····//Заменить¤ ····//Заменить¤
···double·ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);¤ ···double·ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);¤
···double·bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);¤ ···double·bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);¤
···double·spread=ask-bid;¤ ···double·spread=ask-bid;¤
····if·(MaxSpread·&&·spread·Point()·Pip·MaxSpread)¤ ····if·(MaxSpread·&&·spread·Point()·Pip·MaxSpread)¤
········return·(-1);¤ ········return·(-1);¤
¤ ¤
····while·(Tries·5)· ····while·(Tries·5)·
········Tries++;¤ ········Tries++;¤
//Заменить¤ //Заменить¤
········//while·(IsTradeContextBusy())¤ ········//while·(IsTradeContextBusy())¤
········//····Sleep(100);¤ ········//····Sleep(100);¤
¤ ¤
········if·(IsStopped())¤ ········if·(IsStopped())¤
············return·(-1);¤ ············return·(-1);¤
········else·if·(OType·==·0)¤ ········else·if·(OType·==·0)¤
············OrderPrice·ND(SymbolInfoDouble(OSymbol,·SYMBOL_ASK)·OPrice,·(int)·SymbolInfoInteger(OSymbol,·SYMBOL_DIGITS));¤ ············OrderPrice·ND(SymbolInfoDouble(OSymbol,·SYMBOL_ASK)·OPrice,·(int)·SymbolInfoInteger(OSymbol,·SYMBOL_DIGITS));¤
········else¤ ········else¤
············OrderPrice·ND(SymbolInfoDouble(OSymbol,·SYMBOL_BID)·OPrice,·(int)·SymbolInfoInteger(OSymbol,·SYMBOL_DIGITS));¤ ············OrderPrice·ND(SymbolInfoDouble(OSymbol,·SYMBOL_BID)·OPrice,·(int)·SymbolInfoInteger(OSymbol,·SYMBOL_DIGITS));¤
//Заменить¤ //Заменить¤
········Ticket·OrderSend(OSymbol,·OCmd,·OLot,·OrderPrice,·OSlip,·0,·0,·TradeComment,·OMagic,·0,·OColor);¤ ········Ticket·OrderSend(OSymbol,·OCmd,·OLot,·OrderPrice,·OSlip,·0,·0,·TradeComment,·OMagic,·0,·OColor);¤
¤ ¤
········if·(Ticket·0)· ········if·(Ticket·0)·
············Error·GetLastError();¤ ············Error·GetLastError();¤
¤ ¤
············if·(Error·!=·0)¤ ············if·(Error·!=·0)¤
················Print("Error·",·Error,·opening·order·",¤ ················Print("Error·",·Error,·opening·order·",¤
·······················Symbol:·",·OSymbol,··TradeOP:·",·OCmd,··OType:·",·OType,¤ ·······················Symbol:·",·OSymbol,··TradeOP:·",·OCmd,··OType:·",·OType,¤
·······················Ask:·",·DTS(SymbolInfoDouble(OSymbol,·SYMBOL_ASK),·Digits()),¤ ·······················Ask:·",·DTS(SymbolInfoDouble(OSymbol,·SYMBOL_ASK),·Digits()),¤
·······················Bid:·",·DTS(SymbolInfoDouble(OSymbol,·SYMBOL_BID),·Digits()),··OPrice:·",·DTS(OPrice,·Digits()),··Price:·",·DTS(OrderPrice,·Digits()),··Lots:·",·DTS(OLot,·2));¤ ·······················Bid:·",·DTS(SymbolInfoDouble(OSymbol,·SYMBOL_BID),·Digits()),··OPrice:·",·DTS(OPrice,·Digits()),··Price:·",·DTS(OrderPrice,·Digits()),··Lots:·",·DTS(OLot,·2));¤
//Заменить¤ //Заменить¤
············switch·(Error)· ············switch·(Error)·
············case·ERR_TRADE_DISABLED:¤ ············case·ERR_TRADE_DISABLED:¤
················AllowTrading·false;¤ ················AllowTrading·false;¤
················Print("Broker·has·disallowed·EAs·on·this·account");¤ ················Print("Broker·has·disallowed·EAs·on·this·account");¤
················Tries·5;¤ ················Tries·5;¤
············//····break;¤ ············//····break;¤
············//case·ERR_OFF_QUOTES:¤ ············//case·ERR_OFF_QUOTES:¤
············//case·ERR_INVALID_PRICE:¤ ············//case·ERR_INVALID_PRICE:¤
············//····Sleep(5000);¤ ············//····Sleep(5000);¤
············//case·ERR_PRICE_CHANGED:¤ ············//case·ERR_PRICE_CHANGED:¤
············//case·ERR_REQUOTE:¤ ············//case·ERR_REQUOTE:¤
············//····RefreshRates();¤ ············//····RefreshRates();¤
············//case·ERR_SERVER_BUSY:¤ ············//case·ERR_SERVER_BUSY:¤
············//case·ERR_NO_CONNECTION:¤ ············//case·ERR_NO_CONNECTION:¤
············//case·ERR_BROKER_BUSY:¤ ············//case·ERR_BROKER_BUSY:¤
············//case·ERR_TRADE_CONTEXT_BUSY:¤ ············//case·ERR_TRADE_CONTEXT_BUSY:¤
············//····Tries++;¤ ············//····Tries++;¤
············//····break;¤ ············//····break;¤
············//case·149:··········//ERR_TRADE_HEDGE_PROHIBITED:¤ ············//case·149:··········//ERR_TRADE_HEDGE_PROHIBITED:¤
················if·(Debug_)¤ ················if·(Debug_)¤
····················Print("Hedge·trades·are·not·supported·on·this·pair");¤ ····················Print("Hedge·trades·are·not·supported·on·this·pair");¤
¤ ¤
················UseHedge_·false;¤ ················UseHedge_·false;¤
················Tries·5;¤ ················Tries·5;¤
················break;¤ ················break;¤
············default:¤ ············default:¤
················Tries·5;¤ ················Tries·5;¤
············ ············
········else· ········else·
············if·(PlaySounds)¤ ············if·(PlaySounds)¤
················PlaySound(AlertSound);¤ ················PlaySound(AlertSound);¤
¤ ¤
············break;¤ ············break;¤
········ ········
···· ····
¤ ¤
····return·(Ticket);¤ ····return·(Ticket);¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Modify·Order·Function··········································· //|·Modify·Order·Function···········································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
bool·ModifyOrder(double·OrderOP,·double·OrderSL,·color·Color·CLR_NONE)· bool·ModifyOrder(double·OrderOP,·double·OrderSL,·color·Color·CLR_NONE)·
····bool·Success·false;¤ ····bool·Success·false;¤
····int·Tries·0;¤ ····int·Tries·0;¤
¤ ¤
····while·(Tries·&&·!Success)· ····while·(Tries·&&·!Success)·
········Tries++;¤ ········Tries++;¤
//Заменить¤ //Заменить¤
········//while·(IsTradeContextBusy())¤ ········//while·(IsTradeContextBusy())¤
········//····Sleep(100);¤ ········//····Sleep(100);¤
¤ ¤
········if·(IsStopped())¤ ········if·(IsStopped())¤
············return·(false);·····//(-1)¤ ············return·(false);·····//(-1)¤
//Заменить¤ //Заменить¤
········Success·OrderModify(OrderTicket(),·OrderOP,·OrderSL,·0,·0,·Color);¤ ········Success·OrderModify(OrderTicket(),·OrderOP,·OrderSL,·0,·0,·Color);¤
¤ ¤
········if·(!Success)· ········if·(!Success)·
············Error·GetLastError();¤ ············Error·GetLastError();¤
¤ ¤
············if·(Error·1)· ············if·(Error·1)·
//Заменить¤ //Заменить¤
················//Print("Error·",·Error,·modifying·order·",·OrderTicket(),··Ask:·",·Ask,¤ ················//Print("Error·",·Error,·modifying·order·",·OrderTicket(),··Ask:·",·Ask,¤
················//·······Bid:·",·Bid,··OrderPrice:·",·OrderOP,··StopLevel:·",·StopLevel,··SL:·",·OrderSL,··OSL:·",·OrderStopLoss());¤ ················//·······Bid:·",·Bid,··OrderPrice:·",·OrderOP,··StopLevel:·",·StopLevel,··SL:·",·OrderSL,··OSL:·",·OrderStopLoss());¤
¤ ¤
················//switch·(Error)· ················//switch·(Error)·
················//case·ERR_TRADE_MODIFY_DENIED:¤ ················//case·ERR_TRADE_MODIFY_DENIED:¤
················//····Sleep(10000);¤ ················//····Sleep(10000);¤
················//case·ERR_OFF_QUOTES:¤ ················//case·ERR_OFF_QUOTES:¤
················//case·ERR_INVALID_PRICE:¤ ················//case·ERR_INVALID_PRICE:¤
················//····Sleep(5000);¤ ················//····Sleep(5000);¤
················//case·ERR_PRICE_CHANGED:¤ ················//case·ERR_PRICE_CHANGED:¤
················//case·ERR_REQUOTE:¤ ················//case·ERR_REQUOTE:¤
················//····RefreshRates();¤ ················//····RefreshRates();¤
················//case·ERR_SERVER_BUSY:¤ ················//case·ERR_SERVER_BUSY:¤
················//case·ERR_NO_CONNECTION:¤ ················//case·ERR_NO_CONNECTION:¤
················//case·ERR_BROKER_BUSY:¤ ················//case·ERR_BROKER_BUSY:¤
················//case·ERR_TRADE_CONTEXT_BUSY:¤ ················//case·ERR_TRADE_CONTEXT_BUSY:¤
················//case·ERR_TRADE_TIMEOUT:¤ ················//case·ERR_TRADE_TIMEOUT:¤
················//····Tries++;¤ ················//····Tries++;¤
················//····break;¤ ················//····break;¤
················//default:¤ ················//default:¤
················//····Tries·5;¤ ················//····Tries·5;¤
················//····break;¤ ················//····break;¤
················//}¤ ················//}¤
············else¤ ············else¤
················Success·true;¤ ················Success·true;¤
········else¤ ········else¤
············break;¤ ············break;¤
···· ····
¤ ¤
····return·(Success);¤ ····return·(Success);¤
¤ ¤
¤ ¤
//+-------------------------------------------------------------------------+¤ //+-------------------------------------------------------------------------+¤
//|·Exit·Trade·Function·Type:·All·Basket·Hedge·Ticket·Pending············· //|·Exit·Trade·Function·Type:·All·Basket·Hedge·Ticket·Pending·············
//+-------------------------------------------------------------------------+¤ //+-------------------------------------------------------------------------+¤
int·ExitTrades(int·Type,·color·Color,·string·Reason,·int·OTicket·0)· int·ExitTrades(int·Type,·color·Color,·string·Reason,·int·OTicket·0)·
····static·int·OTicketNo;¤ ····static·int·OTicketNo;¤
····bool·Success;¤ ····bool·Success;¤
····int·Tries·0,·Closed·0,·CloseCount·0;¤ ····int·Tries·0,·Closed·0,·CloseCount·0;¤
····int·CloseTrades[,·2];¤ ····int·CloseTrades[,·2];¤
····double·OPrice;¤ ····double·OPrice;¤
····string·s;¤ ····string·s;¤
····ca·Type;¤ ····ca·Type;¤
¤ ¤
····if·(Type·==·T)· ····if·(Type·==·T)·
········if·(OTicket·==·0)¤ ········if·(OTicket·==·0)¤
············OTicket·OTicketNo;¤ ············OTicket·OTicketNo;¤
········else¤ ········else¤
············OTicketNo·OTicket;¤ ············OTicketNo·OTicket;¤
···· ····
//Заменить¤ //Заменить¤
····for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)· ····for·(int·Order·OrdersTotal()·1;·Order·>=·0;·Order--)·
········if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤ ········if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_TRADES))¤
············continue;¤ ············continue;¤
¤ ¤
········if·(Type·==·&&·OrderMagicNumber()·!=·Magic)¤ ········if·(Type·==·&&·OrderMagicNumber()·!=·Magic)¤
············continue;¤ ············continue;¤
········else·if·(Type·==·&&·OrderMagicNumber()·!=·hMagic)¤ ········else·if·(Type·==·&&·OrderMagicNumber()·!=·hMagic)¤
············continue;¤ ············continue;¤
········else·if·(Type·==·&&·OrderMagicNumber()·!=·Magic·&&·OrderMagicNumber()·!=·hMagic)¤ ········else·if·(Type·==·&&·OrderMagicNumber()·!=·Magic·&&·OrderMagicNumber()·!=·hMagic)¤
············continue;¤ ············continue;¤
········else·if·(Type·==·&&·OrderTicket()·!=·OTicket)¤ ········else·if·(Type·==·&&·OrderTicket()·!=·OTicket)¤
············continue;¤ ············continue;¤
········else·if·(Type·==·&&·(OrderMagicNumber()·!=·Magic·||·OrderType()·<=·OP_SELL))¤ ········else·if·(Type·==·&&·(OrderMagicNumber()·!=·Magic·||·OrderType()·<=·OP_SELL))¤
············continue;¤ ············continue;¤
¤ ¤
········ArrayResize(CloseTrades,·CloseCount·1);¤ ········ArrayResize(CloseTrades,·CloseCount·1);¤
········CloseTrades[CloseCount,·0]·(int)·OrderOpenTime();¤ ········CloseTrades[CloseCount,·0]·(int)·OrderOpenTime();¤
········CloseTrades[CloseCount,·1]·OrderTicket();¤ ········CloseTrades[CloseCount,·1]·OrderTicket();¤
········CloseCount++;¤ ········CloseCount++;¤
···· ····
¤ ¤
····if·(CloseCount·0)· ····if·(CloseCount·0)·
········if·(!UseFIFO)¤ ········if·(!UseFIFO)¤
············ArraySort(CloseTrades);¤ ············ArraySort(CloseTrades);¤
········else·if·(CloseCount·!=·ArraySort(CloseTrades))¤ ········else·if·(CloseCount·!=·ArraySort(CloseTrades))¤
············Print("Error·sorting·CloseTrades·Array");¤ ············Print("Error·sorting·CloseTrades·Array");¤
¤ ¤
········for·(int·Order·0;·Order·CloseCount;·Order++)· ········for·(int·Order·0;·Order·CloseCount;·Order++)·
//Заменить¤ //Заменить¤
············if·(!OrderSelect(CloseTrades[Order,·1],·SELECT_BY_TICKET))¤ ············if·(!OrderSelect(CloseTrades[Order,·1],·SELECT_BY_TICKET))¤
················continue;¤ ················continue;¤
¤ ¤
············//while·(IsTradeContextBusy())¤ ············//while·(IsTradeContextBusy())¤
············//····Sleep(100);¤ ············//····Sleep(100);¤
¤ ¤
············if·(IsStopped())¤ ············if·(IsStopped())¤
················return·(-1);¤ ················return·(-1);¤
············else·if·(OrderType()·OP_SELL)¤ ············else·if·(OrderType()·OP_SELL)¤
················Success·OrderDelete(OrderTicket(),·Color);¤ ················Success·OrderDelete(OrderTicket(),·Color);¤
············else· ············else·
················if·(OrderType()·==·OP_BUY)¤ ················if·(OrderType()·==·OP_BUY)¤
····················OPrice·ND(SymbolInfoDouble(OrderSymbol(),·SYMBOL_BID),·(int)·SymbolInfoInteger(OrderSymbol(),·SYMBOL_DIGITS));¤ ····················OPrice·ND(SymbolInfoDouble(OrderSymbol(),·SYMBOL_BID),·(int)·SymbolInfoInteger(OrderSymbol(),·SYMBOL_DIGITS));¤
················else¤ ················else¤
····················OPrice·ND(SymbolInfoDouble(OrderSymbol(),·SYMBOL_ASK),·(int)·SymbolInfoInteger(OrderSymbol(),·SYMBOL_DIGITS));¤ ····················OPrice·ND(SymbolInfoDouble(OrderSymbol(),·SYMBOL_ASK),·(int)·SymbolInfoInteger(OrderSymbol(),·SYMBOL_DIGITS));¤
¤ ¤
················Success·OrderClose(OrderTicket(),·OrderLots(),·OPrice,·slip,·Color);¤ ················Success·OrderClose(OrderTicket(),·OrderLots(),·OPrice,·slip,·Color);¤
············ ············
¤ ¤
············if·(Success)¤ ············if·(Success)¤
················Closed++;¤ ················Closed++;¤
············else· ············else·
················Error·GetLastError();¤ ················Error·GetLastError();¤
················//Print("Error·",·Error,·closing·order·",·OrderTicket());¤ ················//Print("Error·",·Error,·closing·order·",·OrderTicket());¤
//Заменить¤ //Заменить¤
················//switch·(Error)· ················//switch·(Error)·
················//case·ERR_NO_ERROR:¤ ················//case·ERR_NO_ERROR:¤
················//case·ERR_NO_RESULT:¤ ················//case·ERR_NO_RESULT:¤
················//····Success·true;¤ ················//····Success·true;¤
················//····break;¤ ················//····break;¤
················//case·ERR_OFF_QUOTES:¤ ················//case·ERR_OFF_QUOTES:¤
················//case·ERR_INVALID_PRICE:¤ ················//case·ERR_INVALID_PRICE:¤
················//····Sleep(5000);¤ ················//····Sleep(5000);¤
················//case·ERR_PRICE_CHANGED:¤ ················//case·ERR_PRICE_CHANGED:¤
················//case·ERR_REQUOTE:¤ ················//case·ERR_REQUOTE:¤
················//····RefreshRates();¤ ················//····RefreshRates();¤
················//case·ERR_SERVER_BUSY:¤ ················//case·ERR_SERVER_BUSY:¤
················//case·ERR_NO_CONNECTION:¤ ················//case·ERR_NO_CONNECTION:¤
················//case·ERR_BROKER_BUSY:¤ ················//case·ERR_BROKER_BUSY:¤
················//case·ERR_TRADE_CONTEXT_BUSY:¤ ················//case·ERR_TRADE_CONTEXT_BUSY:¤
················//····Print("Attempt·",·(Tries·1),·of·5:·Order·",·OrderTicket(),·failed·to·close.·Error:",·ErrorDescription(Error));¤ ················//····Print("Attempt·",·(Tries·1),·of·5:·Order·",·OrderTicket(),·failed·to·close.·Error:",·ErrorDescription(Error));¤
················//····Tries++;¤ ················//····Tries++;¤
················//····break;¤ ················//····break;¤
················//case·ERR_TRADE_TIMEOUT:¤ ················//case·ERR_TRADE_TIMEOUT:¤
················//default:¤ ················//default:¤
················//····Print("Attempt·",·(Tries·1),·of·5:·Order·",·OrderTicket(),·failed·to·close.·Fatal·Error:",·ErrorDescription(Error));¤ ················//····Print("Attempt·",·(Tries·1),·of·5:·Order·",·OrderTicket(),·failed·to·close.·Fatal·Error:",·ErrorDescription(Error));¤
················//····Tries·5;¤ ················//····Tries·5;¤
················//····ca·0;¤ ················//····ca·0;¤
················//····break;¤ ················//····break;¤
················//}¤ ················//}¤
············ ············
········ ········
¤ ¤
········if·(Closed·==·CloseCount·||·Closed·==·0)¤ ········if·(Closed·==·CloseCount·||·Closed·==·0)¤
············ca·0;¤ ············ca·0;¤
····else¤ ····else¤
········ca·0;¤ ········ca·0;¤
¤ ¤
····if·(Closed·0)· ····if·(Closed·0)·
········if·(Closed·!=·1)¤ ········if·(Closed·!=·1)¤
············"s";¤ ············"s";¤
¤ ¤
········Print("Closed·",·Closed,·position",·s,·because·",·Reason);¤ ········Print("Closed·",·Closed,·position",·s,·because·",·Reason);¤
¤ ¤
········if·(PlaySounds)¤ ········if·(PlaySounds)¤
············PlaySound(AlertSound);¤ ············PlaySound(AlertSound);¤
···· ····
¤ ¤
····return·(Closed);¤ ····return·(Closed);¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Find·Hedge·Profit··············································· //|·Find·Hedge·Profit···············································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
double·FindClosedPL(int·Type)· double·FindClosedPL(int·Type)·
····double·ClosedProfit·0;¤ ····double·ClosedProfit·0;¤
¤ ¤
····if·(Type·==·&&·UseCloseOldest)¤ ····if·(Type·==·&&·UseCloseOldest)¤
········CbC·0;¤ ········CbC·0;¤
¤ ¤
····if·(OTbF·0)· ····if·(OTbF·0)·
//Заменить¤ //Заменить¤
········for·(int·Order·OrdersHistoryTotal()·1;·Order·>=·0;·Order--)· ········for·(int·Order·OrdersHistoryTotal()·1;·Order·>=·0;·Order--)·
············if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_HISTORY))¤ ············if·(!OrderSelect(Order,·SELECT_BY_POS,·MODE_HISTORY))¤
················continue;¤ ················continue;¤
············¤ ············¤
············//ulong·ticket·HistoryOrderGetTicket(Order);¤ ············//ulong·ticket·HistoryOrderGetTicket(Order);¤
············//if·(!HistoryOrderSelect(ticket))¤ ············//if·(!HistoryOrderSelect(ticket))¤
············//····continue;¤ ············//····continue;¤
¤ ¤
············//if·(HistoryOrderGetInteger(ticket,ORDER_TIME_SETUP)·OTbF)¤ ············//if·(HistoryOrderGetInteger(ticket,ORDER_TIME_SETUP)·OTbF)¤
············//····continue;¤ ············//····continue;¤
if·(OrderOpenTime()·OTbF)¤ if·(OrderOpenTime()·OTbF)¤
················continue;¤ ················continue;¤
················¤ ················¤
//············if·(Type·==·&&·HistoryOrderGetInteger(ticket,ORDER_MAGIC)·==·Magic·&&·HistoryOrderGetInteger(ticket,ORDER_TYPE)·<=·ORDER_TYPE_SELL)· //············if·(Type·==·&&·HistoryOrderGetInteger(ticket,ORDER_MAGIC)·==·Magic·&&·HistoryOrderGetInteger(ticket,ORDER_TYPE)·<=·ORDER_TYPE_SELL)·
//···············¤ //···············¤
//················ClosedProfit·+=·OrderProfit()·OrderSwap()·OrderCommission();¤ //················ClosedProfit·+=·OrderProfit()·OrderSwap()·OrderCommission();¤
//¤ //¤
//················if·(UseCloseOldest)¤ //················if·(UseCloseOldest)¤
//····················CbC++;¤ //····················CbC++;¤
//············ //············
············if·(Type·==·&&·OrderMagicNumber()·==·Magic·&&·OrderType()·<=·OP_SELL)· ············if·(Type·==·&&·OrderMagicNumber()·==·Magic·&&·OrderType()·<=·OP_SELL)·
················ClosedProfit·+=·OrderProfit()·OrderSwap()·OrderCommission();¤ ················ClosedProfit·+=·OrderProfit()·OrderSwap()·OrderCommission();¤
¤ ¤
················if·(UseCloseOldest)¤ ················if·(UseCloseOldest)¤
····················CbC++;¤ ····················CbC++;¤
············ ············
¤ ¤
············if·(Type·==·&&·OrderMagicNumber()·==·hMagic)¤ ············if·(Type·==·&&·OrderMagicNumber()·==·hMagic)¤
················ClosedProfit·+=·OrderProfit()·OrderSwap()·OrderCommission();¤ ················ClosedProfit·+=·OrderProfit()·OrderSwap()·OrderCommission();¤
········ ········
···· ····
¤ ¤
····return·(ClosedProfit);¤ ····return·(ClosedProfit);¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Check·Correlation··············································· //|·Check·Correlation···············································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
double·CheckCorr()· double·CheckCorr()·
····double·BaseDiff,·HedgeDiff,·BasePow·0,·HedgePow·0,·Mult·0;¤ ····double·BaseDiff,·HedgeDiff,·BasePow·0,·HedgePow·0,·Mult·0;¤
¤ ¤
····for·(int·Index·CorrPeriod·1;·Index·>=·0;·Index--)· ····for·(int·Index·CorrPeriod·1;·Index·>=·0;·Index--)·
········double·dailyMA1[1];¤ ········double·dailyMA1[1];¤
········double·dailyMA2[1];¤ ········double·dailyMA2[1];¤
········CopyBuffer(dailyMA1handle,·0,·Index,·1,·dailyMA1);¤ ········CopyBuffer(dailyMA1handle,·0,·Index,·1,·dailyMA1);¤
········CopyBuffer(dailyMA2handle,·0,·Index,·1,·dailyMA2);¤ ········CopyBuffer(dailyMA2handle,·0,·Index,·1,·dailyMA2);¤
········BaseDiff·iClose(Symbol(),·PERIOD_D1,·Index)·dailyMA1[0];¤ ········BaseDiff·iClose(Symbol(),·PERIOD_D1,·Index)·dailyMA1[0];¤
········HedgeDiff·iClose(HedgeSymbol_,·PERIOD_D1,·Index)·dailyMA2[0];¤ ········HedgeDiff·iClose(HedgeSymbol_,·PERIOD_D1,·Index)·dailyMA2[0];¤
········Mult·+=·BaseDiff·HedgeDiff;¤ ········Mult·+=·BaseDiff·HedgeDiff;¤
········BasePow·+=·MathPow(BaseDiff,·2);¤ ········BasePow·+=·MathPow(BaseDiff,·2);¤
········HedgePow·+=·MathPow(HedgeDiff,·2);¤ ········HedgePow·+=·MathPow(HedgeDiff,·2);¤
···· ····
¤ ¤
····if·(BasePow·HedgePow·0)¤ ····if·(BasePow·HedgePow·0)¤
········return·(Mult·MathSqrt(BasePow·HedgePow));¤ ········return·(Mult·MathSqrt(BasePow·HedgePow));¤
¤ ¤
····return·(0);¤ ····return·(0);¤
¤ ¤
¤ ¤
//+------------------------------------------------------------------ //+------------------------------------------------------------------
//|··Save·Equity·Balance·Statistics································ //|··Save·Equity·Balance·Statistics································
//+------------------------------------------------------------------ //+------------------------------------------------------------------
void·Stats(bool·NewFile,·bool·IsTick,·double·Balance,·double·DrawDown)· void·Stats(bool·NewFile,·bool·IsTick,·double·Balance,·double·DrawDown)·
····double·Equity·Balance·DrawDown;¤ ····double·Equity·Balance·DrawDown;¤
····datetime·TimeNow·TimeCurrent();¤ ····datetime·TimeNow·TimeCurrent();¤
¤ ¤
····if·(IsTick)· ····if·(IsTick)·
········if·(Equity·StatLowEquity)¤ ········if·(Equity·StatLowEquity)¤
············StatLowEquity·Equity;¤ ············StatLowEquity·Equity;¤
¤ ¤
········if·(Equity·StatHighEquity)¤ ········if·(Equity·StatHighEquity)¤
············StatHighEquity·Equity;¤ ············StatHighEquity·Equity;¤
····else· ····else·
········while·(TimeNow·>=·NextStats)¤ ········while·(TimeNow·>=·NextStats)¤
············NextStats·+=·StatsPeriod;¤ ············NextStats·+=·StatsPeriod;¤
¤ ¤
········int·StatHandle;¤ ········int·StatHandle;¤
¤ ¤
········if·(NewFile)· ········if·(NewFile)·
············StatHandle·FileOpen(StatFile,·FILE_WRITE·FILE_CSV,·',');¤ ············StatHandle·FileOpen(StatFile,·FILE_WRITE·FILE_CSV,·',');¤
············Print("Stats·StatFile·(string)·StatHandle);¤ ············Print("Stats·StatFile·(string)·StatHandle);¤
············FileWrite(StatHandle,·"Date",·"Time",·"Balance",·"Equity·Low",·"Equity·High",·TradeComment);¤ ············FileWrite(StatHandle,·"Date",·"Time",·"Balance",·"Equity·Low",·"Equity·High",·TradeComment);¤
········else· ········else·
············StatHandle·FileOpen(StatFile,·FILE_READ·FILE_WRITE·FILE_CSV,·',');¤ ············StatHandle·FileOpen(StatFile,·FILE_READ·FILE_WRITE·FILE_CSV,·',');¤
············FileSeek(StatHandle,·0,·SEEK_END);¤ ············FileSeek(StatHandle,·0,·SEEK_END);¤
········ ········
¤ ¤
········if·(StatLowEquity·==·0)· ········if·(StatLowEquity·==·0)·
············StatLowEquity·Equity;¤ ············StatLowEquity·Equity;¤
············StatHighEquity·Equity;¤ ············StatHighEquity·Equity;¤
········ ········
¤ ¤
········FileWrite(StatHandle,·TimeToString(TimeNow,·TIME_DATE),·TimeToString(TimeNow,·TIME_SECONDS),·DTS(Balance,·0),·DTS(StatLowEquity,·0),·DTS(StatHighEquity,·0));¤ ········FileWrite(StatHandle,·TimeToString(TimeNow,·TIME_DATE),·TimeToString(TimeNow,·TIME_SECONDS),·DTS(Balance,·0),·DTS(StatLowEquity,·0),·DTS(StatHighEquity,·0));¤
········FileClose(StatHandle);¤ ········FileClose(StatHandle);¤
¤ ¤
········StatLowEquity·Equity;¤ ········StatLowEquity·Equity;¤
········StatHighEquity·Equity;¤ ········StatHighEquity·Equity;¤
···· ····
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Magic·Number·Generator·········································· //|·Magic·Number·Generator··········································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
int·GenerateMagicNumber()· int·GenerateMagicNumber()·
····if·(EANumber_·99)¤ ····if·(EANumber_·99)¤
········return·(EANumber_);¤ ········return·(EANumber_);¤
¤ ¤
····return·(JenkinsHash((string)·EANumber_·"_"·Symbol()·"__"·(string)·Period()));¤ ····return·(JenkinsHash((string)·EANumber_·"_"·Symbol()·"__"·(string)·Period()));¤
¤ ¤
¤ ¤
int·JenkinsHash(string·Input)· int·JenkinsHash(string·Input)·
····int·MagicNo·0;¤ ····int·MagicNo·0;¤
¤ ¤
····for·(int·Index·0;·Index·StringLen(Input);·Index++)· ····for·(int·Index·0;·Index·StringLen(Input);·Index++)·
········MagicNo·+=·StringGetCharacter(Input,·Index);¤ ········MagicNo·+=·StringGetCharacter(Input,·Index);¤
········MagicNo·+=·(MagicNo·<<·10);¤ ········MagicNo·+=·(MagicNo·<<·10);¤
········MagicNo·^=·(MagicNo·>>·6);¤ ········MagicNo·^=·(MagicNo·>>·6);¤
···· ····
¤ ¤
····MagicNo·+=·(MagicNo·<<·3);¤ ····MagicNo·+=·(MagicNo·<<·3);¤
····MagicNo·^=·(MagicNo·>>·11);¤ ····MagicNo·^=·(MagicNo·>>·11);¤
····MagicNo·+=·(MagicNo·<<·15);¤ ····MagicNo·+=·(MagicNo·<<·15);¤
¤ ¤
····return·(MathAbs(MagicNo));¤ ····return·(MathAbs(MagicNo));¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Normalize·Double················································ //|·Normalize·Double················································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
double·ND(double·Value,·int·Precision)· double·ND(double·Value,·int·Precision)·
····return·(NormalizeDouble(Value,·Precision));¤ ····return·(NormalizeDouble(Value,·Precision));¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Double·To·String················································ //|·Double·To·String················································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
string·DTS(double·Value,·int·Precision)· string·DTS(double·Value,·int·Precision)·
····return·(DoubleToString(Value,·Precision));¤ ····return·(DoubleToString(Value,·Precision));¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Integer·To·String················································ //|·Integer·To·String················································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
string·ITS(int·Value)· string·ITS(int·Value)·
····return·(IntegerToString(Value));¤ ····return·(IntegerToString(Value));¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Create·Label·Function·(OBJ_LABEL·ONLY)·························· //|·Create·Label·Function·(OBJ_LABEL·ONLY)··························
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
void·CreateLabel(string·Name,·string·Text,·int·FontSize,·int·Corner,·int·XOffset,·double·YLine,int·anchor,·color·Colour·CLR_NONE,·string·Font·"")· void·CreateLabel(string·Name,·string·Text,·int·FontSize,·int·Corner,·int·XOffset,·double·YLine,int·anchor,·color·Colour·CLR_NONE,·string·Font·"")·
····double·XDistance·0,·YDistance·0;¤ ····double·XDistance·0,·YDistance·0;¤
···¤ ···¤
····if·(Font·==·"")¤ ····if·(Font·==·"")¤
········Font·displayFont;¤ ········Font·displayFont;¤
¤ ¤
····FontSize·+=·displayFontSize;¤ ····FontSize·+=·displayFontSize;¤
····YDistance·displayYcord·displaySpacing·YLine;¤ ····YDistance·displayYcord·displaySpacing·YLine;¤
¤ ¤
····if·(Corner·==·0)¤ ····if·(Corner·==·0)¤
········XDistance·displayXcord·(XOffset·displayFontSize·displayRatio);¤ ········XDistance·displayXcord·(XOffset·displayFontSize·displayRatio);¤
····else·if·(Corner·==·3)¤ ····else·if·(Corner·==·3)¤
········XDistance·displayCCIxCord·XOffset·displayRatio;¤ ········XDistance·displayCCIxCord·XOffset·displayRatio;¤
····else·if·(Corner·==·2)¤ ····else·if·(Corner·==·2)¤
········XDistance·displayXcord·(XOffset·displayFontSize·displayRatio);¤ ········XDistance·displayXcord·(XOffset·displayFontSize·displayRatio);¤
····else·if·(Corner·==·1)· ····else·if·(Corner·==·1)·
········XDistance·XOffset·displayRatio;¤ ········XDistance·XOffset·displayRatio;¤
········YDistance·YLine;¤ ········YDistance·YLine;¤
····else·if·(Corner·==·5)· ····else·if·(Corner·==·5)·
········XDistance·XOffset·displayRatio;¤ ········XDistance·XOffset·displayRatio;¤
········YDistance·14·YLine;¤ ········YDistance·14·YLine;¤
········Corner·1;¤ ········Corner·1;¤
···· ····
···if(Name=="B3LCopy")¤ ···if(Name=="B3LCopy")¤
··· ···
······XDistance·10;¤ ······XDistance·10;¤
······YDistance·10;¤ ······YDistance·10;¤
··· ···
···if(Name=="B3LLogo")¤ ···if(Name=="B3LLogo")¤
··· ···
······XDistance·10;¤ ······XDistance·10;¤
······YDistance·30;······¤ ······YDistance·30;······¤
··· ···
···if(Name=="B3VMNum")¤ ···if(Name=="B3VMNum")¤
··· ···
······XDistance·3;¤ ······XDistance·3;¤
······YDistance·31;¤ ······YDistance·31;¤
··· ···
···if(Name=="B3LComm")¤ ···if(Name=="B3LComm")¤
··· ···
······XDistance·3;¤ ······XDistance·3;¤
······YDistance·20;······¤ ······YDistance·20;······¤
·····¤ ·····¤
····if·(Colour·==·CLR_NONE)¤ ····if·(Colour·==·CLR_NONE)¤
········Colour·displayColor;¤ ········Colour·displayColor;¤
¤ ¤
····ObjectCreate(ChartID(),pref+Name,·OBJ_LABEL,·0,·0,·0);¤ ····ObjectCreate(ChartID(),pref+Name,·OBJ_LABEL,·0,·0,·0);¤
····ObjectSetText(Name,·Text,·FontSize,·Font,·Colour);¤ ····ObjectSetText(Name,·Text,·FontSize,·Font,·Colour);¤
····Name·pref+Name;¤ ····Name·pref+Name;¤
····ObjectSetInteger(ChartID(),Name,·OBJPROP_CORNER,·Corner);¤ ····ObjectSetInteger(ChartID(),Name,·OBJPROP_CORNER,·Corner);¤
····ObjectSetInteger(ChartID(),Name,·OBJPROP_XDISTANCE,·(int)XDistance);¤ ····ObjectSetInteger(ChartID(),Name,·OBJPROP_XDISTANCE,·XDistance);¤
····ObjectSetInteger(ChartID(),Name,·OBJPROP_YDISTANCE,·(int)YDistance);¤ ····ObjectSetInteger(ChartID(),Name,·OBJPROP_YDISTANCE,·YDistance);¤
····ObjectSetInteger(ChartID(),Name,·OBJPROP_ANCHOR,·anchor);¤ ····ObjectSetInteger(ChartID(),Name,·OBJPROP_ANCHOR,·anchor);¤
····ObjectSetInteger(ChartID(),Name,OBJPROP_BACK,false);¤ ····ObjectSetInteger(ChartID(),Name,OBJPROP_BACK,false);¤
····ObjectSetInteger(ChartID(),Name,OBJPROP_ZORDER,1);¤ ····ObjectSetInteger(ChartID(),Name,OBJPROP_ZORDER,1);¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Create·Line·Function·(OBJ_HLINE·ONLY)··························· //|·Create·Line·Function·(OBJ_HLINE·ONLY)···························
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
void·CreateLine(string·Name,·color·Colour,·int·Width,·int·Style)· void·CreateLine(string·Name,·color·Colour,·int·Width,·int·Style)·
····Name·pref+Name;¤ ····Name·pref+Name;¤
····ObjectCreate(ChartID(),Name,·OBJ_HLINE,·0,·0,·0);¤ ····ObjectCreate(ChartID(),Name,·OBJ_HLINE,·0,·0,·0);¤
····ObjectSetInteger(ChartID(),Name,·OBJPROP_COLOR,·Colour);¤ ····ObjectSetInteger(ChartID(),Name,·OBJPROP_COLOR,·Colour);¤
····ObjectSetInteger(ChartID(),Name,·OBJPROP_WIDTH,·Width);¤ ····ObjectSetInteger(ChartID(),Name,·OBJPROP_WIDTH,·Width);¤
····ObjectSetInteger(ChartID(),Name,·OBJPROP_STYLE,·Style);¤ ····ObjectSetInteger(ChartID(),Name,·OBJPROP_STYLE,·Style);¤
¤ ¤
¤ ¤
//+------------------------------------------------------------------ //+------------------------------------------------------------------
//|·Draw·Label·Function·(OBJ_LABEL·ONLY)····························· //|·Draw·Label·Function·(OBJ_LABEL·ONLY)·····························
//+------------------------------------------------------------------ //+------------------------------------------------------------------
void·DrawLabel(string·Name,·double·Value,·int·XOffset,·int·Decimal·2,·color·Colour·CLR_NONE)· void·DrawLabel(string·Name,·double·Value,·int·XOffset,·int·Decimal·2,·color·Colour·CLR_NONE)·
  ····Name·pref+Name;¤
····int·dDigits·Digit[ArrayBsearch(Digit,·(int)·Value),·1];¤ ····int·dDigits·Digit[ArrayBsearch(Digit,·(int)·Value),·1];¤
····ObjectSetInteger(ChartID(),pref+Name,·OBJPROP_XDISTANCE,·displayXcord·(XOffset·dDigits)·(int)((displayFontSize·displayRatio)·9)) ····ObjectSetInteger(ChartID(),Name,·OBJPROP_XDISTANCE,·displayXcord·(XOffset·dDigits)·displayFontSize·9·displayRatio)
····ObjSetTxt(Name,·DTS(Value,·Decimal),·0,·Colour);¤ ····ObjSetTxt(Name,·DTS(Value,·Decimal),·0,·Colour);¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Object·Set·Function············································· //|·Object·Set·Function·············································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
void·ObjSet(string·Name,·int·XCoord)· void·ObjSet(string·Name,·int·XCoord)·
···Name·pref+Name;¤ ···Name·pref+Name;¤
····ObjectSetInteger(ChartID(),Name,·OBJPROP_XDISTANCE,·displayXcord·(int)((XCoord·displayFontSize·displayRatio)·9)) ····ObjectSetInteger(ChartID(),Name,·OBJPROP_XDISTANCE,·displayXcord·XCoord·displayFontSize·9·displayRatio)
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Object·Set·Text·Function········································ //|·Object·Set·Text·Function········································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
void·ObjSetTxt(string·Name,·string·Text,·int·FontSize·0,·color·Colour·CLR_NONE,·string·Font·"")· void·ObjSetTxt(string·Name,·string·Text,·int·FontSize·0,·color·Colour·CLR_NONE,·string·Font·"")·
····FontSize·+=·displayFontSize;¤ ····FontSize·+=·displayFontSize;¤
¤ ¤
····if·(Font·==·"")¤ ····if·(Font·==·"")¤
········Font·displayFont;¤ ········Font·displayFont;¤
¤ ¤
····if·(Colour·==·CLR_NONE)¤ ····if·(Colour·==·CLR_NONE)¤
········Colour·displayColor;¤ ········Colour·displayColor;¤
¤ ¤
····ObjectSetText(Name,·Text,·FontSize,·Font,·Colour);¤ ····ObjectSetText(Name,·Text,·FontSize,·Font,·Colour);¤
¤ ¤
¤ ¤
//+------------------------------------------------------------------ //+------------------------------------------------------------------
//|·Delete·Overlay·Label·Function···································· //|·Delete·Overlay·Label·Function····································
//+------------------------------------------------------------------ //+------------------------------------------------------------------
void·LabelDelete()· void·LabelDelete()·
····for·(int·Object·ObjectsTotal(ChartID());·Object·>=·0;·Object--)· ····for·(int·Object·ObjectsTotal(ChartID());·Object·>=·0;·Object--)·
········if·(StringSubstr(ObjectName(ChartID(),Object),·0,·2)·==·"B3")¤ ········if·(StringSubstr(ObjectName(ChartID(),Object),·0,·2)·==·"B3")¤
············ObjectDelete(ChartID(),ObjectName(ChartID(),Object));¤ ············ObjectDelete(ChartID(),ObjectName(ChartID(),Object));¤
···· ····
¤ ¤
¤ ¤
//+------------------------------------------------------------------ //+------------------------------------------------------------------
//|·Delete·Object·Function··········································· //|·Delete·Object·Function···········································
//+------------------------------------------------------------------ //+------------------------------------------------------------------
void·ObjDel(string·Name)· void·ObjDel(string·Name)·
····if·(ObjectFind(ChartID(),pref+Name)·!=·-1)¤ ····if·(ObjectFind(ChartID(),pref+Name)·!=·-1)¤
········ObjectDelete(ChartID(),pref+Name);¤ ········ObjectDelete(ChartID(),pref+Name);¤
¤ ¤
¤ ¤
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
//|·Create·Object·List·Function····································· //|·Create·Object·List·Function·····································
//+-----------------------------------------------------------------+¤ //+-----------------------------------------------------------------+¤
void·LabelCreate()· void·LabelCreate()·
····if·(displayOverlay·&&·((Testing·&&·Visual)·||·!Testing))· ····if·(displayOverlay·&&·((Testing·&&·Visual)·||·!Testing))·
········int·dDigits;¤ ········int·dDigits;¤
········string·ObjText;¤ ········string·ObjText;¤
········color·ObjClr;¤ ········color·ObjClr;¤
¤ ¤
········//·CreateLabel("B3LMNum",·"Magic:·",·displayFontSize,·5,·59,·1,·displayColorFGnd,·"Tahoma");¤ ········//·CreateLabel("B3LMNum",·"Magic:·",·displayFontSize,·5,·59,·1,·displayColorFGnd,·"Tahoma");¤
········CreateLabel("B3VMNum",·DTS(Magic,·0),·displayFontSize,·3,·5,·0.3,·6,displayColorFGnd,·"Tahoma");¤ ········CreateLabel("B3VMNum",·DTS(Magic,·0),·displayFontSize,·3,·5,·0.3,·6,displayColorFGnd,·"Tahoma");¤
········//·CreateLabel("B3LComm",·"Trade·Comment:·TradeComment,·displayFontSize,·5,·5,·1.8,·displayColorFGnd,·"Tahoma");¤ ········//·CreateLabel("B3LComm",·"Trade·Comment:·TradeComment,·displayFontSize,·5,·5,·1.8,·displayColorFGnd,·"Tahoma");¤
········CreateLabel("B3LComm",·TradeComment,·displayFontSize,·3,·5,·1.1,6,·displayColorFGnd,·"Tahoma");¤ ········CreateLabel("B3LComm",·TradeComment,·displayFontSize,·3,·5,·1.1,6,·displayColorFGnd,·"Tahoma");¤
¤ ¤
········if·(displayLogo)· ········if·(displayLogo)·
············//·changed·from·red·airplane·to·green·thumbs·up,·signify·all·is·good¤ ············//·changed·from·red·airplane·to·green·thumbs·up,·signify·all·is·good¤
············//·CreateLabel("B3LLogo",·"Q",·27,·3,·10,·10,·Crimson,·"Wingdings");······//·Airplane¤ ············//·CreateLabel("B3LLogo",·"Q",·27,·3,·10,·10,·Crimson,·"Wingdings");······//·Airplane¤
············//·CreateLabel("B3LLogo",·"F",·27,·3,·10,·10,·Green,·"Wingdings");····//·right·pointing·finger¤ ············//·CreateLabel("B3LLogo",·"F",·27,·3,·10,·10,·Green,·"Wingdings");····//·right·pointing·finger¤
············CreateLabel("B3LLogo",·"C",·27,·2,·0,·2,5,·Green,·"Wingdings");·····//·thumbs·up¤ ············CreateLabel("B3LLogo",·"C",·27,·2,·0,·2,5,·Green,·"Wingdings");·····//·thumbs·up¤
············CreateLabel("B3LCopy",·"This·software·is·free·and·public·domain",·10·displayFontSize,·2,·0,·0,5,·Silver,·"Arial");¤ ············CreateLabel("B3LCopy",·"This·software·is·free·and·public·domain",·10·displayFontSize,·2,·0,·0,5,·Silver,·"Arial");¤
········ ········
¤ ¤
········CreateLabel("B3LTime",·"Server:",·0,·0,·0,·0,0);¤ ········CreateLabel("B3LTime",·"Server:",·0,·0,·0,·0,0);¤
········CreateLabel("B3VTime",·"",·0,·0,·60,·0,0);¤ ········CreateLabel("B3VTime",·"",·0,·0,·60,·0,0);¤
········CreateLabel("B3Line1",·"=========================",·0,·0,·0,·1,0);¤ ········CreateLabel("B3Line1",·"=========================",·0,·0,·0,·1,0);¤
········CreateLabel("B3LEPPC",·"Equity·Protection·Set:",·0,·0,·0,·2,0);¤ ········CreateLabel("B3LEPPC",·"Equity·Protection·Set:",·0,·0,·0,·2,0);¤
········dDigits·Digit[ArrayBsearch(Digit,·(int)·MaxDDPercent),·1];¤ ········dDigits·Digit[ArrayBsearch(Digit,·(int)·MaxDDPercent),·1];¤
········CreateLabel("B3VEPPC",·DTS(MaxDDPercent,·2),·0,·0,·167·dDigits,·2,0);¤ ········CreateLabel("B3VEPPC",·DTS(MaxDDPercent,·2),·0,·0,·167·dDigits,·2,0);¤
········CreateLabel("B3PEPPC",·"%",·0,·0,·193,·2,0);¤ ········CreateLabel("B3PEPPC",·"%",·0,·0,·193,·2,0);¤
········CreateLabel("B3LSTPC",·"Stop·Trade·Set:",·0,·0,·0,·3,0);¤ ········CreateLabel("B3LSTPC",·"Stop·Trade·Set:",·0,·0,·0,·3,0);¤
········dDigits·Digit[ArrayBsearch(Digit,·(int)·(StopTradePercent_·100)),·1];¤ ········dDigits·Digit[ArrayBsearch(Digit,·(int)·(StopTradePercent_·100)),·1];¤
········CreateLabel("B3VSTPC",·DTS(StopTradePercent_·100,·2),·0,·0,·167·dDigits,·3,0);¤ ········CreateLabel("B3VSTPC",·DTS(StopTradePercent_·100,·2),·0,·0,·167·dDigits,·3,0);¤
········CreateLabel("B3PSTPC",·"%",·0,·0,·193,·3,0);¤ ········CreateLabel("B3PSTPC",·"%",·0,·0,·193,·3,0);¤
········CreateLabel("B3LSTAm",·"Stop·Trade·Amount:",·0,·0,·0,·4,0);¤ ········CreateLabel("B3LSTAm",·"Stop·Trade·Amount:",·0,·0,·0,·4,0);¤
········CreateLabel("B3VSTAm",·"",·0,·0,·167,·4,0,·displayColorLoss);¤ ········CreateLabel("B3VSTAm",·"",·0,·0,·167,·4,0,·displayColorLoss);¤
········CreateLabel("B3LAPPC",·"Account·Portion:",·0,·0,·0,·5,0);¤ ········CreateLabel("B3LAPPC",·"Account·Portion:",·0,·0,·0,·5,0);¤
»   »   if·(PortionPC·100)· //·r.f.¤ »   »   if·(PortionPC·100)· //·r.f.¤
»   »   »   dDigits·Digit[ArrayBsearch(Digit,·(int)·(PortionPC)),·1];¤ »   »   »   dDigits·Digit[ArrayBsearch(Digit,·(int)·(PortionPC)),·1];¤
»   »   »   CreateLabel("B3VAPPC",·DTS(PortionPC,·2),·0,·0,·167·dDigits,·5,0);¤ »   »   »   CreateLabel("B3VAPPC",·DTS(PortionPC,·2),·0,·0,·167·dDigits,·5,0);¤
»   »   »   CreateLabel("B3PAPPC",·",·0,·0,·193,·5,0);¤ »   »   »   CreateLabel("B3PAPPC",·",·0,·0,·193,·5,0);¤
»   »   }·else· »   »   }·else·
»   »   »   dDigits·Digit[ArrayBsearch(Digit,·(int)·(PortionPC_·100)),·1];¤ »   »   »   dDigits·Digit[ArrayBsearch(Digit,·(int)·(PortionPC_·100)),·1];¤
»   »   »   CreateLabel("B3VAPPC",·DTS(PortionPC_·100,·2),·0,·0,·167·dDigits,·5,0);¤ »   »   »   CreateLabel("B3VAPPC",·DTS(PortionPC_·100,·2),·0,·0,·167·dDigits,·5,0);¤
»   »   »   CreateLabel("B3PAPPC",·"%",·0,·0,·193,·5,0);¤ »   »   »   CreateLabel("B3PAPPC",·"%",·0,·0,·193,·5,0);¤
»   »   }¤ »   »   }¤
········CreateLabel("B3LPBal",·"Portion·Balance:",·0,·0,·0,·6,0);¤ ········CreateLabel("B3LPBal",·"Portion·Balance:",·0,·0,·0,·6,0);¤
········CreateLabel("B3VPBal",·"",·0,·0,·167,·6,0);¤ ········CreateLabel("B3VPBal",·"",·0,·0,·167,·6,0);¤
»   »   if·(PortionPC·100)· //·r.f.¤ »   »   if·(PortionPC·100)· //·r.f.¤
»   »   »   CreateLabel("B3LAPCR",·"Portion·Risk:",·0,·0,·228,·6,0);¤ »   »   »   CreateLabel("B3LAPCR",·"Portion·Risk:",·0,·0,·228,·6,0);¤
»   »   }·else· »   »   }·else·
»   »   »   CreateLabel("B3LAPCR",·"Account·Risk:",·0,·0,·228,·6,0);¤ »   »   »   CreateLabel("B3LAPCR",·"Account·Risk:",·0,·0,·228,·6,0);¤
»   »   }¤ »   »   }¤
»   »   CreateLabel("B3VAPCR",·DTS(MaxDDPercent·PortionPC_,·2),·0,·0,·347,·6,0);¤ »   »   CreateLabel("B3VAPCR",·DTS(MaxDDPercent·PortionPC_,·2),·0,·0,·347,·6,0);¤
········CreateLabel("B3PAPCR",·"%",·0,·0,·380,·6,0);¤ ········CreateLabel("B3PAPCR",·"%",·0,·0,·380,·6,0);¤
¤ ¤
········if·(UseMM)· ········if·(UseMM)·
············ObjText·"Money·Management·is·ON";¤ ············ObjText·"Money·Management·is·ON";¤
············ObjClr·displayColorProfit;¤ ············ObjClr·displayColorProfit;¤
········else· ········else·
············ObjText·"Money·Management·is·OFF";¤ ············ObjText·"Money·Management·is·OFF";¤
············ObjClr·displayColorLoss;¤ ············ObjClr·displayColorLoss;¤
········ ········
¤ ¤
········CreateLabel("B3LMMOO",·ObjText,·0,·0,·0,·7,·ObjClr);¤ ········CreateLabel("B3LMMOO",·ObjText,·0,·0,·0,·7,·ObjClr);¤
¤ ¤
········if·(UsePowerOutSL)· ········if·(UsePowerOutSL)·
············ObjText·"Power-Off·StopLoss·is·ON";¤ ············ObjText·"Power-Off·StopLoss·is·ON";¤
············ObjClr·displayColorProfit;¤ ············ObjClr·displayColorProfit;¤
········else· ········else·
············ObjText·"Power-Off·StopLoss·is·OFF";¤ ············ObjText·"Power-Off·StopLoss·is·OFF";¤
············ObjClr·displayColorLoss;¤ ············ObjClr·displayColorLoss;¤
········ ········
¤ ¤
········CreateLabel("B3LPOSL",·ObjText,·0,·0,·0,·8,0,·ObjClr);¤ ········CreateLabel("B3LPOSL",·ObjText,·0,·0,·0,·8,0,·ObjClr);¤
········CreateLabel("B3LDrDn",·"Draw·Down·%:",·0,·0,·228,·8,0);¤ ········CreateLabel("B3LDrDn",·"Draw·Down·%:",·0,·0,·228,·8,0);¤
········CreateLabel("B3VDrDn",·"",·0,·0,·415,·8,0);¤ ········CreateLabel("B3VDrDn",·"",·0,·0,·315,·8,0);¤
¤ ¤
········if·(UseHedge_)· ········if·(UseHedge_)·
············if·(HedgeTypeDD)· ············if·(HedgeTypeDD)·
················CreateLabel("B3LhDDn",·"Hedge",·0,·0,·190,·8,0);¤ ················CreateLabel("B3LhDDn",·"Hedge",·0,·0,·190,·8,0);¤
················CreateLabel("B3ShDDn",·"/",·0,·0,·342,·8,0);¤ ················CreateLabel("B3ShDDn",·"/",·0,·0,·342,·8,0);¤
················CreateLabel("B3VhDDm",·"",·0,·0,·347,·8,0);¤ ················CreateLabel("B3VhDDm",·"",·0,·0,·347,·8,0);¤
············else· ············else·
················CreateLabel("B3LhLvl",·"Hedge·Level:",·0,·0,·228,·9,0);¤ ················CreateLabel("B3LhLvl",·"Hedge·Level:",·0,·0,·228,·9,0);¤
················CreateLabel("B3VhLvl",·"",·0,·0,·318,·9,0);¤ ················CreateLabel("B3VhLvl",·"",·0,·0,·318,·9,0);¤
················CreateLabel("B3ShLvl",·"/",·0,·0,·328,·9,0);¤ ················CreateLabel("B3ShLvl",·"/",·0,·0,·328,·9,0);¤
················CreateLabel("B3VhLvT",·"",·0,·0,·333,·9,0);¤ ················CreateLabel("B3VhLvT",·"",·0,·0,·333,·9,0);¤
············ ············
········ ········
¤ ¤
········CreateLabel("B3Line2",·"======================",·0,·0,·0,·9,0);¤ ········CreateLabel("B3Line2",·"======================",·0,·0,·0,·9,0);¤
········CreateLabel("B3LSLot",·"Starting·Lot·Size:",·0,·0,·0,·10,0);¤ ········CreateLabel("B3LSLot",·"Starting·Lot·Size:",·0,·0,·0,·10,0);¤
········CreateLabel("B3VSLot",·"",·0,·0,·130,·10,0);¤ ········CreateLabel("B3VSLot",·"",·0,·0,·130,·10,0);¤
¤ ¤
········if·(MaximizeProfit)· ········if·(MaximizeProfit)·
············ObjText·"Profit·Maximizer·is·ON";¤ ············ObjText·"Profit·Maximizer·is·ON";¤
············ObjClr·displayColorProfit;¤ ············ObjClr·displayColorProfit;¤
········else· ········else·
············ObjText·"Profit·Maximizer·is·OFF";¤ ············ObjText·"Profit·Maximizer·is·OFF";¤
············ObjClr·displayColorLoss;¤ ············ObjClr·displayColorLoss;¤
········ ········
¤ ¤
········CreateLabel("B3LPrMx",·ObjText,·0,·0,·0,·11,0,·ObjClr);¤ ········CreateLabel("B3LPrMx",·ObjText,·0,·0,·0,·11,0,·ObjClr);¤
········CreateLabel("B3LBask",·"Basket",·0,·0,·200,·11,0);¤ ········CreateLabel("B3LBask",·"Basket",·0,·0,·200,·11,0);¤
········CreateLabel("B3LPPot",·"Profit·Potential:",·0,·0,·30,·12,0);¤ ········CreateLabel("B3LPPot",·"Profit·Potential:",·0,·0,·30,·12,0);¤
········CreateLabel("B3VPPot",·"",·0,·0,·190,·12,0);¤ ········CreateLabel("B3VPPot",·"",·0,·0,·190,·12,0);¤
········CreateLabel("B3LPrSL",·"Profit·Trailing·Stop:",·0,·0,·30,·13,0);¤ ········CreateLabel("B3LPrSL",·"Profit·Trailing·Stop:",·0,·0,·30,·13,0);¤
········CreateLabel("B3VPrSL",·"",·0,·0,·190,·13,0);¤ ········CreateLabel("B3VPrSL",·"",·0,·0,·190,·13,0);¤
········CreateLabel("B3LPnPL",·"Portion·P/L·Pips:",·0,·0,·30,·14,0);¤ ········CreateLabel("B3LPnPL",·"Portion·P/L·Pips:",·0,·0,·30,·14,0);¤
········CreateLabel("B3VPnPL",·"",·0,·0,·190,·14,0);¤ ········CreateLabel("B3VPnPL",·"",·0,·0,·190,·14,0);¤
········CreateLabel("B3SPnPL",·"/",·0,·0,·220,·14,0);¤ ········CreateLabel("B3SPnPL",·"/",·0,·0,·220,·14,0);¤
········CreateLabel("B3VPPip",·"",·0,·0,·229,·14,0);¤ ········CreateLabel("B3VPPip",·"",·0,·0,·229,·14,0);¤
········CreateLabel("B3LPLMM",·"Profit/Loss·Max/Min:",·0,·0,·30,·15,0);¤ ········CreateLabel("B3LPLMM",·"Profit/Loss·Max/Min:",·0,·0,·30,·15,0);¤
········CreateLabel("B3VPLMx",·"",·0,·0,·190,·15,0);¤ ········CreateLabel("B3VPLMx",·"",·0,·0,·190,·15,0);¤
········CreateLabel("B3SPLMM",·"/",·0,·0,·220,·15,0);¤ ········CreateLabel("B3SPLMM",·"/",·0,·0,·220,·15,0);¤
········CreateLabel("B3VPLMn",·"",·0,·0,·225,·15,0);¤ ········CreateLabel("B3VPLMn",·"",·0,·0,·225,·15,0);¤
········CreateLabel("B3LOpen",·"Open·Trades·Lots:",·0,·0,·30,·16,0);¤ ········CreateLabel("B3LOpen",·"Open·Trades·Lots:",·0,·0,·30,·16,0);¤
········CreateLabel("B3LType",·"",·0,·0,·170,·16,0);¤ ········CreateLabel("B3LType",·"",·0,·0,·170,·16,0);¤
········CreateLabel("B3VOpen",·"",·0,·0,·207,·16,0);¤ ········CreateLabel("B3VOpen",·"",·0,·0,·207,·16,0);¤
········CreateLabel("B3SOpen",·"/",·0,·0,·220,·16,0);¤ ········CreateLabel("B3SOpen",·"/",·0,·0,·220,·16,0);¤
········CreateLabel("B3VLots",·"",·0,·0,·229,·16,0);¤ ········CreateLabel("B3VLots",·"",·0,·0,·229,·16,0);¤
········CreateLabel("B3LMvTP",·"Move·TP·by:",·0,·0,·0,·17,0);¤ ········CreateLabel("B3LMvTP",·"Move·TP·by:",·0,·0,·0,·17,0);¤
········CreateLabel("B3VMvTP",·DTS(MoveTP_·Pip,·0),·0,·0,·100,·17,0);¤ ········CreateLabel("B3VMvTP",·DTS(MoveTP_·Pip,·0),·0,·0,·100,·17,0);¤
········CreateLabel("B3LMves",·"#·Moves:",·0,·0,·150,·17,0);¤ ········CreateLabel("B3LMves",·"#·Moves:",·0,·0,·150,·17,0);¤
········CreateLabel("B3VMove",·"",·0,·0,·229,·17,0);¤ ········CreateLabel("B3VMove",·"",·0,·0,·229,·17,0);¤
········CreateLabel("B3SMves",·"/",·0,·0,·242,·17,0);¤ ········CreateLabel("B3SMves",·"/",·0,·0,·242,·17,0);¤
········CreateLabel("B3VMves",·DTS(TotalMoves,·0),·0,·0,·249,·17,0);¤ ········CreateLabel("B3VMves",·DTS(TotalMoves,·0),·0,·0,·249,·17,0);¤
········CreateLabel("B3LMxDD",·"Max·DD:",·0,·0,·0,·18,0);¤ ········CreateLabel("B3LMxDD",·"Max·DD:",·0,·0,·0,·18,0);¤
········CreateLabel("B3VMxDD",·"",·0,·0,·107,·18,0);¤ ········CreateLabel("B3VMxDD",·"",·0,·0,·107,·18,0);¤
········CreateLabel("B3LDDPC",·"Max·DD·%:",·0,·0,·150,·18,0);¤ ········CreateLabel("B3LDDPC",·"Max·DD·%:",·0,·0,·150,·18,0);¤
········CreateLabel("B3VDDPC",·"",·0,·0,·279,·18,0);¤ ········CreateLabel("B3VDDPC",·"",·0,·0,·229,·18,0);¤
········CreateLabel("B3PDDPC",·"%",·0,·0,·257,·18,0);¤ ········CreateLabel("B3PDDPC",·"%",·0,·0,·257,·18,0);¤
¤ ¤
········if·(ForceMarketCond_·3)¤ ········if·(ForceMarketCond_·3)¤
············CreateLabel("B3LFMCn",·"Market·trend·is·forced",·0,·0,·0,·19,0);¤ ············CreateLabel("B3LFMCn",·"Market·trend·is·forced",·0,·0,·0,·19,0);¤
¤ ¤
········CreateLabel("B3LTrnd",·"",·0,·0,·0,·20,0);¤ ········CreateLabel("B3LTrnd",·"",·0,·0,·0,·20,0);¤
¤ ¤
········if·(CCIEntry_·&&·displayCCI)· ········if·(CCIEntry_·&&·displayCCI)·
············CreateLabel("B3LCCIi",·"CCI",·2,·3,·10,·3,ANCHOR_RIGHT_UPPER);¤ ············CreateLabel("B3LCCIi",·"CCI",·2,·3,·10,·3,ANCHOR_RIGHT_UPPER);¤
············CreateLabel("B3LCm05",·"m5",·2,·3,·28,·5,ANCHOR_RIGHT_UPPER);¤ ············CreateLabel("B3LCm05",·"m5",·2,·3,·28,·5,ANCHOR_RIGHT_UPPER);¤
············CreateLabel("B3VCm05",·CharToString(79),·6,·3,·10,·5,ANCHOR_RIGHT_UPPER,·Orange,·"Wingdings");¤ ············CreateLabel("B3VCm05",·CharToString(79),·6,·3,·10,·5,ANCHOR_RIGHT_UPPER,·Orange,·"Wingdings");¤
············CreateLabel("B3LCm15",·"m15",·2,·3,·28,·7,ANCHOR_RIGHT_UPPER);¤ ············CreateLabel("B3LCm15",·"m15",·2,·3,·28,·7,ANCHOR_RIGHT_UPPER);¤
············CreateLabel("B3VCm15",·CharToString(79),·6,·3,·10,·7,ANCHOR_RIGHT_UPPER,·Orange,·"Wingdings");¤ ············CreateLabel("B3VCm15",·CharToString(79),·6,·3,·10,·7,ANCHOR_RIGHT_UPPER,·Orange,·"Wingdings");¤
············CreateLabel("B3LCm30",·"m30",·2,·3,·28,·9,ANCHOR_RIGHT_UPPER);¤ ············CreateLabel("B3LCm30",·"m30",·2,·3,·28,·9,ANCHOR_RIGHT_UPPER);¤
············CreateLabel("B3VCm30",·CharToString(79),·6,·3,·10,·9,ANCHOR_RIGHT_UPPER,·Orange,·"Wingdings");¤ ············CreateLabel("B3VCm30",·CharToString(79),·6,·3,·10,·9,ANCHOR_RIGHT_UPPER,·Orange,·"Wingdings");¤
············CreateLabel("B3LCm60",·"h1",·2,·3,·28,·11,ANCHOR_RIGHT_UPPER);¤ ············CreateLabel("B3LCm60",·"h1",·2,·3,·28,·11,ANCHOR_RIGHT_UPPER);¤
············CreateLabel("B3VCm60",·CharToString(79),·6,·3,·10,·11,ANCHOR_RIGHT_UPPER,·Orange,·"Wingdings");¤ ············CreateLabel("B3VCm60",·CharToString(79),·6,·3,·10,·11,ANCHOR_RIGHT_UPPER,·Orange,·"Wingdings");¤
········ ········
¤ ¤
········if·(UseHolidayShutdown)· ········if·(UseHolidayShutdown)·
············CreateLabel("B3LHols",·"Next·Holiday·Period",·0,·0,·240,·2,0);¤ ············CreateLabel("B3LHols",·"Next·Holiday·Period",·0,·0,·240,·2,0);¤
············CreateLabel("B3LHolD",·"From:·(yyyy.mm.dd)·To:",·0,·0,·232,·3,0);¤ ············CreateLabel("B3LHolD",·"From:·(yyyy.mm.dd)·To:",·0,·0,·232,·3,0);¤
············CreateLabel("B3VHolF",·"",·0,·0,·232,·4,0);¤ ············CreateLabel("B3VHolF",·"",·0,·0,·232,·4,0);¤
············CreateLabel("B3VHolT",·"",·0,·0,·300,·4,0);¤ ············CreateLabel("B3VHolT",·"",·0,·0,·300,·4,0);¤
········ ········
···· ····
¤ ¤
double·iMAOnArrayMQL4(double·&array[],¤ double·iMAOnArrayMQL4(double·&array[],¤
······················int·total,¤ ······················int·total,¤
······················int·period,¤ ······················int·period,¤
······················int·ma_shift,¤ ······················int·ma_shift,¤
······················int·ma_method,¤ ······················int·ma_method,¤
······················int·shift)¤ ······················int·shift)¤
·· ··
···double·buf[],arr[];¤ ···double·buf[],arr[];¤
···if(total==0)·total=ArraySize(array);¤ ···if(total==0)·total=ArraySize(array);¤
···if(total>0·&&·total<=period)·return(0);¤ ···if(total>0·&&·total<=period)·return(0);¤
···if(shift>total-period-ma_shift)·return(0);¤ ···if(shift>total-period-ma_shift)·return(0);¤
···switch(ma_method)¤ ···switch(ma_method)¤
····· ·····
······case·MODE_SMA· ······case·MODE_SMA·
········ ········
·········total=ArrayCopy(arr,array,0,shift+ma_shift,period);¤ ·········total=ArrayCopy(arr,array,0,shift+ma_shift,period);¤
·········if(ArrayResize(buf,total)<0)·return(0);¤ ·········if(ArrayResize(buf,total)<0)·return(0);¤
·········double·sum=0;¤ ·········double·sum=0;¤
·········int····i,pos=total-1;¤ ·········int····i,pos=total-1;¤
·········for(i=1;i<period;i++,pos--)¤ ·········for(i=1;i<period;i++,pos--)¤
············sum+=arr[pos];¤ ············sum+=arr[pos];¤
·········while(pos>=0)¤ ·········while(pos>=0)¤
··········· ···········
············sum+=arr[pos];¤ ············sum+=arr[pos];¤
············buf[pos]=sum/period;¤ ············buf[pos]=sum/period;¤
············sum-=arr[pos+period-1];¤ ············sum-=arr[pos+period-1];¤
············pos--;¤ ············pos--;¤
··········· ···········
·········return(buf[0]);¤ ·········return(buf[0]);¤
········ ········
······case·MODE_EMA· ······case·MODE_EMA·
········ ········
·········if(ArrayResize(buf,total)<0)·return(0);¤ ·········if(ArrayResize(buf,total)<0)·return(0);¤
·········double·pr=2.0/(period+1);¤ ·········double·pr=2.0/(period+1);¤
·········int····pos=total-2;¤ ·········int····pos=total-2;¤
·········while(pos>=0)¤ ·········while(pos>=0)¤
··········· ···········
············if(pos==total-2)·buf[pos+1]=array[pos+1];¤ ············if(pos==total-2)·buf[pos+1]=array[pos+1];¤
············buf[pos]=array[pos]*pr+buf[pos+1]*(1-pr);¤ ············buf[pos]=array[pos]*pr+buf[pos+1]*(1-pr);¤
············pos--;¤ ············pos--;¤
··········· ···········
·········return(buf[shift+ma_shift]);¤ ·········return(buf[shift+ma_shift]);¤
········ ········
······case·MODE_SMMA· ······case·MODE_SMMA·
········ ········
·········if(ArrayResize(buf,total)<0)·return(0);¤ ·········if(ArrayResize(buf,total)<0)·return(0);¤
·········double·sum=0;¤ ·········double·sum=0;¤
·········int····i,k,pos;¤ ·········int····i,k,pos;¤
·········pos=total-period;¤ ·········pos=total-period;¤
·········while(pos>=0)¤ ·········while(pos>=0)¤
··········· ···········
············if(pos==total-period)¤ ············if(pos==total-period)¤
·············· ··············
···············for(i=0,k=pos;i<period;i++,k++)¤ ···············for(i=0,k=pos;i<period;i++,k++)¤
················· ·················
··················sum+=array[k];¤ ··················sum+=array[k];¤
··················buf[k]=0;¤ ··················buf[k]=0;¤
················· ·················
·············· ··············
············else·sum=buf[pos+1]*(period-1)+array[pos];¤ ············else·sum=buf[pos+1]*(period-1)+array[pos];¤
············buf[pos]=sum/period;¤ ············buf[pos]=sum/period;¤
············pos--;¤ ············pos--;¤
··········· ···········
·········return(buf[shift+ma_shift]);¤ ·········return(buf[shift+ma_shift]);¤
········ ········
······case·MODE_LWMA· ······case·MODE_LWMA·
········ ········
·········if(ArrayResize(buf,total)<0)·return(0);¤ ·········if(ArrayResize(buf,total)<0)·return(0);¤
·········double·sum=0.0,lsum=0.0;¤ ·········double·sum=0.0,lsum=0.0;¤
·········double·price;¤ ·········double·price;¤
·········int····i,weight=0,pos=total-1;¤ ·········int····i,weight=0,pos=total-1;¤
·········for(i=1;i<=period;i++,pos--)¤ ·········for(i=1;i<=period;i++,pos--)¤
··········· ···········
············price=array[pos];¤ ············price=array[pos];¤
············sum+=price*i;¤ ············sum+=price*i;¤
············lsum+=price;¤ ············lsum+=price;¤
············weight+=i;¤ ············weight+=i;¤
··········· ···········
·········pos++;¤ ·········pos++;¤
·········i=pos+period;¤ ·········i=pos+period;¤
·········while(pos>=0)¤ ·········while(pos>=0)¤
··········· ···········
············buf[pos]=sum/weight;¤ ············buf[pos]=sum/weight;¤
············if(pos==0)·break;¤ ············if(pos==0)·break;¤
············pos--;¤ ············pos--;¤
············i--;¤ ············i--;¤
············price=array[pos];¤ ············price=array[pos];¤
············sum=sum-lsum+price*period;¤ ············sum=sum-lsum+price*period;¤
············lsum-=array[i];¤ ············lsum-=array[i];¤
············lsum+=price;¤ ············lsum+=price;¤
··········· ···········
·········return(buf[shift+ma_shift]);¤ ·········return(buf[shift+ma_shift]);¤
········ ········
······default:·return(0);¤ ······default:·return(0);¤
····· ·····
···return(0);¤ ···return(0);¤
·· ··
··¤ ··¤
void·ObjectSetText(string·objName,string·text,·int·fontSize,·string·font,·color·col)¤ void·ObjectSetText(string·objName,string·text,·int·fontSize,·string·font,·color·col)¤
···objName·pref+objName;¤ ···objName·pref+objName;¤
···ObjectSetString(ChartID(),objName,OBJPROP_TEXT,text);¤ ···ObjectSetString(ChartID(),objName,OBJPROP_TEXT,text);¤
···ObjectSetInteger(ChartID(),objName,OBJPROP_FONTSIZE,fontSize);¤ ···ObjectSetInteger(ChartID(),objName,OBJPROP_FONTSIZE,fontSize);¤
···ObjectSetString(ChartID(),objName,OBJPROP_FONT,font);¤ ···ObjectSetString(ChartID(),objName,OBJPROP_FONT,font);¤
···ObjectSetInteger(ChartID(),objName,OBJPROP_COLOR,col);¤ ···ObjectSetInteger(ChartID(),objName,OBJPROP_COLOR,col);¤
} }