Ok, spreads kill some pairs. but is theire away to place trades in the middle of a spreads. This way we can save pips and make more money. i have this code and can it be changed to modify the order to chart price not bid ask?
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))
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Ok, spreads kill some pairs. but is theire away to place trades in the middle of a spreads. This way we can save pips and make more money. i have this code and can it be changed to modify the order to chart price not bid ask?
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;
}
}
}
Is this some that can be done?