Just a little fixing:
void trail_order(int type) { if(UseTrailingStopLoss) { if(type==OP_BUY) { //if((Bid-OrderOpenPrice())>(Point*TrailingStopLoss)) //{ if(OrderStopLoss()<(Bid-Point*TrailingStopLoss)) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStopLoss,OrderTakeProfit(),0,Green); } //} } if(type==OP_SELL) { //if((OrderOpenPrice()-Ask)>(Point*TrailingStopLoss)) // { if((OrderStopLoss()>(Ask+Point*TrailingStopLoss)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStopLoss,OrderTakeProfit(),0,Red); } // } } } }
Well, price did not change, but stop loss has changed on every tick. I guess that is not normal? Not sure. Stop loss should change only if price changes in my favor? Right?
Also, could you please explain why author of this code put those lines you commented :)
Edit:
Oh, I get it, this is order open price. It is OK.
Classic TrailingStop starts working when the order has a profit more then the value of trailingstop.
This is to trail at once? Do you have any idea why I have secon problem. Thank you for replaying so fast.
Hi,
I can't help you fix yours but I found a great little very reasonably priced and flexible and effective commercial utility that has a 2 stage Trailing Stop Loss that you can use either on its own or in conjunction with other AEs (it overrides the TSL in other AEs). It is from PipBoxer.Com: look for PBTS. Being a commercial product it is only available in compiled format of course.
Good luck with it.
…………………(8 >) Prosperous Trading (< 8)
DougRH4x
.
PS: I’m looking for someone to splice an adjustable (Trailing &) Stop Loss into the Martingale based program: PipMaker. Overcoming this one downfall of this program will make it VERY profitable!
Hi,
I can't help you fix yours but I found a great little very reasonably priced and flexible and effective commercial utility that has a 2 stage Trailing Stop Loss that you can use either on its own or in conjunction with other AEs (it overrides the TSL in other AEs). It is from PipBoxer.Com: look for PBTS. Being a commercial product it is only available in compiled format of course.
Good luck with it.
…………………(8 >) Prosperous Trading (< 8)
DougRH4x
.
PS: I’m looking for someone to splice an adjustable (Trailing &) Stop Loss into the Martingale based program: PipMaker. Overcoming this one downfall of this program will make it VERY profitable!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello. I am working on my EA and I am having some problems with trailing stop loss. Here is code I have found on some tutorial that I use for trailing:
Problem I am having is that trailing does not start immediately after market go in my favor, but after greater distance is made. For example, if BUY order is sent at price 1.200, and I use stop loss of 15 pips, then it is set to 1.185. If price raise to 1.201, trailing stop loss should change stop loss to 1.186, but it does not. Does anybody know what to change in code above to make this work?
Another problem I have is that sometimes trailing stop loss goes mad. Here is report from journal:
Thanks in advance for all help.