Ordersend issue???

 
extern string C1="EURUSD";
extern int MagicNumber1=1008;
extern int MagicNumber2=1009;
extern double lot=0.15;
extern double lot2=0.75;
int Slippage=3;
int i;
string eurusdStop;
void verifyorder(string symbol, int MN, string direction)
{
int ord_cnt=OrdersTotal();
for (int start=0;start<ord_cnt;start++)
{
OrderSelect(start, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber()==MagicNumber1 ||
OrderMagicNumber()==MagicNumber2)
{return;}
}
if(direction=="LONG"){OrderSend(symbol,OP_BUY,lot,MarketInfo(symbol,MODE_ASK),3,0,0,"Hedge"+symbol,MN);}
return;
}

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
GlobalVariableDel("eurusdStop");
Print("4 Hour eurusd trading is now allowed");
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double MA1=iMA

double MA2=iMA


REST OF DOUBLE VARIABLES ARE HERE AND CONSTRUCTED PROPERLY


int ticket1,ticket2;
int totalO = OrdersTotal();
if(GlobalVariableCheck("eurusdStop")==false)//
{
if(MA1 > MA2 && H1 > H2)
{
if (L1 < L2 && c1 > O1)
{
if(IsTradeAllowed()==true && Ask <= c1 + 2*Point)
{
//LONG EURUSD
OrderSend(C1,OP_BUY,lot,MarketInfo(C1,MODE_ASK),3,Ask-150*Point,Ask+5*Point,NULL,MagicNumber1,0,Green);
if (ticket1<0){verifyorder(C1,MagicNumber1,"LONG");}Sleep(5000);

OrderSend(C1,OP_SELLSTOP,lot2,Ask-150*Point,3,Ask-1*Point,Ask-170*Point,NULL,MagicNumber2,0,Green);
if (ticket2<0){verifyorder(C1,MagicNumber2,"LONG");}Sleep(5000);
GlobalVariableSet("eurusdStop",1);//allows only two orders to be put on!
Print("4 Hour eurusd trading is stopped");
}
}
}
if(MA1 < MA2 && H1 > H2)
{
if(L1 < L2 && c1 < O1)
{
if(IsTradeAllowed()==true && Bid >= c1)
{
//SHORT EURUSD
OrderSend(C1,OP_SELL,lot,MarketInfo(C1,MODE_BID),3,Bid+150*Point,Bid-5*Point,NULL,MagicNumber1,0,Green);
if (ticket1<0){verifyorder(C1,MagicNumber1,"LONG");}Sleep(5000);

OrderSend(C1,OP_BUYSTOP,lot2,Bid+150*Point,3,Bid+1*Point,Bid+170*Point,NULL,MagicNumber2,0,Green);
if (ticket2<0){verifyorder(C1,MagicNumber2,"LONG");}Sleep(5000);
GlobalVariableSet("eurusdStop",1);//allows only two orders to be put on!
Print("4 Hour eurusd trading is stopped");
}
}
}
}
else
bool found = false;
for(int k=OrdersHistoryTotal()-1;k>=0;k--)
{
if((OrderSelect(k,SELECT_BY_POS,MODE_HISTORY))&&(OrderMagicNumber()==MagicNumber1))
{
found = true;
break;
}
}
if(found == true)
{
for(k=OrdersTotal()-1;k>=0;k--)
{
if((OrderSelect(k,SELECT_BY_POS,MODE_TRADES))&&(OrderMagicNumber()==MagicNumber2))
{
OrderDelete(OrderTicket());
}
}
}
//----
return(0);

}


CAN ANYONE POSSIBLY HELP ME UNDERSTAND AN ISSUE I AM HAVING WITH THIS!? I HAVE HAD SEVERAL OCCURENCES WHERE THE INITIAL ORDER FOR A BUY OR SELL IS NOT PLACED, YET THE STOP ORDER GETS PLACED JUST FINE????? OBVIOUSLY I NEVER GET MY POSITION ON SINCE MY ORDER NEVER GETS PLACED! ANY THOUGHTS/SUGGESTIONS WOULD BE GREATLY APPRECIATED! THANK YOU ALL...... DANIEL

 

FM

Which chart is the EA actually running on?

And...

What error messages do you see in the Journal or Experts tab of the Terminal?

-BB-

 
BarrowBoy:

FM

Which chart is the EA actually running on?

And...

What error messages do you see in the Journal or Experts tab of the Terminal?

-BB-

It is running on the eurusd-same as is called out in the code. Funny thing is that I do not get any error messages!!! For example, if my first condition is met and a buy is supposed to placed along with a sellstop(see code above), the sellstop shows up, globalvariable is created and then trading is stopped...what about my buy!! It never places that trade-kind of like that part of the code is "skipped over"....this is odd as I have been running this EA on multiple pairs very successfully for months now! This is one thing I do not like about using EA's-sometimes they just do things that you can't figure out(especially for a very novice programmer like me). Thank you BB for your time and thoughts on this! Daniel

 

Is the account full-pip or sub-pip?

-BB-

 
BarrowBoy:

Is the account full-pip or sub-pip?

-BB-

Account is set up to allow 0.10 on up lots to trade, to two decimal places.....i have this ea on other pairs too and it is funny, now my audusd trader did the same thing to me!!

 

How many decimal points on the price of EURUSD on the chart?

 

What is the result for

MarketInfo(Symbol(), MODE_MINLOT) and

MarketInfo(Symbol(), MODE_LOTSTEP)

Reason: