π° 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ΒΆ
- Get prices:
getAsk(),getBid() - Points offset orders:
buyStopPoints()