This ProBuilder code snippet demonstrates how to manage trading positions based on specific time conditions to avoid overnight fees. The strategy involves exiting positions just before the daily fee calculation time and re-entering them after the fee time has passed.
DEFPARAM CumulateOrders = False
myLongCond = average[10,0](close) CROSSES OVER average[100,0](close)
myShortCond = average[10,0](close) CROSSES UNDER average[100,0](close)
IF myLongCond THEN
BUY 2 CONTRACTS AT MARKET
ELSIF myShortCond THEN
SELLSHORT 3 CONTRACTS AT MARKET
ENDIF
SET STOP pLOSS 100
SET TARGET pPROFIT 200
ONCE Skipped = 0
IF ((OpenTime > 230000) OR (OpenTime > 0 AND OpenDay <> myDay)) AND Skipped THEN
IF Skipped = 1 THEN
BUY myLots CONTRACTS AT MARKET
ELSIF Skipped = -1 THEN
SELLSHORT myLots CONTRACTS AT MARKET
ENDIF
Skipped = 0
ENDIF
IF OpenTime = 225500 THEN
myLots = abs(CountOfPosition)
myDay = OpenDay
Skipped = Longonmarket + ShortOnMarket*-1
IF Skipped THEN
SELL AT MARKET
EXITSHORT AT MARKET
ENDIF
ENDIF
//graph Skipped
This code snippet includes several key components:
This approach helps in managing trading costs by avoiding overnight fees, which can significantly impact profitability especially in high-frequency trading scenarios.
Check out this related content for more information:
https://www.prorealcode.com/topic/avoiding-cfd-financing-costs-overnight-positions/#post-229848
Visit Link