Placing orders between the spreads?

 

How does one place an order between the spreads? If I have this code how can it be changed to do such a thing. Ex if the spreads is 18 how do we place the trade in the midlle of that like 9 or at the actual trade price. So, if the price is 90.18 and the spreads is 18. the robot should send a order should be send at 90.18 plus or minus 3 pip for slippage. does this make since?

void PlaceBuyOrder()
{
double BuyOrders, Lots;
double LowestBuy = 1000, HighestBuy;

if (BarTime != Time[0])
{
BarTime = Time[0];
TickPrice = 0;
TradeAllowed = true;
}

RefreshRates();

for (Order = OrdersTotal() - 1; Order >= 0; Order--)
{
if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_BUY)
{
if (OrderOpenPrice() < LowestBuy) LowestBuy = OrderOpenPrice();
if (OrderOpenPrice() > HighestBuy) HighestBuy = OrderOpenPrice();
BuyOrders++;
}
}
}

if (TradeAllowed)
{
if (Ask >= HighestBuy + (TrendSpacing * Point))
{
// if (Multiplier)
if (Multiplier == 1)
Lots = NormalizeDouble(LotSize * MathPow(LotIncrement, BuyOrders), 2);
else
Lots = NormalizeDouble(LotSize + (LotIncrement * BuyOrders), 2);
}

if (Ask <= LowestBuy - (Spacing * Point))
{
// if (Multiplier)
if (Multiplier == 1)
Lots = NormalizeDouble(LotSize * CounterTrendMultiplier * MathPow(LotIncrement, BuyOrders), 2);
else
Lots = NormalizeDouble((LotSize * CounterTrendMultiplier) + (LotIncrement * BuyOrders), 2);
}

if (Lots == 0)
{
// if (Multiplier)
if (Multiplier == 1)
Lots = NormalizeDouble(LotSize, 2);
else
Lots = NormalizeDouble(LotSize, 2);
}

OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, TradeComment, Reference, Green);

Error = GetLastError();
if (Error != 0)
Write("Error opening BUY order: " + ErrorDescription(Error) + " (C" + Error + ") Ask:" + Ask + " Slippage:" + Slippage);
else
{
TickPrice = Close[0];
TradeAllowed = false;
}
}
}


void PlaceSellOrder()
{
double SellOrders, Lots;
double HighestSell, LowestSell = 1000;

if (BarTime != Time[0])
{
BarTime = Time[0];
TickPrice = 0;
TradeAllowed = true;
}

RefreshRates();

for (Order = OrdersTotal() - 1; Order >= 0; Order--)
{
if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_SELL)
{
if (OrderOpenPrice() > HighestSell) HighestSell = OrderOpenPrice();
if (OrderOpenPrice() < LowestSell) LowestSell = OrderOpenPrice();
SellOrders++;
}
}
}

if (TradeAllowed)
{
if (Bid <= LowestSell - (TrendSpacing * Point))
{
// if (Multiplier)
if (Multiplier == 1)
Lots = NormalizeDouble(LotSize * MathPow(LotIncrement, SellOrders), 2);
else
Lots = NormalizeDouble(LotSize + (LotIncrement * SellOrders), 2);
}

if (Bid >= HighestSell + (Spacing * Point))
{
// if (Multiplier)
if (Multiplier == 1)
Lots = NormalizeDouble(LotSize * CounterTrendMultiplier * MathPow(LotIncrement, SellOrders), 2);
else
Lots = NormalizeDouble((LotSize * CounterTrendMultiplier) + (LotIncrement * SellOrders), 2);
}

if (Lots == 0)
{
// if (Multiplier)
if (Multiplier == 1)
Lots = NormalizeDouble(LotSize, 2);
else
Lots = NormalizeDouble(LotSize, 2);
}


OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, TradeComment, Reference, Red);

Error = GetLastError();
if (Error != 0)
Write("Error opening SELL order: " + ErrorDescription(Error) + " (D" + Error + ") Bid:" + Bid + " Slippage:" + Slippage);
else
{
TickPrice = Close[0];
TradeAllowed = false;
}
}
}

Reason: