
Discover new MetaTrader 5 opportunities with MQL5 community and services
- 2024.06.09
- www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
- help for write my first EA in mql4
- change in coding.
- What's wrong with this code!
Ontick
{
{ remove this duplicate line
-
Always use the CODE button (or Alt+S)! (For large amounts of code, attach it.) I fixed it for you this time.
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Messages Editor
Forum rules and recommendations - General - MQL5 programming forum (2023) -
void OnTick() { {
Why is there an extra bracket? -
for(int i = 0; i < Bars(_Symbol, PERIOD_M1); i++) { datetime time = iTime(_Symbol, PERIOD_M1, i); int hour = TimeCurrent() if(TimeCurrent(time) >= StartHour && TimeMinute(time) >= StartMinute && TimeCurrent(time) <= EndHour && TimeMinute(time) <= EndMinute); double high = iHigh(_Symbol, PERIOD_M1, i); double low = iLow(_Symbol, PERIOD_M1, i); if(high > windowHigh) windowHigh = high; if(low < windowLow) windowLow = low; // After the time window, place BuyStop and SellStop orders if not already placed if(TimeHour(currentTime) == EndHour && TimeMinute(currentTime) == EndMinute && !tradeOpened)
Where is the closing bracket for the for? - Where is the closing bracket for the if?
- TimeCurrent does not return an hour.
- TimeCurrent does not take an argument.
In Meta Editor Settings activate "highlight matching brackets" checkbox.
oyebanji110394:
This is probably gpt code that's why there's so many very clear errorsIn addition to what William said, your for loop is mess
1. There's a missing curled bracket "}" at the end of your loop
2. Your hour variable is missing a ";"
3. Your OnTick function has an extra opening bracket in the beginning and missing one closing bracket at the end
Lastly there is another closing bracket at the end of the code, which.. no. Remove that "};"
And your

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