Inquiry on Trailing Stop - page 2

 
  1. Ibex Thales: I would like to ask if: is the same as:
    Simple algebra, add/subtract the same thing on each side of the equals inequality. They are the same.

  2. But you need to be careful of floating point rounding.
    Doubles are rarely equal. Understand the links in:
              The == operand. - MQL4 and MetaTrader 4 - MQL4 programming forum

    Ask >= OOP+n could be true because of round off and Ask >= OOP+n - 0.000005 and could be false at Ask >= OOP+n + 0.000005.

    If the equality is important use (must be true at Ask == OOP+n) Use "definitely >=": Ask - (OOP+n) > -_Point/2. // Note the minus.

    If the equality is important use (must be false at Ask == OOP+n) Use "definitely >" Ask - (OOP+n) > _Point/2.

    If the equality is not important (false when equal or true when not) just use Ask > OOP+n

 

@whroeder1, I am still in the process of absorbing the equalities. I always thought it is only in Excel that such digits are so precise.

Anyway, I would like to as how this:

if(((Ask<OrderOpenPrice()-MyPoint*TrailingStop)) && (Ask<OrderStopLoss()-MyPoint*TrailingStop) || (OrderStopLoss()==0))	{
{
}

yielded significantly different results than this:

if((Ask<OrderOpenPrice()-MyPoint*TrailingStop))
{
        if ((Ask<OrderStopLoss()-MyPoint*TrailingStop) || (OrderStopLoss()==0))
        {
        }
}

Once again, my readings and common logic seem to elude some deeper technicalities of machine language....

Also, if ever they are different, which is more in line with the standard definition of Trailing Stops. I still have in mind the very concise code with MathMax that you made a few posts ago.
 
Ibex Thales:

@whroeder1, I am still in the process of absorbing the equalities. I always thought it is only in Excel that such digits are so precise.


yielded significantly different results than this:
  1. On a 5 digit price (0.123450000) the values 0.12344500000000001 through 0.12345499999999999 are all the same price but the former is not greater or equal and later is.
  2. The code is identical, so is the result.
  3. What is the meaning of SL - Stop Size? Just that there's room to move SL down another stop size increment. That's not trailing.
 
whroeder1:
  1. On a 5 digit price (0.123450000) the values 0.12344500000000001 through 0.12345499999999999 are all the same price but the former is not greater or equal and later is.
  2. The code is identical, so is the result.
  3. What is the meaning of SL - Stop Size? Just that there's room to move SL down another stop size increment. That's not trailing.

1. That is clearer.

2. But the thing is that when I replaced the 1st block with the 2nd, backtesting it yielded significantly different results..... Could I have missed something else? Everything else was ensured to be held constant.

3. Err... Isn't it that when the code cycles every tick, it will compare the Current price vs the "target profit" c/o the existing StopLoss-Trailing Stop value? That is the way I understood Trailing Stop. At least on how to code trailing stop. Is it not the case? I also reversed the functions created by the EA generator and the MathMax example you taught... 

Reason: