MQL4 Learning - page 102

 

ok i have one more question regarding the OrderSelect function:

say i have 2 open trades. the one which was opened first, has the comment "first" the one which was opened last, has the comment "second".

if i use this code:

for (i = 0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

will it select only the latest trade ("second")? or will it loop through the 2 trades?

what i am trying to code is, that the tp of trade "first" is modified after the second trades is opened. i know how to do that, i am only not sure wheather the order select function only selects the latest order or if it loops.

thanks for your help!

 
surfer90:
ok i have one more question regarding the OrderSelect function:

say i have 2 open trades. the one which was opened first, has the comment "first" the one which was opened last, has the comment "second".

if i use this code:

for (i = 0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

will it select only the latest trade ("second")? or will it loop through the 2 trades?

what i am trying to code is, that the tp of trade "first" is modified after the second trades is opened. i know how to do that, i am only not sure wheather the order select function only selects the latest order or if it loops.

thanks for your help!

Notice you are using "i" in OrderSelect... The value of i will change from 0 to whatever is OrdersTotal() value is minus 1.. that means on each pass ( loop ) the orderselect function will have a new number from "i"0,1,2,3.. so each order is selected,

hope this helps

Guyver

 
Guyver:
will change from 0 to whatever is OrdersTotal() value is minus 1..

so if i have 2 open positions, it will only select one? and if i have 3, it will only select 2? am i getting that right? how can i change that then for it to select all of the orders? (OrdersTotal())

 
surfer90:
so if i have 2 open positions, it will only select one? and if i have 3, it will only select 2? am i getting that right? how can i change that then for it to select all of the orders? (OrdersTotal())

no it will select both in that code if three it will select three .. because the i is set to 0 it is always 1 less than orderstotal

-guyver

 
Files:
 

How to build a line on a chart using external values?

Hello,

I export the values from metatrader to excel, do some analytics and get a value for each bar. So basicly I have the values in the excel file and I want to add them as a line to a chart in metatrader, is there any way to do that? Maybe there is an indicator of a function that allows to apply the line to the chart using external data? If someone knows a way to do that, please let me know.

I thank you in advance for all the help you can provide?

 
 

ask GUYVER , it is his expertise area

in your coding

do you know

if ( (frup==0 ) && frdw!=0 ) return (1);

if ( (frdw==0 ) && frup!=0 ) return (-1);

what do return (1) and return (-1) mean ? or what is the effect , is it invalid or does it mean error ?

usually, we see return (0)

 

Returns = Trend Directions

xx3xxx:
ask GUYVER , it is his expertise area

in your coding

do you know

if ( (frup==0 ) && frdw!=0 ) return (1);

if ( (frdw==0 ) && frup!=0 ) return (-1);

what do return (1) and return (-1) mean ? or what is the effect , is it invalid or does it mean error ?

usually, we see return (0)

Hi xx3xxx,

For the formulas -

if ( (frup==0 ) && frdw!=0 ) return (1);

if ( (frdw==0 ) && frup!=0 ) return (-1);

return(0)

In this EA I believe they mean the following:

return(1) = Uptrend

return(-1) = Downtrend

return(0) = No Trend

Hope this helps,

Robert

 

how to choice a label?

Hello,

in my indicator I have several labels - how I can find out a label I have selected??