Errors, bugs, questions - page 809

 

Going back to the issue of determining stoplosses and takeprofits in the OnTradeTransaction event. I have the following log outputting all fields of the structures (taken from MetaQuotes example), and this is no longer a tester but an online contest. Here we have a buy:

ON 0 transactions (EURUSD,H1) 11:14:23 OrderSendWrapper:0.10 EURUSD BUY JK 0 transactions (EURUSD,H1) 11:14:23 _OrderSend price=1.23575 vol=0.10 GM 0 transactions (EURUSD,H1) 11:14:24 TRADE_TRANSACTION_REQUEST OH 0 transactions (EURUSD,H1) 11:14:24 ------------RequestDescription PK 0 transactions (EURUSD,H1) 11:14:24 TRADE_ACTION_DEAL DJ 0 transactions (EURUSD,H1) 11:14:24 Symbol: EURUSD FN 0 transactions (EURUSD,H1) 11:14:24 Magic Number: 0 PD 0 transactions (EURUSD,H1) 11:14:24 Order ticket: 11670896 PL 0 transactions (EURUSD,H1) 11:14:24 Order type: ORDER_TYPE_BUY JF 0 transactions (EURUSD,H1) 11:14:24 Order filling: ORDER_FILLING_FOK FM 0 transactions (EURUSD,H1) 11:14:24 Order time type: ORDER_TIME_GTC NG 0 transactions (EURUSD,H1) 11:14:24 Order expiration: 1970.01.01 00:00:00 HI 0 transactions (EURUSD,H1) 11:14:24 Price: 1.23579 EG 0 transactions (EURUSD,H1) 11:14:24 Deviation points: 10 DR 0 transactions (EURUSD,H1) 11:14:24 Stop Loss: 1.2354 PJ 0 transactions (EURUSD,H1) 11:14:24 Take Profit: 1.2361 ON 0 transactions (EURUSD,H1) 11:14:24 Stop Limit: 0 MK 0 transactions (EURUSD,H1) 11:14:24 Volume: 0.1 IQ 0 transactions (EURUSD,H1) 11:14:24 Comment: FG 0 transactions (EURUSD,H1) 11:14:24 MF 0 transactions (EURUSD,H1) 11:14:24 ------------ResultDescription JL 0 transactions (EURUSD,H1) 11:14:24 Retcode 10009 ME 0 transactions (EURUSD,H1) 11:14:24 Request ID: 1 RL 0 transactions (EURUSD,H1) 11:14:24 Order ticket: 11670896 NK 0 transactions (EURUSD,H1) 11:14:24 Deal ticket: 10809619 QS 0 transactions (EURUSD,H1) 11:14:24 Volume: 0.1 LJ 0 transactions (EURUSD,H1) 11:14:24 Price: 1.23579 RR 0 transactions (EURUSD,H1) 11:14:24 Ask: 1.23579 PI 0 transactions (EURUSD,H1) 11:14:24 Bid: 1.23566 GE 0 transactions (EURUSD,H1) 11:14:24 Comment: DS 0 transactions (EURUSD,H1) 11:14:24 GE 0 transactions (EURUSD,H1) 11:14:24 Pending Order Ticket 11670896 LR 0 transactions (EURUSD,H1) 1114:24 LG 0 transactions (EURUSD,H1) 11:14:24 ------------TransactionDescription FQ 0 transactions (EURUSD,H1) 11:14:24 TRADE_TRANSACTION_ORDER_ADD HF 0 transactions (EURUSD,H1) 11:14:24 Symbol: EURUSD HM 0 transactions (EURUSD,H1) 11:14:24 Deal ticket: 0 DK 0 transactions (EURUSD,H1) 11:14:24 Deal type: DEAL_TYPE_BUY DQ 0 transactions (EURUSD,H1) 11:14:24 Order ticket: 11670896 DI 0 transactions (EURUSD,H1) 11:14:2424 Order type: ORDER_TYPE_BUY CR 0 transactions (EURUSD,H1) 11:14:24 Order state: ORDER_STATE_STARTED RI 0 transactions (EURUSD,H1) 11:14:24 Order time type: ORDER_TIME_GTC JS 0 transactions (EURUSD,H1) 11:14:24 Order expiration: 1970.01.01 00:00 DE 0 transactions (EURUSD,H1) 11:14:24 Price: 1.23579 QN 0 transactions (EURUSD,H1) 11:14:24 Price trigger: 0 PG 0 transactions (EURUSD,H1) 11:14:24 Stop Loss: 1.2354 LM 0 transactions (EURUSD,H1) 11:14:24 Take Profit: 1.2361 EF 0 transactions (EURUSD,H1) 11:14:24 Volume: 0.1 JI 0 transactions (EURUSD,H1) 11:14:24 NS 0 transactions (EURUSD,H1) 11:14:24 ------------TransactionDescription HH 0 transactions (EURUSD,H1) 11:14:24 TRADE_TRANSACTION_ORDER_DELETE DR 0 transactions (EURUSD,H1) 11:14:24 Symbol: EURUSD LJ 0 transactions (EURUSD,H1) 11:14:24 Deal ticket: 0 PN 0 transactions (EURUSD,H1) 11:14:24 Deal type: DEAL_TYPE_BUY PD 0 transactions (EURUSD,H1) 11:14:24 Order ticket: 11670896 PL 0 transactions (EURUSD,H1) 11:14:24 Order type: ORDER_TYPE_BUY NJ 0 transactions (EURUSD,H1) 11:11:14:24 Order state: ORDER_STATE_FILLED PM 0 transactions (EURUSD,H1) 11:14:24 Order time type: ORDER_TIME_GTC HG 0 transactions (EURUSD,H1) 11:14:24 Order expiration: 1970.01.01 00:00 JI 0 transactions (EURUSD,H1) 11:14:24 Price: 1.23579 OJ 0 transactions (EURUSD,H1) 11:14:24 Price trigger: 0 NS 0 transactions (EURUSD,H1) 11:14:24 Stop Loss: 1.2354 JJ 0 transactions (EURUSD,H1) 11:14:24 Take Profit: 1.2361 FS 0 transactions (EURUSD,H1) 11:14:24 Volume: 0 HE 0 transactions (EURUSD,H1) 11:14:24 HN 0 transactions (EURUSD,H1) 11:14:24 ------------TransactionDescription FI 0 transactions (EURUSD,H1) 11:14:24 TRADE_TRANSACTION_HISTORY_ADD HN 0 transactions (EURUSD,H1) 11:14:24 Symbol: EURUSD HE 0 transactions (EURUSD,H1) 11:14:24 Deal ticket: 0 DS 0 transactions (EURUSD,H1) 11:11:14:24 Deal type: DEAL_TYPE_BUY DI 0 transactions (EURUSD,H1) 11:14:24 Order ticket: 11670896 DQ 0 transactions (EURUSD,H1) 11:14:24 Order type: ORDER_TYPE_BUY RF 0 transactions (EURUSD,H1) 1114:24 Order state: ORDER_STATE_FILLED LQ 0 transactions (EURUSD,H1) 11:14:24 Order time type: ORDER_TIME_GTC DK 0 transactions (EURUSD,H1) 11:14:24 Order expiration: 1970.01.01 00:00 FM 0 transactions (EURUSD,H1) 11:14:24 Price: 1.23579 CF 0 transactions (EURUSD,H1) 11:14:24 Price trigger: 0 RO 0 transactions (EURUSD,H1) 11:14:24 Stop Loss: 1.2354 NE 0 transactions (EURUSD,H1) 11:14:24 Take Profit: 1.2361 RO 0 transactions (EURUSD,H1) 11:14:24 Volume: 0 DQ 0 transactions (EURUSD,H1) 11:14:24 DJ 0 transactions (EURUSD,H1) 11:14:24 ------------TransactionDescription LQ 0 transactions (EURUSD,H1) 11:14:24 TRADE_TRANSACTION_DEAL_ADD FK 0 transactions (EURUSD,H1) 11:14:24 Symbol: EURUSD DR 0 transactions (EURUSD,H1) 11:14:24 Deal ticket: 10809619 PF 0 transactions (EURUSD,H1) 11:14:24 Deal type: DEAL_TYPE_BUY PL 0 transactions (EURUSD,H1) 11:14:24 Order ticket: 11670896 PD 0 transactions (EURUSD,H1) 11:14:24 Order type: ORDER_TYPE_BUY GN 0 transactions (EURUSD,H1) 11:11:14:24 Order state: ORDER_STATE_STARTED FE 0 transactions (EURUSD,H1) 11:14:24 Order time type: ORDER_TIME_GTC NO 0 transactions (EURUSD,H1) 11:14:24 Order expiration: 1970.01.01 00:00:00 HQ 0 transactions (EURUSD,H1) 11:14:24 Price: 1.23579 MR 0 transactions (EURUSD,H1) 11:14:24 Price trigger: 0 LK 0 transactions (EURUSD,H1) 11:14:24 Stop Loss: 1.2354 HR 0 transactions (EURUSD,H1) 11:14:24 Take Profit: 1.2361 QJ 0 transactions (EURUSD,H1) 11:14:24 Volume: 0.1 NR 0 transactions (EURUSD,H1) 11:14:24

