Coding questions ...

 

mladen

This is an indicator so I'm not sure OrderType works in an indicator.

I can't seem to get OrderType() to work. In the last line of code the BasketType always shows 1 for both op_BUY & OP_SELL. the OrderType always shows 0.

Thanks for your help, I hope.

Ray

Line 231

if((OrderType())== OP_BUY) BasketType = OPEN_BUY ; //1

Print("!TLE-Basket Type-start===== ",OrderType());

if((OrderType())== OP_SELL) BasketType = OPEN_SELL ; //2

Print("!TLE-Basket Type-start===== ",OrderType());

if (BasketType != OPEN_BUY && BasketType != OPEN_SELL) return(0);

Print("!TLE-Basket Type-start===== ",BasketType," ",OrderType());
Files:
tle_hama.mq4  10 kb
 

Ray

The probable problem is in a line proceeding that code. In it you have :
OrderSelect ( SELECT_BY_POS, MODE_TRADES);[/PHP]

and in that line you are missing one parameter - the first parameter should be the index of the order you would like to access (if you want to use the SELECT_BY_POS selection mode). Change that line to something like this :

[PHP]OrderSelect ( desiredIndexOfOrder, SELECT_BY_POS, MODE_TRADES);

where "desiredIndexOfOrder" should be an integer value

traderduke:
mladen

This is an indicator so I'm not sure OrderType works in an indicator.

I can't seem to get OrderType() to work. In the last line of code the BasketType always shows 1 for both op_BUY & OP_SELL. the OrderType always shows 0.

Thanks for your help, I hope.

Ray

Line 231

if((OrderType())== OP_BUY) BasketType = OPEN_BUY ; //1

Print("!TLE-Basket Type-start===== ",OrderType());

if((OrderType())== OP_SELL) BasketType = OPEN_SELL ; //2

Print("!TLE-Basket Type-start===== ",OrderType());

if (BasketType != OPEN_BUY && BasketType != OPEN_SELL) return(0);

Print("!TLE-Basket Type-start===== ",BasketType," ",OrderType());
 

mladen

I'm confued about the integer, see charts, what is the first paramater refering too.

Ray

mladen:
Ray The probable problem is in a line proceeding that code. In it you have :
OrderSelect ( SELECT_BY_POS, MODE_TRADES);[/PHP]

and in that line you are missing one parameter - the first parameter should be the index of the order you would like to access (if you want to use the SELECT_BY_POS selection mode). Change that line to something like this :

[PHP]OrderSelect ( desiredIndexOfOrder, SELECT_BY_POS, MODE_TRADES);
where "desiredIndexOfOrder" should be an integer value
 

Ray

Some more info about OrderSelect() : OrderSelect - MQL4 Documentation

Prototype for OrderSelect function is the following : bool OrderSelect( int index, int select, int pool=MODE_TRADES)

 

mladen

I think I'm lost. Can I re-state my request. I'm trying to determine what my present condition is OP_BUY or OP_SELL or neither, so that I can use it for the CLOSE_ORDER in my indicator.

Is OrderSelect even necessary?

Ray

mladen:
Ray

Some more info about OrderSelect() : OrderSelect - MQL4 Documentation

Prototype for OrderSelect function is the following : bool OrderSelect( int index, int select, int pool=MODE_TRADES)
 

Coding questions ...

There are some similar threads in public sections, but it won't hurt to have a similar one in this section too (with a bit more freedom of questions since they are going to be less public... )

 

Ray

I am lost this time.

May I remind the original question :
I can't seem to get OrderType() to work. In the last line of code the BasketType always shows 1 for both op_BUY & OP_SELL. the OrderType always shows 0.

And I answered that the line prior to the code you posted contains an invalid call to OrderSelect() function.

Other than that I have no idea what are you trying to achieve and there is no way that I can answer if you need that function or not.

All I can tell is that if you want to test the type of some order you must call OrderSelect() prior to trying to see the type of order, otherwise you do not know which order (as in which identified order) and its type are you reading (that is the purpose of index parameter there - to position to a specific order among opened orders if you use MODE_TRADES for pool parameter)

regards

Mladen

traderduke:
mladen

I think I'm lost. Can I re-state my request. I'm trying to determine what my present condition is OP_BUY or OP_SELL or neither, so that I can use it for the CLOSE_ORDER in my indicator.

Is OrderSelect even necessary?

Ray
 

mladen

This indicator changes the numerical value of OPEN_BUY to 1. I thought OP_BUY was also a one, DDDAAAA, its 0. I was looking at the OrderType = OP_BUY which = 0 all the time thinking it should be a 1. I'm Havvvinng a baaaad day. Thank you for not screaming into my ear, god knows I deserve it.

Thanks for your Patience, I GOT IT.

Ray

PS: did you create this blog only for excepionally stupid question, why am I the only one in here??

mladen:
Ray

I am lost this time.

May I remind the original question :
I can't seem to get OrderType() to work. In the last line of code the BasketType always shows 1 for both op_BUY & OP_SELL. the OrderType always shows 0.

And I answered that the line prior to the code you posted contains an invalid call to OrderSelect() function.

Other than that I have no idea what are you trying to achieve and there is no way that I can answer if you need that function or not.

All I can tell is that if you want to test the type of some order you must call OrderSelect() prior to trying to see the type of order, otherwise you do not know which order (as in which identified order) and its type are you reading (that is the purpose of index parameter there - to position to a specific order among opened orders if you use MODE_TRADES for pool parameter)

regards

Mladen
 

Ray

Glad that you solved it As of the new question : I think that maybe a thread like this should have been created earlier. Some reasons :

- asking questions in public threads about some coding stuff might be a bit tricky (after all I told a lot of times that I am not posting so much at public sections because I do not like what some people do with my code. I believe that nobody likes that stuff happening to their code and / or ideas, and a thread like this in elite section can help a bit in that)

- as much as it is possible, code and coding problems solutions that can be and will be with time, posted here, are avoiding the trap of becoming "public property"

- and last (for now ) : I do not think that questions about coding can be stupid. Pretending to know everything in coding is stupid, asking was and never will be stupid. I sincerely believe that, apart from Donald Knuth ,there is no other computer coding guru and god. Maybe I am going ask questions here too. Coding is a language and we all are learning to "talk" coding language : with time we can "say" things nicer, shorter, more efficiently ... and a thread where we ask and / or answer (since even answering can be a part of learning process) can only help in improving our coding skills

 

mladen

Thank you for setting this blog up. God knows I need it.

Ray

 

Mladen

I'm sure this question will be redundent but I can't get it to work so here goes another MTF question. My EA calls the Indicator for that chart it is on and works great. I can't get the MTF to work correctly, for instance 1m chart with 15m indicator. The indicator works on the chart as you can see but the EA will only use the Chart TF. I 'm sure I got the layout wrong near line 1672 to 1750 is the area of the problem.

Can you help??

Ray

Reason: