Won't Place A Trade?

 

Hello,


I've been working on a EA for something of a grid system.


I finished the EA, and ran it on the Strategy Tester. It ran perfectly fine, and trades were placed normally. But when I when I try to run it on a chart (yes I do have "Allow Live Trades" on) it won't place a trade.


I've been beating my head against my desk trying to make this work. I keep trying idea after idea. What's really messed up- is that I have used this "initial trade" code in the past- and it worked fine for me.


All I want to do at this point- is to just get it to make a trade....I can figure out the rest later.

if(OrdersTotal() < 1)
 {
  (OrderSend(Symbol(),OP_BUY,NewLots,BuyPrice,Slippage,Sl,Tp,NULL,0,0,Green);
 }

That's as simple as it is. And like I said- when I run the Strategy Tester, it places the trades fine.


Just creating a new Expert and having only one line of code:

OrderSend(Symbol(),OP_BUY,0.1,Bid,3,Bid - 10*Point,Bid + 10*Point,NULL,0,0,Blue);

It places 100 trades on the Strategy tester, but doesn't place the order when I go live. I know that my Broker will do a lot size that small.


Is there some setting I might have messed up or something?


I tried uninstalling and re-installing the platform, but still nothing.


If I enable the "Manual Confirmation"- it will open a box to let me trade when it's supposed to. But it won't place one. There's no error codes either.


I will let me run other EA's. Like Multi-Lot Scalper for example. It will place trades. But it run a base "OrderSend" command.


So I wanted to know if anyone else has had this problem, and if so- can they direct me to a fix or workaround. All I need is a command that will initiate a trade as soon as the program starts (well after the first tick of course). I normally use "TotalOrders() < 1" command, and it worked fine. But it doesn't seem to work now.

 

Embstj

What errors are seen in the Journal or Experts tabs of the Terminal?

My guess its to do with Slippage, especially if your account is sub-pip?

Try different (higher) values for Slippage - perhaps 50 if you are sub-pip?

Good Luck

-BB-

 

I get no errros in the Expert tab of the terminal.

I would imagine if that was the problem, I would get the the error about the Price-Data changing. I don't remember the exact name of the error- but I know what you mean. I'm not getting that error. I'm not getting any errors. Just nothing is happening.

It's weird, huh?

-Jacob

 

BB is right you know - gotta essentially play with the call actuals, yes?

and: do you know for sure what call actuals are physically being sent to the server?

Having got the test print out, take each value in turn and totally understand if it is acceptable value for OrderSend() and your Broker - use MarketWatch window + symbol properties

Unless 100% sure about this stuff, can be massive headache... ;)

eg,

if(OrdersTotal() < 1)
{
  Print("NewLots=",DoubleToStr(NewLots,8)
       ,", BuyPrice=",DoubleToStr(BuyPrice,8)
       ,", Slippage=",Slippage
       ,", Sl=",DoubleToStr(Sl,8)
       ,", Tp=",DoubleToStr(Tp,8)
       );
  OrderSend(Symbol(),OP_BUY,NewLots,BuyPrice,Slippage,Sl,Tp,NULL,0,0,Green);
}

edit: I changed DoubleToStr(xxxx,Digits) to DoubleToStr(xxxx,8) Why? how do I/you know that the values are Normalized to Digits ??? if not, can also give headaches etc ;)

so play safe and dump out the maximum digits the system can handle!

 
Embstj:

Hello,


I've been working on a EA for something of a grid system.


I finished the EA, and ran it on the Strategy Tester. It ran perfectly fine, and trades were placed normally. But when I when I try to run it on a chart (yes I do have "Allow Live Trades" on) it won't place a trade.


I've been beating my head against my desk trying to make this work. I keep trying idea after idea. What's really messed up- is that I have used this "initial trade" code in the past- and it worked fine for me.


All I want to do at this point- is to just get it to make a trade....I can figure out the rest later.

That's as simple as it is. And like I said- when I run the Strategy Tester, it places the trades fine.


Just creating a new Expert and having only one line of code:

It places 100 trades on the Strategy tester, but doesn't place the order when I go live. I know that my Broker will do a lot size that small.


Is there some setting I might have messed up or something?


I tried uninstalling and re-installing the platform, but still nothing.


If I enable the "Manual Confirmation"- it will open a box to let me trade when it's supposed to. But it won't place one. There's no error codes either.


I will let me run other EA's. Like Multi-Lot Scalper for example. It will place trades. But it run a base "OrderSend" command.


So I wanted to know if anyone else has had this problem, and if so- can they direct me to a fix or workaround. All I need is a command that will initiate a trade as soon as the program starts (well after the first tick of course). I normally use "TotalOrders() < 1" command, and it worked fine. But it doesn't seem to work now.

Hi there embstj,


Had a quick look at your code. Could it be that you're trying to Buy with the Bid price? You should use the Ask price along with Ask-Stoploss for a Buy operation.


Regds,

CB

 
Embstj wrote >>

Hello,

I've been working on a EA for something of a grid system.

I finished the EA, and ran it on the Strategy Tester. It ran perfectly fine, and trades were placed normally. But when I when I try to run it on a chart (yes I do have "Allow Live Trades" on) it won't place a trade.

I've been beating my head against my desk trying to make this work. I keep trying idea after idea. What's really messed up- is that I have used this "initial trade" code in the past- and it worked fine for me.

All I want to do at this point- is to just get it to make a trade....I can figure out the rest later.

That's as simple as it is. And like I said- when I run the Strategy Tester, it places the trades fine.

Just creating a new Expert and having only one line of code:

It places 100 trades on the Strategy tester, but doesn't place the order when I go live. I know that my Broker will do a lot size that small.

Is there some setting I might have messed up or something?

I tried uninstalling and re-installing the platform, but still nothing.

If I enable the "Manual Confirmation"- it will open a box to let me trade when it's supposed to. But it won't place one. There's no error codes either.

I will let me run other EA's. Like Multi-Lot Scalper for example. It will place trades. But it run a base "OrderSend" command.

So I wanted to know if anyone else has had this problem, and if so- can they direct me to a fix or workaround. All I need is a command that will initiate a trade as soon as the program starts (well after the first tick of course). I normally use "TotalOrders() < 1" command, and it worked fine. But it doesn't seem to work now.

If you are running other Ea"s on the same account, then the OrdersTotal() will count the other ea's orders as well. If this is the problem you will need to use magic numbers in order to determine if this particular ea has an open order.

HTH

Keith