And here it closes on Take Profit:

DJ 0 transactions (EURUSD,H1) 11:20:38 ------------TransactionDescription JN 0 transactions (EURUSD,H1) 11:20:38 TRADE_TRANSACTION_ORDER_ADD DH 0 transactions (EURUSD,H1) 11:20:38 Symbol: EURUSD PP 0 transactions (EURUSD,H1) 11:20:38 Deal ticket: 0 PH 0 transactions (EURUSD,H1) 11:20:38 Deal type: DEAL_TYPE_BUY LR 0 transactions (EURUSD,H1)20:38 Order ticket: 11670968 HG 0 transactions (EURUSD,H1) 11:20:38 Order type: ORDER_TYPE_SELL MO 0 transactions (EURUSD,H1) 11:20:38 Order state: ORDER_STATE_STARTED HF 0 transactions (EURUSD,H1) 11:20:38 Order time type: ORDER_TIME_GTC PN 0 transactions (EURUSD,H1) 11:20:38 Order expiration: 1970.01.01 00:00:00 JE 0 transactions (EURUSD,H1) 11:20:38 Price: 1.2361 MS 0 transactions (EURUSD,H1) 11:20:38 Price trigger: 0 MJ 0 transactions (EURUSD,H1) 11:20:38 Stop Loss: 0 IR 0 transactions (EURUSD,H1) 11:20:38 Take Profit: 0 QD 0 transactions (EURUSD,H1) 11:20:38 Volume: 0.1 NO 0 transactions (EURUSD,H1) 11:20:38 NP 0 transactions (EURUSD,H1) 11:20:38 ------------TransactionDescription LN 0 transactions (EURUSD,H1) 11:20:38 TRADE_TRANSACTION_ORDER_DELETE DE 0 transactions (EURUSD,H1) 11:20:38 Symbol: EURUSD PK 0 transactions (EURUSD,H1) 11:20:38 Deal ticket: 0 PM 0 transactions (EURUSD,H1) 11:20:38 Deal type: DEAL_TYPE_BUY LG 0 transactions (EURUSD,H1) 11:20:38 Order ticket: 11670968 HR 0 transactions (EURUSD,H1) 11:20:38 Order type: ORDER_TYPE_SELL HH 0 transactions (EURUSD,H1) 11:20:38 Order state: ORDER_STATE_FILLED FK 0 transactions (EURUSD,H1) 11:20:38 Order time type: ORDER_TIME_GTC NQ 0 transactions (EURUSD,H1) 11:20:38 Order expiration: 1970.01.01 00:00:00 HH 0 transactions (EURUSD,H1) 11:20:38 Price: 1.2361 KL 0 transactions (EURUSD,H1) 11:20:38 Price trigger: 0 GG 0 transactions (EURUSD,H1) 11:20:38 Stop Loss: 0 GI 0 transactions (EURUSD,H1) 11:20:38 Take Profit: 0 RS 0 transactions (EURUSD,H1) 11:20:38 Volume: 0 DJ 0 transactions (EURUSD,H1) 11:20:38 HO 0 transactions (EURUSD,H1) 11:20:38 ------------TransactionDescription JI 0 transactions (EURUSD,H1) 11:20:38 TRADE_TRANSACTION_HISTORY_ADD LN 0 transactions (EURUSD,H1) 11:20:38 Symbol: EURUSD HF 0 transactions (EURUSD,H1) 11:20:38 Deal ticket: 0 HR 0 transactions (EURUSD,H1) 11:20:38 Deal type: DEAL_TYPE_BUY DH 0 transactions (EURUSD,H1) 11:20:38 Order ticket: 11670968 PM 0 transactions (EURUSD,H1) 11:20:3838 Order type: ORDER_TYPE_SELL PF 0 transactions (EURUSD,H1) 11:20:38 Order state: ORDER_STATE_FILLED NQ 0 transactions (EURUSD,H1) 11:20:38 Order time type: ORDER_TIME_GTC FK 0 transactions (EURUSD,H1) 11:20:38 Order expiration: 1970.01.01 00:00 PO 0 transactions (EURUSD,H1) 11:20:38 Price: 1.2361 CF 0 transactions (EURUSD,H1) 11:20:38 Price trigger: 0 OM 0 transactions (EURUSD,H1) 11:20:38 Stop Loss: 0 OG 0 transactions (EURUSD,H1) 11:20:38 Take Profit: 0 JN 0 transactions (EURUSD,H1) 11:20:38 Volume: 0 LP 0 transactions (EURUSD,H1) 11:20:38 PE 0 transactions (EURUSD,H1) 11:20:38 ------------TransactionDescription MR 0 transactions (EURUSD,H1) 11:20:38 TRADE_TRANSACTION_POSITION JH 0 transactions (EURUSD,H1) 11:20:38 Symbol: EURUSD JP 0 transactions (EURUSD,H1) 11:20:38 Deal ticket: 0 FH 0 transactions (EURUSD,H1) 11:20:38 Deal type: DEAL_TYPE_BUY HQ 0 transactions (EURUSD,H1) 11:20:38 Order ticket: 0 DK 0 transactions (EURUSD,H1) 11:20:38 Order type: ORDER_TYPE_BUY GQ 0 transactions (EURUSD,H1) 11:20:38 Order state: ORDER_STATE_STARTED RH 0 transactions (EURUSD,H1) 11:20:38 Order time type: ORDER_TIME_GTC JL 0 transactions (EURUSD,H1) 11:20:38 Order expiration: 1970.01.01 00:00:00 HG 0 transactions (EURUSD,H1) 11:20:38 Price: 1.23579 QP 0 transactions (EURUSD,H1) 11:20:38 Price trigger: 0 LI 0 transactions (EURUSD,H1) 11:20:38 Stop Loss: 1.2354 HO 0 transactions (EURUSD,H1) 11:20:38 Take Profit: 1.2361 QD 0 transactions (EURUSD,H1) 11:20:38 Volume: 0.1 NO 0 transactions (EURUSD,H1) 11:20:38 NP 0 transactions (EURUSD,H1) 11:20:38 ------------TransactionDescription FO 0 transactions (EURUSD,H1) 11:20:38 TRADE_TRANSACTION_DEAL_ADD LE 0 transactions (EURUSD,H1) 11:20:38 Symbol: EURUSD EH 0 transactions (EURUSD,H1) 11:20:38 Deal ticket: 10809689 RQ 0 transactions (EURUSD,H1) 11:20:38 Deal type: DEAL_TYPE_SELL DF 0 transactions (EURUSD,H1) 11:20:38 Order ticket: 11670968 HN 0 transactions (EURUSD,H1) 11:20:38 Order type: ORDER_TYPE_BUY CD 0 transactions (EURUSD,H1) 11:20:38 Order state: ORDER_STATE_STARTED NK 0 transactions (EURUSD,H1) 11:20:38 Order time type: ORDER_TIME_GTC FQ 0 transactions (EURUSD,H1) 11:20:38 Order expiration: 1970.01.01 00:00:00 PI 0 transactions (EURUSD,H1) 11:20:38 Price: 1.2361 CL 0 transactions (EURUSD,H1) 11:20:38 Price trigger: 0 OG 0 transactions (EURUSD,H1) 11:20:38 Stop Loss: 0 OI 0 transactions (EURUSD,H1) 11:20:38 Take Profit: 0 KQ 0 transactions (EURUSD,H1) 11:20:38 Volume: 0.1

