-
Why did you post your MT4 question in the
Root /
MT5 EA section
instead of the MQL4 section,
(bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - When you post code please use the CODE button (Alt-S)!
(For large amounts of code, attach it.)
Please edit
your (original) post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
Help you with what?
You haven't stated a problem, you stated a want.
You have only four choices:- Search for it,
-
Beg at
- Coding help - MQL4 and MetaTrader 4 - MQL4 programming forum
- Requests & Ideas (MQL5 only!) - Trade FX - Expert Advisors and Automated Trading - MQL5 programming forum
- Free coding for your trading system.. - Easy Trading Strategy - General - MQL5 programming forum
- I will code & automate your strategy for free - Options Trading Strategies - General - MQL5 programming forum
- Make It No Repaint Please! - MetaTrader 5 - MQL4 and MetaTrader 4 - MQL4 programming forum
- learn 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 yours.
- or pay (Freelance) someone to code it.
No free help
urgent help. - And unless you want to open an order every tick, you need to test for open orders or a new bar.
- And you are looking at bar zero MA. That may cross and uncross multiple times as price moves.
Hi,
thank you for your answer.
1. As this is my first time writing this on this forum I made a mistake which was not intentional.
2. Changed!
3. O I stated the problem o right, the problem is that I don't know how to code my intention.
In the mean time I managed to make some progress but your number 4. is right where my next problem is, I am having milion of orders opened. I suspect this is because of the "void OnThick" function.
I am trying to learn the code but my intention is not to learn the whole thing but only what I need.
4. Like I said before now I am getting many trades open on every thick and this is not what I want, can you point me in the right direction?
5. Unfortunately, I have no clue what does "bar zero" mean.
Thanks for the links!
This is my current code:
void OnTick() { double SlowMovingAverage = iMA(NULL,0,10,0, MODE_EMA,PRICE_CLOSE,0); double LastSlowMovingAverage = iMA(NULL,0,10,0, MODE_EMA,PRICE_CLOSE,1); double FastMovingAverage = iMA(NULL,0,20,0, MODE_EMA,PRICE_CLOSE,0); double LastFastMovingAverage = iMA(NULL,0,20,0, MODE_EMA,PRICE_CLOSE,1); if ((LastFastMovingAverage < LastSlowMovingAverage) && (FastMovingAverage > SlowMovingAverage)) //Comment ("SELL"); OrderSend (Symbol(),OP_SELL,0.3,Bid,2,Bid-50*Point,Bid+70*Point); if ((LastFastMovingAverage > LastSlowMovingAverage) && (FastMovingAverage < SlowMovingAverage)) //Comment ("BUY"); OrderSend (Symbol(),OP_BUY,0.3,Ask,10,Ask-50*Point,Ask+70*Point); }
Hi,
thank you for your answer.
1. As this is my first time writing this on this forum I made a mistake which was not intentional.
2. Changed!
3. O I stated the problem o right, the problem is that I don't know how to code my intention.
In the mean time I managed to make some progress but your number 4. is right where my next problem is, I am having milion of orders opened. I suspect this is because of the "void OnThick" function.
I am trying to learn the code but my intention is not to learn the whole thing but only what I need.
4. Like I said before now I am getting many trades open on every thick and this is not what I want, can you point me in the right direction?
5. Unfortunately, I have no clue what does "bar zero" mean.
Thanks for the links!
This is my current code:
Hi,
thank you for your input, I have corrected the numbers but am still getting many orders opened. It has to be onThick function.
...and check your open conditions, do you really want to sell when fast MA up-crosses slow MA?
...and the SL/TP values for the sell order are wrong
Hi,
thank you for your answer.
1. As this is my first time writing this on this forum I made a mistake which was not intentional.
2. Changed!
3. O I stated the problem o right, the problem is that I don't know how to code my intention.
In the mean time I managed to make some progress but your number 4. is right where my next problem is, I am having milion of orders opened. I suspect this is because of the "void OnThick" function.
I am trying to learn the code but my intention is not to learn the whole thing but only what I need.
4. Like I said before now I am getting many trades open on every thick and this is not what I want, can you point me in the right direction?
5. Unfortunately, I have no clue what does "bar zero" mean.
Thanks for the links!
This is my current code:
Thank you all for participating!
I did not expect this at all, every single one of your posts helped me in coming closer to my full functional EA.
I will try to perfect it for couple of more days and when I get stuck, I will report back here.
My Ideas are:
1. Implement a trailing stop after the order has been issued, so I can have a larger takeprofit margin.
2. Implementing a time option to trade only during London hours.
3. Enter the trade after MA's have crossed on the next closed bar which has to be in the "direction" of the cross.
I wont mind if anybody writes some hints about these ideas.
Thank you once again guys, really appreciate it!
Hi Kidfisto,
I understand you as a newb, I was in the same case before and did not know how to build any EA. Then one week-end I read the whole documentation and all became clear...
You say you don't want to learn the whole thing but you cannot have anything for nothing. Either you pay it or you learn it.
Your question about bar zero : bar zero is the current bar. If you don't check that the bar is new, then you are checking the current tick, which is crazy, your orders can be triggered every second.
One tip for you. After I read the documentation, I went into an online tool that would generate the code for me with a few clicks (it is called EA builder). By reading the source code of what it generates, it dramatically improved my understanding of the whole thing.
Then I read "clean code" by M. Fowler, and I definitely reached another level of knowledge, far above what you can expect. I would highly recommend you to learn more. It's fun!
![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
Hi,
I want to create my own EA, but I am stuck because programming is not my forte.
I have created/copied a simple alert indicator with which I am happy, but instead of Comment SELL or BUY I want the EA to enter a trade.
Can someone please replace the comment part with the code necessary to enter an order? the first part about the variables is still commented because i don't know how to proceed after "if" statement.
Keep ti simple please, noob here.
Thanks in advance.