Hi. Is there anyway to code or take in consideration the Brokers overnight interest rate in ProOrder?
I can see there is an estimated brokers fee, but that does not add overnight interests, only add a one time fee. Since IG actually charge what more or less would be 0.8 euro a night/position on DAX 1e mini, it kind of adds up. for example if you have 2 position open a week you will be charged around 11 euros of interests+ spread. that’s quite a lot,so it would be nice to have the possibility to code this with your strategy.
Cheers Kasper
EricParticipant
Master
and forex has this rule
“three day funding is charged on a wednesday”
So if you have overnight forex positions on a wednesday they charge you for 3 days?
There is a possibility to compute the interest rate. But you will not be able to have all the benefit of the Probacktest window result. You could make a new variable, graphed on chart with STRATEGYPROFIT minus the interest rate previously calculated. This is the first idea that come to mind 🙂
Hi Nicolas, and thanks for the idea, I will try and come up with something 🙂
could this be true?
on a 4H chart- given is 0.8 euro interest per Position per night on DAX 1euro mini.
it just took out 21% of pathfinder profit 🙁
FourHoursChart=5
once countofdays=0
if not onmarket then
countofdays=0
elsif onmarket and Intradaybarindex =FourHoursChart then
countofdays=countofdays+1
else
countofdays=countofdays
endif
graph strategyprofit-(countofdays*0.8*countofposition) COLOURED(0,0,255) AS "IGprofit"
graph countofdays COLOURED(0,0,0) AS "countofdays"
There is a problem with this code. I will return when I solved the issue
I think this is more correct. also it did not take 21% profit as first assumed. I can see around 6% of Pathfinder V6.0 DAX 4H. I Have added a screendump for verification.
Please comment on this.
ONCE BrokerProfit=0
FourHoursChart=5
once countofdays=0
if not onmarket then
countofdays=0
elsif onmarket and Intradaybarindex =FourHoursChart then
countofdays=countofdays+1
BrokerProfit=BrokerProfit+countofdays*0.8*countofposition
else
countofdays=countofdays
BrokerProfit=BrokerProfit
endif
trueEquity=Equity-BrokerProfit
graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
graph trueEquity COLOURED(0,0,255) AS "trueEquity"
graph countofdays COLOURED(0,0,0) AS "countofdays"
Sorry if I missed something but you never defined what is the ‘Equity’ variable?
6% fees of +500% of profit is nothing 🙂
Ahh of cause. And yes. 6% is nothing I agree on that:-)
I forgot the rest of the code. here it is
Capital = 10000
equity = Capital + StrategyProfit
ONCE BrokerProfit=0
FourHoursChart=5
once countofdays=0
if not onmarket then
countofdays=0
elsif onmarket and Intradaybarindex =FourHoursChart then
countofdays=countofdays+1
BrokerProfit=BrokerProfit+countofdays*0.8*countofposition
else
countofdays=countofdays
BrokerProfit=BrokerProfit
endif
trueEquity=Equity-BrokerProfit
graph BrokerProfit COLOURED(255,0,0) AS "BrokerProfit"
graph trueEquity COLOURED(0,0,255) AS "trueEquity"
graph countofdays COLOURED(0,0,0) AS "countofdays"
Thanks Kasper for this code snippet, fees are a major thing we too much often ignore and that can broke up a nice equity curve.
I’ll put this code into the blog for future references.
Hi Nicolas, yes that is a great idea to put it in the Blog section. I would have taken the task off your busy hands but I couldn’t create a blog. Perhaps it meant to be like this?
Cheers Kasper
Congratulations about your first blog post: https://www.prorealcode.com/blog/learning/overnight-fees-calculation-proorder-strategies/
Any other ideas are welcome, everyone can be published in the blog section of the website 🙂
I just did a little update to this code to make it work with all timeframes. I also added the 3x overnight fees on the weekend, that the previous code didnt have. Let me know if you see any issues with it, but it seem to work correct for me. I’m a noob at coding so there might be some issues! You need to update the time where overnight fee take action in your timezone. You also need to adjust posSize to your sizing.
// --- Parameters ---
Capital = 10000 // Initial capital of the account
overnightfee = 3.5 // Broker overnight fee per conract per day in money. 3.5 EURO 20240610 in Sweden with IG.
posSize = 1
OnlyCountWeekends = 0 // 0 = Count all overNightFees, 1 = Only Count Weekend OvernightFees
// --- Define Trading Day End ---
endOfDayTime = 230000
// --- Equity and Broker Profit Calculation ---
equity = Capital + StrategyProfit
ONCE BrokerProfit = 0
ONCE totalOvernights = 0
ONCE countOfDays = 0
if not onmarket then
countOfDays = 0
elsif onmarket and time >= endOfDayTime then
// Increment countOfDays only if this is the first time during the day
if OnlyCountWeekends = 0 and time = endOfDayTime and currentDayOfWeek <> 5 then
countOfDays = countOfDays + 1
totalOvernights = totalOvernights + 1
elsif time = endOfDayTime and currentDayOfWeek = 5 then
countOfDays = countOfDays + 3
totalOvernights = totalOvernights + 3
endif
endif
BrokerProfit = totalOvernights * overnightfee * posSize
trueEquity = Capital + StrategyProfit - BrokerProfit
// --- Graph Plotting ---
graph BrokerProfit coloured(255,0,0) as "Broker Profit"
graph trueEquity coloured(0,0,255) as "True Equity"
graph totalOvernights coloured(0,0,0) as "Total Overnights"
How do I use this code snippet? I compare the trueEquity number, with the strategy profit if I add an exit at 224500, to avoid overnight fees (either all overnight fees or only close positions before the weekend). For example:
//Time Exit
//If currentDayOfWeek = 5 and time=224500 then //or use next row
If time=224500 then
sell at market
exitshort at market
endif
Maybe this helps someone! Please let me know if you find any issues or have any improvements to the code.