Experts: TP SL Trailing

 

TP SL Trailing:

Stop loss and take profit initial setting. Trailing.

Author: Vladimir Karputov

 
there is a small bug that i have found, while you SELL a position, it shows reduced TP as in TP - (minus) SPREADS, and SL+ SPREADS while the same does not happen with BUY position as it shows exact values of TP and SL. kindly check and please fix the bug. (also the trailing step is taken by default at 20 points which is good but if you add that as an option for users it would be interesting)!
 
Yui kmitokawa :
there is a small bug that i have found, while you SELL a position, it shows reduced TP as in TP - (minus) SPREADS, and SL+ SPREADS while the same does not happen with BUY position as it shows exact values of TP and SL. kindly check and please fix the bug. (also the trailing step is taken by default at 20 points which is good but if you add that as an option for users it would be interesting)!

This is old code. It works according to this specification:

If Only zero values is "true" - this means searching for positions having either stop loss, or take profit equal to zero. As soon as such a position is found:

  • If this is a BUY position
    • a stop loss is set: current price (Bid) minus stop loss
    • a take profit is set: current price (Bid) plus take profit
  • If this is a SELL position
    • a stop loss is set: current price (Ask) plus stop loss
    • a take profit is set: current price (Ask) minus take profit
 
Is there an easy way to disable the Trailing Stop in your code?
 
ajforex:
Is there an easy way to disable the Trailing Stop in your code?

No

 
This EA is fanastic! Would it be possible instead of setting n° of pips as TP and SL, to actually copy the same TP/SL as the already opened and set positions? (where TP/SL are the same for all opened positions already)
 
tonyalcapon # :
This EA is fanastic! Would it be possible instead of setting n° of pips as TP and SL, to actually copy the same TP/SL as the already opened and set positions? (where TP/SL are the same for all opened positions already)

What's the point of this?

 

For example I have 3 Buys opened orders with TP and SL set.

And I have also 15 limit buy pendings with SL set but no TP because it will depends where the trend will go.

During the night (because I am trading on H4 and i need to sleep) maybe 3 limit buy will be trigered but without TP set.


So if this EA could copy the already existing TP from opened positions that would be a huge help!

 
tonyalcapon # :

For example I have 3 Buys opened orders with TP and SL set.

And I have also 15 limit buy pendings with SL set but no TP because it will depends where the trend will go.

During the night (because I am trading on H4 and i need to sleep) maybe 3 limit buy will be trigered but without TP set.


So if this EA could copy the already existing TP from opened positions that would be a huge help!

Broken logic. Each position (note: a POSITION, not an ORDER) can have its own Take profit.

This logic is better: if a pending order has triggered (and even better: if a new position has appeared), then the adviser checks whether the position has Take profit or not.

 

Hello, thanks for your code.


but what is trailing stop and trailing step? what's the difference?

for example:

my stop loss is 50 pip, 

(now for trailing)

i want for each 10 pip in profit,

move stoploss 20 pip,

what should i do?

 
The only expert advisor worth using on VPS
Reason: