VBA Functions Reference: IG Index

All Excel Price Feed VBA functions can be used from VBA by using the Application.Run function.

Excel Price Feed includes several functions which are specially designed to be used from VBA. They all begin with EPF.IG.VBA and can be used for market analysis, automated trading etc.

EPF.IG.VBA.Mid

EPF.IG.VBA.Bid

EPF.IG.VBA.Offer

EPF.IG.VBA.SentimentLong

EPF.IG.VBA.SentimentShort

Description

Returns the current mid/bid/offer price for the specified epic code.

Syntax

currentMidPrice = Application.Run("EPF.IG.VBA.Mid", epicCode)

currentBidPrice = Application.Run("EPF.IG.VBA.Bid", epicCode)

currentOfferPrice = Application.Run("EPF.IG.VBA.Offer", epicCode)

currentOfferPrice = Application.Run("EPF.IG.VBA.SentimentLong", epicCode)

currentOfferPrice = Application.Run("EPF.IG.VBA.SentimentShort", epicCode)

These functions all have the one single parameter:

Parameters
Parameter Description
epicCode The IG Index epic code

EPF.IG.VBA.NewMarketOrder

Description

Open a new position at the current market price

Syntax

returnValue = Application.Run("EPF.IG.VBA.NewMarketOrder", epicCode, currencyCode, expiry, buySell, dealSize, stopDistance, limitDistance)

The EPF.IG.VBA.NewMarketOrder function has the following parameters:

Parameters
Parameter Description
epicCode The IG Index epic code eg: CS.D.EURUSD.TODAY.IP
currencyCode The currency denomination eg: USD, GBP or EUR
expiry The date (or sometimes time) a spreadbet or CFD will automatically close. Often for spreadbets this is "DFB" for a Daily Funded Bet or for CFDs which do not expire this is "-"
buySell Direction, either "BUY" for long or "SELL" for short
dealSize The deal size, eg: for a spreadbet at £1 a point this will be set to 1
stopDistance Stop distance from opening price, if no stop is required then this value should be 0
limitDistance Limit distance from opening price, if no limit is required then this value should be 0
Examples
1. Open a new position at current market price to BUY EURUSD at £1 per point with no stoploss or limit:

Dim returnValue As Variant

returnValue = Application.Run("EPF.IG.VBA.NewMarketOrder", "CS.D.EURUSD.TODAY.IP", "GBP", "DFB", "BUY", 1, 0, 0)



EPF.IG.VBA.NewWorkingOrder

Description

Open a new working order, either a limit or stop order. The order can be either "Good Till Cancelled" or "Good Till Date".

Syntax

returnValue = Application.Run("EPF.IG.VBA.NewWorkingOrder", epicCode, currencyCode, expiry, buySell, dealSize, priceLevel, orderType, timeInForce, goodTillDate, stopDistance, limitDistance)

The EPF.IG.VBA.NewWorkingOrder function has the following parameters:

Parameters
Parameter Description
epicCode The IG Index epic code eg: CS.D.EURUSD.TODAY.IP
currencyCode The currency denomination eg: USD, GBP or EUR
expiry The date (or sometimes time) a spreadbet or CFD will automatically close. Often for spreadbets this is "DFB" for a Daily Funded Bet or for CFDs which do not expire this is "-"
buySell Direction, either "BUY" for long or "SELL" for short
dealSize The deal size, eg: for a spreadbet at £1 a point this will be set to 1
priceLevel Price level for the order
orderType Order type, either "LIMIT" or "STOP"
timeInForce Time in force for the order, either "GOOD_TILL_CANCELLED" or "GOOD_TILL_DATE"
goodTillDate If timeInForce is set to "GOOD_TILL_DATE" then this value can be either a UTC date/time in this format: "yyyy/mm/dd hh:mm:ss" or a Unix Timestamp in milliseconds
stopDistance Stop distance from opening price, if no stop is required then this value should be 0
limitDistance Limit distance from opening price, if no limit is required then this value should be 0
Examples
1. Submit a working Limit order to SELL GBPUSD at £1 per point if the price goes above 1.3200 with no expiry date on the order (Good Till Cancelled) with no stoploss or limit:

Dim returnValue As Variant

returnValue = Application.Run("EPF.IG.VBA.NewWorkingOrder", "CS.D.GBPUSD.TODAY.IP", "GBP", "DFB", "SELL", 1, 13200, "LIMIT", "GOOD_TILL_CANCELLED", "", 0, 0)


2. Submit a working Stop order to BUY EURUSD at $1 per point if the price goes above 1.1500 with an expiry date on the order (Good Till Date) of 1 March 2018 8AM (UTC) with no stoploss or limit:

Dim returnValue As Variant

returnValue = Application.Run("EPF.IG.VBA.NewWorkingOrder", "CS.D.EURUSD.TODAY.IP", "USD", "DFB", "BUY", 1, 11500, "STOP", "GOOD_TILL_DATE", "2019/03/01 08:00:00", 0, 0)