EA Mechanics, Scope and Working with Decimals Questions

 
Hello Everyone,

I have some simple questions about programming in MT4.

1). When using an Expert Advisor and I have defined a global variable (i.e. int MyVal = 5;) which is Global in Scope to the whole EA, if I add this EA to several different charts is the scope of this variable across all charts or is the scope separate for each EA (I assume this is the case). If I wanted the variable available for all instances of the EA would I declare it as Static int MyVal = 5; ?

2). If I have a EA on several different charts and I need to look at open orders and close orders based on market action. I would need to poll open orders and select open orders that match the pair and timeframe that I am concerned with to get the correct list of open orders then I could close the ones that needed to be closed. My question is that a fair statement of what I need to do?

3). Does anyone have a function they could share that extracts values of a decimal without rounding? For example if my value is .0653 what I want is the .06 and drop the 53 from it and not to round it up to .07 or does anyone have any ideas on how I could code this?

Thank you for your Time
EK
 
1) Scope is seperate for each EA, you assume correct. To have a variable available for all instances of an EA and/or all EA's, use the GlobalVariableSet() function. Look in dicitonary for more explanation.

2) Basically correct, but orders don't have a timeframe property so you can only check what pair it is...unless you use comments and then you can check the comment property. Set the comment to include the timeframe info and there you go. The mechanics of this would be tricky at first. Look at the available string functions in the dictionary.

3) Unfortunately NormalizeDouble() rounds, but you can convert a double to a string, trim the end, then convert back to double.
 
Hello Tony,

Thank you for taking the time to answer my questions
EK
Reason: