Let's say a, b , c boolean values :
a = (TrailingStop>0);
b = (Bid-OrderOpenPrice()>MyPoint*TrailingStop);
c = (OrderStopLoss()<Bid-MyPoint*TrailingStop);
it is same of :
c = (Bid>MyPoint*TrailingStop+OrderOpenPrice());
------------------------------------
codeblock 1 is executed only if a = b = c = true
if (a.b.c) {//your pg1 };
------------------------
codeblock 2 is executed if a = b = true (regardless of c)
codeblock 3 is executed if a = c = true (regardless of b)
if (a.b) {//your pg2 };
if (a.c) {//your pg3 };
--------------------
In boolean operations :
a.b.c is different of a.b ( it's equal in case c = true)
a.b.c != a.c ( it's equal in case b = true)
paulselvan:
codeblock 1 is executed only if a = b = c = true
if (a.b.c) {//your pg1 };
double cur = MathMax(OrderOpenPrice(), OrderStopLoss() ); // Move to BE minimum. double tsl = Bid - MyPoint*TrailingStop; if(TrailingStop > 0 && tsl >= cur +_Point) // At least 1 pt (no Err 1)
Invalid syntax. Us if( a && b && c) and no semi after closing brace.
you've probably noticed the syntax wasnt in mql4.
AND is exprimed by '.' (point) as in boolean expression
You used mathematic notification and mixed it with if code. Thus you confused all the non-mathematicians here.
I have just realized that
(Bid-OrderOpenPrice()>MyPoint*TrailingStop)&& (OrderStopLoss()<Bid-MyPoint*TrailingStop))
will have the same effect as:
(Bid>MyPoint*TrailingStop+OrderOpenPrice())&& (Bid>MyPoint*TrailingStop+OrderStopLoss())
Hence, the self documenting code you posted.
But i would just like to inquire on where the "cur" variable is used? Could I also write it as:
double cur = MathMax(OrderOpenPrice(), OrderStopLoss() ); // To pick the higher of either Open or StopLoss double tsl = Bid - MyPoint*TrailingStop; if(TrailingStop > 0 && tsl >= cur+_Point) // At least 1 pt (no Err 1)
?
Lastly, is the Error1 you refer to same as Error 145 in this site: https://book.mql4.com/appendix/errors
Thank you once more, y'all!

- book.mql4.com
But i would just like to inquire on where the "cur" variable is used? Could I also write it as:
double cur = MathMax(OrderOpenPrice(), OrderStopLoss() ); // To pick the higher of either Open or StopLoss double tsl = Bid - MyPoint*TrailingStop; if(TrailingStop > 0 && tsl >= cur+_Point)
Lastly, is the Error1 you refer to same as Error 145 in this site: https://book.mql4.com/appendix/errors
- This is what I meant to write.
- MyPoint*TrailingStop must be made larger.
You can't move stops (or pending prices) closer to the market than the minimum
(MODE_STOPLEVEL * _Point.)
Requirements and Limitations in Making Trades - Appendixes - MQL4&Tutorial
- This is what I meant to write.
- MyPoint*TrailingStop must be made larger.
You can't move stops (or pending prices) closer to the market than the minimum
(MODE_STOPLEVEL * _Point.)
Requirements and Limitations in Making Trades - Appendixes - MQL4&Tutorial
I am really sorry but what do you mean "write"?
@ the minimum moves, I see. Thank you for that. :)
Synonyms for write
address | sign | ghost | comp | scriven |
compose | tell | indite | dash off | set down |
create | author | ink | draw up | set forth |
draft | autograph | inscribe | drop a line | take down |
note | chalk | letter | drop a note | turn out |
pen | commit | pencil | jot down | write down |
communicate | reproduce | knock off | write up | |
record | copy | scribe | knock out | |
rewrite | correspond | transcribe | note down | post |
scrawl | engross | typewrite | push a pencil | |
scribble | formulate | bang out | put in writing |
Synonyms for write
address | sign | ghost | comp | scriven |
compose | tell | indite | dash off | set down |
create | author | ink | draw up | set forth |
draft | autograph | inscribe | drop a line | take down |
note | chalk | letter | drop a note | turn out |
pen | commit | pencil | jot down | write down |
communicate | reproduce | knock off | write up | |
record | copy | scribe | knock out | |
rewrite | correspond | transcribe | note down | post |
scrawl | engross | typewrite | push a pencil | |
scribble | formulate | bang out | put in writing |
meh. lol! all these stuff seem to sap out the little sense I have left. Thanks, though!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Greetings!
I would just like to ask if the following code:
is will have a similar effect to this:
and this:
I am trying to come up with a way to establish trailing stops. Needless to say, I have scoured almost all thread and guide this site has to offer and I want to keep the code simple and concise. (spare me the detailed scientific theories of MT4 for now).
The above codes are for a BUY order
The way I understood, a trailing stop will be revised when the Current Price hits upward the target number of pips moved (x MyPoint[10]).
As for codeblock 1, I cannot come up with a scenario where Line 2 will be TRUE and Line 3 will be FALSE. Either both are TRUE or both are FALSE.
So the main question is, Is the Line 3 of codeblock 1 removable without consequence?
Please just take the code as it is. The other parts not pasted here have no direct functional relation to the codeblocks in question.
As always, your responses are much appreciated.
Thank you guys!