Invalid stop driving me nuts

 

I am getting an invalid stop every time my EA goes to trade. It is driving me nuts. I have posted the OrderSend code for you to look over.

int ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,6,Bid+15*point,Bid-takeProfit*Point,"comment",283,0,CLR_NONE);

int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-15*point,Ask+takeProfit*Point,"comment",283,0,CLR_NONE);

A side point. I have int ticket for both functions as I have the buy and sell in seperate modules. Didn't want anyone to think I was declaring it twice.

 

int ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,6,Bid+15*point,Bid-takeProfit*Point,"comment",283,0,CLR_NONE);

Hit the space bar. It is correct in my code.

 

Hi caldolegare

I see the space between "1" and "5". That's one problem.

The other problem is "point" instead of "Point". You must write it with "P".

So, it should be like this:

int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-15*Point,Ask+takeProfit*Point,"comment",283,0,CLR_ NONE);

Bye.

 

Upon further review. I made those changes already. Sorry about that. I actually had it in my code like that and still got the problem.

int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-15*Point,Ask+takeProfit*Point,"comment",magic,0,CLR_NONE);

 
caldolegare:
Upon further review. I made those changes already. Sorry about that. I actually had it in my code like that and still got the problem. int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-15*Point,Ask+takeProfit*Point,"comment",magic,0,CLR_NONE);

caldolegare,

There's no problem in your above line of code Could u send the EA?

 
caldolegare:
Upon further review. I made those changes already. Sorry about that. I actually had it in my code like that and still got the problem. int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-15*Point,Ask+takeProfit*Point,"comment",magic,0,CLR_NONE);

The problem still persists? I don't see any problem.

Try to define the stoploss variable:

extern int stoploss=15

and modify the ticket to:

int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-stoploss*Point,Ask+takeProfit*Point,0,magic,0,CLR_NONE);

may be this will work. However I can't see any problem.

 

Already tried that. Even tried this.

double stopLoss=15*Point

int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-stopLoss,Ask+takeProfit*Point,0,magic,0,CLR_ NONE);

Could it be that I am using double instead of int?

 
caldolegare:
Already tried that. Even tried this.

double stopLoss=15*Point

int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-stopLoss,Ask+takeProfit*Point,0,magic,0,CLR_ NONE);

Could it be that I am using double instead of int?

I am not sure if this will work, but give it a try...

double stopLoss=NormalizeDouble(15*Point, Digits);

int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Bid-stopLoss,Ask+takeProfit*Point,0,magic,0,CLR_ NONE);

 

Some things in mq4 are case sensitive.

Ex: colors ...brown isn`t recognized while Brown is.

Everywhere in your code (including variables), try changing these:

stopLoss to StopLoss

takeProfit to TakeProfit

point to Point

Make sure that all words "lots" are either all spelled lots or Lots

---------------------------------------

caldolegare:
Already tried that. Even tried this.

double stopLoss=15*Point

int ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,6,Ask-stopLoss,Ask+takeProfit*Point,0,magic,0,CLR_ NONE);

Could it be that I am using double instead of int?
 

Well, other possibility is the SL or the TP is too tight and your MT4 platform can't accept it. Just my two cents

 

OK I am completely confused now. It worked today and I didn't change a thing from the last time I ran it.

Just a question. If the price is jumping around quite a bit could it possibly give me an invalid stop error?

Reason: