jthornton: I'm currently setting up a buy order when a certain condition is true.
| Don't do that. Open the order when you get a change in condition.
static bool isBuyCondition=false; bool wasBuyCondition = isBuyCondition; isBuyCondition = ...; if(!wasBuyCondition && isBuyCondition) // Now open. |
Don't do that. Open the order when you get a change in condition. |
So let's go with a more specific situation:
if close[0] is > than MA(5) --> BUY
if close[0] is <= SL --> SELL
The problem is arising that on the same day the price will drop below the SL and then pop back up and re-purchase. I know one solution is to not set the SL so close, but I also want to add in "Don't BUY if it was closed today".
Can you show me a more specific example using these parameters?
I'm currently setting up a buy order when a certain condition is true. The problem I'm running into is the stoploss is triggering and then trying to re-purchase the buy order right away.
So, the end result is multiple trades per day that is just eroding the capital.
How can I put something in my code that basically says... "When s/l triggered, don't buy anything else today"?
When you open a trade for the day, set a variable containing the dateTime value for the daily candle.
https://docs.mql4.com/series/itime
iTime() will tell you information you need.
Then just check that before you open a new order.
- docs.mql4.com
When you open a trade for the day, set a variable containing the dateTime value for the daily candle.
https://docs.mql4.com/series/itime
iTime() will tell you information you need.
Then just check that before you open a new order.
jthornton: "Don't BUY if it was closed today".
| If you want that, code that specifically.
|
- 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'm currently setting up a buy order when a certain condition is true. The problem I'm running into is the stoploss is triggering and then trying to re-purchase the buy order right away.
So, the end result is multiple trades per day that is just eroding the capital.
How can I put something in my code that basically says... "When s/l triggered, don't buy anything else today"?