Using Custom Indicator in EA (MT4) - page 5

 

thank you very much. It has worked.

nduru22:
thanks, so this should give me the size of the last order. So if I want the next order to be double the size of the last order, i should now just multiply the result of this function by whichever number that i want to multiply with, whether it is 2 or 3 right? I had not thought of the history, and the syntax that i was using was abit wrong compared to yours but i hope that it will now work. thanks
 

please have a look at this for me and help me find out where i am going wrong

for(cnt=0;cnt<=OrdersTotal()-2;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); //this code selects all the orders

if (OrderType()<=OP_SELL && OrderSymbol()==Symbol()) //this code assesses which are buys and which are sells

{

if (OrderType()==OP_BUY) //this confirms if it is a buy, where by it will go on to close

{

OrderModify(OrderTicket(), OrderOpenPrice(), ns, np, 0, White);

Print ("Your Buy order has been modified");

}

}

else

if(OrderType() == OP_SELL)

OrderModify(OrderTicket(), OrderOpenPrice(), ns, np, 0, White);

Print("Your Sell order has been modified");

return (0);

}

return(0);

}

the code is supposed to modify any order that is below the current order. it is supposed to change the stoploss and takeprofit values to the one of the current order. I have used the function that yo gave me, to be able to get the values of takeprofit and stoploss for the most recent order. when i have them i am storing them in ns-new stoploss and np new takeprofit. but it only seems to modify the values for the 1st order is there something wrong with my logic or is it the syntax?

mladen:
It will work, don't worry
 

What is "the current order"?

You can not just skip one order from that loop (the "-2" there). Remeber that metaquotes does not guarantee any sort order. Also, OrderSelect(0,....) is selecting what I suppose you call a "current order".

Add criteria : best to identify a single order is OrderTicket() and if it is the same as the ticket number of "the current order" then skip it.

nduru22:
please have a look at this for me and help me find out where i am going wrong

for(cnt=0;cnt<=OrdersTotal()-2;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); //this code selects all the orders

if (OrderType()<=OP_SELL && OrderSymbol()==Symbol()) //this code assesses which are buys and which are sells

{

if (OrderType()==OP_BUY) //this confirms if it is a buy, where by it will go on to close

{

OrderModify(OrderTicket(), OrderOpenPrice(), ns, np, 0, White);

Print ("Your Buy order has been modified");

}

}

else

if(OrderType() == OP_SELL)

OrderModify(OrderTicket(), OrderOpenPrice(), ns, np, 0, White);

Print("Your Sell order has been modified");

return (0);

}

return(0);

}

the code is supposed to modify any order that is below the current order. it is supposed to change the stoploss and takeprofit values to the one of the current order. I have used the function that yo gave me, to be able to get the values of takeprofit and stoploss for the most recent order. when i have them i am storing them in ns-new stoploss and np new takeprofit. but it only seems to modify the values for the 1st order is there something wrong with my logic or is it the syntax?
 

okay, OrdersTotal()-1. im assuming that it is right if I call it the current order.

So iv just modified the function that you gave me to get the lastorderPrice to be able to give me the T.P and the S.L for the OrdersTotal()-1

mladen:
What is "the current order"?

You can not just skip one order from that loop (the "-2" there). Remeber that metaquotes does not guarantee any sort order. Also, OrderSelect(0,....) is selecting what I suppose you call a "current order".

Add criteria : best to identify a single order is OrderTicket() and if it is the same as the ticket number of "the current order" then skip it.
 

If you mean that the current order is the last order time wise, then you have to use the function that loops through all orders for that.

As I told a couple of times : metaquotes explicitly states that orders queue is not ordered by dates/times (they have two ways of selecting : by position and by ticket) so if you want to make sure that order is the last according to time, you must go through the whole orders queue

nduru22:
okay, OrdersTotal()-1. im assuming that it is right if I call it the current order. So iv just modified the function that you gave me to get the lastorderPrice to be able to give me the T.P and the S.L for the OrdersTotal()-1
 

okay, thanks. Yes, you have told me that about metaquotes a couple of times.

thanks.

mladen:
If you mean that the current order is the last order time wise, then you have to use the function that loops through all orders for that. As I told a couple of times : metaquotes explicitly states that orders queue is not ordered by dates/times (they have two ways of selecting : by position and by ticket) so if you want to make sure that order is the last according to time, you must go through the whole orders queue
 

thank you for all your help. It has finally been able to modify the orders.

mladen:
If you mean that the current order is the last order time wise, then you have to use the function that loops through all orders for that. As I told a couple of times : metaquotes explicitly states that orders queue is not ordered by dates/times (they have two ways of selecting : by position and by ticket) so if you want to make sure that order is the last according to time, you must go through the whole orders queue
 

error 138

hey Mladen, i trust your well, id like to ask about error number 138 requote. im trying to close orders but i get this error and iv ran out of ideas to solve it. My e.a heavily depends the current order(int i= OrdersTotal()-1; i>=0; i--) and if it goes into negatives, id like to close it before it gets to stoploss. So im using the selection function that you gave me, to choose it should it be heading to negative. I am altho not being able to close it. Do you think you are able to help me out?

mladen:
If you mean that the current order is the last order time wise, then you have to use the function that loops through all orders for that. As I told a couple of times : metaquotes explicitly states that orders queue is not ordered by dates/times (they have two ways of selecting : by position and by ticket) so if you want to make sure that order is the last according to time, you must go through the whole orders queue
 

I want to Make EA through Zup 117 Indicator

european:
or you can use a script and check what each buffer returns, place text label called say 'lx' on your chart, compile your code and d.click on the script - results will be shown in your label

ex:

double vFMACD=iCustom("GBPUSD",5,"FlatTrend w MACD",5,5,6,25,2,0);

string text = vFMACD;

ObjectSetText("lx", text, 10, "Arial", White);

Dear i am trying to get Buy or Sell Signal from Harmonic Pattern EA name "Zup 117 NEN STAR" , i am trying to get parameters through icustom but not able to get correct parameters, Can you please help me to do it?

 

Using Custom Indicator Variable Values in an Expert Advisor?

Hello,

I have a very intricate custom indicator I created with many variables.

When I call this icustom indicator into the Expert Advisor, how do I pull some of the variable values (esp. Bool) from the indicator code into the Expert Advisor to use them in decision making?

Here's the portion of the expert advisor code I wrote that doesn't seem to be working:

Here's where I call the custom indicators....TradeL, Trade S and RSI_Length_L are the Variables I want to pull into the Expert Advisor.

...

double K_L=iCustom(NULL,PeriodShort,"CUSTOM INDICATOR",TradeL,RSI_Length_L,0,0);

double D_L=iCustom(NULL,PeriodShort,"CUSTOM INDICATOR",TradeL,RSI_Length_L,1,0);

double K_S=iCustom(NULL,PeriodLong,"CUSTOM INDICATOR",TradeS,RSI_Length_L,0,0);

double D_S=iCustom(NULL,PeriodLong,"CUSTOM INDICATOR",TradeS,RSI_Length_L,1,0);

...

Here's where I try to use the TradeS and TradeL variables:

...

if (TradeL==False || TradeS==False)

{

Alert ("Do not trade at this Pair and TImeframe set at this time.");

return(0);

}

...

The problem is that the alert always sounds meaning TradeL and TradeS are always false, which I know their not.

Any suggestions would be appreciated!

Thank You

ThemBonez

Reason: