Automatic Buy Order with 10 Pips Lower or Higher Price

Hello.
We are looking for MQL4 programmer who can create our Expert Adviser. For example; our expert adviser will make BUY order when EUR/USD bid price is 1.3452 . After that this EA will make BUY order when EUR/USD bid price 1.3442 or 1.3462 . And if our EA has made order with 1.3442 bid price, it will make BUY order again 1.3432 or 1.3452 . If our EA has made order with 1.3462 bid price, it will make BUY order again 1.3452 or 1.3472 . Shortly, our expert adviser will make BUY order when the bid price 10 pip higher or 10 pip lower from previous BUY order. Our system is BUY order circle. Also, our EA will add automatically STOP LOSS and TAKE PROFIT orders. Our graphic is like this:
1.3452 (BUY)
/
1.3442 (new BUY) 1.3462 (new BUY)
/ \ /
1.3432 (new BUY) 1.3452 (new BUY) 1.3572 (new BUY)
/ \ / \ /
… … … …

We will pay money for this work. We are waiting for your contacts us. We can talk details of EA with interested programmers.

OK… Here is a first approach for this EA. Need to backtest it…

Parameters are:

Lots = 0.1; Trade Lots
tp=10; Take Profit in pips
sl=200; Stop Loss in pips

gridsize = 0.0010; This is the price distance you want between trades.

TradeBuys = true; If you set this to true, it will place buy orders. If you put it to false it will place sell orders.

openprice = 1.3452; At what price you want the EA to open the first trade.
price_error = 0.0001; This is the slippage you want to admit, as it’s very difficult to enter at an exact price.

Hope it goes well for you! good luck!

kurnaz.zip (5.47 KB)

Thank you for your answer.

I will explain EA that we want with details.

For example; price has decreased from 0,9155 to 0,9091 so price has gone on 0,9143 , 0,9123 , and 0,9103 .Our EA has made BUY order on 0,9143 , 0,9123 and 0,9103. And after that price has increased form 0,9091 to 0,9115 , our EA will not make BUY order again on 0,9103. Because price has not reached to 0,9083 or 0,9123 . But, price has increased from 0,9115 to 0,9130, EA will make order on 0,9123 . After that price has decreased from 0,9130 to 0,9105, EA will not make BUY order again on 0,9123. Because price has not reached 0,9143. It will make BUY order only on 0,9103 .

We want to also testing option on real history of forex trading of MetaTrader4 (For example: We want to try this EA between 01.01.2011 and 01.01.2012 or 01.01.2012 and 01.02.2012) .

This EA can be readable and writable from us like pip deviations, TP and SL points, lot size, BUY order price and SELL order price ….

It will be designed for MetaTrader4.
Also, this EA will give permit to open BUY and SELL orders at the same time and at the same price. That is, this EA will make BUY and SELL orders at the same price on same account.

And also some details; we will decide the first price with watching forex market and we will create this first price manually. That is, this EA will give permission for determining the first price. Also we want to stop point (optionally, we will use or not this option) for this EA (on any price that we can determine), if we want to finish this trading system. Finally, EA can be used any currency like EUR/USD, USD/CHF….

Please refer to this thread in order to setup your backtest environment

http://forums.babypips.com/expert-advisors-automated-trading/52287-tutorial-complete-backtesting-analysis-setup-100-free.html

Once you have it, you can test the EA I sent in my last post and take it as a base for modifications. We can talk by Skype if you want.

averi i would like ot kw…is the orderopenprice greater thn bidprice ??..as well wht is the difference between currentprice & orderopenrprice??

whn i take a buy order with code ordersend on mql terminal…the order opens above the ask everytime,bt whn it comes to sell…its perfect…hw do i correct the code in order to open a buy order at exact point

You can’t select the price at which you open a position. It is a market and so, prices move frequently.

They call it slippage…

i ws asking…wht i need to do so tht the buy order opens exact at market price …fr the sell the order opens exact at the market price bid perfectly…so wht need to be corrected on ordersend function of buy…thou i tested this on various broker…i m finding the same problem…if u r using hotforex or xm…u can kw urself on demo…kindly plz guide me

@tasaoirse I insist, it is not possible.

Can you share the part of the code where OrderSend is written? Maybe there is some confussion here…

ok buddy i gonna share the code as requested

  if(X1>X2 && X3>X4 && Open[1]<Close[1]  &&  buycnt == 0 && buyflag == 0 && prevTime !=Time[0]) {
  

     

        RefreshRates();
        
           if(TakeProfit==0)  TP = 0;
           if(StopLoss == 0)  SL = 0;
           
           RefreshRates();
           if(TakeProfit != 0)     TP = Ask+TakeProfit*MarketInfo(Symbol(),MODE_POINT);
           if(StopLoss != 0)       SL = Ask-StopLoss*MarketInfo(Symbol(),MODE_POINT);
        
        
         int ticket = OrderSend(Symbol(),OP_BUY,Lot,Ask,Slippage,0,0,EAName,Magic,0,Blue);
         if(ticket > 0) {

          bool chk = OrderModify(ticket,Ask,SL,TP,0,Green);
          prevTime = Time[0];
           buyflag = 1;
           sellflag = 0;
        }
    
     
  }

In the following part, you send an order to the broker to open at the last available Ask price in your terminal.

It doesn’t mean the broker will open at that specific price, as some slippage could affect.

If you want to set the SL and TP at specific distance from entry price, then calculate these values after OrderSend:

   int ticket = OrderSend(Symbol(),OP_BUY,Lot,Ask,Slippage,0,0,EAName,Magic,0,Blue);
   if(ticket > 0 && OrderSelect(ticket,SELECT_BY_TICKET)){
      double entry_price = OrderOpenPrice();
      if(TakeProfit != 0)     
         TP = entry_price+TakeProfit*MarketInfo(Symbol(),MODE_POINT);
      if(StopLoss != 0)       
         SL = entry_price-StopLoss*MarketInfo(Symbol(),MODE_POINT);
      bool chk = OrderModify(ticket,entry_price,SL,TP,0,Green);
   }

paul thank u fr kind reply…tomorrow…i will check hw tht works… the code which u given me…n get back to u…i m using xm broker fr nw

paul the problem still didnt resolve…i m sending u the screenshot…the sell order opening is perfect…bt buy order is getting open above ask

Right-click on the chart, click on Properties, check Show ask line.

image

i ws asking u…i want to open the trade exact at market price bid price …buy or sell trade anything either…

It isn’t possible. The broker will open at the “best possible price” but not at the price you want.

u sure its nt possible…i mean any code to correct the slippage…r else i will drop completely…bt i wish some solution would be ther…

With the slippage parameter you can reduce the distance from the ask you set in the price. But this is only a condition you send to the broker that the broker may reject. Not all the brokers accept this condition and they just open directly at the best available price.

When you go to a shop to a buy a phone, the price is the same you saw on the internet. But when you are in a financial market, prices change very fast and you cannot get the price you previously saw.

I don’t like to do this but I have to do it: I don’t think it is your time to trade. Better, if you learn first.

I’m not a teacher but I’m sure this is a good first lesson: it is very common to lose in trading, get used to it. Don’t trade if you can’t handle a loss.

haha k k…atleast nw tell me kwing everything…how do i take a buy or sell order frm the middle of the candle price…atleast can tht be done nw??..middle of the candle

1 Like

helo paul i came up with other problem a new one…i specify stoploss as 5 pips n takeprofit 5 pips,bt it happens so tht many a times the stoploss is taken as zero on terminal n take profit as zero,very rare it is displayed 5pips …hw do i corret tht,n sorry fr troubling u with weird queries…hope this would be last…the previous post solution is nt yet solved to open a trade with the price of the middle of candle…u didnt say tht…sending u the screenshot of the stoploss nw