• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 10:03am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 10:03am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

EA for mad (moving average delta) 2 replies

Audible alert for (mad) Moving Average Delta indicator 9 replies

Diary of a Mad Surfer 658 replies

Mad Money ... Mad Market? 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

please please help going mad

  • Post #1
  • Quote
  • First Post: May 24, 2010 2:29pm May 24, 2010 2:29pm
  •  censura
  • | Joined Sep 2006 | Status: Member | 405 Posts
Does anyone have a simple buy and sell funtion, i have the following but get errors order send error 130 and am pulling my hair out this is a 5 digit broker. I took this code from the mt4 f1 help so thought it would be fine, i notice when i print Bid, Ask ect i get different digit lengths ie
Bid was 1.4448 and ask was 1.445 and understand that this may be an issue i have set slippage to 30 and take profit to 500 and stoploss to 300 so plent of room i would think - please please help



if(total < 1)
{

if(position == 1)

{
ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-30*Point,Ask+50*Point,"ragstoriches",080464,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}

}

if(position == -1)
{
ticket=OrderSend(Symbol(),OP_SELL,1,Bid,3,Bid+30*Point,Bid-50*Point,"ragstoriches",080464,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}


}
return(0);
}
  • Post #2
  • Quote
  • May 24, 2010 2:39pm May 24, 2010 2:39pm
  •  CodeMeister
  • Joined Sep 2009 | Status: Making Code While Making Pips | 1,672 Posts
Values sent to the server must be precise; ie. no trailing decimal digits. You need to normalize the values such as NormalizeDouble(Bid+30*Point, Digits).
 
 
  • Post #3
  • Quote
  • May 24, 2010 3:02pm May 24, 2010 3:02pm
  •  sangmane
  • Joined Apr 2009 | Status: MT4 Programmer | 758 Posts
try using very big sl/tp, like 1000 point (in 5 digits it equals 100 pip). if you still get error 130 (invalid stop), chances are your broker uses "ECN style" order processing. if that is the case, try using sl/tp = 0
ticket=OrderSend(Symbol(),OP_BUY,1, Ask,3,0,0,"ragstoriches ",080464,0,Green);
then modify it after the order is succeeded

ps: be relax, panic won't solve the problems
 
 
  • Post #4
  • Quote
  • May 24, 2010 4:47pm May 24, 2010 4:47pm
  •  censura
  • | Joined Sep 2006 | Status: Member | 405 Posts
Quoting CodeMeister
Disliked
Values sent to the server must be precise; ie. no trailing decimal digits. You need to normalize the values such as NormalizeDouble(Bid+30*Point, Digits).
Ignored
do i use it as variable declaration or as assignment ie

sl=NormalizeDouble(Bid+30*point,digits)

ticket=OrderSend(Symbol(),OP_SELL,1,Bid,30,sl,Bid-500*Point,"ragstoriches",080464,0,Green);

thank you
 
 
  • Post #5
  • Quote
  • Last Post: May 24, 2010 5:39pm May 24, 2010 5:39pm
  •  CodeMeister
  • Joined Sep 2009 | Status: Making Code While Making Pips | 1,672 Posts
Either way works.
 
 
  • Platform Tech
  • /
  • please please help going mad
  • Reply to Thread
0 traders viewing now
Top of Page
Forex Factory Blog Updated: Alerting All Members
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022