Coding help - page 141

 
arroganzmaschine:
But this doesn't help me. The two buffers are 4 and 5. But the Buffers were arrays before.

here is the code: SetIndexBuffer(4, Long);

SetIndexBuffer(5, Short);

In the indicator, these buffers are declared first with "double Long[]". This buffer has two values. Long[1] and Long[2]. How can I get these values in the expert advisor?

Try something like this :

double value1 = iCustom(NULL,0,"indicatorName",4,1); double value2 = iCustom(NULL,0,"indicatorName",4,2);

______________________________

PS: have no idea what are the parameters, so the iCustom() will use default parameter values. You will have to supply desired parameters to the iCustom() call. And all that is described in the thread from the link I posted in previous post.

all the best

 

Works! Thank you very much!!!!

 
arroganzmaschine:
Works! Thank you very much!!!!

Good

Happy coding

 

Hey mladen, one last question:

How can I close the open Buy or Sell Order of the current symbol? There is only one open order at time.

 
arroganzmaschine:
Hey mladen, one last question: How can I close the open Buy or Sell Order of the current symbol? There is only one open order at time.

You can do something like this :

if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES))

{

if (OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);

if (OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,0,CLR_NONE);

}

 

Do I have to get all open orders? Or does this piece of code you posted get the current open orders?

 
arroganzmaschine:
Do I have to get all open orders? Or does this piece of code you posted get the current open orders?

You told that there is only one opened order at a time

That code works only if there is just one opened order

 

There is just one open order for one symbol. But I have different open charts. So the code has to pick the order of the symbol and close this one. How do I have to do that?

 
arroganzmaschine:
There is just one open order for one symbol. But I have different open charts. So the code has to pick the order of the symbol and close this one. How do I have to do that?

Like this :

for (int i=OrdersTotal()-1; i>=0; i--)

if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol())

{

if (OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);

if (OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,0,CLR_NONE);

}

 

Worked! You are great!

Reason: