Error 130 Issues

 

Hey everyone,


I have wasted an half hour trouble shooting the "invalid stops" code of myEA. I dont know why the issue persists.



extern string Label1="===General Trade Settings===";
extern int   TakeProfit=25;
extern int    StopLoss=10;
extern int    TrailingStop=0;
extern int    Slippage=2;
extern double  Lot=0.1;
//---------Time Filter--------//

extern string Label5="===Moving Average Settings===";
extern int    MA_Period=200;
extern int    MA_Shift=0;
extern int    MA_Type=1;
extern int    MA_Price=0;
//-------Stochastics----------//


//-------Initialize EA Orders Accounting-----//

//----------Money Management----------//

int start()
{
//--------------Bar CHeck------//
double EMA=iMA(NULL,PERIOD_M1,MA_Period,MA_Shift,MA_Type,MA_Price,0);
double BarClose;
BarClose=iClose(0,PERIOD_M1,0);


if(BarClose>EMA)
{
double SLB=Bid-StopLoss*Point;
double TPB=Bid+TakeProfit*Point;
int buy= OrderSend(Symbol(),0,Lot,Ask,Slippage,SLB,TPB);
}

if(BarClose<EMA)
{
double SLS=Ask+StopLoss*Point;
double TPS=Ask-TakeProfit*Point;

int sell= OrderSend(Symbol(),1,Lot,Bid,Slippage,SLS,TPS);
}

string err=GetLastError();
Alert(err);

return(0);
}

 
ZacharyRC:

Hey everyone,


I have wasted an half hour trouble shooting the "invalid stops" code of myEA. I dont know why the issue persists.



 

I would appreciate anyones support.


TY

 

 ECN  Broker ??

Take also a read at  

 What are Function return values ? How do I use them ? 

and you have not adjusted the code to work as well on a 5 digit notation EURUSD account

So there might be more time needed then a half hour 

 
ZacharyRC:

I would appreciate anyones support.

GetLastError() returns an int not a string,  read the documentation if you aare not sure about a function that you want to use.

The 1st parameter you pass to iClose()  is a string,  not an int,  so zero is not valid.  iClose or Close[] for bar zero is Bid . . .

 
Thank you for the info. gentlemen. Will research.
 
deVries:

 ECN  Broker ??

Take also a read at  

 What are Function return values ? How do I use them ? 

and you have not adjusted the code to work as well on a 5 digit notation EURUSD account

So there might be more time needed then a half hour 

Oanda, not an ECN.



Still having issues, looked at the information and tried the Orderreliable() code. When I include the code in my EA, it is coming up with 56 errors, all from the #include file.


I will try a standard order modify.

 
ZacharyRC:

Oanda, not an ECN.

Still having issues, looked at the information and tried the Orderreliable() code. When I include the code in my EA, it is coming up with 56 errors, all from the #include file.

I will try a standard order modify.

If your Broker is not an ECN you caan send the TP & SL with the OrderSend() so you don't need to do the OrderModify(), you do need to make sure your SL isn't too close . . .

Read this:   Requirements and Limitations in Making Trades  what is your Stoplevel ?  is it greater than 10 ?

 
ZacharyRC:

Oanda, not an ECN.



Still having issues, looked at the information and tried the Orderreliable() code. When I include the code in my EA, it is coming up with 56 errors, all from the #include file.


I will try a standard order modify.


Your Stoploss and takeprofit is almost at Orderopenprice

make it 10 times greater and see if you have that way no error...

it is if it is solved that way an issue because the code is not adjusted to work as well on a 5 digit notation EURUSD account 

 
//+------------------------------------------------------------------+
//|                                                    Simple EA.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//Literally copying Ferrus Format to a tee

extern string Label1="===General Trade Settings===";
extern int   TakeProfit=25;
extern int    StopLoss=10;
extern int    TrailingStop=0;
extern int    Slippage=2;
extern double  Lot=0.1;
//---------Time Filter--------//

extern string Label5="===Moving Average Settings===";
extern int    MA_Period=200;
extern int    MA_Shift=0;
extern int    MA_Type=1;
extern int    MA_Price=0;



//-------Initialize EA Orders Accounting-----//



int start()
{
//--------------Bar CHeck------//
double EMA=iMA(NULL,PERIOD_M1,MA_Period,MA_Shift,MA_Type,MA_Price,0);
double BarClose;
BarClose=iClose(Symbol(),PERIOD_M1,0);
//---------Adjusting for every digit broker-------------//
int mypoint;

if (Digits==3||Digits==5){ mypoint=10;}
else {mypoint=1;}
//------------Taking Trades----------//
if(BarClose>EMA)
{
double SLB=Bid-StopLoss*Point*mypoint;
double TPB=Bid+TakeProfit*Point*mypoint;
int buy= OrderSend(Symbol(),0,Lot,Ask,Slippage,SLB,TPB);
}

if(BarClose<EMA)
{
double SLS=Ask+StopLoss*Point*mypoint;
double TPS=Ask-TakeProfit*Point*mypoint;

int sell= OrderSend(Symbol(),1,Lot,Bid,Slippage,SLS,TPS);
}

int err=GetLastError();
Alert(err);

return(0);
}
 

Raptor UK: I reviewed the information and made note of referring to definitions. I am also researching how to put a log in with Print so I can update the journal.


1321: I have tried each link you sent me and made adjustments for Oandas 5 digit broker. So far it has been to no avail. I am in first month or so of coding, but this is a hang up just for stops.


I appreciate your help and info immensely.


ZRC