MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Source code library - Expert Advisors, Indicators and Scripts

Freelancers needed to develop Expert Advisors for traders
To post a new code, please log in or register

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2011.04.01 08:31
Place OCO Order, One pip Limit Order and One Pip Stop Order

Place OCO Order, One pip Limit Order and One Pip Stop Order - expert for MetaTrader 4

| English Spanish Portuguese

Views:
12125
Rating:
votes: 3
OCO_EA.mq4 (8.4 KB)view

Description:

Places One-Cancels-the-Other Order (OCO Order), One pip Limit Order and One Pip Stop Order on MetaTrader 4 (MT4) platform.

Global variables:

  • OCO_BUY_LIMIT - Buy Limit Price
  • OCO_BUY_STOP - Buy Stop Price
  • OCO_SELL_LIMIT - Sell Limit Price
  • OCO_SELL_STOP - Sell Stop Price
  • OCO_confirmation - After input Buy Limit Price, Buy Stop Price, Sell Limit Price or Sell Stop Price set OCO_confirmation = "1"
  • OCO_lots - Lots
  • OCO_oCO - if OCO_oCO = "1", One Canel Others
  • OCO_sL_Pips - Stop Loss Pips
  • OCO_tP_Pips -Take Profit Pips

Last comments | Go to discussion (7)
MQL4 Comments
mql4_comments | 14 Jun 2011 at 08:37

thanks but in fact i have some question

how could this EA place pending order about 1 pip from current price while the broker doesn't accept below 5 pips ( descibe the idea )

i put it on chart and it didn't place any orders how does it work

i need such expert but to place only sellstop and buystop from 1 or 2 pips from the current price

Raymond
fxpingpong | 15 Jun 2011 at 07:45
somaare:

thanks but in fact i have some question

how could this EA place pending order about 1 pip from current price while the broker doesn't accept below 5 pips ( descibe the idea )

i put it on chart and it didn't place any orders how does it work

i need such expert but to place only sellstop and buystop from 1 or 2 pips from the current price


No conern the broker doesn't accept below 5 pips

Market Price Bid 1.44226 Ask 1.44250

OCO_BUY_STOP - Buy Stop Price set to "1.44260"

OCO_SELL_STOP - Sell Stop Price set to "1.44216"

OCO_confirmation - set "1"

OCO_oCO - if OCO_oCO = "1", One Canel Others

OCO_sL_Pips - Stop Loss Pips set to "50"

OCO_tP_Pips -Take Profit Pips set to "50"

Fine

MQL4 Comments
mql4_comments | 8 Jul 2011 at 18:42

Hi,

I haven't tried this yet. But as a NuB wanting to build up a Library of reusable programming modules and looking for OCO, which I didn't expect to be native to MQL4; a very hearty 'Thanks: VERY nice! (< 8)

OTO = One-Triggers-the-Other Module?

MQL4 Comments
mql4_comments | 8 Jul 2011 at 18:51
hkjonus:

Sorry, 2 questions:

1. OCO? whats this EA supposed to do?


OCO stands for 'Order Cancels Other' This places two (pending) orders: both a Buy and a Sell order; When the market movement triggers one in the direction that is profitable, the other order is automatically cancelled. Here is a description from BabyPips.Com:

One-Cancels-the-Other (OCO)

An OCO order is a mixture of two entry and/or stop-loss orders. Two orders with price and duration variables are placed above and below the current price. When one of the orders is executed the other order is canceled.

Let's say the price of EUR/USD is 1.2040. You want to either buy at 1.2095 over the resistance level in anticipation of a breakout or initiate a selling position if the price falls below 1.1985. The understanding is that if 1.2095 is reached, your buy order will be triggered and the 1.1985 sell order will be automatically canceled.

Read more: http://www.babypips.com/school/types-of-orders.html#ixzz1RX7qZaJg
MQL4 Comments
mql4_comments | 3 Sep 2013 at 20:12

What am I doing wrong:

downloaded the EA into my MT4 experts folder - shut down the MT4 dealing station - double-clicked the EA, and compiled it. It now became .ex file - re-open MT4, OCO EA appears in experts (it has lost all colours, just like other EAs) - dragging it onto a chart, (click allow live trading) OCO EA appears in top right corner

but then what - nothing else happens: no dialog window for parameters pops up.

tky!