The only thing that unites these transactions is price(close price equals the TP price). Question - is that the way to determine the fact of TP? Imho, inconvenient and ambiguous (if I remember correctly, the exact TP price may not happen and TP will be closed at the nearest other price).

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы - Документация по MQL5
 

Good afternoon! I apologise in advance, maybe I'm being obtuse, or I don't understand some obvious things. I'm trying to use iMA indicator, trying to write according to examples I've read.

In general, I try to do it this way. I declare at the top, above all functions of EA.

double      MA[];                // массив для индикатора iMA
//---- handles for indicators
int         MA_handle;           // указатель на индикатор iMA

Then I use a function that will work in OnTick() function. In the sample, the function itself is at the bottom. In fact, for now, I will use only the last-zero value of the array.

 if (EURNZD_d1 != 0.0) countq++;
      EURUSD_d1 = CalculateStrengthPairsTF("EURUSD"+dop_symb, PERIOD_D1);
      if (EURUSD_d1 != 0.0) countq++;
      EURCAD_d1 = CalculateStrengthPairsTF("EURCAD"+dop_symb, PERIOD_D1);
      if (EURCAD_d1 != 0.0) countq++;
      EURGBP_d1 = CalculateStrengthPairsTF("EURGBP"+dop_symb, PERIOD_D1);
      if (EURGBP_d1 != 0.0) countq++;
      EURAUD_d1 = CalculateStrengthPairsTF("EURAUD"+dop_symb, PERIOD_D1);
      if (EURAUD_d1 != 0.0) countq++;
      EURCHF_d1 = CalculateStrengthPairsTF("EURCHF"+dop_symb, PERIOD_D1);
      if (EURCHF_d1 != 0.0) countq++;
      if (countq != 0) D1_eur = NormalizeDouble((EURJPY_d1 + EURNZD_d1 + EURUSD_d1 + EURCAD_d1 + EURGBP_d1 + EURAUD_d1 + EURCHF_d1) / countq, 0);
   }
   int l_count_4 = 0;
   AVG_eur = 0;
   if (M1_eur != 0.0) l_count_4++;
   if (M5_eur != 0.0) l_count_4++;
   if (M15_eur != 0.0) l_count_4++;
   if (M30_eur != 0.0) l_count_4++;
   if (H1_eur != 0.0) l_count_4++;
   if (H4_eur != 0.0) l_count_4++;
   if (D1_eur != 0.0) l_count_4++;
   if (l_count_4 != 0) AVG_eur = (M1_eur + M5_eur + M15_eur + M30_eur + H1_eur + H4_eur + D1_eur) / l_count_4;
}

double CalculateStrengthPairsTF(string a_symbol, int a_timeframe) {
    int DIGITS_ = SymbolInfoInteger(a_symbol,SYMBOL_DIGITS);
   //---
    MqlTick last_tick;
   if(SymbolInfoTick(a_symbol,last_tick));
   double BID_ = last_tick.bid;
   BID_ = NormalizeDouble( BID_, DIGITS_);
    MA_handle=iMA(a_symbol,a_timeframe,Period_,0,method_ma,price_applied);
    //--- заполнение массива MA[] текущими значениями индикатора iMA
   //--- в массив будет записано 100 элементов
   CopyBuffer(MA_handle,0,0,100,MA);
   //--- задаём порядок индексации массива MA[] как в MQL4
   ArraySetAsSeries(MA,true);  
   double iMA_ = NormalizeDouble(MA[0], DIGITS_);

I will only use the last-zero-value.

Error 'a_timeframe' - can't convert enum Owl.mq5 2009 28

Regarding this imino variable, it's in the string-type instruction, you see it's glowing blue itself...

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - Документация по MQL5
 
Dimka-novitsek:

Writes error 'a_timeframe' - can't convert enum Owl.mq5 2009 28

Oblige it with type ENUM_TIMEFRAMES
 

Thank you!!! Is it the same as double, string or int? I don't understand, sorry, where do I put this type?

Alright, thanks!

 
Valmars:
This is purely a tester bug. Trans.price_tp field in case of TRADE_TRANSACTION_DEAL_ADD may contain 0 or any rubbish. On-line trading outputs everything correctly.
Thank you. Fixed. A fix will be available in the next build.
 
//+------------------------------------------------------------------+
//| cs2011.mq5 |
//| Copyright © 2011, Xupypr |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Xupypr"
#property version "1.1"
//+-----------------------------------+
input double Risk=3; // start lot
input int TP=2200;
input int SL=0;
input int Fast=30;
input int Slow=500;
input int Sign=36;
//+-----------------------------------+
int Money, Deposit=5000;
int MACD;
//+-----------------------------------+
void OnInit()
{
MACD=iMACD(NULL,0,Fast,Slow,Sign,PRICE_CLOSE);
}
//+-----------------------------------+
void OnTick()
{
static bool UpSignal,DnSignal;
if(TradeSignalCounter(UpSignal,DnSignal)) TradePerformer(UpSignal,DnSignal);
}
//+-----------------------------------+
bool TradeSignalCounter(bool &UpSignal,bool &DnSignal)
{
if(Bars(_Symbol,0)<100) return(false);
static int Recount;
if(IsNewBar() || Recount)
{
double Ind[2],Sig[3];
DnSignal=false;
UpSignal=false;
Recount=false;
if(CopyBuffer(MACD,0,1,2,Ind)<0) Recount=true;
if(CopyBuffer(MACD,1,1,3,Sig)<0) Recount=true;
if(Recount==true) return(false);
if(Ind[0]>0 && Ind[1]<0) DnSignal=true;
if(Ind[0]<0 && Ind[1]>0) UpSignal=true;
if(Ind[1]<0 && Sig[0]<Sig[1] && Sig[1]>Sig[2]) DnSignal=true;
if(Ind[1]>0 && Sig[0]>Sig[1] && Sig[1]<Sig[2]) UpSignal=true;
return(true);
}
return(false);
}
//+-----------------------------------+
bool TradePerformer(bool &UpSignal,bool &DnSignal)
{
if(UpSignal)
{
if(PositionOpen(POSITION_TYPE_BUY)) UpSignal=false;
}
if(DnSignal)
{
if(PositionOpen(POSITION_TYPE_SELL)) DnSignal=false;
}
return(true);
}
//+-----------------------------------+
double Money_M()
{
HistorySelect(0,TimeCurrent());
int total=HistoryDealsTotal();
double profit=0;
for(int i=0;i<total;i++)
{
ulong deal_ticket=HistoryDealGetTicket(i);
if(HistoryDealGetString(deal_ticket,DEAL_SYMBOL)!=_Symbol) continue;
if(HistoryDealGetInteger(deal_ticket,DEAL_TYPE)>1) continue;
profit+=HistoryDealGetDouble(deal_ticket,DEAL_PROFIT);
profit+=HistoryDealGetDouble(deal_ticket,DEAL_SWAP);
}
Money=Deposit+profit;
if(PositionSelect(_Symbol))
{
Money+=PositionGetDouble(POSITION_PROFIT);
Money+=PositionGetDouble(POSITION_SWAP);
}
double Min=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
double Limit=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_LIMIT);
double Lots=Risk*Money/Deposit;
Lots=MathMin(Limit,MathMax(Min,Lots));
return(Lots);
}
//+-----------------------------------+
bool PositionOpen(ENUM_POSITION_TYPE Type)
{
MqlTradeRequest request;
MqlTradeResult result;
double volume=Money_M();
double takeprofit=0,stoploss=0;
if(PositionSelect(_Symbol))
{
double volumepos=PositionGetDouble(POSITION_VOLUME);
if(PositionGetInteger(POSITION_TYPE)==Type) volume-=volumepos;
else volume+=volumepos;
}
for(int i=0;i<10;i++)
{
volume=NormalizeDouble(volume,1);
if(volume<=0) break;
if(Type==POSITION_TYPE_SELL)
{
request.type=ORDER_TYPE_SELL;
request.price=SymbolInfoDouble(_Symbol,SYMBOL_BID);
if(TP!=0) takeprofit = request.price-TP*_Point;
if(SL!=0) stoploss = request.price+SL*_Point;
}
if(Type==POSITION_TYPE_BUY)
{
request.type=ORDER_TYPE_BUY;
request.price=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
if(TP!=0) takeprofit = request.price+TP*_Point;
if(SL!=0) stoploss = request.price-SL*_Point;
}
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = MathMin(volume,SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX));
request.sl = stoploss;
request.tp = takeprofit;
request.deviation=SymbolInfoInteger(_Symbol,SYMBOL_SPREAD);
request.type_filling=ORDER_FILLING_AON;
request.comment=DoubleToString(Money,2)+"$";
if(!OrderCheck(request,check))
{
if(check.margin_level<100) volume=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
Print("OrderCheck Code: ",check.retcode);
continue;
}
if(!OrderSend(request,result) || result.deal==0)
{
Print("OrderSend Code: ",result.retcode);
if(result.retcode==TRADE_RETCODE_TRADE_DISABLED) break;
if(result.retcode==TRADE_RETCODE_MARKET_CLOSED) break;
if(result.retcode==TRADE_RETCODE_NO_MONEY) break;
if(result.retcode==TRADE_RETCODE_TOO_MANY_REQUESTS) Sleep(5000);
if(result.retcode==TRADE_RETCODE_FROZEN) break;
if(result.retcode==TRADE_RETCODE_CONNECTION) Sleep(15000);
if(result.retcode==TRADE_RETCODE_LIMIT_VOLUME) break;
}
else volume-=result.volume;
Sleep(1000);
}
if(!PositionSelect(_Symbol)) return(false);
return(true);
}
//+-----------------------------------+
bool IsNewBar()
{
static datetime Told;
datetime Tnew[1];
CopyTime(_Symbol,PERIOD_CURRENT,0,1,Tnew);
if(Tnew[0]!=Told)
{
Told=Tnew[0];
return(true);
}
return(false);
}
//+-----------------------------------+

