Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Keith Watford:
Thanks Keith! I am quite new here. I appreciate your help.
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
jok kok:
I want to make EA like this EA takes position when price during above 20ma and does not exit before price once goes down below 20ma then exits when price comes back above 20ma. But my EA exits soon after taking position because price is above 20ma. If someone knows how to fix this, It would be very helpful.
It seems to me that it makes no sense that the exit condition should be basically the same as the entry condition.
Keith Watford:
It seems to me that it makes no sense that the exit condition should be basically the same as the entry condition.
Yeah you are right. but if it works only making Short position, I thought it would be better to avoid many lose trades. Thanks though.
Your code | Result |
---|---|
int sum = 0; int Shortsum = 0; int CloseStrtagy2=Shortsum; double Ma3=iMA(NULL,PERIOD_M5,1,0,0,0,0); double Ma4=iMA(NULL,PERIOD_M5,5,0,0,0,0); if(ShortNum!=0 && Ma3>Ma4 )sum = 1; if(sum=1 && Ma3<Ma4 )Shortsum = 1; if(Shortsum!=0 && ( CloseStrtagy2!=-1 )) { ExitSell=1; ShortNum=0; } | sum is zero. Shortsum is zero. CloseStrtagy2 is zero. irrevalent. Don't use zeros, use the proper enumerations: ENUM_MA_METHOD ENUM_APPLIED_PRICE ShortNum is zero, line does nothing. sum is zero, line does nothing. Shortsum is zero, lines do nothing. |

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
I want to make EA like this EA takes position when price during above 20ma and does not exit before price once goes down below 20ma then exits when price comes back above 20ma. But my EA exits soon after taking position because price is above 20ma. If someone knows how to fix this, It would be very helpful.
Thanks
Ken