Questions from Beginners MQL4 MT4 MetaTrader 4 - page 225

 
Hello dear programmers, I am new to mgl4, can you help me? I need a trading robot that opens in the morning ( 9:00 )after taking a profit waits for the next day. Could you tell me in simple words what to add?
 
Nargiz Ravanova:
Hello, dear programmers, I'm new to mgl4, can you please help me? I need a trading robot that opens in the morning ( 9:00 )after getting a profit waited for the next day. Can you tell me in simple words what to add where?

Well, in simple words, it goes like this:

We create a variable of datetime type and record the time of the current D1 candle in it when we close the order with a profit. And before opening another order, we check the value of this variable with the time of the current D1 candle. Accordingly, if the current time is higher, we can open. Otherwise, we smoke smoke smoke.

 
Aleksei Stepanenko:

Here's a working code:

Note that the arrow is drawn with the back number BufferDn[i+1]=. That's unfortunate.

Oh, thank you, thank you, thank you, thank you! :)) Good programmers are wizards for mere mortals, after all! :))

So, is there a sense in such an indicator? I do not quite understand how much the arrow will be drawn retroactively? That is, for example, the candle ended, the arrow is drawn, and at the same moment we have entered the trade on a new candle (that is, at the beginning of the next candle)? If so, it seems to be good. But if it is different, how?

Документация по MQL5: Константы, перечисления и структуры / Константы индикаторов / Стили рисования
Документация по MQL5: Константы, перечисления и структуры / Константы индикаторов / Стили рисования
  • www.mql5.com
При создании пользовательского индикатора можно указать один из 18 типов графического построения (способа отображения на главном окне графика или в подокне графика), значения которых указаны в перечислении ENUM_DRAW_TYPE. В зависимости от стиля рисования, может потребоваться от одного до четырех буферов значений (отмеченных как INDICATOR_DATA...
 
Good afternoon. In Prof() the numbers are set. In ProfS() these numbers should add up. Can you tell me what's wrong and how to fix it?
double Prof(){
   double  Prof = ObjectDescription("Prof"+Bars(Symbol(),0));{
   ObjectCreate("Prof"+Bars(Symbol(),0),OBJ_TEXT,1,TimeCurrent(),GlobalVariableGet( Symbol()+"_vGrafEquity" ));
   ObjectSetText("Prof"+Bars(Symbol(),0),DoubleToStr(Equity[0],2),18,"Arial",clrWhite);   
   ObjectSetInteger(0,"Prof"+Bars(Symbol(),0),OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);}
    return(0);}

double ProfS(){double  ProfS;
   double  Prof1 = ObjectDescription("Prof"+Bars(Symbol(),0));
     ProfS += Prof1;{ Comment("   ",ProfS);
   ObjectCreate("ProfS",OBJ_LABEL,1,0,0);   
   ObjectSetInteger(0,"ProfS",OBJPROP_XDISTANCE,1600); 
   ObjectSetInteger(0,"ProfS",OBJPROP_YDISTANCE,30); 
   ObjectSetText("ProfS",DoubleToStr(ProfS,2),18,"Arial",clrWhite);   
   ObjectSetInteger(0,"ProfS",OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);}
    return(0);}
 
Rustam Bikbulatov:
Good afternoon. In Prof() the numbers are set. In ProfS() these numbers should add up. Can you tell me what's wrong and how to fix it?
static double  ProfS;
 
Alekseu Fedotov:

Thank you very much Alexei!

 
ElenkaVladi:

i is just closed candle, the arrow is drawn on i+1. There will always be a lag, you should try to optimise and see what happens.

 
Aleksei Stepanenko:

i is just closed candle, the arrow is drawn on i+1. There will always be a lag, you need to try and optimise, see what happens.

I am trying)

 
Good afternoon. Can you tell me how to find an open position the furthest away in pips fromthe current priceand close it. Regardless of which currency pair and which way it goes. Thank you.
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Приказы на проведение торговых операций оформляются ордерами. Каждый ордер имеет множество свойств для чтения, информацию по ним можно получать с помощью функций Идентификатор позиции, который ставится на ордере при его исполнении. Каждый исполненный ордер порождает сделку, которая открывает новую или изменяет уже существующую позицию...
 
makssub:
Good afternoon. Can you tell me how to find an open position the furthest away in pips fromthe current priceand close it. Regardless of which currency pair and which way it is going. Thank you.

You have been answered in your topichttps://www.mql5.com/ru/forum/334987

moderator using SBhttps://www.mql5.com/ru/docs/standardlibrary/tradeclasses

I wrote an example based on the help

if the question is how to close a position, again the help ishttps://www.mql5.com/ru/docs/constants/tradingconstants/enum_trade_request_actions


ExampleTRADE_ACTION_DEAL trade operationto close a position:

or SBhttps://www.mql5.com/ru/docs/standardlibrary/tradeclasses/ctrade
Reason: