Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1210

 
MQL_User:

I didn't think I would encounter such a problem, because at first glance it should be a matter of course to redraw the chart from the program. In this light, the purpose of the ChartRedraw() function is unclear...

It is not for indicators, but to display the changes made in the properties of graphical objects.

You need to send a tick to the indicator - then the indicator will be redrawn. Well, i.e. it will do what it should do on the new tick.

And to send a new tick, you need either to wait for it, which is not an option, or to refresh the chart by PCM --> Refresh, which is also not an option, or to use the ChartSetSymbolPeriod() function with such parameters for the current chart:

ChartSetSymbolPeriod(0,NULL,PERIOD_CURRENT);
Документация по MQL5: Операции с графиками / ChartSetSymbolPeriod
Документация по MQL5: Операции с графиками / ChartSetSymbolPeriod
  • www.mql5.com
Меняет значения символа и периода указанного графика. Функция работает асинхронно, то есть отдает команду и не ждет окончания ее выполнения. Отданная команда поступает в очередь сообщений графика и выполняется только после обработки всех предыдущих команд. Возвращает true в случае удачного помещения команды в очередь графика, иначе false. Чтобы...
 


Hello, help me out, I wrote a script that opens a limit order but at market price. All works, decided to change it to put a limit below/above market, nothing works, although the return code of the trading server 10009, and GetLastError() returns 0. Code:

void OnStart()
 {MqlTradeRequest request={0};
  MqlTradeResult  result={0};
 double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
 double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
 int digits=SymbolInfoInteger(_Symbol,SYMBOL_DIGITS);  
 double p=NormalizeDouble(ChartPriceOnDropped(),digits); 
 if( SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE)==10)
 {p=NormalizeDouble(ChartPriceOnDropped()*0.1,digits)/0.1;
 } 
 int V=75;
           if (p<Ask)
            {
             request.action   =TRADE_ACTION_PENDING;                     // тип торговой операции
             request.symbol   =Symbol();                              // символ
             request.volume   =MathFloor(AccountInfoDouble(ACCOUNT_BALANCE)/V/((Ask-p)/
             SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE)*SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE)));  
             if (request.volume>AccountInfoDouble(ACCOUNT_BALANCE)/SymbolInfoDouble(_Symbol,SYMBOL_MARGIN_INITIAL)) 
             { request.volume=MathFloor(AccountInfoDouble(ACCOUNT_BALANCE)/SymbolInfoDouble(_Symbol,SYMBOL_MARGIN_INITIAL));
             }                             
             request.type     =ORDER_TYPE_BUY_LIMIT;                        // тип ордера
             request.price    =Ask;                                    // цена для открытия
             request.deviation=50;                                     // допустимое отклонение от цены
             request.sl      =p;                                      // Stop Loss позиции
             request.tp      =NormalizeDouble(Ask+(Ask-p)*3,digits);    // Take Profit позиции
             request.type_filling=ORDER_FILLING_IOC;
             request.type_time=ORDER_TIME_DAY;
             request.stoplimit=Ask;
             OrderSend(request,result);
            }
if request.price for example put: Ask-Point()*30 does not set it, price normalization does not give anything either
 
Artem, what can you say, to the question above, interesting opinion. as a learning experience.
 
Artyom Trishkin:

This is not for indicators, but to show changes made to the properties of graphical objects.

You need to send a tick to the indicator - then the indicator will redraw. That is, it will do what it should do on the new tick.

For sending a new tick you have either to wait for it, which is not an option, or to refresh the chart using PKM --> Refresh, which is also not an option, or to use ChartSetSymbolPeriod() with these parameters for the current chart:

Artem, thank you.

It's all working. :)

 
Does anyone know how to disable the display of all indicators used in the EA on the chart during visual testing?
 
Сергей Таболин:
Does anyone know how to disable displaying all indicators used in the EA on the chart during visual testing?

TesterHideIndicators(true);

 

How can I tell if the indicator is not ready to work with another timeframe?

The history is not paging (not built) for adjacent timeframes. The indicator works on M15, but I need to look at H1 (on top of M15 chart), when I switch it - the chart is empty. When I refresh in a couple of seconds - beauty, all the buffers are rendered.

How can I make the indicator check the history on another timeframe and hold the calculation until it appears?

 
Igor Zakharov:

TesterHideIndicators(true);

Thank you very much ))))

 

I can't get ATP values from another timeframe:

ATR_handle=iATR(_Symbol,ATR_TF,ATR_Period);
CopyBuffer(ATR_handle,0,time[i],1,ATR);

from the current timeframe - works. from older timeframes - always 0

 

On futures, how do you create a continuous contract? for technical chart analysis?

Reason: