If you're long, the market price to close the position is the Bid, not the Ask.
Try setting the stoploss to:
Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point
Try setting the stoploss to:
Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point
Thanks.
something is definitely wrong. I.E.- testing GBPJPY, MODE_STOPLEVEL=15 (SPREAD=12), and EA opens LONG @232.76 - then it tries to trail the stoplevel and here it comes:
@233.06 (30 pips) - error 130
@233.27 (51 pips) - error 130
@233.24 (48 pips) - SET!
This not the one case. This is with all orders!!! For now modifying orders seems USELESS! Any comments? Thanks
or is the code so BAD?:
@233.06 (30 pips) - error 130
@233.27 (51 pips) - error 130
@233.24 (48 pips) - SET!
This not the one case. This is with all orders!!! For now modifying orders seems USELESS! Any comments? Thanks
or is the code so BAD?:
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(newSL, Digits), OrderTakeProfit(), OrderExpiration(), Yellow)
double TMinStop( string order_symbol) { return (( MarketInfo( order_symbol, MODE_STOPLEVEL) + 1.0) * MarketInfo( order_symbol, MODE_POINT)); } bool TValidMarketBuyLimit( string order_symbol, double new_price) { return ( new_price < ( MarketInfo( order_symbol, MODE_ASK) - TMinStop( order_symbol))); } bool TValidMarketSellLimit( string order_symbol, double new_price) { return ( new_price > ( MarketInfo( order_symbol, MODE_BID) + TMinStop( order_symbol))); } bool TValidMarketBuyStop( string order_symbol, double new_price) { return ( new_price > ( MarketInfo( order_symbol, MODE_ASK) + TMinStop( order_symbol))); } bool TValidMarketSellStop( string order_symbol, double new_price) { return ( new_price < ( MarketInfo( order_symbol, MODE_BID) - TMinStop( order_symbol))); }
The distance will be same. If you can set waiting order you can move or modify any order with the same value.
I.e. you try to set Stop Level above current price for Long?
O, s***t am I so stupid?! Will never program anything with such a brain! LOL , Thanks all!
Don't mention it. Lol
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
But if I try 2* the stop level or even 1.5 * the stop level, the order is accepted.
I would assume that stoplevel alone, or at the worst case +/- 1 Point for sell/buy should have been sufficient.
Errors:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,...,Ask-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,...);
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,...,Ask-(MarketInfo(Symbol(),MODE_STOPLEVEL)+1)*Point,...);
Accepted:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,...,Ask-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point*2,...);
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,...,Ask-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point*1.5,...);
I want every losing trade to lose a known maximum. I've seen orders lose more than a given maximum if no initial stoploss was set at OrderSend, because it never reaches OrderModify code in many samples.