i got solutions, so i work at OrderClose() & OrderCcloseby()... ty
- Glaadiator: I had difficulty closing the current order with the indicator. I
Glaadiator: i got solutions, so i work at OrderClose() & OrderCcloseby()... ty Indicator's can not trade. Your solutions will not work in an indicator.Indicators can not trade. Your solutions will never work.
-
double AO1= iAO(NULL,PERIOD_D1,1); double AO2= iAO(NULL,PERIOD_D1,2); double AO3= iAO(NULL,PERIOD_D1,3); // double AO_up = (AO1 < AO2); double AO_dw = (AO1 > AO2); // double close1 =iClose(NULL,PERIOD_D1,1); double close2 =iClose(NULL,PERIOD_D1,3); double high2 =iHigh(NULL,PERIOD_D1,2); double low2 =iLow(NULL,PERIOD_D1,2);
Those are not assignments; it's initialization of a common (globally declared,) or static variable with a constant. They work exactly the same way in MT4/MT5/C/C++. - They are initialized once on program load.
- They don't update unless you assign to them.
- In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use.)
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
- Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
external static variable - MQL4 programming forum -
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4 2019.05.20

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I studied personally in the forum, no coding skills at all, I did it for 2 years. thank you for everything.
and this time, I had difficulty closing the current order with the indicator. I want to close it with the indicator I chose, I think it might be done. but I was at my wits end and finally here.
this is my code:
I study with various codes here, I thank you for everything
it's a condition that I made and it benefits me.