Please advise why the request.type_filling=ORDER_FILLING_AON; line in the EA contains the error 'ORDER_FILLING_AON' - undeclared identifier cs2011.mq5 127 28 in version 697



Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура результатов проверки торгового запроса
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура результатов проверки торгового запроса
  • www.mql5.com
Стандартные константы, перечисления и структуры / Структуры данных / Структура результатов проверки торгового запроса - Документация по MQL5
 
FRX154:

Please advise why the request.type_filling=ORDER_FILLING_AON; line in the EA contains the error 'ORDER_FILLING_AON' - undeclared identifier cs2011.mq5 127 28 in version 697

Because the language has changed since the EA was written.

put request.type_filling=ORDER_FILLING_AON in this line;

request.type_filling=ORDER_FILLING_FOK; and good luck.

Or you can just put 0

request.type_filling=0;

will also work.

PS or alternatively (to avoid having to edit the entire EA) you can put a patch at the very top of everything

#define ORDER_FILLING_AON ORDER_FILLING_FOK

This is just in case ORDER_FILLING_AON is mentioned several times.

 
For some reason I see the following picture: when I paste in the terminal an indicator from the Navigator to a chart, but the chart shows an empty area for the indicator, the indicator itself is not displayed, but if I open the list of chart indices, it appears there with the note "Debugging". What is this bug and how do I fight it?
 
marketeer:
For some reason I see the following picture: when I paste in the terminal an indicator from the Navigator to a chart, an empty area for the indicator appears on the chart, the indicator itself is not displayed, but if I open the list of chart indices, it appears there with the note "Debugging". What is this bug and how do I cope with it?
Recompile
 

Good people, help!

Take the simplest code.

#property copyright "Copyright 2011,"
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
double Vhod;
       Vhod=linfunc(15);

//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
     }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
     }
//+------------------------------------------------------------------+
double  linfunc(int b) // имя функции и список параметров
  {
  double a;
   while((a/b)<1 && !IsStopped())//---------
     {
      a=a+1;
     }
     double f=a+b;
// составной оператор
   return(a+b);           // возвращаемое значение

  }

We compile it on the 687 build and get Vhod=0 in the debugger.

How do you understand it? At the same time, sometimes I got Vhod=30. (strange but true).

return returns some nonsense...

What are these glitches or am I missing something?

Reason: