Monitoring trailing stop - page 2

 
dabbler:
This first OrderSelect is a disaster waiting to happen. You really must check it to see that it worked or your EA could get you into serious trouble.

Yes, it's the first OrderSelect in the function but not in the complete code. This function is called after the ticketnumber has been retrieved using an OrderSelect by SELECT_BY_POS. The only way this could go wrong is when the open position has hit it's stoploss or takeprofit between the first order select and the one in this function. I assume the OrderModify will then fail but that's not a real disaster, is it?
 
burgie:

Yes, it's the first OrderSelect in the function but not in the complete code. This function is called after the ticketnumber has been retrieved using an OrderSelect by SELECT_BY_POS. The only way this could go wrong is when the open position has hit it's stoploss or takeprofit between the first order select and the one in this function. I assume the OrderModify will then fail but that's not a real disaster, is it?

No, I suppose not. But having to analyse each one to be really sure it cannot cause a problem is a time consuming and error prone process. I have been caught out on an OrderSelect failing and leaving previous order data there. I can't remember what trouble it caused because it was so long ago. I just check all of them now as a matter of course. The computational cost penalty is negligible and I feel it makes my code more robust.

In fact I have been coding this stuff for just over two years now and I have only just started making the subroutines more modular with them stored in a word document as a library. That way I don't have to keep writing them from scratch or remembering which EA I last worked on that used that function.

 
dabbler:

No, I suppose not. But having to analyse each one to be really sure it cannot cause a problem is a time consuming and error prone process. I have been caught out on an OrderSelect failing and leaving previous order data there. I can't remember what trouble it caused because it was so long ago. I just check all of them now as a matter of course. The computational cost penalty is negligible and I feel it makes my code more robust.

In fact I have been coding this stuff for just over two years now and I have only just started making the subroutines more modular with them stored in a word document as a library. That way I don't have to keep writing them from scratch or remembering which EA I last worked on that used that function.


Yes, it's true that eliminating such a fail might be woth the extra computational cost. And you only have to write it once :-)

I keep all such functions in include files so that I can create new EAs much quicker. I've been coding in another language for 12 years and it uses the same principle.

But Calmar, as you can see there is no easy solution to your problem unfortunately. You could place such a routine in a script but it requires some coding and testing.