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

 
This is a slightly modified example to the post above
 
rapid_minus:

r772ra andartmedia70, thanks for the clarification.

My understanding is that magic is needed mainly when a trader uses several EAs, with several open orders, on several currency pairs, accounts, etc. (right?)

I do not think so, and if I think that my Expert Advisor will work in profit, it will be enough for me. I am still developing it for one pair, one account at one brokerage company and only one order should be open and the magician (or any other identifier for an open position) is needed so that it closes only upon the occurence of certain conditions for this very order and other conditions which are valid for closing other orders (which may be open only after the closure of this order) are not valid for this order.

For example, an order may be open when conditions (a+b+c+d+d) or (a+d+e) or (f+c+i+c) appear and, depending on the conditions on which the BAY is open, it should close according to its own conditions:(a+b+c+d) by (f+j+l),(a+d+e) by (h+l+m+n),(g+z+i+k) by (p+r+c+t) .

It seems to me that the order loop is not needed here either. There has to be some simple solution that does not take much space. I stated my vision above, but haven't got to analysis yet, and besides logical errors I must have syntax errors (there may be brackets missing or wrong variable set, etc.).

Don't consider it a problem, please help. I'm stuck without it. Thanks

Determine the ticket of the last open position and process it. IMHO - storing the ticket number in a variable is bad, as it is easy to lose it in case of any failure. To work with an order, it must first be selected. And you can select it either by index, or by ticket. The ticket must be known exactly. After a successful selection using the ticket, we must also check if the position with this ticket has been closed. If there is only one position in the market, the cycle is not a time-consuming operation. But we don't need to store the number of the ticket in a variable. You can select the last order in the list, but there is a sorting dependence, which can be changed (earlier, there was a sorting dependence in the terminal, then it was removed, then it appeared again, then it was removed again) - do you believe that it won't appear again? I don't. There will be only one iteration in the loop when there is only one position in the market - is it a lot?

Has the Buy close condition come?
If so, we will look for the ticket of the last open Buy position
If no, then we go to the beginning.
If we have found the ticket, we do what we need in the given situation with the order
Otherwise, go to the beginning

 
rapid_minus:
This is a slightly modified example to the post above

What is the OrdBuy_1() function ? It's not a variable but a function. This construct is completely wrong. A function is defined outside any other function, not inside.

 
artmedia70:

Determine the ticket of last open position and process it. IMHO - storing the ticket number in a variable is bad, as it is easy to lose it with any failure. To work with the order, it must first be selected. And you can select it either by index, or by ticket. The ticket must be known exactly. After a successful selection using the ticket, we must also check if the position with this ticket has been closed. If there is only one position in the market, the cycle is not a time-consuming operation. But we don't need to store the number of the ticket in a variable. You can select the last order in the list, but there is a sorting dependence, which can be changed (earlier, there was a sorting dependence in the terminal, then it was removed, then it appeared again, then it was removed again) - do you believe that it won't appear again? I don't. In the cycle there will be only one iteration with only one position in the market - is it a lot?

Has the Buy close condition come?
If so, we will look for the ticket of the last open Buy position
If no, then we go to the beginning.
If we have found the ticket, we do what we need in the given situation with the order
Otherwise, go to the beginning

Thank you, I will try to redo it. Still, although I will try to redo according to your explanation, voice my mistakes in the example above so I don't repeat them.

Thanks

 
rapid_minus:

Thank you, I will try to redo it. Still, although I will try to redo according to your explanation, voice my mistakes in the example above so I don't repeat them.

Thanks

I have to go - I have no time. Briefly - if the variable is int, why do you check it as a bool ? Stop Loss and Take Profit values should be normalized. I did not look further.
 

I have fiddled with the trend line and learned how to get it. But it turns out that graphical objects do not work during optimization in the tester.

What should I do? Is it worth to get it in an indicator?

Buffer[i]= ObjectGetValueByTime(chart_ID,name,Time[1],sub_window);

Will the optimization work in this way?

 
artmedia70:
I have to go - I have no time. In brief - if the variable is int, why do you check it as bool ? Stop Loss and Take Profit values should be normalized. I did not look further.

Well, I'm completely confused: OrdBuy_1( ) is the function that opens BAY on conditions #1 above this function. Only probably the correct type is double rather than int, because it returns the opening price of the order. And as far as I understand, I haven't inserted it into any function; it is placed separately, after int start(), extracting the values of all the necessary indicators and analysing the current market situation (am I wrong?).

And how do I normalize the stop and take, or better yet, how do I not set them at all?

And I don't understand about the check. I must have misunderstood the tutorial - "bool OrderClose (int ticket, double lots, double price, int slippage, color Color=CLR_NONE)Function for closing a market order." What is a check?

Anyway, the further we go, the dumber it gets :(.

 
Forexman77:

I have fiddled with the trend line and learned how to get it. But it turns out that graphical objects do not work during optimization in the tester.

What should I do? Is it worth to get it in an indicator?

Will the optimization work in such a way?

Calculate a virtual line instead of the real one.
 
Forexman77:

I have fiddled with the trend line and learned how to get it. But it turns out that graphical objects do not work during optimization in the tester.

What should I do? Is it worth to get it in an indicator?

Will the optimization work in such a way?

No, it will not. The graphics are only displayed in visualisation mode.
 
rapid_minus:

Well, I'm completely confused: OrdBuy_1( ) is the function that opens BAY on conditions #1 above this function. Only probably the correct type is double rather than int, because it returns the opening price of the order. And as far as I understand, I haven't inserted it into any function; it is placed separately, after int start(), extracting the values of all the necessary indicators and analysing the current market situation (am I wrong?).

And how do I normalize the stop and take, or better yet, how do I not set them at all?

And I don't understand about the check. I must have misunderstood the tutorial - "bool OrderClose (int ticket, double lots, double price, int slippage, color Color=CLR_NONE)Function for closing a market order." What is a check?

Anyway, the further you go, the dumber it gets :(.

Why would you think this is correct?

//Локальная переменная, открывающая ордер БАЙ
   int OrdBuy_1() = (OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Bid-1500*Point,Bid+1500*Point));

You have written - variable. But two parentheses mean that it was you who declared the function. Inside another function. And what follows is not its description, but its assignment.

And if you say it must return the opening price, why are you comparing it to the truth?

if (OrdBuy_1()==true)                              //Если был открыт ордер №1, то...

Actually OrderSend() returns the open position ticket number on success. Otherwise -1 on error. In order to find out what the error is, you need to look at the contents of the last error GetLastError () and, if possible, handle the error code returned by the trade server (this is what I was talking about).

You check the ticket number for "true". And this is either 0 (false) or any value other than zero (true). On error OrderSend() will return -1, which is true, and then what?

Reason: