Download MetaTrader 5

Script for multiple pending orders with slippage control

To add comments, please log in or register
keen lum tham
168
keen lum tham  
Dear All,

Goodday. 

I am currently using the attached script to open multiple pending orders.

It can also be used as market orders, but is it possible for me to specify the slippage? something like "enable maximum deviation" in pips size in mt4 new orders box?

Thanks.
whroeder1
16102
whroeder1  
keen lum tham: I am currently using the attached script to open multiple pending orders.

It can also be used as market orders, but is it possible for me to specify the slippage? something like "enable maximum deviation" in pips size in mt4 new orders box?
  1. Move the slippage to an extern, like your other parameters.
  2. Slippage is only valid for buy/sell orders and only on those brokers that use it. For buyStop/sellStop, they become market orders when hit, slippage is irrelevant.
  3. double SLB = Entry - StopLoss*Point, TPB = Entry + TakeProfit*Point;
    
    These values are given in points not in pips. You are not adjusting SL, TP, and slippage; for 4/5 digit brokers and for JPY pairs.
  4. Lots = NormalizeDouble( AccountBalance()*Risk/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);       
    
    Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    • Do NOT use TickValue by itself - DeltaPerLot
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out

To add comments, please log in or register