I've also tried with this
if(bar[holding-1] != EMPTY_VALUE ) { trade.PositionClose(_Symbol, 5); }
but the error persits.
'!=' - illegal operation use moving average cross strategy.mq5 148 25
what's wrong?
Create a global variable called "current_hold=0;"
- set it to zero on init
- when you enter a trade set it to 0
- for every new bar that forms after a trade increase it by 1
- when you hit the limit (the input variable) then close the trade and reset the current_hold to zero
- Lorentzos Roussos #: for every new bar that forms after a trade increase it by 1
EAs must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static / global count variables will have been lost.
- Javier Santiago Gaston De Iriarte Cabrera: How can I close an order after 25 bars
Get the order open time, use iBarShift to find the bar index, close when it is 25 or greater.
-
EAs must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static / global count variables will have been lost.
-
Get the order open time, use iBarShift to find the bar index, close when it is 25 or greater.
I haven't even though of that .
Use this OP
In your code "bar" is an array of MqlRates which is a struct data type.
You are getting "illegal operation use" error because you are trying to compare struct with integer. This can't be done.
Read again documentation on CopyRates and study the code example on that page.
- www.mql5.com
-
EAs must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static / global count variables will have been lost.
-
Get the order open time, use iBarShift to find the bar index, close when it is 25 or greater.
Thanks, it worked
- 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'm getting this error:
when using this:
with this
and
What is wrong, and how can I fix this?