Anyone know why I would be getting the 130 error, I've made sure my SL is wide enough and that it is on the right side of the market (i.e. below for a buy). Any help would be much appreciated and a big relief* sigh
if(BUYING)
{
if(stoploss > 0) //SL is set to 35
realSL = Ask - (stoploss * Point);
if(takeprofit > 0)
realTP = Ask + takeprofit * Point;
//BUYING!!
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, realSL, realTP, nameEA, 887722,0,Red);
if(ticket < 0)
Print("OrderSend (",nameEA,") failed with error #", GetLastError());
Alert("CODE_TEST: BUY BUY BUY");
Thanks all,
Pat
try this... I think you are mixng up when to use Bid and Ask
if(BUYING)
{
if(stoploss > 0) //SL is set to 35
realSL = Bid- (stoploss * Point);
if(takeprofit > 0)
realTP = Bid+ takeprofit * Point;
//BUYING!!
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, realSL, realTP, nameEA, 887722,0,Red);
if(ticket < 0)
Print("OrderSend (",nameEA,") failed with error #", GetLastError());
Alert("CODE_TEST: BUY BUY BUY");
************************************
Rule of thumb... if you enter on the ask, you exit with bid, if you enter on Bid you exit with ask
LongStop = Bid-(stoploss*Point)
LongLimit =Bid+(limit*Point)
LongEntry= ASK
LongTrail = Bid-(stoploss*Point)
ShortStop = Ask+(stoploss*Point)
ShortLimit =Ask-(limit*Point)
ShortEntry= BID
ShortTrail = Ask+(stoploss*Point)
Seawolf
try this... I think you are mixng up when to use Bid and Ask
if(BUYING)
{
if(stoploss > 0) //SL is set to 35
realSL = Bid- (stoploss * Point);
if(takeprofit > 0)
realTP = Bid+ takeprofit * Point;
//BUYING!!
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, realSL, realTP, nameEA, 887722,0,Red);
if(ticket < 0)
Print("OrderSend (",nameEA,") failed with error #", GetLastError());
Alert("CODE_TEST: BUY BUY BUY");
************************************
Rule of thumb... if you enter on the ask, you exit with bid, if you enter on Bid you exit with ask
LongStop = Bid-(stoploss*Point)
LongLimit =Bid+(limit*Point)
LongEntry= ASK
LongTrail = Bid-(stoploss*Point)
ShortStop = Ask+(stoploss*Point)
ShortLimit =Ask-(limit*Point)
ShortEntry= BID
ShortTrail = Ask+(stoploss*Point)
Seawolf
Thanks for your reply seawolf, so in my original piece of code, if I'm going to be buying, shouldn't I use the ask price for my calculation, because that is going to be the price I am going to have to pay?
it is the price you pay going in, but you have to cover the spread so you pay the other price coming out... the fact that you are using the ask for entries AND exits is absolutely wrong.
follow the rule of thumb I gave you and all will work fine... I know it can be very confusing, that's why I keep it written on my white board and after many years of trading and programing, I still refer to it on almost a daily basis. I have found many articles that don't even get it right, so don't feel bad.
Hi
Although the original code is wrong because you are using Bid instead of Ask to buy it still should have worked if the stoploss is truly 35 points. Make sure the system you are running on has not change to 5 decimal places otherwise the stoploss should be 350 points. Interbank was running 5 decimals on the demo but 4 on the live system at one point.
Anyone know why I would be getting the 130 error, I've made sure my SL is wide enough and that it is on the right side of the market (i.e. below for a buy). Any help would be much appreciated and a big relief* sigh
if(BUYING)
{
if(stoploss > 0) //SL is set to 35
realSL = Ask - (stoploss * Point);
if(takeprofit > 0)
realTP = Ask + takeprofit * Point;
//BUYING!!
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, realSL, realTP, nameEA, 887722,0,Red);
if(ticket < 0)
Print("OrderSend (",nameEA,") failed with error #", GetLastError());
Alert("CODE_TEST: BUY BUY BUY");
Thanks all,
Pat
Well I can categorically state that Seawolf and Ruptor are talking out of their collective rear end.
For an OP_BUY order, you are absolutely correct to use the Ask price to generate your entry price and stops.
What you need to do is to check the values in your stops by using a Print("realSL =,"DoubleToStr(realSL,Digits)," realTP=",DoubleToStr(realTP,Digits)) statement directly before your order send in order to ensure the values are as you expect. If they are as you expect, then you should check the acceptable values using the MarketInfo() function with the MODE_STOPLEVEL identifier.
Well I can categorically state that Seawolf and Ruptor are talking out of their collective rear end.
For an OP_BUY order, you are absolutely correct to use the Ask price to generate your entry price and stops.
What you need to do is to check the values in your stops by using a Print("realSL =,"DoubleToStr(realSL,Digits)," realTP=",DoubleToStr(realTP,Digits)) statement directly before your order send in order to ensure the values are as you expect. If they are as you expect, then you should check the acceptable values using the MarketInfo() function with the MODE_STOPLEVEL identifier.
Thank you cloudbreaker, I knew I was right with paying the ask, no where do I ever state that i'm also paying the ask coming out of the trade, printing the SL value is a great idea, thank you for all of your input.
Thank you cloudbreaker, I knew I was right with paying the ask, no where do I ever state that i'm also paying the ask coming out of the trade, printing the SL value is a great idea, thank you for all of your input.
Allright Cloud, this one was giving me a run for my money but I think I solved it, for some reason both the TP & SL were being retruned as 1.0 (far too small) so I traced my variables through the whole process and notice I declared the takeprofit and stoploss values as double and teh realSL realTP values as integers, changing realTP & realSL to doubles fixed the problem, thanks again.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Anyone know why I would be getting the 130 error, I've made sure my SL is wide enough and that it is on the right side of the market (i.e. below for a buy). Any help would be much appreciated and a big relief* sigh
if(BUYING)
{
if(stoploss > 0) //SL is set to 35
realSL = Ask - (stoploss * Point);
if(takeprofit > 0)
realTP = Ask + takeprofit * Point;
//BUYING!!
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, realSL, realTP, nameEA, 887722,0,Red);
if(ticket < 0)
Print("OrderSend (",nameEA,") failed with error #", GetLastError());
Alert("CODE_TEST: BUY BUY BUY");
Thanks all,
Pat