Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1024

 

Hello!

How can I start e.g. the for function once after switching on the "Auto-trade" button or restarting the terminal?

 

Hello ladies and gentlemen!

There is a problem, maybe someone can help.

if (ld_76 >= Porog && ld_84 >= Porog && l_iopen > l_ilow && day_sell != Day())

{

ticket_sell = OrderSend(Symbol(), OP_SELLSTOP, Lot, l_ilow - P, 0, l_ilow - P + SL, 0, 0, 0, iTime(Symbol(), PERIOD_D1, 0) + 86400);

ticket_sell_buy = OrderSend(Symbol(), OP_BUYSTOP, Lot, l_ilow + P, 0, 0, 0, 0, 0, iTime(Symbol(), PERIOD_D1, 0) + 86400);

if (ticket_sell == -1)

{

l_error = GetLastError();

Print("error(", l_error, ")");

}

}

In the tester, one order opens, while the second (BUYSTOP) does not open with error 130. As you see, I didn't put a Stop Loss on it. Where is this error coming from? My broker is Alpari.

 
abeiks:

Hello!

How can I start e.g. the for function once after switching on the "Auto-trade" button or restarting the terminal?

You need to write the for loop in the Init() function. Then it will be executed 1 time during EA initialization. https://docs.mql4.com/ru/runtime/event_fire
 
Sphinxzzz:
You need to write a for loop in the Init() function. Then it will be executed once at EA initialization. https://docs.mql4.com/ru/runtime/event_fire
Thank you.
 
With iTime I can get the opening time of a bar, for example for iHighest. Is there any way to get the exact time of the highest found value of this bar?
 
Please, I could not find it in the description (how many characters can be placed in the tooltip text?

OBJPROP_TOOLTIP

Tooltip text. If the property is not specified, the tooltip automatically generated by the terminal is displayed. Tooltip can be disabled by setting its value to "\n" (line translation)

 

Good afternoon.

A line of code in an indicator:

if(ChartPeriod(0)<=240);//Если период текущего графика H4 и меньше

Error during compilation:

empty controlled statement found News4.mq4 108 42

Please advise how to write it correctly?

 
Shurkin:

Good afternoon.

A line of code in an indicator:

Error during compilation:

empty controlled statement found News4.mq4 108 42

Please advise how to write it correctly?

Have you tried using Period() or _Period?
 
Vinin:
Have you tried using Period() or _Period?

Tried it, same result in all editions:

empty controlled statement found News4.mq4 108 41

Something else might be wrong here?

 
Shurkin:

Tried it, same result in all editions:

empty controlled statement found News4.mq4 108 41

Can something else be wrong here?

Why do you have a semicolon at the end of the statement?