Hi guys, let me say first up, I am absolutely not a programmers butthole.
Thanks in advance to all that offer their skills, may the trading deity bless you with low draw downs and many pips
-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon. -
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Forum rules and recommendations - General - MQL5 programming forum (2023)
Messages Editor -
I agree with Dominik. Three enumerations describing a bool is ridiculous.
-
double tpbuy = Ask + (tpfix)*10*Point; double slbuy = Ask - (slfix)*10*Point;
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
My GBPJPY shows average spread = 26 points, average maximum spread = 134.
My EURCHF shows average spread = 18 points, average maximum spread = 106.
(your broker will be similar).
Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)
-
Your code.
Do not hard code constants.
Code breaks on MT5.if(timema==PERIOD_M1 || (timema==PERIOD_CURRENT && Period()==1)) { miantimeframess="M1"; } if(timema==PERIOD_M5 || (timema==PERIOD_CURRENT && Period()==5)) { miantimeframess="M5"; } if(timema==PERIOD_M15 || (timema==PERIOD_CURRENT && Period()==15)) { miantimeframess="M15"; } if(timema==PERIOD_M30 || (timema==PERIOD_CURRENT && Period()==30)) { miantimeframess="M30"; } if(timema==PERIOD_H1 || (timema==PERIOD_CURRENT && Period()==60)) { miantimeframess="H1"; } if(timema==PERIOD_H4 || (timema==PERIOD_CURRENT && Period()==240)) { miantimeframess="H4"; } if(timema==PERIOD_D1 || (timema==PERIOD_CURRENT && Period()==1440)) { miantimeframess="D1"; } if(timema==PERIOD_W1|| (timema==PERIOD_CURRENT && Period()==10080)) { miantimeframess="W1"; } if(timema==PERIOD_MN1 || (timema==PERIOD_CURRENT && Period()==43200)) { miantimeframess="MN1"; }
Simplified miantimeframess=as_string(timema); ////////////////////////////////////////// string as_string(ENUM_TIMEFRAMES aePeriod){ if(aePeriod == PERIOD_CURRENT) aePeriod = ENUM_TIMEFRAMES(_Period); string period_xxx = EnumToString(aePeriod); // PERIOD_XXX return StringSubstr(period_xxx, 7); // XXX }
Yep, I unfortunately paid money for this.
The guy was a complete rookie, no idea.
Thank you for your reply, any help I can get is appreciated.
-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon. -
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Forum rules and recommendations - General - MQL5 programming forum (2023)
Messages Editor -
I agree with Dominik. Three enumerations describing a bool is ridiculous.
-
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
My GBPJPY shows average spread = 26 points, average maximum spread = 134.
My EURCHF shows average spread = 18 points, average maximum spread = 106.
(your broker will be similar).
Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)
-
Your code.
Do not hard code constants.
Code breaks on MT5.Simplified
Hey William, in response to your questions
1.1Why post in the MT5 are - Im a bit special?
1.2 Sorry, as above, im special, I didnt know there was a way to post code, and didn't realise it'd drive people mental. Ive fixed it, obviously.
1.3 I don't know what a Bool is, im guessing some type of true of false logic, I dunno, not a programmer at all. Hence why I am here, to mooch off you good people.
2.1 Don't you want the specified amount used in either direction?
Yeah, I think that's what I want, I sort of grasp what you're saying, Im not sure what to change to fix it though. What you are saying about the SL/TP being closer and further, respectively, and why you wouldn't want that makes sense.
Would you steer me in the right direction on what to change there? Im terribly sorry, I am a complete noob as far as programming goes. I can trade, I've been in the game a little while now, everyday is a school day but.
2.2 I need to read that a few more times and get my head around it.
2.3 Im all across charts showing bid and ask prices, it'd be about the only thing Im all over.
With regards to the "simplified" code you posted, Im not sure what I should do with that? Im sure its blisteringly obvious to you, but am I to assume I shit can the bit of code (your code) and replace it with the simplified version?
I assume all that code he's come up with is superfluous and unnecessary?
Thanks a million for your comments so far, I really appreciate it.
Cheers
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Thanks in advance to all that offer their skills, may the trading deity bless you with low draw downs and many pips