- You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
- AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
- Do NOT use TickValue by itself - DeltaPerLot
and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it
is returning a value in the instrument's base currency.
MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum 2017.10.10
Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19 - You must normalize lots properly and check against min and max.
- You must also check FreeMargin to avoid stop out
Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.
- www.metatrader5.com
What you just said is the SL moves in the direction of the trade, lessening risk and finally locking in profits. Fine. If it makes no difference if
the trade is loosing or winning, just remove any test for break even.
If there is no hard stop loss, then you are moving the SL away from price and you have infinite risk. It is possible but you don't want that.
Make up your mind what your question is; don't change it mid-post.
If there is no hard stop loss, then you are moving the SL away from price and you have infinite risk. It is possible but you don't want that.
Thank you for your reply. I actually mean the opposite. In other words, I want the SL to move towards my OrderOpenPrice and thereby minimizing the loss. So I will try and explain like this:
I have a trailingstop on my winning trades. The SL is activated/ triggered after the price moves X pips (say 50 pips) in my favor and trails behind by say 10 pips locking in a minimum profit of 40 pips. This part I have figured out and it's easy. My question is, is it possible to have a similar trailingstop on my losing trades? In other words, the Stoploss is activated/triggered after the price moves X pips (say 50 pips) against me and trails 10 pips behind locking in a maximum loss of 60 pips. But if the price turns and start moving in my favor to keep adjusting this SL (trailing it) so as to minimize the loss. For example once the SL is triggered at 50 pips minus the 10 pip trail, but the price improves by 10 pips, the SL is then adjusted to a max loss of only 50 pips and so on. This is as per the code I posted in post #1
Answered in #4. What part of "just remove any test for break
even." was unclear? Here is your originally posted code minus the BE test:
if(OrderType()==OP_BUY){ //No BE if(Bid-OrderOpenPrice()>TSTP){ if(OrderStopLoss()<Bid-Trail){ if(OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Trail,OrderTakeProfit(),0,Orange))
Thank you once again, but with this the price has no room to breath, The SL is way to tight. I would like it to first move 50 pips before the SL sequence of events are triggered, So buy order moves against me. When Bid is 50 pips away from OrderOpenPrice it triggers and sets a buystop like this:
//Glogal variables extern int StoplossStart=50; extern string Label_Trailingstop="Pips trailing behind price once activated"; extern int TrailingStop=2; void double TSTP=StoplossStart*Pip; if(Bid-OrderOpenPrice()>TSTP){ //This allows the price to breathe and moves away by 50 pips before SL is locked in at 2 pips if(OrderStopLoss()<Bid-Trail){
If I remove this as suggested the SL starts trailing immediately. Is there no way it can first breathe exactly as per my TrailingStop code at the top? Thanks
You asked if it is possible. I've answered that 3+ times.
You just said you want it to "first move 50 pips" and move to BE. Then you don't want to trail a loosing trade.
Make up your mind what you want. Until you can express it in concrete terms it can't be coded.
Okay thanks, I will try and explain it line by line:
I place a Buy order, but the price turns against me. When the price is 50 pips against me, I want the EA to set a Stoploss that is a further 10 pips away so there is room to breathe. In other words:
OpenOrderPrice of buy order =x Stoploss is triggered (OrderModify) at x -50 and set at x-50-10:
extern int Trailingstart=50; extern int Trailing=10; //--------------------- double TSTP=Trailingstart*Pip,Trail=Trailing*Pip; for(int i=OrdersTotal()-1; i>=0; i--){ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ if(OrderSymbol()==Symbol()){ if(OrderType()==OP_BUY){ if(OrderOpenPrice()-Bid>TSTP){ //Stoploss is triggered when price reach -50 pips from OrderOpenPrice. if(OrderStopLoss()<Bid-Trail){ //Stoploss is set at Bid -10 pips if(OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Trail,OrderTakeProfit(),0,Orange))The hope is now that during the breathing space of 10 pips that the price will turn in my favor and the stoploss will be adjusted upwards with every tick. In other words if Bid price goes up, so does the trailing stoploss until, hopefully, it might break even or better yet, show a profit. My biggest problem is that if(OrderOpenPrice()-Bid>TSTP){ cannot remain true if the price starts to go up again. This is merely suppose to act as a trigger. How could I do this?
Now you've changed back to no hard stop
loss (#0, #2 #9) Infinite risk.
Normal SL (#2, #3, #5, #7)
Make up your mind
You can't live on the East coast and the West coast at the same time. Your title is "is it possible," NO!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi I have a trailing stop on my winning trades that works very well. Is it possible to have a similar trailing stop on losing trades rather than a hard stop loss. Can the stop loss be adjusted/ decreased as the price moves in my favor? Here is the code for my trailing stop loss on winning trades:
And the code that I have tried on losing trades, but it doesn't always work. Only most of the time: