sixtysecound ea.mq4
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «sixtysecound ea.mq4» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
Это торговый советник для MetaTrader 4, написанный на языке MQL4. Программа использует блочную архитектуру с моделями обработки торговых ситуаций: проверка отсутствия открытых позиций, отслеживание видимости индикаторных значений, однократное выполнение сделок в рамках бара, закрытие сделок по таймеру, а также открытие покупок и продаж с различными режимами управления объёмом и стоп-лосс/тейк-профит. Советник обрабатывает события тиков, торговых транзакций и таймера, поддерживает виртуальные стопы, экстренные стопы, счётчик спреда и отображение статуса на графике.
Настройки программы
| Настройка | Описание |
|---|---|
| Magic Number, kind of... (MagicStart) | Магический номер — Уникальный идентификатор ордеров, генерируемых советником, используется для группировки и фильтрации сделок. |
| inp2_Indicator_ADXbars | Бары индикатора 1 — Количество баров, используемых первым индикатором для расчёта значения. |
| inp3_Indicator_ADXbars | Бары индикатора 2 — Количество баров, используемых вторым индикатором для расчёта значения. |
| inp9_VolumeSize | Размер лота покупок — Фиксированный размер торгового объёма для сделок покупки. |
| inp9_StopLossPips | Стоп-лосс покупок в пипсах — Размер стоп-лосса в пипсах для сделок покупки; ноль означает отсутствие фиксированного стоп-лосса. |
| inp9_TakeProfitPips | Тейк-профит покупок в пипсах — Размер тейк-профита в пипсах для сделок покупки; ноль означает отсутствие фиксированного тейк-профита. |
| inp10_VolumeSize | Размер лота продаж — Фиксированный размер торгового объёма для сделок продажи. |
| inp10_StopLossPips | Стоп-лосс продаж в пипсах — Размер стоп-лосса в пипсах для сделок продажи; ноль означает отсутствие фиксированного стоп-лосса. |
| inp10_TakeProfitPips | Тейк-профит продаж в пипсах — Размер тейк-профита в пипсах для сделок продажи; ноль означает отсутствие фиксированного тейк-профита. |
Поиск по коду файла
#property strict
/************************************************************************************************************************/
/************************************************************************************************************************/
#define PROJECT_ID "mt4-9863"
#define POINT_FORMAT_RULES "0.001=0.01,0.00001=0.0001,0.000001=0.0001" // this is deserialized in a special function later
#define ENABLE_SPREAD_METER true
#define ENABLE_STATUS true
#define ENABLE_EVENT_TICK 1 // enable "Tick" event
#define ENABLE_EVENT_TRADE 0 // enable "Trade" event
#define ENABLE_EVENT_TIMER 0 // enable "Timer" event
#define VIRTUAL_STOPS_ENABLED 0 // enable virtual stops
#define VIRTUAL_STOPS_TIMEOUT 0 // virtual stops timeout
#define USE_EMERGENCY_STOPS "no" // "yes" to use emergency (hard stops) when virtual stops are in use. "always" to use EMERGENCY_STOPS_ADD as emergency stops when there is no virtual stop.
#define EMERGENCY_STOPS_REL 0 // use 0 to disable hard stops when virtual stops are enabled. Use a value >=0 to automatically set hard stops with virtual. Example: if 2 is used, then hard stops will be 2 times bigger than virtual ones.
#define EMERGENCY_STOPS_ADD 0 // add pips to relative size of emergency stops (hard stops)
#define ON_TRADE_REALTIME 0 //
#define ON_TIMER_PERIOD 60 // Timer event period (in seconds)
#define TLOBJPROP_TIME1 801
#define OBJPROP_TL_PRICE_BY_SHIFT 802
#define OBJPROP_TL_SHIFT_BY_PRICE 803
#define OBJPROP_FIBOVALUE 804
#define OBJPROP_FIBOPRICEVALUE 805
#define OBJPROP_BARSHIFT1 807
#define OBJPROP_BARSHIFT2 808
#define OBJPROP_BARSHIFT3 809
#define SEL_CURRENT 0
#define SEL_INITIAL 1
input int MagicStart = 9863; // Magic Number, kind of...
class c
{
public:
static int MagicStart;
};
int c::MagicStart;
class v
{
public:
};
input int inp2_Indicator_ADXbars = 4;
input int inp3_Indicator_ADXbars = 4;
input double inp9_VolumeSize = 0.1;
input double inp9_StopLossPips = 0;
input double inp9_TakeProfitPips = 0;
input double inp10_VolumeSize = 0.1;
input double inp10_StopLossPips = 0;
input double inp10_TakeProfitPips = 0;
class _externs
{
public:
static int inp2_Indicator_ADXbars;
static int inp3_Indicator_ADXbars;
static double inp9_VolumeSize;
static double inp9_StopLossPips;
static double inp9_TakeProfitPips;
static double inp10_VolumeSize;
static double inp10_StopLossPips;
static double inp10_TakeProfitPips;
};
int _externs::inp2_Indicator_ADXbars = inp2_Indicator_ADXbars;
int _externs::inp3_Indicator_ADXbars = inp3_Indicator_ADXbars;
double _externs::inp9_VolumeSize = inp9_VolumeSize;
double _externs::inp9_StopLossPips = inp9_StopLossPips;
double _externs::inp9_TakeProfitPips = inp9_TakeProfitPips;
double _externs::inp10_VolumeSize = inp10_VolumeSize;
double _externs::inp10_StopLossPips = inp10_StopLossPips;
double _externs::inp10_TakeProfitPips = inp10_TakeProfitPips;
int FXD_CURRENT_FUNCTION_ID = 0;
double FXD_MILS_INIT_END = 0;
int FXD_TICKS_FROM_START = 0;
int FXD_MORE_SHIFT = 0;
bool FXD_DRAW_SPREAD_INFO = false;
bool FXD_FIRST_TICK_PASSED = false;
bool FXD_BREAK = false;
bool FXD_CONTINUE = false;
bool FXD_CHART_IS_OFFLINE = false;
bool FXD_ONTIMER_TAKEN = false;
bool FXD_ONTIMER_TAKEN_IN_MILLISECONDS = false;
double FXD_ONTIMER_TAKEN_TIME = 0;
bool USE_VIRTUAL_STOPS = VIRTUAL_STOPS_ENABLED;
string FXD_CURRENT_SYMBOL = "";
int FXD_BLOCKS_COUNT = 10;
datetime FXD_TICKSKIP_UNTIL = 0;
struct fxd_onchart
{
int id;
long lparam;
double dparam;
string sparam;
};
fxd_onchart FXD_ONCHART;
/************************************************************************************************************************/
/************************************************************************************************************************/
int OnInit()
{
// код доступен только после оплаты
}
void OnTick()
{
// код доступен только после оплаты
}
void EventTrade()
{
OnTradeQueue(-1);
}
void OnTimer()
{
if (FXD_CHART_IS_OFFLINE && RefreshRates()) {
OnTick();
}
if (ON_TRADE_REALTIME == 1) {
OnTradeListener();
}
static datetime t0 = 0;
datetime t = 0;
bool ok = false;
if (FXD_ONTIMER_TAKEN)
{
if (FXD_ONTIMER_TAKEN_TIME > 0)
{
if (FXD_ONTIMER_TAKEN_IN_MILLISECONDS == true)
{
t = GetTickCount();
}
else
{
t = TimeLocal();
}
if ((t - t0) >= FXD_ONTIMER_TAKEN_TIME)
{
t0 = t;
ok = true;
}
}
if (ok == false) {
return;
}
}
}
void OnChartEvent(
const int id, // Event ID
const long& lparam, // Parameter of type long event
const double& dparam, // Parameter of type double event
const string& sparam // Parameter of type string events
)
{
FXD_ONCHART.id = id;
FXD_ONCHART.lparam = lparam;
FXD_ONCHART.dparam = dparam;
FXD_ONCHART.sparam = sparam;
return;
}
void OnDeinit(const int reason)
{
int reson = UninitializeReason();
if (reson == REASON_CHARTCHANGE || reson == REASON_PARAMETERS || reason == REASON_TEMPLATE) {return;}
EventKillTimer();
if (ENABLE_STATUS) DrawStatus("stopped");
if (ENABLE_SPREAD_METER) DrawSpreadInfo();
if (MQLInfoInteger(MQL_TESTER)) {
Print("Backtested in "+DoubleToString((GetTickCount()-FXD_MILS_INIT_END)/1000, 2)+" seconds");
double tc = GetTickCount()-FXD_MILS_INIT_END;
if (tc > 0)
{
Print("Average ticks per second: "+DoubleToString(FXD_TICKS_FROM_START/tc, 0));
}
}
if (MQLInfoInteger(MQL_PROGRAM_TYPE) == PROGRAM_EXPERT)
{
switch(UninitializeReason())
{
case REASON_PROGRAM : Print("Expert Advisor self terminated"); break;
case REASON_REMOVE : Print("Expert Advisor removed from the chart"); break;
case REASON_RECOMPILE : Print("Expert Advisorhas been recompiled"); break;
case REASON_CHARTCHANGE : Print("Symbol or chart period has been changed"); break;
case REASON_CHARTCLOSE : Print("Chart has been closed"); break;
case REASON_PARAMETERS : Print("Input parameters have been changed by a user"); break;
case REASON_ACCOUNT : Print("Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings"); break;
case REASON_TEMPLATE : Print("A new template has been applied"); break;
case REASON_INITFAILED : Print("OnInit() handler has returned a nonzero value"); break;
case REASON_CLOSE : Print("Terminal has been closed"); break;
}
}
for (int i=0; i<ArraySize(_blocks_); i++)
{
delete _blocks_[i];
_blocks_[i] = NULL;
}
ArrayResize(_blocks_, 0);
return;
}
/************************************************************************************************************************/
/************************************************************************************************************************/
/**
The base class for all block calls
*/
class BlockCalls
{
public:
bool __disabled; // whether or not the block is disabled
string __block_user_number;
int __block_number;
int __block_waiting;
int __parent_number;
int __inbound_blocks[];
int __outbound_blocks[];
void __addInboundBlock(int id = 0) {
int size = ArraySize(__inbound_blocks);
for (int i = 0; i < size; i++) {
if (__inbound_blocks[i] == id) {
return;
}
}
ArrayResize(__inbound_blocks, size + 1);
__inbound_blocks[size] = id;
}
/**
Announce this block to the list of inbound connections of all the blocks to which this block is connected to
*/
void __announceThisBlock()
{
for (int i = 0; i < ArraySize(__outbound_blocks); i++)
{
int block = __outbound_blocks[i]; // outbound block number
int size = ArraySize(_blocks_[block].__inbound_blocks); // the size of its inbound list
for (int j = 0; j < size; j++) {
if (_blocks_[block].__inbound_blocks[j] == __block_number)
{
return;
}
}
ArrayResize(_blocks_[block].__inbound_blocks, size + 1);
_blocks_[block].__inbound_blocks[size] = __block_number;
}
}
virtual void _execute_() = 0;
/**
In the derived class this method should be used to set dynamic parameters or other stuff before the main execute.
This method is automatically called within the main "run" method below, before the execution of the main class.
*/
virtual void _beforeExecute_() {return;};
bool _beforeExecuteEnabled; // for speed
/**
Same as _beforeExecute_, but to work after the execute method.
*/
virtual void _afterExecute_() {return;};
bool _afterExecuteEnabled; // for speed
/**
This is the method that is used to run the block
*/
virtual void run(int _parent_=0) {
__parent_number = _parent_;
if (__disabled || FXD_BREAK) {return;}
FXD_CURRENT_FUNCTION_ID = __block_number;
if (_beforeExecuteEnabled) {_beforeExecute_();}
_execute_();
if (_afterExecuteEnabled) {_afterExecute_();}
if (__block_waiting && FXD_CURRENT_FUNCTION_ID == __block_number) {fxdWait.Accumulate(FXD_CURRENT_FUNCTION_ID);}
}
};
BlockCalls *_blocks_[];
template<typename T1,typename T2,typename T3,typename T4,typename T5>
class MDL_NoOpenedOrders: public BlockCalls
{
public: /* Input Parameters */
T1 OrdersScope;
T2 OrdersGroup;
T3 SymbolScope;
T4 SYMBOL;
T5 BuysOrSells;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDL_NoOpenedOrders()
{
OrdersScope = "group";
OrdersGroup = "";
SymbolScope = "symbol";
SYMBOL = CurrentSymbol();
BuysOrSells = "both";
}
public: /* The main method */
virtual void _execute_()
{
bool exist = false;
for (int pos=OrdersTotal()-1; pos>=0; pos--) {
if (!OrderSelect(pos, SELECT_BY_POS, MODE_TRADES)) {continue;}
if (FilterOrderBy(OrdersScope, (string)OrdersGroup, SymbolScope, SYMBOL, BuysOrSells)) {
exist = true;
break;
}
}
if (exist == false) {_callback_(1);} else {_callback_(0);}
}
};
template<typename T1,typename _T1_,typename T2,typename T3>
class MDL_IndicatorIsVisible: public BlockCalls
{
public: /* Input Parameters */
T1 Indicator; virtual _T1_ _Indicator_(){return(_T1_)0;}
T2 AdditionalCandles;
T3 ExceptionCandles;
/* Static Parameters */
int itf;
string isymbol;
datetime bartime;
bool lastpass;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDL_IndicatorIsVisible()
{
AdditionalCandles = 0;
ExceptionCandles = 0;
/* Static Parameters (initial value) */
itf = 0;
isymbol = "";
lastpass = false;
}
public: /* The main method */
virtual void _execute_()
{
int exceptions=0;
bool next=true;
for (int i=0; i<=AdditionalCandles; i++)
{
FXD_MORE_SHIFT = i;
_T1_ ivalue=_Indicator_();
FXD_MORE_SHIFT = 0; // reset
/*
if (AdditionalCandles > 0 && i == 0)
{
if (Indicator.TIMEFRAME == itf && Indicator.SYMBOL == isymbol)
{
if (bartime >= iTime(isymbol, itf, Indicator.SHIFT))
{
next = lastpass; break;
}
else
{
bartime = iTime(Indicator.SYMBOL, Indicator.TIMEFRAME, Indicator.SHIFT);
}
}
else
{
itf = Indicator.TIMEFRAME;
isymbol = Indicator.SYMBOL;
bartime = iTime(Indicator.SYMBOL, Indicator.TIMEFRAME, Indicator.SHIFT);
}
}
*/
if (ivalue==0 || ivalue==EMPTY_VALUE || ivalue==-EMPTY_VALUE) {
if (AdditionalCandles>0 && ExceptionCandles>0) {
exceptions++;
if (exceptions<=ExceptionCandles) {continue;}
}
next=false; break;
}
}
lastpass=next;
if (next==true) {_callback_(1);} else {_callback_(0);}
}
};
template<typename T1,typename T2,typename T3>
class MDL_OncePerBar: public BlockCalls
{
public: /* Input Parameters */
T1 SYMBOL;
T2 TIMEFRAME;
T3 PassMaxTimes;
/* Static Parameters */
datetime old_value;
int pass_count;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDL_OncePerBar()
{
SYMBOL = CurrentSymbol();
TIMEFRAME = CurrentTimeframe();
PassMaxTimes = 1;
/* Static Parameters (initial value) */
pass_count = 0;
}
public: /* The main method */
virtual void _execute_()
{
bool next = false;
datetime new_value = iTime(SYMBOL, TIMEFRAME, 1);
if (new_value > old_value)
{
pass_count++;
if (pass_count >= PassMaxTimes)
{
old_value = new_value;
pass_count = 0;
}
next = true;
}
if (next) {_callback_(1);} else {_callback_(0);}
}
};
template<typename T1,typename T2,typename T3,typename T4,typename T5,typename T6,typename T7,typename T8>
class MDL_CloseOpened: public BlockCalls
{
public: /* Input Parameters */
T1 OrdersScope;
T2 OrdersGroup;
T3 SymbolScope;
T4 SYMBOL;
T5 BuysOrSells;
T6 OrderMinutes;
T7 Slippage;
T8 ArrowColor;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDL_CloseOpened()
{
OrdersScope = "group";
OrdersGroup = "";
SymbolScope = "symbol";
SYMBOL = CurrentSymbol();
BuysOrSells = "both";
OrderMinutes = 0;
Slippage = 4;
ArrowColor = DeepPink;
}
public: /* The main method */
virtual void _execute_()
{
int closed_count=0;
bool finished=false;
while (finished==false) {
int count=0;
for (int pos=OrdersTotal()-1; pos>=0; pos--) {
if (OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)) {
if (FilterOrderBy(OrdersScope,OrdersGroup, SymbolScope,SYMBOL, BuysOrSells)) {
datetime time_diff = TimeCurrent()-attrOpenTime();
if (time_diff < 0) {time_diff = 0;} // this actually happens sometimes
if (time_diff >= 60*OrderMinutes)
{
if (CloseTrade(attrTicket(),Slippage,ArrowColor)) {closed_count++;}
count++;
}
}
}
}
if (count==0) {finished=true;}
}
_callback_(1);
}
};
template<typename T1,typename T2,typename T3,typename T4,typename T5,typename T6,typename T7,typename T8,typename T9,typename _T9_,typename T10,typename T11,typename T12,typename T13,typename T14,typename T15,typename T16,typename T17,typename T18,typename T19,typename T20,typename T21,typename T22,typename T23,typename T24,typename T25,typename T26,typename T27,typename T28,typename T29,typename T30,typename T31,typename T32,typename T33,typename T34,typename T35,typename _T35_,typename T36,typename _T36_,typename T37,typename _T37_,typename T38,typename T39,typename T40,typename T41,typename _T41_,typename T42,typename _T42_,typename T43,typename _T43_,typename T44,typename T45,typename T46,typename T47,typename T48,typename _T48_,typename T49,typename T50,typename T51>
class MDL_BuyNow: public BlockCalls
{
public: /* Input Parameters */
T1 OrdersGroup;
T2 SYMBOL;
T3 VolumeMode;
T4 VolumeSize;
T5 VolumeSizeRisk;
T6 VolumeRisk;
T7 VolumePercent;
T8 VolumeBlockPercent;
T9 dVolumeSize; virtual _T9_ _dVolumeSize_(){return(_T9_)0;}
T10 FixedRatioUnitSize;
T11 FixedRatioDelta;
T12 mmMgInitialLots;
T13 mmMgMultiplyOnLoss;
T14 mmMgMultiplyOnProfit;
T15 mmMgAddLotsOnLoss;
T16 mmMgAddLotsOnProfit;
T17 mmMgResetOnLoss;
T18 mmMgResetOnProfit;
T19 mm1326InitialLots;
T20 mm1326Reverse;
T21 mmFiboInitialLots;
T22 mmDalembertInitialLots;
T23 mmDalembertReverse;
T24 mmLabouchereInitialLots;
T25 mmLabouchereList;
T26 mmLabouchereReverse;
T27 mmSeqBaseLots;
T28 mmSeqOnLoss;
T29 mmSeqOnProfit;
T30 mmSeqReverse;
T31 VolumeUpperLimit;
T32 StopLossMode;
T33 StopLossPips;
T34 StopLossPercentTP;
T35 dlStopLoss; virtual _T35_ _dlStopLoss_(){return(_T35_)0;}
T36 dpStopLoss; virtual _T36_ _dpStopLoss_(){return(_T36_)0;}
T37 ddStopLoss; virtual _T37_ _ddStopLoss_(){return(_T37_)0;}
T38 TakeProfitMode;
T39 TakeProfitPips;
T40 TakeProfitPercentSL;
T41 dlTakeProfit; virtual _T41_ _dlTakeProfit_(){return(_T41_)0;}
T42 dpTakeProfit; virtual _T42_ _dpTakeProfit_(){return(_T42_)0;}
T43 ddTakeProfit; virtual _T43_ _ddTakeProfit_(){return(_T43_)0;}
T44 ExpMode;
T45 ExpDays;
T46 ExpHours;
T47 ExpMinutes;
T48 dExp; virtual _T48_ _dExp_(){return(_T48_)0;}
T49 Slippage;
T50 MyComment;
T51 ArrowColorBuy;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDL_BuyNow()
{
OrdersGroup = "";
SYMBOL = CurrentSymbol();
VolumeMode = "fixed";
VolumeSize = 0.1;
VolumeSizeRisk = 50;
VolumeRisk = 2.5;
VolumePercent = 100;
VolumeBlockPercent = 3;
FixedRatioUnitSize = 0.01;
FixedRatioDelta = 20;
mmMgInitialLots = 0.1;
mmMgMultiplyOnLoss = 2;
mmMgMultiplyOnProfit = 1;
mmMgAddLotsOnLoss = 0;
mmMgAddLotsOnProfit = 0;
mmMgResetOnLoss = 0;
mmMgResetOnProfit = 1;
mm1326InitialLots = 0.1;
mm1326Reverse = false;
mmFiboInitialLots = 0.1;
mmDalembertInitialLots = 0.1;
mmDalembertReverse = false;
mmLabouchereInitialLots = 0.1;
mmLabouchereList = "1,2,3,4,5,6";
mmLabouchereReverse = false;
mmSeqBaseLots = 0.1;
mmSeqOnLoss = "3,2,6";
mmSeqOnProfit = "1";
mmSeqReverse = false;
VolumeUpperLimit = 0;
StopLossMode = "fixed";
StopLossPips = 5000;
StopLossPercentTP = 100;
TakeProfitMode = "fixed";
TakeProfitPips = 50;
TakeProfitPercentSL = 100;
ExpMode = "GTC";
ExpDays = 0;
ExpHours = 1;
ExpMinutes = 0;
Slippage = 4;
MyComment = "Long trade";
ArrowColorBuy = Blue;
}
public: /* The main method */
virtual void _execute_()
{
SetSymbol(SYMBOL);
double sll=0, slp=0, tpl=0, tpp=0;
if (StopLossMode=="fixed") {slp=StopLossPips;}
else if (StopLossMode=="dynamicPips") {slp=_dpStopLoss_();}
else if (StopLossMode=="dynamicDigits"){slp=toPips(_ddStopLoss_(),SYMBOL);}
else if (StopLossMode=="dynamicLevel") {sll=_dlStopLoss_();}
if (TakeProfitMode=="fixed") {tpp=TakeProfitPips;}
else if (TakeProfitMode=="dynamicPips") {tpp=_dpTakeProfit_();}
else if (TakeProfitMode=="dynamicDigits") {tpp=toPips(_ddTakeProfit_(),SYMBOL);}
else if (TakeProfitMode=="dynamicLevel") {tpl=_dlTakeProfit_();}
if (StopLossMode == "percentTP") {
if (tpp > 0) {slp = tpp*StopLossPercentTP/100;}
if (tpl > 0) {slp = toPips(MathAbs(SymbolAsk(SYMBOL) - tpl), SYMBOL)*StopLossPercentTP/100;}
}
if (TakeProfitMode == "percentSL") {
if (slp > 0) {tpp = slp*TakeProfitPercentSL/100;}
if (sll > 0) {tpp = toPips(MathAbs(SymbolAsk(SYMBOL) - sll), SYMBOL)*TakeProfitPercentSL/100;}
}
double lots=0;
double pre_sll=sll; if (pre_sll==0) {pre_sll=SymbolAsk(SYMBOL);}
double pre_sl_pips=toPips(SymbolAsk(SYMBOL)-(pre_sll-toDigits(slp,SYMBOL)));
if (VolumeMode=="fixed") {lots=DynamicLots(VolumeMode, VolumeSize);}
else if (VolumeMode=="block-equity") {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
else if (VolumeMode=="block-balance") {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
else if (VolumeMode=="block-freemargin") {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
else if (VolumeMode=="equity") {lots=DynamicLots(VolumeMode, VolumePercent);}
else if (VolumeMode=="balance") {lots=DynamicLots(VolumeMode, VolumePercent);}
else if (VolumeMode=="freemargin") {lots=DynamicLots(VolumeMode, VolumePercent);}
else if (VolumeMode=="equityRisk") {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
else if (VolumeMode=="balanceRisk") {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
else if (VolumeMode=="freemarginRisk") {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
else if (VolumeMode=="fixedRisk") {lots=DynamicLots(VolumeMode, VolumeSizeRisk, pre_sl_pips);}
else if (VolumeMode=="fixedRatio") {lots=DynamicLots(VolumeMode, FixedRatioUnitSize, FixedRatioDelta);}
else if (VolumeMode=="dynamic") {lots=AlignLots(_dVolumeSize_());}
else if (VolumeMode=="1326") {lots=Bet1326((int)OrdersGroup, SYMBOL, mm1326InitialLots, mm1326Reverse);}
else if (VolumeMode=="fibonacci") {lots=BetFibonacci((int)OrdersGroup, SYMBOL, mmFiboInitialLots);}
else if (VolumeMode=="dalembert") {lots=BetDalembert((int)OrdersGroup, SYMBOL, mmDalembertInitialLots, mmDalembertReverse);}
else if (VolumeMode=="labouchere") {lots=BetLabouchere((int)OrdersGroup, SYMBOL, mmLabouchereInitialLots, mmLabouchereList, mmLabouchereReverse);}
else if (VolumeMode=="martingale") {lots=BetMartingale((int)OrdersGroup, SYMBOL, mmMgInitialLots, mmMgMultiplyOnLoss, mmMgMultiplyOnProfit, mmMgAddLotsOnLoss, mmMgAddLotsOnProfit, mmMgResetOnLoss, mmMgResetOnProfit);}
else if (VolumeMode=="sequence") {lots=BetSequence((int)OrdersGroup, SYMBOL, mmSeqBaseLots, mmSeqOnLoss, mmSeqOnProfit, mmSeqReverse);}
lots = AlignLots(lots, 0, VolumeUpperLimit);
datetime exp = ExpirationTime(ExpMode,ExpDays,ExpHours,ExpMinutes,_dExp_());
int ticket=BuyNow(SYMBOL, lots, sll, tpl, slp, tpp, Slippage, (MagicStart+(int)OrdersGroup), MyComment, ArrowColorBuy, exp);
if (ticket>0) {_callback_(1);} else {_callback_(0);}
}
};
template<typename T1,typename T2,typename T3,typename T4,typename T5,typename T6,typename T7,typename T8,typename T9,typename _T9_,typename T10,typename T11,typename T12,typename T13,typename T14,typename T15,typename T16,typename T17,typename T18,typename T19,typename T20,typename T21,typename T22,typename T23,typename T24,typename T25,typename T26,typename T27,typename T28,typename T29,typename T30,typename T31,typename T32,typename T33,typename T34,typename T35,typename _T35_,typename T36,typename _T36_,typename T37,typename _T37_,typename T38,typename T39,typename T40,typename T41,typename _T41_,typename T42,typename _T42_,typename T43,typename _T43_,typename T44,typename T45,typename T46,typename T47,typename T48,typename _T48_,typename T49,typename T50,typename T51>
class MDL_SellNow: public BlockCalls
{
public: /* Input Parameters */
T1 OrdersGroup;
T2 SYMBOL;
T3 VolumeMode;
T4 VolumeSize;
T5 VolumeSizeRisk;
T6 VolumeRisk;
T7 VolumePercent;
T8 VolumeBlockPercent;
T9 dVolumeSize; virtual _T9_ _dVolumeSize_(){return(_T9_)0;}
T10 FixedRatioUnitSize;
T11 FixedRatioDelta;
T12 mmMgInitialLots;
T13 mmMgMultiplyOnLoss;
T14 mmMgMultiplyOnProfit;
T15 mmMgAddLotsOnLoss;
T16 mmMgAddLotsOnProfit;
T17 mmMgResetOnLoss;
T18 mmMgResetOnProfit;
T19 mm1326InitialLots;
T20 mm1326Reverse;
T21 mmFiboInitialLots;
T22 mmDalembertInitialLots;
T23 mmDalembertReverse;
T24 mmLabouchereInitialLots;
T25 mmLabouchereList;
T26 mmLabouchereReverse;
T27 mmSeqBaseLots;
T28 mmSeqOnLoss;
T29 mmSeqOnProfit;
T30 mmSeqReverse;
T31 VolumeUpperLimit;
T32 StopLossMode;
T33 StopLossPips;
T34 StopLossPercentTP;
T35 dlStopLoss; virtual _T35_ _dlStopLoss_(){return(_T35_)0;}
T36 dpStopLoss; virtual _T36_ _dpStopLoss_(){return(_T36_)0;}
T37 ddStopLoss; virtual _T37_ _ddStopLoss_(){return(_T37_)0;}
T38 TakeProfitMode;
T39 TakeProfitPips;
T40 TakeProfitPercentSL;
T41 dlTakeProfit; virtual _T41_ _dlTakeProfit_(){return(_T41_)0;}
T42 dpTakeProfit; virtual _T42_ _dpTakeProfit_(){return(_T42_)0;}
T43 ddTakeProfit; virtual _T43_ _ddTakeProfit_(){return(_T43_)0;}
T44 ExpMode;
T45 ExpDays;
T46 ExpHours;
T47 ExpMinutes;
T48 dExp; virtual _T48_ _dExp_(){return(_T48_)0;}
T49 Slippage;
T50 MyComment;
T51 ArrowColorSell;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDL_SellNow()
{
OrdersGroup = "";
SYMBOL = CurrentSymbol();
VolumeMode = "fixed";
VolumeSize = 0.1;
VolumeSizeRisk = 50;
VolumeRisk = 2.5;
VolumePercent = 100;
VolumeBlockPercent = 3;
FixedRatioUnitSize = 0.01;
FixedRatioDelta = 20;
mmMgInitialLots = 0.1;
mmMgMultiplyOnLoss = 2;
mmMgMultiplyOnProfit = 1;
mmMgAddLotsOnLoss = 0;
mmMgAddLotsOnProfit = 0;
mmMgResetOnLoss = 0;
mmMgResetOnProfit = 1;
mm1326InitialLots = 0.1;
mm1326Reverse = false;
mmFiboInitialLots = 0.1;
mmDalembertInitialLots = 0.1;
mmDalembertReverse = false;
mmLabouchereInitialLots = 0.1;
mmLabouchereList = "1,2,3,4,5,6";
mmLabouchereReverse = false;
mmSeqBaseLots = 0.1;
mmSeqOnLoss = "3,2,6";
mmSeqOnProfit = "1";
mmSeqReverse = false;
VolumeUpperLimit = 0;
StopLossMode = "fixed";
StopLossPips = 5000;
StopLossPercentTP = 100;
TakeProfitMode = "fixed";
TakeProfitPips = 50;
TakeProfitPercentSL = 100;
ExpMode = "GTC";
ExpDays = 0;
ExpHours = 1;
ExpMinutes = 0;
Slippage = 4;
MyComment = "Short trade";
ArrowColorSell = Red;
}
public: /* The main method */
virtual void _execute_()
{
SetSymbol(SYMBOL);
double sll=0, slp=0, tpl=0, tpp=0;
if (StopLossMode=="fixed") {slp=StopLossPips;}
else if (StopLossMode=="dynamicPips") {slp=_dpStopLoss_();}
else if (StopLossMode=="dynamicDigits"){slp=toPips(_ddStopLoss_(),SYMBOL);}
else if (StopLossMode=="dynamicLevel") {sll=_dlStopLoss_();}
if (TakeProfitMode=="fixed") {tpp=TakeProfitPips;}
else if (TakeProfitMode=="dynamicPips") {tpp=_dpTakeProfit_();}
else if (TakeProfitMode=="dynamicDigits") {tpp=toPips(_ddTakeProfit_(),SYMBOL);}
else if (TakeProfitMode=="dynamicLevel") {tpl=_dlTakeProfit_();}
if (StopLossMode == "percentTP") {
if (tpp > 0) {slp = tpp*StopLossPercentTP/100;}
if (tpl > 0) {slp = toPips(MathAbs(SymbolAsk(SYMBOL) - tpl), SYMBOL)*StopLossPercentTP/100;}
}
if (TakeProfitMode == "percentSL") {
if (slp > 0) {tpp = slp*TakeProfitPercentSL/100;}
if (sll > 0) {tpp = toPips(MathAbs(SymbolAsk(SYMBOL) - sll), SYMBOL)*TakeProfitPercentSL/100;}
}
double lots=0;
double pre_sll=sll; if (pre_sll==0) {pre_sll=SymbolBid(SYMBOL);}
double pre_sl_pips=toPips((pre_sll+toDigits(slp,SYMBOL))-SymbolBid(SYMBOL));
if (VolumeMode=="fixed") {lots=DynamicLots(VolumeMode, VolumeSize);}
else if (VolumeMode=="block-equity") {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
else if (VolumeMode=="block-balance") {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
else if (VolumeMode=="block-freemargin") {lots=DynamicLots(VolumeMode, VolumeBlockPercent);}
else if (VolumeMode=="equity") {lots=DynamicLots(VolumeMode, VolumePercent);}
else if (VolumeMode=="balance") {lots=DynamicLots(VolumeMode, VolumePercent);}
else if (VolumeMode=="freemargin") {lots=DynamicLots(VolumeMode, VolumePercent);}
else if (VolumeMode=="equityRisk") {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
else if (VolumeMode=="balanceRisk") {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
else if (VolumeMode=="freemarginRisk") {lots=DynamicLots(VolumeMode, VolumeRisk, pre_sl_pips);}
else if (VolumeMode=="fixedRisk") {lots=DynamicLots(VolumeMode, VolumeSizeRisk, pre_sl_pips);}
else if (VolumeMode=="fixedRatio") {lots=DynamicLots(VolumeMode, FixedRatioUnitSize, FixedRatioDelta);}
else if (VolumeMode=="dynamic") {lots=AlignLots(_dVolumeSize_());}
else if (VolumeMode=="1326") {lots=Bet1326((int)OrdersGroup, SYMBOL, mm1326InitialLots, mm1326Reverse);}
else if (VolumeMode=="fibonacci") {lots=BetFibonacci((int)OrdersGroup, SYMBOL, mmFiboInitialLots);}
else if (VolumeMode=="dalembert") {lots=BetDalembert((int)OrdersGroup, SYMBOL, mmDalembertInitialLots, mmDalembertReverse);}
else if (VolumeMode=="labouchere") {lots=BetLabouchere((int)OrdersGroup, SYMBOL, mmLabouchereInitialLots, mmLabouchereList, mmLabouchereReverse);}
else if (VolumeMode=="martingale") {lots=BetMartingale((int)OrdersGroup, SYMBOL, mmMgInitialLots, mmMgMultiplyOnLoss, mmMgMultiplyOnProfit, mmMgAddLotsOnLoss, mmMgAddLotsOnProfit, mmMgResetOnLoss, mmMgResetOnProfit);}
else if (VolumeMode=="sequence") {lots=BetSequence((int)OrdersGroup, SYMBOL, mmSeqBaseLots, mmSeqOnLoss, mmSeqOnProfit, mmSeqReverse);}
lots = AlignLots(lots, 0, VolumeUpperLimit);
datetime exp = ExpirationTime(ExpMode,ExpDays,ExpHours,ExpMinutes,_dExp_());
int ticket=SellNow(SYMBOL, lots, sll, tpl, slp, tpp, Slippage, (MagicStart+(int)OrdersGroup), MyComment, ArrowColorSell, exp);
if (ticket>0) {_callback_(1);} else {_callback_(0);}
}
};
class MDLIC_myindicators_myindicators_1
{
public: /* Input Parameters */
string SYMBOL;
ENUM_TIMEFRAMES TIMEFRAME;
string ModeOutput;
string TimeStamp;
int VisibleID;
int VisibleShift;
int VisibleLimit;
int RangeCandleStart;
int RangeCandleEnd;
string RangeTimeSource;
string RangeTimeStart;
string RangeTimeEnd;
double RangeDayOffset;
string RangeValue;
int SHIFT;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDLIC_myindicators_myindicators_1()
{
SYMBOL = CurrentSymbol();
TIMEFRAME = CurrentTimeframe();
ModeOutput = "id";
TimeStamp = "00:00";
VisibleID = 0;
VisibleShift = 0;
VisibleLimit = 100;
RangeCandleStart = 0;
RangeCandleEnd = 10;
RangeTimeSource = "server";
RangeTimeStart = "01:00";
RangeTimeEnd = "08:00";
RangeDayOffset = 0;
RangeValue = "max";
SHIFT = 0;
}
public: /* The main method */
double _execute_()
{
string symbol = SYMBOL;
ENUM_TIMEFRAMES timeframe = TIMEFRAME;
int buffer = 0;
int shift = SHIFT + FXD_MORE_SHIFT;
double retval = EMPTY_VALUE;
int i;
double ival;
if (ModeOutput == "id")
{
retval = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp2_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift);
}
else if (ModeOutput == "time")
{
datetime time;
if (0 && StringFind(TimeStamp, ":") == -1)
{
time = (datetime)StringToInteger(TimeStamp); // hangs in MQL4!!!
}
else
{
time = StringToTime(TimeStamp);
}
shift = iCandleID(symbol, timeframe, time);
retval = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp2_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift);
}
else if (ModeOutput == "visible" || ModeOutput == "id_by_visible")
{
if (VisibleLimit == 0) {VisibleLimit = iBars(symbol, timeframe);}
int vid = 0;
for (i = shift; i <= VisibleLimit; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp2_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (vid >= VisibleID) {
if (ModeOutput == "visible") {retval = ival;}
else {retval = i;}
break;
}
vid++;
}
}
else if (ModeOutput == "range")
{
int cstart = RangeCandleStart;
int cend = RangeCandleEnd;
if (RangeCandleStart > RangeCandleEnd) {
int ctmp = RangeCandleEnd;
RangeCandleEnd = RangeCandleStart;
RangeCandleStart = ctmp;
}
if (RangeValue == "max")
{
retval = -EMPTY_VALUE;
for (i = RangeCandleStart; i <= RangeCandleEnd; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp2_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (ival > retval) {retval = ival;}
}
if (retval == -EMPTY_VALUE) {retval = EMPTY_VALUE;}
}
else if (RangeValue == "min")
{
retval = EMPTY_VALUE;
for (i = RangeCandleStart; i <= RangeCandleEnd; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp2_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (ival < retval) {retval = ival;}
}
}
}
else if (ModeOutput == "range_time")
{
datetime offset = 0;
if (RangeTimeSource == "gmt") {offset = (int)(TimeCurrent() - TimeLocal() + TimeGMTOffset());}
else if (RangeTimeSource == "server") {offset = (int)(TimeCurrent() - TimeLocal());}
datetime time1 = StringToTime(RangeTimeStart)-(datetime)(86400*RangeDayOffset) + offset;
datetime time2 = StringToTime(RangeTimeEnd)-(datetime)(86400*RangeDayOffset) + offset;
int x1 = iBarShift(symbol, timeframe, time1, false);
int x2 = iBarShift(symbol, timeframe, time2, false);
if (x1<x2) {x1=iBarShift(symbol,timeframe,(time1-86400),false);}
if (RangeValue == "max")
{
retval = -EMPTY_VALUE;
for (i=x2; i<=x1; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp2_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (ival > retval) {retval = ival;}
}
if (retval == -EMPTY_VALUE) {retval = EMPTY_VALUE;}
}
else if (RangeValue == "min")
{
retval = EMPTY_VALUE;
for (i=x2; i<=x1; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp2_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (ival < retval) {retval = ival;}
}
}
}
return (retval);
}
};
class MDLIC_myindicators_myindicators_2
{
public: /* Input Parameters */
string SYMBOL;
ENUM_TIMEFRAMES TIMEFRAME;
string ModeOutput;
string TimeStamp;
int VisibleID;
int VisibleShift;
int VisibleLimit;
int RangeCandleStart;
int RangeCandleEnd;
string RangeTimeSource;
string RangeTimeStart;
string RangeTimeEnd;
double RangeDayOffset;
string RangeValue;
int SHIFT;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDLIC_myindicators_myindicators_2()
{
SYMBOL = CurrentSymbol();
TIMEFRAME = CurrentTimeframe();
ModeOutput = "id";
TimeStamp = "00:00";
VisibleID = 0;
VisibleShift = 0;
VisibleLimit = 100;
RangeCandleStart = 0;
RangeCandleEnd = 10;
RangeTimeSource = "server";
RangeTimeStart = "01:00";
RangeTimeEnd = "08:00";
RangeDayOffset = 0;
RangeValue = "max";
SHIFT = 0;
}
public: /* The main method */
double _execute_()
{
string symbol = SYMBOL;
ENUM_TIMEFRAMES timeframe = TIMEFRAME;
int buffer = 1;
int shift = SHIFT + FXD_MORE_SHIFT;
double retval = EMPTY_VALUE;
int i;
double ival;
if (ModeOutput == "id")
{
retval = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp3_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift);
}
else if (ModeOutput == "time")
{
datetime time;
if (0 && StringFind(TimeStamp, ":") == -1)
{
time = (datetime)StringToInteger(TimeStamp); // hangs in MQL4!!!
}
else
{
time = StringToTime(TimeStamp);
}
shift = iCandleID(symbol, timeframe, time);
retval = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp3_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift);
}
else if (ModeOutput == "visible" || ModeOutput == "id_by_visible")
{
if (VisibleLimit == 0) {VisibleLimit = iBars(symbol, timeframe);}
int vid = 0;
for (i = shift; i <= VisibleLimit; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp3_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (vid >= VisibleID) {
if (ModeOutput == "visible") {retval = ival;}
else {retval = i;}
break;
}
vid++;
}
}
else if (ModeOutput == "range")
{
int cstart = RangeCandleStart;
int cend = RangeCandleEnd;
if (RangeCandleStart > RangeCandleEnd) {
int ctmp = RangeCandleEnd;
RangeCandleEnd = RangeCandleStart;
RangeCandleStart = ctmp;
}
if (RangeValue == "max")
{
retval = -EMPTY_VALUE;
for (i = RangeCandleStart; i <= RangeCandleEnd; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp3_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (ival > retval) {retval = ival;}
}
if (retval == -EMPTY_VALUE) {retval = EMPTY_VALUE;}
}
else if (RangeValue == "min")
{
retval = EMPTY_VALUE;
for (i = RangeCandleStart; i <= RangeCandleEnd; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp3_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (ival < retval) {retval = ival;}
}
}
}
else if (ModeOutput == "range_time")
{
datetime offset = 0;
if (RangeTimeSource == "gmt") {offset = (int)(TimeCurrent() - TimeLocal() + TimeGMTOffset());}
else if (RangeTimeSource == "server") {offset = (int)(TimeCurrent() - TimeLocal());}
datetime time1 = StringToTime(RangeTimeStart)-(datetime)(86400*RangeDayOffset) + offset;
datetime time2 = StringToTime(RangeTimeEnd)-(datetime)(86400*RangeDayOffset) + offset;
int x1 = iBarShift(symbol, timeframe, time1, false);
int x2 = iBarShift(symbol, timeframe, time2, false);
if (x1<x2) {x1=iBarShift(symbol,timeframe,(time1-86400),false);}
if (RangeValue == "max")
{
retval = -EMPTY_VALUE;
for (i=x2; i<=x1; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp3_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (ival > retval) {retval = ival;}
}
if (retval == -EMPTY_VALUE) {retval = EMPTY_VALUE;}
}
else if (RangeValue == "min")
{
retval = EMPTY_VALUE;
for (i=x2; i<=x1; i++)
{
ival = iCustom(symbol, timeframe, "SixtySecondTrades_Alerts2" , (int)_externs::inp3_Indicator_ADXbars, (int)5000, (bool)false, buffer, shift + i);
if (ival == EMPTY_VALUE || ival == 0) {continue;}
if (ival < retval) {retval = ival;}
}
}
}
return (retval);
}
};
class MDLIC_value_value
{
public: /* Input Parameters */
double Value;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDLIC_value_value()
{
Value = 1;
}
public: /* The main method */
double _execute_()
{
return Value;
}
};
class MDLIC_value_time
{
public: /* Input Parameters */
int ModeTime;
int TimeSource;
string TimeStamp;
int TimeCandleID;
string TimeMarket;
ENUM_TIMEFRAMES TimeCandleTimeframe;
int TimeComponentYear;
int TimeComponentMonth;
int TimeComponentDay;
int TimeComponentHour;
int TimeComponentMinute;
int TimeComponentSecond;
int ModeTimeShift;
int TimeShiftYears;
int TimeShiftMonths;
int TimeShiftWeeks;
int TimeShiftDays;
int TimeShiftHours;
int TimeShiftMinutes;
int TimeShiftSeconds;
bool TimeSkipWeekdays;
/* Static Parameters */
datetime retval;
datetime retval0;
int ModeTime0;
int smodeshift;
virtual void _callback_(int r) {return;}
public: /* Constructor */
MDLIC_value_time()
{
ModeTime = 0;
TimeSource = 0;
TimeStamp = "00:00";
TimeCandleID = 1;
TimeMarket = "";
TimeCandleTimeframe = 0;
TimeComponentYear = 0;
TimeComponentMonth = 0;
TimeComponentDay = 0;
TimeComponentHour = 12;
TimeComponentMinute = 0;
TimeComponentSecond = 0;
ModeTimeShift = 0;
TimeShiftYears = 0;
TimeShiftMonths = 0;
TimeShiftWeeks = 0;
TimeShiftDays = 0;
TimeShiftHours = 0;
TimeShiftMinutes = 0;
TimeShiftSeconds = 0;
TimeSkipWeekdays = false;
/* Static Parameters (initial value) */
retval = 0;
retval0 = 0;
ModeTime0 = 0;
smodeshift = 0;
}
public: /* The main method */
datetime _execute_()
{
if(ModeTime==0) {
if (TimeSource == 0) {retval = TimeCurrent();}
else if (TimeSource == 1) {retval = TimeLocal();}
else if (TimeSource == 2) {retval = TimeGMT();}
}
else if(ModeTime==1) {
retval = StringToTime(TimeStamp);
retval0 = retval;
}
else if(ModeTime==2) {
retval = TimeFromComponents(TimeSource, TimeComponentYear, TimeComponentMonth, TimeComponentDay, TimeComponentHour, TimeComponentMinute, TimeComponentSecond);
}
else if(ModeTime==3) {
if (TimeMarket == "") {TimeMarket = Symbol();}
retval = iTime(TimeMarket,TimeCandleTimeframe,TimeCandleID);
}
if (ModeTimeShift>0) {
int sh=1;
if (ModeTimeShift==1) {sh=-1;}
static int years0=0,months0=0;
if (
ModeTimeShift!=smodeshift
|| TimeShiftYears!=years0 || TimeShiftMonths!=months0
)
{
years0=TimeShiftYears; months0=TimeShiftMonths;
if (TimeShiftYears>0 || TimeShiftMonths>0) {
int year=0,month=0,week=0,day=0,hour=0,minute=0,second=0;
if (ModeTime==3) {
year=TimeComponentYear; month=TimeComponentYear; day=TimeComponentDay;
hour=TimeComponentHour; minute=TimeComponentMinute; second=TimeComponentSecond;
}
else {
year=TimeYear(retval); month=TimeMonth(retval); day=TimeDay(retval);
hour=TimeHour(retval); minute=TimeMinute(retval); second=TimeSeconds(retval);
}
year = year + TimeShiftYears * sh;
month = month + TimeShiftMonths * sh;
if (month<0) {month=12-month;}
else if (month>12) {month=month-12;}
retval = StringToTime(IntegerToString(year)+"."+IntegerToString(month)+"."+IntegerToString(day)+" "+IntegerToString(hour)+":"+IntegerToString(minute)+":"+IntegerToString(second));
}
}
retval = retval + TimeShiftWeeks*604800*sh+TimeShiftDays*86400*sh+TimeShiftHours*3600*sh+TimeShiftMinutes*60*sh+TimeShiftSeconds*sh;
if (TimeSkipWeekdays==true) {
int weekday=TimeDayOfWeek(retval);
if (sh>0) { // forward
if (weekday==0) {retval=retval+86400;}
else if (weekday==6) {retval=retval+172800;}
}
else if (sh<0) { // back
if (weekday==0) {retval=retval-172800;}
else if (weekday==6) {retval=retval-86400;}
}
}
}
smodeshift = ModeTimeShift;
ModeTime0 = ModeTime;
return (datetime)retval;
}
};
class Block0: public MDL_NoOpenedOrders<string,string,string,string,string>
{
public: /* Constructor */
Block0() {
__block_number = 0;
__block_user_number = "1";
_beforeExecuteEnabled = true;
int ___outbound_blocks[1] = {2};
ArrayCopy(__outbound_blocks, ___outbound_blocks);
BuysOrSells = "buys";
}
public: /* Callback & Run */
virtual void _callback_(int value) {
if (value == 1) {
_blocks_[2].run(0);
}
}
virtual void _beforeExecute_()
{
SYMBOL = CurrentSymbol();
}
};
class Block1: public MDL_NoOpenedOrders<string,string,string,string,string>
{
public: /* Constructor */
Block1() {
__block_number = 1;
__block_user_number = "2";
_beforeExecuteEnabled = true;
int ___outbound_blocks[1] = {3};
ArrayCopy(__outbound_blocks, ___outbound_blocks);
BuysOrSells = "sells";
}
public: /* Callback & Run */
virtual void _callback_(int value) {
if (value == 1) {
_blocks_[3].run(1);
}
}
virtual void _beforeExecute_()
{
SYMBOL = CurrentSymbol();
}
};
class Block2: public MDL_IndicatorIsVisible<MDLIC_myindicators_myindicators_1,double,int,int>
{
public: /* Constructor */
Block2() {
__block_number = 2;
__block_user_number = "3";
_beforeExecuteEnabled = true;
int ___outbound_blocks[1] = {4};
ArrayCopy(__outbound_blocks, ___outbound_blocks);
Indicator.SHIFT = 1;
}
public: /* Custom methods */
virtual double _Indicator_() {
Indicator.SYMBOL = CurrentSymbol();
Indicator.TIMEFRAME = CurrentTimeframe();
return Indicator._execute_();
}
public: /* Callback & Run */
virtual void _callback_(int value) {
if (value == 1) {
_blocks_[4].run(2);
}
}
virtual void _beforeExecute_()
{
/* Inputs, modified into the code must be set here every time */
Indicator.RangeCandleStart = 0;
Indicator.RangeCandleEnd = 10;
}
};
class Block3: public MDL_IndicatorIsVisible<MDLIC_myindicators_myindicators_2,double,int,int>
{
public: /* Constructor */
Block3() {
__block_number = 3;
__block_user_number = "4";
_beforeExecuteEnabled = true;
int ___outbound_blocks[1] = {5};
ArrayCopy(__outbound_blocks, ___outbound_blocks);
Indicator.SHIFT = 1;
}
public: /* Custom methods */
virtual double _Indicator_() {
Indicator.SYMBOL = CurrentSymbol();
Indicator.TIMEFRAME = CurrentTimeframe();
return Indicator._execute_();
}
public: /* Callback & Run */
virtual void _callback_(int value) {
if (value == 1) {
_blocks_[5].run(3);
}
}
virtual void _beforeExecute_()
{
/* Inputs, modified into the code must be set here every time */
Indicator.RangeCandleStart = 0;
Indicator.RangeCandleEnd = 10;
}
};
class Block4: public MDL_OncePerBar<string,ENUM_TIMEFRAMES,int>
{
public: /* Constructor */
Block4() {
__block_number = 4;
__block_user_number = "5";
_beforeExecuteEnabled = true;
int ___outbound_blocks[1] = {6};
ArrayCopy(__outbound_blocks, ___outbound_blocks);
}
public: /* Callback & Run */
virtual void _callback_(int value) {
if (value == 1) {
_blocks_[6].run(4);
}
}
virtual void _beforeExecute_()
{
SYMBOL = CurrentSymbol();
TIMEFRAME = CurrentTimeframe();
}
};
class Block5: public MDL_OncePerBar<string,ENUM_TIMEFRAMES,int>
{
public: /* Constructor */
Block5() {
__block_number = 5;
__block_user_number = "6";
_beforeExecuteEnabled = true;
int ___outbound_blocks[1] = {7};
ArrayCopy(__outbound_blocks, ___outbound_blocks);
}
public: /* Callback & Run */
virtual void _callback_(int value) {
if (value == 1) {
_blocks_[7].run(5);
}
}
virtual void _beforeExecute_()
{
SYMBOL = CurrentSymbol();
TIMEFRAME = CurrentTimeframe();
}
};
class Block6: public MDL_CloseOpened<string,string,string,string,string,int,double,color>
{
public: /* Constructor */
Block6() {
__block_number = 6;
__block_user_number = "7";
_beforeExecuteEnabled = true;
int ___outbound_blocks[1] = {8};
ArrayCopy(__outbound_blocks, ___outbound_blocks);
BuysOrSells = "sells";
}
public: /* Callback & Run */
virtual void _callback_(int value) {
if (value == 1) {
_blocks_[8].run(6);
}
}
virtual void _beforeExecute_()
{
SYMBOL = CurrentSymbol();
ArrowColor = DeepPink;
}
};
class Block7: public MDL_CloseOpened<string,string,string,string,string,int,double,color>
{
public: /* Constructor */
Block7() {
__block_number = 7;
__block_user_number = "8";
_beforeExecuteEnabled = true;
int ___outbound_blocks[1] = {9};
ArrayCopy(__outbound_blocks, ___outbound_blocks);
BuysOrSells = "buys";
}
public: /* Callback & Run */
virtual void _callback_(int value) {
if (value == 1) {
_blocks_[9].run(7);
}
}
virtual void _beforeExecute_()
{
SYMBOL = CurrentSymbol();
ArrowColor = DeepPink;
}
};
class Block8: public MDL_BuyNow<string,string,string,double,double,double,double,double,MDLIC_value_value,double,double,double,double,double,double,double,double,int,int,double,bool,double,double,bool,double,string,bool,double,string,string,bool,double,string,double,double,MDLIC_value_value,double,MDLIC_value_value,double,MDLIC_value_value,double,string,double,double,MDLIC_value_value,double,MDLIC_value_value,double,MDLIC_value_value,double,string,int,int,int,MDLIC_value_time,datetime,double,string,color>
{
public: /* Constructor */
Block8() {
__block_number = 8;
__block_user_number = "9";
_beforeExecuteEnabled = true;
dVolumeSize.Value = 0.1;
dpStopLoss.Value = 100;
ddStopLoss.Value = 0.01;
dpTakeProfit.Value = 100;
ddTakeProfit.Value = 0.01;
dExp.ModeTimeShift = 2;
dExp.TimeShiftDays = 1;
dExp.TimeSkipWeekdays = true;
}
public: /* Custom methods */
virtual double _dVolumeSize_() {return dVolumeSize._execute_();}
virtual double _dlStopLoss_() {return dlStopLoss._execute_();}
virtual double _dpStopLoss_() {return dpStopLoss._execute_();}
virtual double _ddStopLoss_() {return ddStopLoss._execute_();}
virtual double _dlTakeProfit_() {return dlTakeProfit._execute_();}
virtual double _dpTakeProfit_() {return dpTakeProfit._execute_();}
virtual double _ddTakeProfit_() {return ddTakeProfit._execute_();}
virtual datetime _dExp_() {return dExp._execute_();}
public: /* Callback & Run */
virtual void _callback_(int value) {
}
virtual void _beforeExecute_()
{
SYMBOL = CurrentSymbol();
VolumeSize = _externs::inp9_VolumeSize;
StopLossPips = _externs::inp9_StopLossPips;
TakeProfitPips = _externs::inp9_TakeProfitPips;
ArrowColorBuy = Blue;
}
};
class Block9: public MDL_SellNow<string,string,string,double,double,double,double,double,MDLIC_value_value,double,double,double,double,double,double,double,double,int,int,double,bool,double,double,bool,double,string,bool,double,string,string,bool,double,string,double,double,MDLIC_value_value,double,MDLIC_value_value,double,MDLIC_value_value,double,string,double,double,MDLIC_value_value,double,MDLIC_value_value,double,MDLIC_value_value,double,string,int,int,int,MDLIC_value_time,datetime,double,string,color>
{
public: /* Constructor */
Block9() {
__block_number = 9;
__block_user_number = "10";
_beforeExecuteEnabled = true;
dVolumeSize.Value = 0.1;
dpStopLoss.Value = 100;
ddStopLoss.Value = 0.01;
dpTakeProfit.Value = 100;
ddTakeProfit.Value = 0.01;
dExp.ModeTimeShift = 2;
dExp.TimeShiftDays = 1;
dExp.TimeSkipWeekdays = true;
}
public: /* Custom methods */
virtual double _dVolumeSize_() {return dVolumeSize._execute_();}
virtual double _dlStopLoss_() {return dlStopLoss._execute_();}
virtual double _dpStopLoss_() {return dpStopLoss._execute_();}
virtual double _ddStopLoss_() {return ddStopLoss._execute_();}
virtual double _dlTakeProfit_() {return dlTakeProfit._execute_();}
virtual double _dpTakeProfit_() {return dpTakeProfit._execute_();}
virtual double _ddTakeProfit_() {return ddTakeProfit._execute_();}
virtual datetime _dExp_() {return dExp._execute_();}
public: /* Callback & Run */
virtual void _callback_(int value) {
}
virtual void _beforeExecute_()
{
SYMBOL = CurrentSymbol();
VolumeSize = _externs::inp10_VolumeSize;
StopLossPips = _externs::inp10_StopLossPips;
TakeProfitPips = _externs::inp10_TakeProfitPips;
ArrowColorSell = Red;
}
};
/************************************************************************************************************************/
/************************************************************************************************************************/
double AccountBalanceAtStart()
{
static double memory=0;
if (memory==0) {memory=AccountBalance();}
return(memory);
}
double AlignLots(double lots, double lowerlots=0, double upperlots=0)
{
string symbol=GetSymbol();
double LotStep=MarketInfo(symbol,MODE_LOTSTEP);
double LotSize=MarketInfo(symbol,MODE_LOTSIZE);
double MinLots=MarketInfo(symbol,MODE_MINLOT);
double MaxLots=MarketInfo(symbol,MODE_MAXLOT);
double margin_required=MarketInfo(symbol,MODE_MARGINREQUIRED);
if (lots==EMPTY_VALUE) {lots=0;}
lots=MathRound(lots/LotStep)*LotStep;
if (lots<MinLots) {lots=MinLots;}
if (lots>MaxLots) {lots=MaxLots;}
if (lowerlots > 0)
{
lowerlots = MathRound(lowerlots/LotStep)*LotStep;
if (lots < lowerlots) {lots = lowerlots;}
}
if (upperlots > 0)
{
upperlots = MathRound(upperlots/LotStep)*LotStep;
if (lots > upperlots) {lots = upperlots;}
}
return (lots);
}
double AlignStopLoss(
string symbol,
int type,
double price,
double slo=0, // original sl, used when modifying
double sll=0,
double slp=0,
bool consider_freezelevel=false
)
{
double sl=0;
if (MathAbs(sll)==EMPTY_VALUE) {sll=0;}
if (MathAbs(slp)==EMPTY_VALUE) {slp=0;}
if (sll==0 && slp==0) {return(0);} // no sl - return 0
if (price<=0) {Print("AlignStopLoss() error: No price entered");return(-1);}
double point =MarketInfo(symbol,MODE_POINT);
int digits =(int)MarketInfo(symbol,MODE_DIGITS);
slp = slp*PipValue(symbol)*point;
int bs=1;
if (
type==OP_BUY
|| type==OP_BUYSTOP
|| type==OP_BUYLIMIT
)
{
bs=1;
}
else if (
type==OP_SELL
|| type==OP_SELLSTOP
|| type==OP_SELLLIMIT
)
{
bs=-1;
}
double askbid=price;
double bidask=price;
if (type==OP_BUY || type==OP_SELL)
{
double ask =MarketInfo(symbol,MODE_ASK);
double bid =MarketInfo(symbol,MODE_BID);
askbid=ask;
bidask=bid;
if (bs<0) {
askbid=bid;
bidask=ask;
}
}
if (sll==0 && slp!=0) {sll=price;}
if (sll>0) {sl=sll-slp*bs;}
if (sl<0) {return(-1);}
sl=NormalizeDouble(sl,digits);
slo = NormalizeDouble(slo,digits);
if (sl == slo) {return sl;}
double minstops=MarketInfo(symbol,MODE_STOPLEVEL);
if (consider_freezelevel==true) {
double freezelevel=MarketInfo(symbol,MODE_FREEZELEVEL);
if (freezelevel>minstops) {minstops=freezelevel;}
}
minstops=NormalizeDouble(minstops*point,digits);
double sllimit=bidask-minstops*bs; // SL min price level
if (sl>0) {
/*if (sl==askbid)
{
sl=0;
}
else */
if ((bs>0 && sl>askbid) || (bs<0 && sl<askbid))
{
string abstr="";
if (bs>0) {abstr="Bid";} else {abstr="Ask";}
Print(
"Error: Invalid SL requested (",
DoubleToStr(sl,digits),
" for ",abstr," price ",
bidask,
")"
);
return(-1);
}
else if ((bs>0 && sl>sllimit) || (bs<0 && sl<sllimit))
{
if (USE_VIRTUAL_STOPS) {
return(sl);
}
Print(
"Warning: Too short SL requested (",
DoubleToStr(sl,digits),
" or ",
DoubleToStr(MathAbs(sl-askbid)/point,0),
" points), minimum will be taken (",
DoubleToStr(sllimit,digits),
" or ",
DoubleToStr(MathAbs(askbid-sllimit)/point,0),
" points)"
);
sl=sllimit;
return(sl);
}
}
double ticksize = MarketInfo(symbol, MODE_TICKSIZE);
sl = MathRound(sl/ticksize)*ticksize;
return(sl);
}
double AlignTakeProfit(
string symbol,
int type,
double price,
double tpo=0, // original tp, used when modifying
double tpl=0,
double tpp=0,
bool consider_freezelevel=false
)
{
double tp=0;
if (MathAbs(tpl)==EMPTY_VALUE) {tpl=0;}
if (MathAbs(tpp)==EMPTY_VALUE) {tpp=0;}
if (tpl==0 && tpp==0) {return(0);} // no tp - return 0
if (price<=0) {Print("AlignTakeProfit() error: No price entered");return(-1);}
double point = MarketInfo(symbol,MODE_POINT);
int digits = (int)MarketInfo(symbol,MODE_DIGITS);
tpp=tpp*PipValue(symbol)*point;
int bs=1;
if (
type==OP_BUY
|| type==OP_BUYSTOP
|| type==OP_BUYLIMIT
)
{
bs=1;
}
else if (
type==OP_SELL
|| type==OP_SELLSTOP
|| type==OP_SELLLIMIT
)
{
bs=-1;
}
double askbid=price;
double bidask=price;
if (type==OP_BUY || type==OP_SELL)
{
double ask =MarketInfo(symbol,MODE_ASK);
double bid =MarketInfo(symbol,MODE_BID);
askbid=ask;
bidask=bid;
if (bs<0) {
askbid=bid;
bidask=ask;
}
}
if (tpl==0 && tpp!=0) {tpl=price;}
if (tpl>0) {tp=tpl+tpp*bs;}
if (tp<0) {return(-1);}
tp=NormalizeDouble(tp,digits);
tpo = NormalizeDouble(tpo,digits);
if (tp == tpo) {return tp;}
double minstops=MarketInfo(symbol,MODE_STOPLEVEL);
if (consider_freezelevel==true) {
double freezelevel=MarketInfo(symbol,MODE_FREEZELEVEL);
if (freezelevel>minstops) {minstops=freezelevel;}
}
minstops=NormalizeDouble(minstops*point,digits);
double tplimit=bidask+minstops*bs; // TP min price level
if (tp>0) {
/*if (tp==askbid)
{
tp=0;
}
else */
if ((bs>0 && tp<bidask) || (bs<0 && tp>bidask))
{
string abstr="";
if (bs>0) {abstr="Bid";} else {abstr="Ask";}
Print(
"Error: Invalid TP requested (",
DoubleToStr(tp,digits),
" for ",abstr," price ",
askbid,
")"
);
return(-1);
}
else if ((bs>0 && tp<tplimit) || (bs<0 && tp>tplimit))
{
if (USE_VIRTUAL_STOPS) {
return(tp);
}
Print(
"Warning: Too short TP requested (",
DoubleToStr(tp,digits),
" or ",
DoubleToStr(MathAbs(tp-askbid)/point,0),
" points), minimum will be taken (",
DoubleToStr(tplimit,digits),
" or ",
DoubleToStr(MathAbs(askbid-tplimit)/point,0),
" points)"
);
tp=tplimit;
return(tp);
}
}
double ticksize = MarketInfo(symbol, MODE_TICKSIZE);
tp = MathRound(tp/ticksize)*ticksize;
return(tp);
}
template<typename T>
int ArraySearch(T &array[], T value)
{
static int index;
static int size;
index = -1;
size = ArraySize(array);
for (int i=0; i<size; i++)
{
if (array[i] == value)
{
index = i;
break;
}
}
return index;
}
template<typename T>
bool ArrayStrip(T &array[], T value)
{
int x = 0;
int size = ArraySize(array);
for (int i=0; i<size; i++)
{
if (array[i] != value)
{
array[x] = array[i];
x++;
}
}
if (x < size)
{
ArrayResize(array, x);
return true; // stripped
}
return false; // not stripped
}
template<typename T>
bool ArrayStripKey(T &array[], int key)
{
int x = 0;
int size = ArraySize(array);
for (int i=0; i<size; i++)
{
if (i != key)
{
array[x] = array[i];
x++;
}
}
if (x < size)
{
ArrayResize(array, x);
return true; // stripped
}
return false; // not stripped
}
template<typename T>
bool ArrayValue(T &array[], T value)
{
int size = ArraySize(array);
if (size > 0)
{
if (InArray(array, value))
{
return false; // no value added
}
}
ArrayResize(array, size+1);
array[size] = value;
return true; // value added
}
double Bet1326(int group, string symbol, double initial_lots, bool reverse=false)
{
int pos=0;
int total=0;
double lots=0;
double profit=0;
int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
total=OrdersTotal();
for (pos=total-1; pos>=0; pos--)
{
if (!OrderSelect(pos, SELECT_BY_POS, MODE_TRADES)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
if (OrderExpiration() > 0 && OrderExpiration() <= OrderCloseTime()) {continue;} // no expired po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
if (lots==0)
{
total=OrdersHistoryTotal();
for (pos=total-1; pos>=0; pos--)
{
if(!OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (OrderType() > OP_SELL) {continue;} // no po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
}
if (initial_lots < MarketInfo(symbol,MODE_MINLOT)) {
initial_lots = MarketInfo(symbol,MODE_MINLOT);
}
if (lots==0) {lots = initial_lots;}
else
{
if ((reverse==false && profit_or_loss==1) || (reverse==true && profit_or_loss==-1))
{
double div = lots/initial_lots;
if (div < 1.5) {lots = initial_lots*3;}
else if (div < 2.5) {lots = initial_lots*6;}
else if (div < 3.5) {lots = initial_lots*2;}
else {lots = initial_lots;}
}
else {
lots = initial_lots;
}
}
return lots;
}
double BetDalembert(int group, string symbol, double initial_lots, double reverse=false)
{
int pos=0;
int total=0;
double lots=0;
double profit=0;
int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
total=OrdersTotal();
for (pos=total-1; pos>=0; pos--)
{
if (!OrderSelect(pos, SELECT_BY_POS, MODE_TRADES)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
if (OrderExpiration() > 0 && OrderExpiration() <= OrderCloseTime()) {continue;} // no expired po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
if (lots==0)
{
total=OrdersHistoryTotal();
for (pos=total-1; pos>=0; pos--)
{
if(!OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (OrderType() > OP_SELL) {continue;} // no po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
}
if (initial_lots < MarketInfo(symbol,MODE_MINLOT)) {
initial_lots = MarketInfo(symbol,MODE_MINLOT);
}
if (lots==0) {lots = initial_lots;}
else
{
if ((reverse==0 && profit_or_loss==1) || (reverse==1 && profit_or_loss==-1))
{
lots = lots - initial_lots;
if (lots < initial_lots) {lots = initial_lots;}
}
else {
lots = lots + initial_lots;
}
}
return lots;
}
double BetFibonacci(
int group,
string symbol,
double initial_lots
)
{
int pos=0;
int total=0;
double lots=0;
double profit=0;
int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
total=OrdersTotal();
for (pos=total-1; pos>=0; pos--)
{
if (!OrderSelect(pos, SELECT_BY_POS, MODE_TRADES)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
if (OrderExpiration() > 0 && OrderExpiration() <= OrderCloseTime()) {continue;} // no expired po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
if (lots==0)
{
total=OrdersHistoryTotal();
for (pos=total-1; pos>=0; pos--)
{
if(!OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (OrderType() > OP_SELL) {continue;} // no po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
}
if (initial_lots < MarketInfo(symbol,MODE_MINLOT)) {
initial_lots = MarketInfo(symbol,MODE_MINLOT);
}
if (lots==0) {lots = initial_lots;}
else
{
int fibo1=1, fibo2=0, fibo3=0, fibo4=0;
double div = lots/initial_lots;
if (div<=0) {div=1;}
while(true)
{
fibo1=fibo1+fibo2;
fibo3=fibo2;
fibo2=fibo1-fibo2;
fibo4=fibo2-fibo3;
if (fibo1 > NormalizeDouble(div, 2)) {break;}
}
if (profit_or_loss==1)
{
if (fibo4<=0) {fibo4=1;}
lots=initial_lots*(fibo4);
}
else {
lots=initial_lots*(fibo1);
}
}
lots=NormalizeDouble(lots, 2);
return lots;
}
double BetLabouchere(int group, string symbol, double initial_lots, string list_of_numbers, double reverse=false)
{
int pos=0;
int total=0;
double lots=0;
double profit=0;
int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
total=OrdersTotal();
for (pos=total-1; pos>=0; pos--)
{
if (!OrderSelect(pos, SELECT_BY_POS, MODE_TRADES)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
if (OrderExpiration() > 0 && OrderExpiration() <= OrderCloseTime()) {continue;} // no expired po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
if (lots==0)
{
total=OrdersHistoryTotal();
for (pos=total-1; pos>=0; pos--)
{
if(!OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (OrderType() > OP_SELL) {continue;} // no po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
}
static int mem_group[];
static string mem_list[];
static int mem_ticket[];
int start_again=false;
int id=ArraySearch(mem_group, group);
if (id == -1) {
start_again=true;
if (list_of_numbers=="") {list_of_numbers="1";}
id = ArraySize(mem_group);
ArrayResize(mem_group, id+1, id+1);
ArrayResize(mem_list, id+1, id+1);
ArrayResize(mem_ticket, id+1, id+1);
mem_group[id]=group;
mem_list[id]=list_of_numbers;
}
if (mem_ticket[id]==OrderTicket()) {
mem_list[id]=list_of_numbers;
}
mem_ticket[id]=OrderTicket();
int list[];
string listS[];
StringExplode(",", mem_list[id], listS);
ArrayResize(list, ArraySize(listS));
for (int s=0; s<ArraySize(listS); s++) {
list[s]=(int)StringToInteger(StringTrim(listS[s]));
}
int size = ArraySize(list);
if (initial_lots < MarketInfo(symbol,MODE_MINLOT)) {
initial_lots = MarketInfo(symbol,MODE_MINLOT);
}
if (lots==0) {
start_again=true;
}
if (start_again==true)
{
if (size==1) {
lots = initial_lots*list[0];
} else {
lots = initial_lots*(list[0]+list[size-1]);
}
}
else
{
if ((reverse==0 && profit_or_loss==1) || (reverse==1 && profit_or_loss==-1))
{
if (size==1) {
lots=initial_lots*list[0];
ArrayResize(list, 0);
}
else if (size==2) {
lots = initial_lots*(list[0]+list[1]);
ArrayResize(list, 0);
}
else if (size>2) {
lots = initial_lots*(list[0]+list[size-1]);
for(pos=0; pos<size-1; pos++) {
list[pos]=list[pos+1];
}
ArrayResize(list,ArraySize(list)-2); // remove last 2 elements
}
if (lots < initial_lots) {lots = initial_lots;}
}
else {
if (size>1)
{
ArrayResize(list, size+1);
list[size]=list[0]+list[size-1];
lots = initial_lots*(list[0]+list[size]);
} else {
lots = initial_lots*list[0];
}
if (lots < initial_lots) {lots = initial_lots;}
}
}
Print("Labouchere (for group "+(string)id+") current list of numbers:"+StringImplode(",", list));
size=ArraySize(list);
if (size==0) {
ArrayStripKey(mem_group, id);
ArrayStripKey(mem_list, id);
ArrayStripKey(mem_ticket, id);
} else {
mem_list[id]=StringImplode(",", list);
}
return lots;
}
double BetMartingale(
int group,
string symbol,
double initial_lots,
double multiply_on_loss,
double multiply_on_profit,
double add_on_loss,
double add_on_profit,
int reset_on_loss,
int reset_on_profit
)
{
int pos=0;
int total=0;
double lots=0;
double profit=0;
int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
int in_a_row=0;
total=OrdersTotal();
for (pos=total-1; pos>=0; pos--)
{
if (!OrderSelect(pos, SELECT_BY_POS, MODE_TRADES)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
if (OrderExpiration() > 0 && OrderExpiration() <= OrderCloseTime()) {continue;} // no expired po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit_or_loss == 0)
{
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
}
else {
if (profit_or_loss==1 && profit<0) {break;}
else if (profit_or_loss==-1 && profit>=0) {break;}
}
in_a_row++;
}
if (lots==0)
{
total=OrdersHistoryTotal();
for (pos=total-1; pos>=0; pos--)
{
if(!OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (OrderType() > OP_SELL) {continue;} // no po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit_or_loss == 0)
{
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
}
else {
if (profit_or_loss==1 && profit<0) {break;}
else if (profit_or_loss==-1 && profit>=0) {break;}
}
in_a_row++;
}
}
/*
if (initial_lots < MarketInfo(symbol,MODE_MINLOT)) {
initial_lots = MarketInfo(symbol,MODE_MINLOT);
}*/
if (lots==0) {lots = initial_lots;}
else {
if (profit_or_loss==1)
{
if (reset_on_profit>0 && in_a_row >= reset_on_profit) {
lots=initial_lots;
}
else {
if (multiply_on_profit<=0) {multiply_on_profit=1;}
lots=(lots*multiply_on_profit) + add_on_profit;
}
}
else {
if (reset_on_loss>0 && in_a_row >= reset_on_loss) {
lots=initial_lots;
}
else {
if (multiply_on_loss<=0) {multiply_on_loss=1;}
lots=(lots*multiply_on_loss) + add_on_loss;
}
}
}
return lots;
}
double BetSequence(int group, string symbol, double initial_lots, string sequence_on_loss, string sequence_on_profit, bool reverse=false)
{
int pos=0;
int total=0;
double lots=0;
int size=0;
double profit=0;
int profit_or_loss=0; // 0 - unknown, 1 - profit, -1 - loss
total=OrdersTotal();
for (pos=total-1; pos>=0; pos--)
{
if (!OrderSelect(pos, SELECT_BY_POS, MODE_TRADES)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (TimeCurrent() - OrderOpenTime() < 3) {continue;}
if (OrderExpiration() > 0 && OrderExpiration() <= OrderCloseTime()) {continue;} // no expired po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
if (lots==0)
{
total=OrdersHistoryTotal();
for (pos=total-1; pos>=0; pos--)
{
if(!OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY)) {continue;}
if (OrderMagicNumber() != MagicStart+group) {continue;}
if (OrderSymbol() != symbol) {continue;}
if (OrderType() > OP_SELL) {continue;} // no po
if (lots==0) {
lots=OrderLots();
}
profit = OrderClosePrice()-OrderOpenPrice();
profit = NormalizeDouble(profit, SymbolDigits(OrderSymbol()));
if (IsOrderTypeSell()) {profit = -1*profit;}
if (profit == 0) {
return(lots);
}
if (profit<0) {profit_or_loss=-1;}
else {profit_or_loss=1;}
break;
}
}
static int mem_group[];
static string mem_list_loss[];
static string mem_list_profit[];
static int mem_ticket[];
int id=ArraySearch(mem_group, group);
if (id == -1)
{
if (sequence_on_loss=="") {sequence_on_loss="1";}
if (sequence_on_profit=="") {sequence_on_profit="1";}
id = ArraySize(mem_group);
ArrayResize(mem_group, id+1, id+1);
ArrayResize(mem_list_loss, id+1, id+1);
ArrayResize(mem_list_profit, id+1, id+1);
ArrayResize(mem_ticket, id+1, id+1);
mem_group[id] =group;
mem_list_loss[id] =sequence_on_loss;
mem_list_profit[id] =sequence_on_profit;
}
bool loss_reset=false;
bool profit_reset=false;
if (profit_or_loss==-1 && mem_list_loss[id]=="") {
loss_reset=true;
mem_list_profit[id]="";
}
if (profit_or_loss==1 && mem_list_profit[id]=="") {
profit_reset=true;
mem_list_loss[id]="";
}
if (profit_or_loss==1 || mem_list_loss[id]=="") {
mem_list_loss[id]=sequence_on_loss;
if (loss_reset) {mem_list_loss[id]="1,"+mem_list_loss[id];}
}
if (profit_or_loss==-1 ||mem_list_profit[id]=="") {
mem_list_profit[id]=sequence_on_profit;
if (profit_reset) {mem_list_profit[id]="1,"+mem_list_profit[id];}
}
if (mem_ticket[id]==OrderTicket()) {
mem_list_loss[id]=sequence_on_loss;
mem_list_profit[id]=sequence_on_profit;
}
mem_ticket[id]=OrderTicket();
int s=0;
double list_loss[];
double list_profit[];
string listS[];
StringExplode(",", mem_list_loss[id], listS);
ArrayResize(list_loss, ArraySize(listS), ArraySize(listS));
for (s=0; s<ArraySize(listS); s++) {
list_loss[s]=(double)StringToDouble(StringTrim(listS[s]));
}
StringExplode(",", mem_list_profit[id], listS);
ArrayResize(list_profit, ArraySize(listS), ArraySize(listS));
for (s=0; s<ArraySize(listS); s++) {
list_profit[s]=(double)StringToDouble(StringTrim(listS[s]));
}
if (initial_lots < MarketInfo(symbol,MODE_MINLOT)) {
initial_lots = MarketInfo(symbol,MODE_MINLOT);
}
if (lots==0) {lots = initial_lots;}
else
{
if ((reverse==false && profit_or_loss==1) || (reverse==true && profit_or_loss==-1))
{
lots = initial_lots*list_profit[0];
size=ArraySize(list_profit);
for(pos=0; pos<size-1; pos++) {
list_profit[pos]=list_profit[pos+1];
}
if (size>0) {
ArrayResize(list_profit, size-1, size-1);
mem_list_profit[id]=StringImplode(",", list_profit);
}
}
else {
lots = initial_lots*list_loss[0];
size=ArraySize(list_loss);
for(pos=0; pos<size-1; pos++) {
list_loss[pos]=list_loss[pos+1];
}
if (size>0) {
ArrayResize(list_loss, size-1, size-1);
mem_list_loss[id]=StringImplode(",", list_loss);
}
}
}
return lots;
}
int BuyNow(
string symbol,
double lots,
double sll,
double tpl,
double slp,
double tpp,
double slippage=0,
int magic=0,
string comment="",
color arrowcolor=CLR_NONE,
datetime expiration = 0
)
{
int ticket=OrderCreate(
symbol,
OP_BUY,
lots,
0,
sll,
tpl,
slp,
tpp,
slippage,
magic,
comment,
arrowcolor,
expiration
);
return(ticket);
}
int CheckForTradingError(int error_code=-1, string msg_prefix="")
{
if (error_code<0) {
error_code=GetLastError();
}
int retval=0;
static int tryouts=0;
switch(error_code)
{
case 0:
retval=0;
break;
case 1: // No error returned
RefreshRates();
retval=1;
break;
case 4: //ERR_SERVER_BUSY
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Retrying.."));}
Sleep(1000);
RefreshRates();
retval=1;
break;
case 6: //ERR_NO_CONNECTION
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Retrying.."));}
while(!IsConnected()) {Sleep(100);}
while(IsTradeContextBusy()) {Sleep(50);}
RefreshRates();
retval=1;
break;
case 128: //ERR_TRADE_TIMEOUT
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Retrying.."));}
RefreshRates();
retval=1;
break;
case 129: //ERR_INVALID_PRICE
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Retrying.."));}
if (!IsTesting()) {while(RefreshRates()==false) {Sleep(1);}}
retval=1;
break;
case 130: //ERR_INVALID_STOPS
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Waiting for a new tick to retry.."));}
if (!IsTesting()) {while(RefreshRates()==false) {Sleep(1);}}
retval=1;
break;
case 135: //ERR_PRICE_CHANGED
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Waiting for a new tick to retry.."));}
if (!IsTesting()) {while(RefreshRates()==false) {Sleep(1);}}
retval=1;
break;
case 136: //ERR_OFF_QUOTES
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Waiting for a new tick to retry.."));}
if (!IsTesting()) {while(RefreshRates()==false) {Sleep(1);}}
retval=1;
break;
case 137: //ERR_BROKER_BUSY
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Retrying.."));}
Sleep(1000);
retval=1;
break;
case 138: //ERR_REQUOTE
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Waiting for a new tick to retry.."));}
if (!IsTesting()) {while(RefreshRates()==false) {Sleep(1);}}
retval=1;
break;
case 142: //This code should be processed in the same way as error 128.
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Retrying.."));}
RefreshRates();
retval=1;
break;
case 143: //This code should be processed in the same way as error 128.
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Retrying.."));}
RefreshRates();
retval=1;
break;
/*case 145: //ERR_TRADE_MODIFY_DENIED
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Waiting for a new tick to retry.."));}
while(RefreshRates()==false) {Sleep(1);}
return(1);
*/
case 146: //ERR_TRADE_CONTEXT_BUSY
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code),". Retrying.."));}
while(IsTradeContextBusy()) {Sleep(50);}
RefreshRates();
retval=1;
break;
default:
if (msg_prefix!="") {Print(StringConcatenate(msg_prefix,": ",ErrorMessage(error_code)));}
retval=2;
break;
}
if (retval==0) {tryouts=0;}
else if (retval==1) {
tryouts++;
if (tryouts>=10) {
tryouts=0;
retval=2;
} else {
Print("retry #"+(string)tryouts+" of 10");
}
}
return(retval);
}
bool CloseTrade(int ticket, double slippage=0, color arrowcolor=CLR_NONE)
{
bool success=false;
if (!OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {return(false);}
while(true)
{
WaitTradeContextIfBusy();
success=OrderClose(ticket,attrLots(),attrClosePrice(),(int)(slippage*PipValue(attrSymbol())),arrowcolor);
if (success==true) {
if (USE_VIRTUAL_STOPS) {
VirtualStopsDriver("clear",ticket);
}
RegisterEvent("trade");
return(true);
}
int erraction=CheckForTradingError(GetLastError(), "Closing trade #"+(string)ticket+" error");
switch(erraction)
{
case 0: break; // no error
case 1: continue; // overcomable error
case 2: break; // fatal error
}
break;
}
return(false);
}
string CurrentSymbol(string symbol="")
{
static string memory="";
if (symbol!="") {memory=symbol;} else
if (memory=="") {memory=Symbol();}
return(memory);
}
ENUM_TIMEFRAMES CurrentTimeframe(ENUM_TIMEFRAMES tf=-1)
{
static ENUM_TIMEFRAMES memory=0;
if (tf>=0) {memory=tf;}
return(memory);
}
bool DeleteOrder(int ticket, color arrowcolor)
{
bool success=false;
if (!OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {return(false);}
while(true)
{
WaitTradeContextIfBusy();
success=OrderDelete(ticket,arrowcolor);
if (success==true) {
if (USE_VIRTUAL_STOPS) {
VirtualStopsDriver("clear",ticket);
}
RegisterEvent("trade");
return(true);
}
int erraction=CheckForTradingError(GetLastError(), "Deleting order #"+(string)ticket+" error");
switch(erraction)
{
case 0: break; // no error
case 1: continue; // overcomable error
case 2: break; // fatal error
}
break;
}
return(false);
}
void DrawSpreadInfo()
{
static bool allow_draw = true;
if (allow_draw==false) {return;}
if (MQLInfoInteger(MQL_TESTER) && !MQLInfoInteger(MQL_VISUAL_MODE)) {allow_draw=false;} // Allowed to draw only once in testing mode
static bool passed = false;
static double max_spread = 0;
static double min_spread = EMPTY_VALUE;
static double avg_spread = 0;
static double avg_add = 0;
static double avg_cnt = 0;
double custom_point = CustomPoint(Symbol());
double current_spread = 0;
if (custom_point > 0) {
current_spread = (SymbolInfoDouble(Symbol(),SYMBOL_ASK)-SymbolInfoDouble(Symbol(),SYMBOL_BID))/custom_point;
}
if (current_spread > max_spread) {max_spread = current_spread;}
if (current_spread < min_spread) {min_spread = current_spread;}
avg_cnt++;
avg_add = avg_add + current_spread;
avg_spread = avg_add / avg_cnt;
int x=0; int y=0;
string name;
if (passed == false)
{
passed=true;
name="fxd_spread_current_label";
if (ObjectFind(0, name)==-1) {
ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+1);
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+1);
ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 18);
ObjectSetInteger(0, name, OBJPROP_COLOR, clrDarkOrange);
ObjectSetString(0, name, OBJPROP_FONT, "Arial");
ObjectSetString(0, name, OBJPROP_TEXT, "Spread:");
}
name="fxd_spread_max_label";
if (ObjectFind(0, name)==-1) {
ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+148);
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+17);
ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 7);
ObjectSetInteger(0, name, OBJPROP_COLOR, clrOrangeRed);
ObjectSetString(0, name, OBJPROP_FONT, "Arial");
ObjectSetString(0, name, OBJPROP_TEXT, "max:");
}
name="fxd_spread_avg_label";
if (ObjectFind(0, name)==-1) {
ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+148);
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y+9);
ObjectSetInteger(0, name, OBJPROP_CORNER, CORNER_LEFT_LOWER);
ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER);
ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 7);
ObjectSetInteger(0, name, OBJPROP_COLOR, clrDarkOrange);
ObjectSetString(0, name, OBJPROP_FONT, "Arial");
ObjectSetString(0, name, OBJPROP_TEXT, "avg:");
}
name="fxd_spread_min_label";
if (ObjectFind(0, name)==-1) {
ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x+148);
ObjectSetInteger(0, name, OBJPROP_YПоказано первые 50% кода (символов: 136687)
Открыть по тарифу
Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.
Разовая покупка файла
На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.
Зачем нужен email? После подтверждения оплаты файл сохранится в кабинете на этот email. Если аккаунта ещё нет, мы создадим его и пришлём ссылку для задания пароля. Если аккаунт уже есть, покупка добавится в него. Укажите адрес, к которому у вас есть доступ.
Чтобы оформить заказ, введите email и перейдите к оплате.