
double low=Low[1];
double high=High[1];
и ты не знаешь как вставить функцию вызова онТестер в командную строку онТикА зачем мне это знать, если прямая обязанность функции OnTester() в языке mql4 в другом, а не в том, в чем вы придумали
//+------------------------------------------------------------------+
//| EA_simple_MA.mq4 |
//| Oxy |
//| http://oxy.opentraders.ru/bio/ |
//+------------------------------------------------------------------+
#property copyright "Oxy"
#property link "http://oxy.opentraders.ru/bio/"
#property version "1.00"
#property strict
//------- external parameters ---------------------------------------+
extern int MA_period = 36; // MA период
extern ENUM_MA_METHOD MA_method = MODE_SMA; // MA метод усреднения
extern ENUM_APPLIED_PRICE MA_app_price = PRICE_CLOSE; // MA тип цены
extern double Lot = 0.1; // Лот
extern int StopLoss = 200; // Stop Loss, 0 - без
extern int TakeProfit = 200; // Take Profit, 0 - без
extern int MagicNumber = 1; // Magic
extern int Slippage = 30; // Slippage
//------- global variables ------------------------------------------+
datetime prevTime = 0;
int NUM_OpenPos = 0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
double OnTester()
{
// Здесь мы произведем расчеты по окончании тестирования, если надо
// НО в данном случае мы просто в тестере вернем количество открытых позиций
return(NUM_OpenPos);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(HaveAnyOpenPosition()) {prevTime=Time[0]; return;}
if(prevTime==Time[0]) return;
double _ma = iMA(Symbol(), 0, MA_period, 0, MA_method, MA_app_price, 0);
if(Open[0]<_ma && Bid>_ma) { // BUY
if(BuyPosition(Lot, StopLoss, TakeProfit)) NUM_OpenPos++;
}
if(Open[0]>_ma && Ask<_ma) { // SELL
if(SellPosition(Lot, StopLoss, TakeProfit)) NUM_OpenPos++;
}
}
//+------------------------------------------------------------------+
bool HaveAnyOpenPosition() {
int i, k = OrdersTotal ();
for (i=k-1; i>=0; i--) {
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) {
if(OrderType()==OP_BUY || OrderType()==OP_SELL) return (true);
}
}
}
return (false);
}
//+------------------------------------------------------------------+
//| BUY |
//+------------------------------------------------------------------+
bool BuyPosition(double _lot, int _sl=0, int _tp=0, string _comment=NULL) {
double sl=0,tp=0;
RefreshRates();
if(_sl>0) sl=Ask-(double)_sl*Point;
if(_tp>0) tp=Ask+(double)_tp*Point;
if (OrderSend(Symbol(), OP_BUY, _lot, NormalizeDouble(Ask,Digits), Slippage, NormalizeDouble(sl,Digits), NormalizeDouble(tp,Digits), _comment, MagicNumber)==-1) {
Print("Failed OP_BUY !"); return(false);
}
return(true);
}
//+------------------------------------------------------------------+
//| SELL |
//+------------------------------------------------------------------+
bool SellPosition(double _lot, int _sl=0, int _tp=0, string _comment=NULL) {
double sl=0,tp=0;
RefreshRates();
if(_sl>0) sl=Bid+(double)_sl*Point;
if(_tp>0) tp=Bid-(double)_tp*Point;
if (OrderSend(Symbol(), OP_SELL, _lot, NormalizeDouble(Bid,Digits), Slippage, NormalizeDouble(sl,Digits), NormalizeDouble(tp,Digits), _comment, MagicNumber)==-1) {
Print("Failed OP_SELL !"); return(false);
}
return(true);
}
//+------------------------------------------------------------------+
Oxy