Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1340

 
@Vitaly Muzichenko@Iurii Tokman Thanks a lot guys, it all worked! Don't know what I'd do without you. Good luck in the year.
Vitaly Muzichenko
Vitaly Muzichenko
  • www.mql5.com
Профиль трейдера
 

Good day to all. I have an EA which signals on crossing a trend line and a horizontal line of a certain colour. I decided to re-do it so it signals when the trend line and horizontal line cross a certain style. It worked. But I need it to signal when a trend line crosses only the beam to the right. I understand that I have to add

OBJPROP_RAY_RIGHT

but I don't know where or how. Thanks in advance.
Files:
 

Hi all J. I keep sawing the Grail machine. And encountered such a not pleasant thing as error 130 when setting pending orders. But what's interesting is that when opening with market orders everything is fine. There are no wrong stops appearing.

I will mention the fact that there are two ways to calculate the stop. You can use either a fixed stop in points or atp.

If we set a fixed stop or atp, we get error 130 when opening a pending Sell Stop order, but pending Buy Stop seems to open normally, although I am not 100% sure. Although I check it and see that the pending buy stop orders are opened with the error 130 as well. I get the stop loss value this way


extern double atr_sl_period= 14; // ПЕРИОД АТR СТОП ЛОССА

extern   ENUM_TIMEFRAMES   PeriodForWork_sl        =  PERIOD_H4;           // ТФ SL  ПО АТР

void OnTick()
  {
double sl; // стоп лосс ордеров
if(tip_sl==en_po_atr)
     { //ЕСЛИ ТИП СТОП ЛОССА СТОИТ ПО АТР ТО ВЫСЧИТЫВАЕМ ЕГО ИЗ АТР
     //Print("СТОП ПО АТР, ЕГО РАЗМЕР ");
     sl= iATR( NULL,PeriodForWork_sl,atr_sl_period,1);// ПОЛУЧЕНИЕ ЗНАЧЕНИЙ АТР ДЛЯ ВЫСТАВЛЕНИЯ СТОПЛОССА
      //Print("СТОП ПО АТР, ЕГО РАЗМЕР "+sl);
     }
     else //ИНАЧЕ- ТО ЕСТЬ ЕСЛИ СТОП ЛОСС ФИКСИРОВАННЫЙ В ПУНКТАХ
     {
     //Print("СТОП ЛОС ФИКСИРОВАННЫЙ В ПУНКТАХ");
     sl= razmer_fikc_sl*Point; // ПЕЕРМЕННОЙ СТОП ЛОССА ПРИСВАЕВАЕМ ФИКСИРОВАНОНЕ ЗНАЧЕНИЕ ПУНКТОВ И ДОМНОЖАЕМ НА ПОИНТ
     }


   
  }

Everything is normal when opening using market orders. I open pending orders like this

OrderSend(Symbol(),OP_SELLSTOP,lot,min_Price,slippages,min_Price+sl , min_Price-tp ,comment_ao_otloj_sell); // ОТКРКЫВВАЕМ ОТЛОЖЕННЫЙ СЕЛ ОРДЕР

OrderSend(Symbol(),OP_BUYSTOP,lot,max_Price,slippages,max_Price-sl,max_Price+tp ,comment_ao_otloj_buy,magik_number,TimeCurrent()+order_life_time); // ОТКРЫВАЕМ ОТЛОЖЕННЫЙ БАЙ ОРДЕР

Please, tell me what I am doing wrong and how should I fix it?

Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
DanilaMactep:

Hi all J. I keep sawing the Grail machine. And encountered such a not pleasant thing as error 130 when setting pending orders. But what's interesting is that when opening with market orders everything is fine. There are no wrong stops appearing.

I will mention the fact that there are two ways to calculate the stop. You can use either a fixed stop in points or atp.

If we set a fixed stop or atp, we get error 130 when opening a pending Sell Stop order, but pending Buy Stop seems to open normally, although I am not 100% sure. Although I check it and see that the pending buy stop orders are opened with the error 130 as well. I get the stop loss value this way


Everything is normal when opening using market orders. I open pending orders like this

Please, tell me what I am doing wrong and how should I fix it?

no price normalization
no stop loss accounting

 

DanilaMactep: Получаю значение стоп лосса во таким макаром

Makar, please don't touch it.)

DanilaMactep:

Can you tell me what I'm doing wrong and how to fix it?

Try increasing the fixed stop and if the error for a fixed stop disappears, the problem is in MODE_STOPLEVEL

TakeProfit should also be checked

 
DanilaMactep:

Hi all J. I keep sawing the Grail machine. And encountered such a not pleasant thing as error 130 when setting pending orders. But what's interesting is that when opening with market orders everything is fine. There are no wrong stops appearing.

I will mention the fact that there are two ways to calculate the stop. You can use either a fixed stop in points or atp.

If we set a fixed stop or atp, we get error 130 when opening a pending Sell Stop order, but pending Buy Stop seems to open normally, although I am not 100% sure. Although I check it and see that the pending buy stop orders are opened with the error 130 as well. I get the stop loss value this way


Everything is normal when opening using market orders. I open pending orders like this

Please, please, tell me what I am doing wrong and how should I fix it?

Error 130 occurs not only when a stop or take order is placed, but also when the pending order is placed too close to the current price. Not the stop or take of that order, but the opening/setting price of the order.

 
        if(CopyTicks(Symbol(),ticks,COPY_TICKS_TRADE,0,1)==1)
            start_time=ulong(ticks[0].time_msc);
  

What does the dot mean?

 
ascerdfg:

What does the dot mean?

This is where you come in.
 
ascerdfg:

What does a dot mean?

Structures and, classes and interfaces
 
Alexey Viktorov:

Error 130 occurs not only when a stop or take is set, but also when a pending order is set too close to the current price. Not the stop or take of this order, but the opening/setting price of the order.

WHEN SETTING A PENDING ORDER, I CALCULATE THE PRICE AS FOLLOWS (I DON'T INTERFERE WITH YOU, YOU ARE AT LEAST NOT MY TYPE TO INTERFERE;-))

                    int min_bars= iLowest(NULL, // ТЕКУЩИЙ СИМВОЛ
          double min_Price=iHigh(Symbol(),// СИМВОЛ ТЕКУЩЕГО ИНСТРУМЕНТА(НА КОТОРОМ РАБОТАЕТ ГРААЛЬ;-)
          PeriodForWork_pending_orders, // ТФ НА КОТОРОМ АСЧИТЫВАЕМ ЦЕНУ МИНИМУМА
          min_bars//  НА КАКОМ БАРЕ БЫЛ МАКС ТОТ И ПОДСТАВИМ;)
        
          
          ); 

HOW DO I CHECK IF THE OBTAINED VALUE FALLS WITHIN THE ALLOWED RANGE? I DON'T UNDERSTAND WHAT I SHOULD DO, AND HOW DO I MAKE SURE THAT IF THE CALCULATED VALUE IS LESS THAN THE ALLOWED ONE, THE ORDER WOULD BE OPENED AT THE MINIMUM POSSIBLE DISTANCE ANYWAY?

Reason: