And let's make a "cartoon" out of it (multicurrency) - page 4

 
rid писал(а) >>

maybe one of these will do, -

The function PriceOpenLastPos().
This function returns the open price of the last position opened. The selection of positions to be taken into account is specified by external parameters:
sy - Name of market instrument. If this parameter is set, the function will only consider positions of the specified symbol. The default value - "" means any market instrument. NULL value means the current instrument.
op - Trade operation, position type. Valid values: OP_BUY, OP_SELL or -1. The default value -1 means any position.
mn - Position identifier, MagicNumber. Default value -1 means any identifier.

https://forum.mql4.com/ru/11287/page24

Thank you, I will try it, does this function also work in the indicator?

 

I can't tell. After all, the indicator does not open positions . Why does the indicator need the price of open or closed positions?

It has other tasks.

I think it will work in the indicator as well.

 
rid писал(а) >>

I can't tell. After all, the indicator does not open positions . Why does the indicator need the price of open or closed positions?

It has other tasks.

I think it will work in the indicator as well.

Do you know how to insert this function to the indicator correctly?

When compiling, the editor generates an error on the first bracket and the next variables.

double PriceOpenLastPos( string sy="", int op=-1, int mn=-1) {
datetime t;
double r=0;
int k=OrdersTotal();

if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy==") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (t<OrderOpenTime()) {
t=OrderOpenTime();
r=OrderOpenPrice();
}
}
}
}
}
}
}
return(r);
}
}

'(' - function definition unexpected D:\MT4\experts\indicators\Astrea.mq4 (627, 24)
'sy' - variable not defined D:MT4\experts\indicators\Astrea.mq4 (632, 7)
etc.

 

It's hard to tell. I am not a specialist in indices.

And I do not understand why the order opening price should be considered in the indicator.

Are you sure that this particular indicator is needed for your purposes?

Maybe, it would be easier to implement the functions you need in a separate EA which takes orders into account?

 
rid писал(а) >>

It's hard to tell. I am not a specialist in indices.

And I do not understand why the order opening price should be considered in the indicator.

Are you sure that this particular indicator is needed for your purposes?

Perhaps, it would be easier to implement the necessary functions in a separate EA that will consider orders?

I implement the logic of generation of trading signals in an indicator and send the generated signal to the EA through a global variable to open/close orders.

I need the open price of an order to make some decisions and that is why I am trying to solve this problem. I have a dynamic indicator, you can only debug it in a demo or in a tester in visualisation mode.

 

I've now inserted this function into the first turkey I came across (ATR) and it all complied.

(1 warning only, as it should).

And in which part of the code do you insert this function? It should be inserted at the very end of the code, outside the START function.

And then, in the START function call it to calculate your

 
rid писал(а) >>
I just pasted this function into the first available turkey (ATR) and it all complied.

How was it inserted? All the above text one-to-one, or as a void sub-function?

 
One to one.
 
rid писал(а) >>
>> One to one.

Strange, I get errors when I compile.

 
rid писал(а) >>

I've now inserted this function into the first turkey I came across (ATR) and it all complied.

(1 warning only, as it should).

And in which part of the code do you insert this function? It should be inserted at the very end of the code, outside the START function.

You should call it in the START function to make calculations.

I did it, I inserted it outside the start function, and the compilation went through.

>> Thank you.

Reason: