first - change your lower "Comment" statements instead of "Print" statement.
I don´t read your thoughts, but at first glance it seems that if you compare logical negative values using the less- or greater than operators, you may have to turn the other way around. If You are a beginner I would avoid this and use the MathAbs() function that passes the absolute value without the minus and now it is easier for you to make logics. If you do not need extra tight scalper you can try element WPArray[1] instead of [0] .
I don´t read your thoughts, but at first glance it seems that if you compare logical negative values using the less- or greater than operators, you may have to turn the other way around. If You are a beginner I would avoid this and use the MathAbs() function that passes the absolute value without the minus and now it is easier for you to make logics. If you do not need extra tight scalper you can try element WPArray[1] instead of [0] .
double WPVal = MathAbs(NormalizeDouble(WPArray[0],2));The main thing is that you use the Print() function to debug your code. it would also be good if you added your variable WPVal in the comment to see its value on an ongoing basis. for that change your first comment "Comment(WPVal)"
I see four major problems here:
1. You do not check if there is an already opened trade. So when the condition is met it enters several times.
2. You are using too small stop loss(5 points) probably that causes trouble.
3. You are entering Buy trade with Bid price. You should enter with Ask price.
4. TP and SL are to be calculated separately depending on the direction of the trade.
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,
im newbie in MQL5 and i wrote this simple code me to test whats going on...
Well, i would expect if it is the value of Williams %R up to -20 it will be opened a sell position and if it is below -80 it will be opened the buy position however it doesnt happend...Actually sometimes yes sometimes no, but definitely not by every crossing of these values...whats wrong? My code is probably too simple and it miss something....
Im trying understand how to open position by given parameters..
Thanks for help