Scripts: Trailing Function

 

Trailing Function:

This Is a Normal Trailing Function For All Open Order In MT4. Just paste The Whole Function in Global And To Use The Function Paste The Name Of The Function In OnTick and also give input for pips to Trail.

Author: Kailash Bai Mina

 

There are several issues with this function.


First: you assume that a pip is always "Points() * 10". This is not always true as it depends on the particular symbol: PIPs are specific to currency pairs only (and not to stocks and indices).

Second: you don't always calculate the  t/s correctly. For a buy order the issue arises when the s/l is below the order opening price. This is because you have the "if (OrderStopLoss() >= OrderOpeningPrice())". You probably meant to do "if (OrderStopLoss() == 0.0)". A similar thing applies to sell orders.

Third: you may consider to return the result of the OrderModify(...) statement.

 
Onno Rijkers #:

There are several issues with this function.


First: you assume that a pip is always "Points() * 10". This is not always true as it depends on the particular symbol: PIPs are specific to currency pairs only (and not to stocks and indices).

Second: you don't always calculate the  t/s correctly. For a buy order the issue arises when the s/l is below the order opening price. This is because you have the "if (OrderStopLoss() >= OrderOpeningPrice())". You probably meant to do "if (OrderStopLoss() == 0.0)". A similar thing applies to sell orders.

Third: you may consider to return the result of the OrderModify(...) statement.

Onno Rijkers #:
There are several issues with this function.



First: you assume that a pip is always "Points() * 10". This is not always true as it depends on the particular symbol: PIPs are specific to currency pairs only (and not to stocks and indices).

Second: you don't always calculate the t/s correctly. For a buy order the issue arises when the s/l is below the order opening price. This is because you have the "if (OrderStopLoss() >= OrderOpeningPrice())". You probably meant to do "if (OrderStopLoss() == 0.0)". A similar thing applies to sell orders.

Third: you may consider to return the result of the OrderModify(...) statement.


Hi,
First : i didn't gave it that much thought because I thought most probably on developers will see this or use this.
And developer can easily change that.
And also if you go in synthetic indices.
They are too much different and they cannot be generalized.

Second : No, if for buy orders so is below open price then first it will think of Breakeven and after that it will think to take sl even futher.
I think you understood what I meant.

Third: that good idea.
I will do it.
 
did not work by myself.