Why won't SetOrder take my prices

 
I'm using MT3 (I think). MT4 crashes my computer, but that's another rant. I tried to post a SetOrder and it fails.
The code is:

input: cPriceEnter(0);
input: Spread(0);
input: Slippage(0);
var: cPriceStop(0),cPriceProfit(0);

cPriceStop = cPriceEnter + (StopLoss * Point);
cPriceProfit = cPriceEnter - (TakeProfit * Point);
SetOrder(OP_SELL,Lots,cPriceEnter - (Spread * Point),Slippage,cPriceStop,cPriceProfit,Red);

The log reads this:

17:18:42 Expert 'PlaceOrder2': sell 1.00 EURUSD at 1.2073 [slippage 1000], sl: 1.3073 tp: 1.1073
17:18:42 Expert 'PlaceOrder2': invalid prices in SetOrder

What doesn't it like about my prices?

Steve
 
If I'm overlooking some good technical documentation on this website that explains this sort of thing, please tell me where to find those tech docs. I've looked through the menus here and didn't see it.

Thanks

Steve
 
What are you trying to accomplish exactly? I'm not sure I understand.

Perhaps you should try:
SetOrder(OP_SELL,Lots,Bid,Slippage,cPriceStop,cPriceProfit,Red);

If you are not trying to sell at the current price then you should use a stop or limit order, not a market order. In other words, if type is 'OP_BUY' or 'OP_SELL' then the price should always be 'Ask' or 'Bid' respectively. Anything else should use a stop or limit order.
 
Maybe I'm trying to do something that the program isn't designed to do. I'm doing this to backtest an idea, and not yet to trade live with this Expert Advisor. I'm comparing the previous bar High or Low price to a trigger level. If the trigger level is passed then I want to enter a trade at that trigger level.

Maybe the answer is that I need to study the technical docs a little more, but what I saw on my broker's website was not helpful in this area. If you can tell me where to find the real developers documentation on this website I would be grateful and I will try to study it.

I think I'm confused about how the program uses the data in the graph bars (I'm using a 5-minute graph) and some other, unseen real tick-by-tick historical data. I've never seen the technical docs that explain this.

Thanks

Steve
 
Then this is what you would do..basically.

var: LongTriggerLevel(0);
var: ShortTriggerLevel(0);

LongTriggerLevel=....;
ShortTriggerLevel=....;

If Ask > LongTriggerLevel then {
   SetOrder(OP_BUY,Lots,Ask,Slippage,cPriceStop,cPriceProfit,Red);
   };

If Bid < ShortTriggerLevel then {
   SetOrder(OP_SELL,Lots,Bid,Slippage,cPriceStop,cPriceProfit,Red);
   };



There are also other ways of doing this by setting BuyStop and SellStop orders. But this should basically get you there. It at least should give you an idea of how things should work.

I think this goes back to the whole issue of, traders typically don't have fundamental programming skills. You need this in order to be writing EAs.

 
GT

Thanks for your help. I think I see what is happening, but I wish I could find more in-depth technical docs about what MQL is doing behind the scenes. In case you think I don't have fundamental programming skills, I've been working as a VB developer for the last 10 years. Some programmers would say VB's not a REAL programming language, but my employers think it's real enough. ;-) I just don't have training in MQL and I'm trying to piece it together from what I see on different websites. I need something like MSDN for this language. Again, if you know where it is, I'd love to study it. The closest I have found is the language dictionary in the Forex Trader that I'm using.

Thanks again

Steve
Reason: