Skip to content

πŸ’° Calculate Price from Points OffsetΒΆ

Helper method: calculates price from current market price with points offset. Handles BUY (Ask) vs SELL (Bid) automatically.

API Information:

  • Sugar method: MT5Sugar.priceFromOffsetPoints(String symbol, boolean isBuy, double pointsOffset)
  • Returns: double - Calculated price
  • Formula:
  • BUY: Ask + (pointsOffset Γ— point)
  • SELL: Bid + (pointsOffset Γ— point)

πŸ”½ InputΒΆ

Parameter Type Required Description
symbol String βœ… Symbol name
isBuy boolean βœ… true=use Ask, false=use Bid
pointsOffset double βœ… Points offset (positive or negative)

⬆️ OutputΒΆ

Returns: double - Calculated price


πŸ”— Usage ExampleΒΆ

String symbol = "EURUSD";

// BUY: 50 points above Ask
double buyPrice = sugar.priceFromOffsetPoints(symbol, true, 50);

// SELL: 50 points below Bid
double sellPrice = sugar.priceFromOffsetPoints(symbol, false, -50);

System.out.printf("BUY entry 50p above: %.5f%n", buyPrice);
System.out.printf("SELL entry 50p below: %.5f%n", sellPrice);

See alsoΒΆ