
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
MT4 - Error #130 with Ordersend()
Hi. Im trying to generate an order using OrderSend() in MT4 but keep getting Error #130. I understand that Error #130 relates to the stop-loss or take-profit levels being set too close to the current market price. I have varied them with no success. I have used both relative and actual values.
1. Using relative take profit and stop loss values for a buy:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-50*Point,Ask+50*Point,"Long Breakout",16384,0,Green);
2.Using Actual values for Stoploss and TakeProfit for a buy:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss,TakeProfit,"Long Breakout ",16384,0,Green);
where:
double StopLoss = NormalizeDouble(StopLoss, Digits);
double TakeProfit = NormalizeDouble(TakeProfit, Digits);
and these values are set as external values (e.g. extern double StopLoss=1.5000, extern double=TakeProfit=1.6000)
My broker is FXCM. I have tried multiplying the StoplLoss and TakeProfit values by 10. I get the same result for all currency pairs.
In each case I get Error #130. Any ideas?
Cheers
When setting the take profit for a buy position. The TP is
As opposed to Ask+...
Chris
Sorry, yes, my fault in typing. Still, the problem persists I'm afraid
Try placing a comment or print just before the ordersend function to print out the stoploss and takeprofit levels. Also, make sure the stoploss/tp are more than the minimum distance.
Place this before the order send:
if(StopLoss!=0 && StopLoss<(MarketInfo(Symbol(),MODE_STOPLEVEL)))
{
StopLoss=MarketInfo(Symbol(),MODE_STOPLEVEL);
}
if(TakeProfit!=0 && TakeProfit<(MarketInfo(Symbol(),MODE_STOPLEVEL)))
{
TakeProfit=MarketInfo(Symbol(),MODE_STOPLEVEL);
}
Chris
Hi. Im trying to generate an order using OrderSend() in MT4 but keep getting Error #130. I understand that Error #130 relates to the stop-loss or take-profit levels being set too close to the current market price. I have varied them with no success. I have used both relative and actual values.
1. Using relative take profit and stop loss values for a buy:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-50*Point,Ask+50*Point,"Long Breakout",16384,0,Green);
2.Using Actual values for Stoploss and TakeProfit for a buy:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss,TakeProfit,"Long Breakout ",16384,0,Green);
where:
double StopLoss = NormalizeDouble(StopLoss, Digits);
double TakeProfit = NormalizeDouble(TakeProfit, Digits);
and these values are set as external values (e.g. extern double StopLoss=1.5000, extern double=TakeProfit=1.6000)
My broker is FXCM. I have tried multiplying the StoplLoss and TakeProfit values by 10. I get the same result for all currency pairs.
In each case I get Error #130. Any ideas?
CheersFXCM with 5 digits.. or you are using FXCM from wich country?
Thanks for your replies. Yeah, I used print statements to check the Stop Loss and Take Profit values. Seemed ok on the printout.
I'm using FXCM in the UK. Non Yen currencies have 5 digits after the decimal place (e.g. GBPUSD: 1.55125). Yen crosses have three digits (e.g. GBPJPY: 132.393). I figured with this being the case the values would probably have to be multiplied by 10.
Cheers
I figured with this being the case the values would probably have to be multiplied by 10. Cheers
Do you have something like this in the init function?
{
Factor = 10;
StopLoss *= 10;
TakeProfit *= 10;
MaxSpread *= 10;
Slippage *=10;
}No, in the OrderSend() statement I just multiply the Take Profit and StopLoss values by 10. Can you elaborate a little more on the use of these values? Many Thanks
They are just the external variables being multiplied by ten. You adjust them to include your variables. But you only do variables that differ on fractional pip brokers like Stoploss.
It means that if stoploss is entered as 20 pips in the input list, it will automatically adjust it to 200 if the broker is fractional.