Forex Factory
  • Login

  • Username: Password:
  • 12:08am

  • Search
  • Home

  • Forums

  • Trades

  • Calendar

  • News

  • Market

  • Brokers

Options

Search

Subscribe to Thread

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

EA to place pending order at MA price line 5 replies

Current price different for pending order sell and buy? 7 replies

Modify Pending Order Price 2 replies

Buy/Sell stop order issue - Broker changing price difference 0 replies

Can a broker execute a market order 1 minute 11 seconds after one clicked the price?? 23 replies

  • Platform Tech
  • /
  • Reply to Thread
  • 3

Help.. Pending stop order when market price and Open price between broker requirement

  • Post# 1
  • Quote
  • First Post: Jan 14, 2009 6:29pm | Edited Jan 15, 2009 5:58pm
  • dewaforex
    Joined Dec 2008 | 6 Posts | Status: Member
Hi, I need help with my code.

My broker rule for pending order is 5 pips from market price
I want set 2 position Buy stop and Sell stop

How to code when differ of market price and open price between 5 pips and 0 pips, how to code this?

Thank you

This is my code:
Inserted Code
if(OrdersTotal()==0)
{
if (PriceToBuy-(5*Point)>=Ask || PriceToSell+(5*Point)<=Bid//The differ of Open price and Market price is 5 or more, put Pending order 
{
int Retry=0;
while(Retry<5 && !IsTradeAllowed()) {Retry++; Sleep(2000);}
RefreshRates();
OrderSend(Symbol(), OP_BUYSTOP,Lots,PriceToBuy,Slippage, SLBuy,GetBuyTakeProfit(),"OD Buy(#" + Magic + ")", Magic, 0, Blue);
while(Retry<5 && !IsTradeAllowed()) {Retry++; Sleep(2000);}
RefreshRates();
OrderSend(Symbol(), OP_SELLSTOP,Lots,PriceToSell,Slippage, SLSell,GetSellTakeProfit(),"OD Sell(#" + Magic + ")", Magic, 0, Red);
while(Retry<5 && !IsTradeAllowed()) {Retry++; Sleep(2000);}
 
}
if (PriceToBuy<=Ask || PriceToSell>=Bid) //The differ of Open price and Market price is less or same than 0, I Buy/Sell on market price 
{
Retry=0;
while(Retry<5 && !IsTradeAllowed()) {Retry++; Sleep(2000);}
RefreshRates();
OrderSend(Symbol(), OP_BUY,Lots,Ask,Slippage, SLBuy,GetBuyTakeProfit(),"OD Buy(#" + Magic + ")", Magic, 0, Blue);
while(Retry<5 && !IsTradeAllowed()) {Retry++; Sleep(2000);}
RefreshRates();
OrderSend(Symbol(), OP_SELL,Lots,Bid,Slippage, SLSell,GetSellTakeProfit(),"OD Sell(#" + Magic + ")", Magic, 0, Red);
while(Retry<5 && !IsTradeAllowed()) {Retry++; Sleep(2000);}
}
else start(); //The differ of Open price and Market price is between 5 and 0. Is correct? :D 
}
  • Post# 2
  • Quote
  • Jan 15, 2009 5:15am
  • trendchaser
    Infractions Overload | 2,045 Posts | Joined Oct 2007
what u have to do, if the order is within 5 pips, just open a trade
  • Post# 3
  • Quote
  • Jan 15, 2009 5:19am
  • trendchaser
    Infractions Overload | 2,045 Posts | Joined Oct 2007
wouldnt you want this

if (PriceToBuy<=Ask || PriceToSell>=Bid)

to be this

if (PriceToBuy<=Ask+5*Point || PriceToSell>=Bid-5*Point)
  • Post# 4
  • Quote
  • Jan 15, 2009 5:44pm
  • dewaforex
    Joined Dec 2008 | 6 Posts | Status: Member
Hi,

Thank you for reply..

What I mean is when the differ of open price and market price is 4 or 3 or 2 or 1 pips..

IF the differ 5 or more is like on first code, I put the Buy Stop or Sell Stop.
I had edit and add description on my code so you can not confused again

and IF the differ same or less than 0, I put Buy or Sell on market price..

But when the differ between 5 and 0, is my code correct?
Because I just put back to start() again when the condition not match...
  • Post# 5
  • Quote
  • Jan 15, 2009 6:31pm | Edited at 7:36pm
  • Dale
    Joined Feb 2008 | 491 Posts | Status: Member
Here is what I use as a script, I send the script first so I do not miss the entry, if the market allows me to order modify I can do so manually. Maybee my coding will help you. If you know how to code so the the computer does the order modify I woud appreciate a copy of the code.


Best regards


Dale
Attached Files
File Type: mq4 adjustSendBuyPost.mq4   1 KB | 529 downloads
File Type: ex4 adjustSendBuyPost.ex4   2 KB | 423 downloads
  • Post# 6
  • Quote
  • Last Post: Apr 5, 2010 5:32am
  • izzanaf
    Joined Apr 2010 | 11 Posts | Status: Junior Member
Hai...

I think this is the script that u search.. the distance from market price can be adjust

but it is more batter if u can modify this script for me where by just add the buy and sell limit order so it useful for hedging
Attached File
File Type: mq4 Set2StopOrders breaking news.mq4   4 KB | 492 downloads
Thread Tools Search this Thread
Show Printable Version Show Printable Version
Email This Thread Email This Thread
Search this Thread:

Advanced Search

  • Platform Tech
  • /
  • Help.. Pending stop order when market price and Open price between broker requirement
  • Reply to Thread
0 traders viewing now

©2013 Forex Factory, Inc. / Terms of Use / Privacy Policy

Forex Factory® is a registered trademark.

Connect

  • Facebook
  • Twitter
  • RSS

Company

  • About FF
  • FF Blog
  • Careers at FF
  • Advertising
  • Contact FF

Products

  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer

Website

  • Homepage
  • Search
  • User Guide
  • Member List
  • Online Now
  • Report a Bug