
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 went through the code and had some difficulty with the "continue;" as I don't have cycle code for the Trailing stop. I added the magic Number as the the message returned "symbol doesnt equal" (Symbol(0 to OrderSymbol() ) .Now I get messgage "Symbol Equals" when using the magic No.
My Trailing stop is moving back and forth, Is there anything I should add to my code ?
Please let me know if you can see any other issues with my code ? Thanks .
I went through the code and had some difficulty with the "continue;" as I don't have cycle code for the Trailing stop.
What about the for loop ?
Without the continue you try to do the OrderModify() regardless of a match on the Symbol or not . . .
I tried "While(trailingstop > 0) " code in and it caused the MT4 to freeze, When ever I see examples of continue; being used the "While statement is being used. If I don't add the while statement I get errors . It seems like it is almost working.
I've been looking at https://www.mql5.com/en/articles/1404 but I can't get rid of the errors in my code. But, I can't seem to get rid of the errors ,
Any assistance you can provide to get me over this hurdle would be welcome. Thanks.
I tried "While(trailingstop > 0) " code in and it caused the MT4 to freeze, When ever I see examples of continue; being used the "While statement is being used. If I don't add the while statement I get errors .
Why have these 2 lines when they do exactly the same thing ?
They don't do exactly the same thing....
OrderStopLoss() can be smaller, equal or higher value then the OrderOpenPrice()
It makes the trailing happen if BreakEvenPoint has past.....
They don't do exactly the same thing....
OrderStopLoss() can be smaller, equal or higher value then the OrderOpenPrice()
It makes the trailing happen if BreakEvenPoint has past.....
If I remove this block of code from the EA it compiles with NO Errors and and it works.
So the Error is due to this block of code in the // TrailingStop.
I am getting 3 Errors; Error 1/ ' continue' - 'break' or 'continue' used with some cycle only
(Same as Error 1) Error 2/ 'continue' - 'break' or 'continue' used with some cycle only
Error 3/ 'Error' - internal error
The above Errors are as per the code in SRC.
If I put: While (trailingstop > 0) it causes the MT4 platform to freeze, even though it does compile with "Zero Errors".
If I remove this block of code from the EA it compiles with NO Errors and and it works.
So the Error is due to this block of code in the // TrailingStop.
I am getting 3 Errors; Error 1/ ' continue' - 'break' or 'continue' used with some cycle only
(Same as Error 1) Error 2/ 'continue' - 'break' or 'continue' used with some cycle only
Error 3/ 'Error' - internal error
The above Errors are as per the code in SRC.
If I put: While (trailingstop > 0) it causes the MT4 platform to freeze, even though it does compile with "Zero Errors".
You don't need the while . . .
The problem is the second block of code is outside of the for loop so the continues cannot apply to the for loop, hence the errors.
If it were me I would combine some of your if statements to make your code easier to follow and less prone to this kind of error, also use { } braces with your for loop for clarity. I have to go out for a couple of hours, when I get back I'll show you what I mean if you haven't done it already by then.
I have to go out for a couple of hours, when I get back I'll show you what I mean if you haven't done it already by then.
OK, this is what I would do . . .
There is no need for continue in this code, it will apply the trailing stop to all open orders that match your Symbol and Magic Number.
As I said previously you are going to have issues with comparing doubles.
OK, this is what I would do . . .
There is no need for continue in this code, it will apply the trailing stop to all open orders that match your Symbol and Magic Number.
As I said previously you are going to have issues with comparing doubles.
Thanks Raptoruk, I now realise the importance of the parenthesis to keep things in the loop. I was suprised that there was no return; , After alert .. , Well , I'll add it to my list of things I need to learn more about.
If I didn't have a magic number is it better to use Continue; to stop it flowing to the next code if the Symbol() doesn't Equate to Ordersymbol() ? Using or not using continue; is there anything important to consider when deciding ?
I looked at the "can price!= price?" , The issues you are refering to would that be for "Orderopen price , Orderstoploss ,Bid and Ask as they are of "Double type" ?
My understanding is Never compare double type for equality and that there may be slippage due to the rounding (Early/Late Entry/Exit or Alert on an indicator ? Are these the main issues ?
Thanks .