Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 353
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
Hi all.
I haven't liked programming since university, but the time came when I needed a bot for trading on the stock market (I understand that EA and bot are the same thing?).
It (bot) should close position when muwings are crossed (fast one crosses slow one).
Found a couple of codes in kodobase. But:
1. it is not clear where to set the timeframe in the Expert Advisor code?
2. Some EAs have 2 files: one with extension mq4, the other with extension mqh. Why do we need an mqh file?
3. How to set up an Expert Advisor in mt4? Is it enough just to add an Expert Advisor in "experts" folder and activate it? Or what else needs to be done to make it work? In general, I would be grateful if the process of EA installation into a trading program would be explained in detail.
I am not too clueless in C ++. I need an EA, I just have to change timeframe and muwings.
I trade on btc-e cryptocurrency exchange. For those who will help (and just good people), I can help and answer questions about this exchange and BitCoin currency. Contact me in person or skype okidoki543
I think I found what I need:
https://www.mql5.com/ru/code/8463?source=terminal4_codebase
I'm going to finalise it and try it on small lots. But thank you to everyone who has an opinion on my question here. I don't know yet, that everything will work out for me. I have a strong aversion to programming. )
Comrades, I removed the following line in the code (see link above): //============================================================================================
int CrossPositionOpen()
{
PosOpen=0; // Here is where the dog is buried!!!:)
if ((MA1_1<=MA2_0 && MA1_0>MA2_0) || (MA1_1<MA2_0 && MA1_0>=MA2_0)) // Crossing from bottom to top
{
PosOpen=1;
}
if ((MA1_1>=MA2_0 && MA1_0<MA2_0) || (MA1_1>MA2_0 && MA1_0<=MA2_0)) // Top-down intersection
{
PosOpen=2;
}
return(PosOpen); // Return direction of intersection.
}
As far as I understood it with my feeble mind, this code section is responsible for opening positions at MA crossing. I don't need it because the EA is only needed (at least, for now) to close positions.
Could you advise me, if I understand correctly, that this EA will only close positions that are already open when the MA is crossed (e.g., crossed from above downwards - closed the long position)?
Am I thinking correctly, MA1_Price is the price used to calculate the MA and if I put "4" there, it will be the close price?
Am I following correctly - extern double - this is the number of lots for which the position will be opened. After all, I want my position opened by any number of lots to be closed by this code. Can you please advise how to configure this in the code? Or this code will close position with any lot without any settings?
I'm relying on some help.
Comrades, I've removed the line in the code (see link above): //============================================================================================
int CrossPositionOpen()
{
PosOpen=0; // Here is where the dog is buried!!:)
if ((MA1_1<=MA2_0 && MA1_0>MA2_0) || (MA1_1<MA2_0 && MA1_0>=MA2_0)) // Crossing from bottom to top
{
PosOpen=1;
}
if ((MA1_1>=MA2_0 && MA1_0<MA2_0) || (MA1_1>MA2_0 && MA1_0<=MA2_0)) // Top-down intersection
{
PosOpen=2;
}
return(PosOpen); // return direction of intersection.
}
As far as I could understand with my feeble mind, this section of the code is responsible for opening positions when the MA is crossed. I do not need it, because I need the EA (at least for now) only to close positions.
Could you advise me, if I understand correctly, that this EA will only close positions that are already open when the MA is crossed (e.g., crossed from above downwards - closed the long position)?
Am I thinking correctly, MA1_Price is the price used to calculate the MA and if I put "4" there, it will be the close price?
Am I following correctly - extern double - this is the number of lots for which the position will be opened. After all, I want my position opened by any number of lots to be closed by this code. Can you please advise how to configure this in the code? Or this code will close position with any lot without any settings?
I rely on your help.
Yeah, I removed the line with the comments))))) Really bad at programming))))
At a glance, if you do not need to open orders, comment out the following lines:
// OpenBuy();
и
// OpenSell();
MA1_Price is indeed a price type, but 4 is the average price. And this is only for the first mask; there is also MA2_Price. For price constants, check here
The EA has no check for Magik and symbol. It will close all of them one by one.
And after making changes in the text of the EA, do not forget to recompile it.
The lots in your case are not needed, do not pay attention to them.
Yeah, I removed the line with the comments))))) Really bad at programming))))
You seem to be wrong. Там после строки //============================================================================================
The commands were in blue, so it wasn't a comment.
And after making changes to the EA text, don't forget to recompile it.
Yes! And don't rush into real trading with this EA. It has no error handling, you have to bring it to a real account. Try it in the tester first.
Yes, I think I will try it on demo for a week first.
Thank you very much for your help. I hope for further help. ;)
I also tweaked the code, removing everything unnecessary.
I have understood how to compile it, I have uploaded the Expert Advisor to the minute chart on the demo, I will test it and in about 20 minutes I will know if it works or not.
If something goes wrong, I will ask more questions.
Questions:
If I change the timeframe on the chart, will all EA settings be lost? That is, can I change the timeframe on the chart where the EA is installed?
I have closed charts in the real account where I have installed EA (I did not figure out how to delete EAs otherwise). Have the EAs been deleted or not?
Does the EA work when I am not connected to MT4 via internet?