Go Back   BabyPips.com Forex Forum > Everything Else > Rate my Software
Rate my Software This is the place to discuss the many different charting software packages out there. If you need help finding the right software, then this is the place for you. Also, check out our Forex Charts Guide for reviews of the various charts.

Welcome to the BabyPips.com forum!

You are currently viewing our boards as a guest which allows you to view the discussions, but prevents you from contributing. By joining our FREE community you will be able to do all of the following:

  • Post topics & responses to other discussions
  • Communicate privately with other members (PM)
  • Respond to polls
  • Upload content
  • Post comments on our blogs
  • Contribute on our Forexpedia

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.



Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-15-2008, 11:16 AM
Sweet Pip's Avatar
Superior Master Contributor and Member
 

Join Date: Nov 2007
Location: BC, Canada
Posts: 622
Default HELP! MT4 Expert Advisor Coding Problem

Hi,
I was wondering if anyone can help me with a problem I'm having with my EA.
When it sending an order, it's generating "Ordersend error: 130", everytime.

It seems it's either related to incorrect stop levels, or something to do with normalizing double variables.

My stop levels tp & sl are correct as far as I can tell when printing out their values, and I tried using the NormalizeDouble function, but it's still not working. Here's a snippet of code:

if (AccountBalance() < 1000) {Lots = 1; } // calculate Lot Size based on balance
else if(AccountBalance()<2000) {Lots = 2;}
else {Lots=NormalizeDouble(MathRound(AccountBalance()+1 000)/1000,Digits);}

TakeProfit1= NormalizeDouble( MathRound ( (AccountBalance()*0.04) /Lots),Digits); // calculate stop levels based on % of balance
StopLoss = NormalizeDouble(MathRound( (AccountBalance()*0.02) /Lots),Digits);
if(StopLoss <= 10){StopLoss = 11;}

if (buysignal)
{
ticket=OrderSend(Symbol(),OP_BUY,(Lots/10),Ask,3,Ask-StopLoss*Point,Ask + TakeProfit1 * Point,"Sweet Stoch EA",0,0,Green);
if(ticket>0)
{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0); // end long order entry
}

These are the variable values:
EURJPY,M15: Lots = 0.2 Stop Loss = 11 Point = 0.01 Ask = 158.18 Take Profit = 20 Stop Loss Value = 158.07

I've tried searching the net but to no avail for a solution yet.
Thanks

Last edited by Sweet Pip; 02-15-2008 at 12:32 PM.
Reply With Quote
Reply



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -4. The time now is 07:57 PM.
Content Relevant URLs by vBSEO 3.2.0
"If we all did things we are capable of doing, we would literally astound ourselves."
Thomas Edison