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

 
Trader7777:

And maybe the third time someone will still pay attention to my request?

I wrote the function by SAM, but the tester gives error 4051, i.e. impossible number of lots. Anyone have an opinion on this?


for (int i = OrdersTotal()-1; i>0; i--)  // надо i>=0
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType() == otype)    // не надо OrderType() == otype, далее проверяете на бай и сел, а про отложки варианта нет.
Lot = NormalizeDouble (((OrderOpenPrice()-Bid)*Point)*OrderLots()/TP,2); 

TP is a Take Profit value for the selected order? So take the value from the order, there are different Take Profits.

At this point you look for the amount of pips you are in the drawdown, divide it by the take profit and multiply by the lot value.

If you have a buy ticket, you are in profit when the Bid is above the buy price (ask). (Bid - OrderOpenPrice ())

You don't account for negative and positive profit tickets in general,

in case you don't have enough free funds to open with such a lot, because one negative ticket can overlap all the positive ones.

return (TotalLot); the function may return 0, under certain circumstances, is this checked further?

 
Trader7777:

Are you sure you know what you're talking about?

The above phrase has several meanings. The meanings of this phrase are described below.

1 - A rebuke that I have misunderstood the code and have accordingly given wrong instruction.
2 - An indication of the difficulty of understanding my texts.
3 - A questioning of my psychological health.

Choose one of the options to continue communicating with me, as I cannot answer your question by intuitively choosing the option of interpreting the phrase.
 
Link_x:

The above phrase has several meanings. The meanings of this phrase are described below.

1 - A rebuke that I have misunderstood the code and have accordingly given wrong instruction.
2 - An indication of the difficulty of understanding my texts.
3 - A questioning of my psychological health.

Choose one of the options to continue communicating with me, as I cannot answer your question by intuitively choosing an option for interpreting the phrase.

I am sure that 1. You cannot reliably judge with what lot the position is opened, if only because the code of opening the position was not given by the author. And where you have seen zero, it is the initial value of the variable. It is too early for you to teach anyone.
 
Hello comrades. I'm new to programming, I'm just learning MQL4. Please explain how to open one order without waiting for certain conditions, and not on every candlestick, like mine. Maybe you have a standard code example or something else?
 
hmpr:
Hello comrades. I'm new to programming, I'm just learning MQL4. Please explain how to open one order without waiting for certain conditions, and not on every candlestick, like mine. Maybe you have a standard code example or something else?
The algorithm is as follows: if the EA checks for an open order and if there is already an open order, then exit from start(). The codes are here.
 
Trader7777:

And maybe someone will pay attention to my request after the third time?

Wrote a CAM function, but the tester gives error 4051, i.e. impossible number of lots. Does anyone have an opinion on this?

функция поиска лота, необходимого для выхода из просадки после  

//closing a grid of orders

In order to assess the correctness of the code, you need to know exactly what the author wanted to get. Your information is not enough. What you wanted to get is not quite clear. If you wanted to compensate for the loss after closing the grid by opening an opposite order and expecting that the price will pass in the direction of the last order some amount of points, the compensation process depends both on the lot of this order and the distance the price will pass in the favorable direction. That means when you calculate the lot, you should also define the distance that the price will have to pass to compensate for the loss. But maybe you mean something else.
 

the code ends with a view of

I would like to insert the sleep function with a period of 30 sec.

the whole code should run 2 times per minute instead of every tick, and

how to correctly insert this function ? where ? and how ? preferably at the end of the code with an example, thanks

 
bergkamp.:

the code ends with the view

I would like to insert a sleep function with a period of 30 seconds

the whole code should run 2 times per minute instead of every tick, and

how to correctly insert this function ? where ? and how ? preferably at the end of the code with an example, thanks

Store the time at the end of the function code. Then compare it with the current time and if the current time exceeds the memorised time by 30 seconds, start the function again.
 
khorosh:
Remember the time at the end of the function code. Then compare it with the current time and if the current time exceeds the memorised time by 30 seconds, run the function again.
here's an example ... if you just insert sleep at the end of the code, how will it work ?
 
bergkamp.:
here is an example ... if you just put sleep at the end of the code, how will it work ?

If you don't care that start function will not start after start function for 30 seconds (and hence EA will not perform any actions during this time), then please put sleep.

Reason: