Forums ProRealTime English forum ProOrder support Trailing Stop and Breakeven codes Reply To: Trailing Stop and Breakeven codes

#179818

The above code is 1/4 of 100 lines!

Is it still too much much?

There you go with just 4 lines:

That’s pretty short!
Add this to your code and you will soon report that it will not always exit at the expected entry price + 10 pips.

That’s because pending orders expire each bar, so when your profit is 30+ pips they will be placed, but if they are not triggered and the next bar your profit is, say, 29 pips, they will not be placed again and you may suffer an unexpected big loss! How can this be dealt with? By adding a few lines to RECORD that your trigger level has been reached, so the stop orders are to be placed again, next bar, even if by that time your profit is lower than that level:

as you can see, a few more lines have been added, but they are still not so many!

Well… there’s still a problem. Next trade NewSL will still retain the previous exit price and it may exit at an incorrect price,

We need to add a few more lines to prevent this from happening:

it’s no more just a few lines (and I did not add comments to make code easier to read),  it it can’t be done with less than that!

100+ lines can easily be reached to add more sophisticated features.

It’s like starting a car, you don’t need too much engineering, but then you have to add support for speeding up, then slowing down, then braking, then steering, then accommodating people, etc…

1 user thanked author for this post.