-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
int init(){ mySymbol="AUDJPY"; OpenBuy(); mySymbol="AUDUSD"; OpenBuy(); ⋮
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.
Broker's use a variety of naming patterns: EURUSD, EURUSDc, EURUSDct, EURUSDecn, EURUSDi, EURUSDm, EURUSDme, EURUSDpro, EURUSDt, "EUR.USD", "EUR/USD", "EURUSD!", "EURUSD#", "EURUSD.", "EURUSD..", "EURUSD.c", "EURUSD.cfx", "EURUSD.G", "EURUSD.i", "EURUSD.r", "EURUSD.SBe", "EURUSD.stp", "EURUSD+", "EURUSD-5", "EURUSD-m", "EURUSD-sb", etc., Financial symbols with '-', '=', '_' and '+'
If the pattern your broker uses doesn't match the pattern of your signal provider's broker, you can't copy the signal/open a trade.
If the naming pattern of your charts isn't exactly "BasQuo" then hard coded symbols fails.
Don't hard code things; just use the predefined _Symbol, or remove the adornments during processing.
I need to know how to fill an enum or get a drop down list, with a string array :)) - MQL4 programming forum #10 2020.06.12 -
int start(){
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 2016.05.11 -
ask=MarketInfo(mySymbol,MODE_ASK); ticket=OrderSend(mySymbol,OP_BUY,Lots,ask,Slippage,0,0,TradeComment,MagicNumber,Green);
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 -
total=OrdersTotal(); if(total<1)
You understand that is all orders on any symbol?
Try placing RefreshRates above the bid + ask price requests .
Also place RefreshRates and bid price request in the sell for loop.
bid request not needed in buys loop.
ask request not needed in sells loop.
Not using Bid/Ask predefined symbols. RefreshRates is irrevalent.
Not using Bid/Ask predefined symbols. RefreshRates is irrevalent.
did not know that thanks .
Should he/she use SymbolInfoDouble ?
Tip 1 done - thank you
I am old, but very new to this, to much time spent copy/paste code together. thanks for the help, will give it a crack and see how we go.
- 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.
Broker's use a variety of naming patterns: EURUSD, EURUSDc, EURUSDct, EURUSDecn, EURUSDi, EURUSDm, EURUSDme, EURUSDpro, EURUSDt, "EUR.USD", "EUR/USD", "EURUSD!", "EURUSD#", "EURUSD.", "EURUSD..", "EURUSD.c", "EURUSD.cfx", "EURUSD.G", "EURUSD.i", "EURUSD.r", "EURUSD.SBe", "EURUSD.stp", "EURUSD+", "EURUSD-5", "EURUSD-m", "EURUSD-sb", etc., Financial symbols with '-', '=', '_' and '+'
If the pattern your broker uses doesn't match the pattern of your signal provider's broker, you can't copy the signal/open a trade.
If the naming pattern of your charts isn't exactly "BasQuo" then hard coded symbols fails.
Don't hard code things; just use the predefined _Symbol, or remove the adornments during processing.
I need to know how to fill an enum or get a drop down list, with a string array :)) - MQL4 programming forum #10 2020.06.1
I think i understand this, and most likly my issue.
This part of the code came from a Script i use, which is on the go as soon as you load it, where as the newer code is waiting for a time setting before doing anything, by which time the first part has been closed out. so it has nothing to relate to.
will try moving this and see how i go.
thank you.
MT4: MarketInfo or SymbolInfoDouble is the same.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4 2019.05.20
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, can any one help. i keep getting error codes and can't find the solution. compiles fine, just won't open the trades. idea is to run the EA on a single chart and open all trades at a set time of day.
Thanks in advance.