- Don't post code that will not even compile!
if (isBuy == true); «««««««« if(condition) statement; The if is done. double EntryPrice == Ask; «««««««« If you remove the semicolon above, the if stops here. double StopLossType =0; { «««««««« why have you isolated this code group? if (StopLossType == SL_TYPE1) StopLossType = PreviousLow (NULL,OpenPrice); if (StopLossType == SL_TYPE2) StopLossType = iLow(NULL, 0, 1); else StopLossType == SL_TYPE3; return (StopLossType); } double CalculateStopLoss; { «««««««« why have you isolated this code group? CalculateStopLoss = Ask - StopLossType* MyPipValue(); } «««««««« If you had used strict, the above line doesn't compile. else ««««««« else without a matching if. { CalculateStopLoss= Ask + StopLossType * MyPipValue (); }
-
You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
- Don't use NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum 2020.07.25
-
Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.
Yes you do. Learn to code. Then write one!
You haven't stated a problem, you stated a want.How To Ask Questions The Smart Way. 2004
Prune pointless queries. You have only four choices:
-
Search for it. Do you expect us to do your research for you?
-
Beg at:
- Coding help - MQL4 programming forum
- Make It No Repaint Please! - MQL4 programming forum
- MT4 to MT5 code converter - MQL5 programming forum
- Please fix this indicator or EA - General - MQL5 programming forum - Page 193 #1027
- Requests & Ideas (MQL5 only!) - Expert Advisors and Automated Trading - MQL5 programming forum
-
MT4: Learn to code it.
MT5: Begin learning to code it.
If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code. -
or pay (Freelance) someone to code it. Top of every page is the link Code Base.
Hiring to write script - General - MQL5 programming forum 2019.08.21
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
No free help 2017.04.21
Understood Mr.Reoder.
I didn't mean you to do ALL for me, I was wondering where did I do wrong in creating my first function and how to do that. This is my first time to learn programming, I have read mql Book and will re-read again, and bought courses on Udemy. What you said is right, I need to able to read my code out loud and make sense of it, which still not. So I will keep learning till I can read my own code out loud and make sense for me. Thanks for your advice. :-)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have been trading for over 5 years, I understand how to trade, and now I want to learn how to code mql4 my own.
b. based on the last candle hi/low
c. fixed pips
I am still very new to all this, I may make mistakes on small things like semicolons, etc.. or probably the whole functions is wrong.
Please help.