Trailing Stop Needed For EA

 

I'm sure this might sound like an easy task for a lot of people here but I really have no programming experience. All I need is a working trailing stop input added to this "TimeEntry" EA. Maybe it could have an input to either have the trailing stop on or off. And if set to on, then another input for the trailing stop amount. I don't need anything else changed or deleted. If anyone could add this for me or teach me how I would really appreciate it. Thanks!

Files:
timeentry.mq4  6 kb
 
meshleman3:
I'm sure this might sound like an easy task for a lot of people here but I really have no programming experience. All I need is a working trailing stop input added to this "TimeEntry" EA. Maybe it could have an input to either have the trailing stop on or off. And if set to on, then another input for the trailing stop amount. I don't need anything else changed or deleted. If anyone could add this for me or teach me how I would really appreciate it. Thanks!

here it is, just wanna help.....i hope you like it

Files:
 

faizalperu, Thanks a lot! It is exactly what I wanted. And it was done so fast too. All I need to do now is test it but I'm sure it will work just fine. Thank you.

 

extern double lTrailingStop = 20;

extern double sTrailingStop = 10;

void TrailingPositionsBuy(int trailingStop) {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol()) {

if (OrderType()==OP_BUY) {

if (Bid-OrderOpenPrice()>trailingStop*Point) {

if (OrderStopLoss()<Bid-trailingStop*Point)

ModifyStopLoss(Bid-trailingStop*Point);

}

}

}

}

}

}

void TrailingPositionsSell(int trailingStop) {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol()) {

if (OrderType()==OP_SELL) {

if (OrderOpenPrice()-Ask>trailingStop*Point) {

if (OrderStopLoss()>Ask+trailingStop*Point ||

maybe work well

 

Here is the trail Ea most traders like as it has 1 pip breakeven function for tight manual trading.

Files:
 

Thanks everyone for your help. People in this forum are great!

 

I have tested this TimeEntry_V1 EA and it works good. However, for some reason it does not always enter the orders at the time that is input. I am assuming that it is probably because of the misspelling, "Shor" instead of "short" in the user inputs. Also, the EA doesn't enter orders correctly unless the EA is removed from the chart and reattached between orders. It seems like it can not reinitialize itself or something. Overall it is a good EA and thank you.

Reason: