Profile Picture

Trading Using Margin

Posted By mathewjames 5 Years Ago
Posted Sunday May 29 2016
Hi everyone, first off I apologies if this is a dumb question and it's something simple I am missing but I am needing some help with creating a trading system for back-testing when the account parameters involve trading on margin. Just to give a bit of background I am trying to implement a back-test solution for back-testing different ideas in either a Spread Betting (for the UK) account or CFD account.

To keep things simple for now I am just focusing on Stocks. Each Stock can have a different %age margin required for making a purchase.

If my Account Value is $2000 and I want to buy 200 shares of a Stock trading at $10, this would usually take up my entire Account Value of $2000. If I am able to trade this Stock through my broker with a 10% margin I only need to use $200 from my Account Value (though I understand my exposure is still $2000), leaving me with $1800 to open up other trades if I so wished.

How do I configure a trading system in RE in such a way that when my system opens a position it will only use up n% (in this example, 10%) of my Account Value.

Posted Saturday June 04 2016
Hi MathewJames,

I have a trading system that uses CFDs on futures. I add the watchlist instruments using "Future" asset type. In the 'Symbol Information' window I put 'Contract Size' as 1, and initial margin as 0.1 ( 10% margin). If short margin is the same as long margin, you can put 100% in the short margin field.

The hard part with CFDs is modelling the costs. In the case of stock CFDs you have a daily funding charge and a bid/ask spread. The daily funding cost can grow very large if you trade longer term. Expiring CFDs based on futures contracts are cheaper, without daily funding charge.
Posted Friday August 11 2017
Hi Cardan,
I have the same problem as MathewJames. i.e. i'm trying to configure RE for CFD Trading. I have looked st your recommendation. The issue i have is that, based on my testing, the margin field (called Initial Margin) works as a absolute value (i'm using RE 2010 Build 57) rather as a percentage as you seem to indicate in your response. My CFD broker apply margin as a percentage of notional. Any idea on how to go around this issue?

Many thanks in advance


RE_margin_for_CFD.png (424 views, 107.00 KB)
Posted Friday August 11 2017
Hi Lam,

Yes, I was wrong in my answer, thanks for pointing it out, to avoid confusion. The initial margin field is absolute value. I tried later to set the margin as % but was not able to. At the end it didn't matter for my system as my real overall portfolio margin is typically 8-15% (Trend following system).

Maybe dplaisted can help us out on this one?

Carlos Mata
Posted Monday August 14 2017
Hi Carlos,
I'm also building a Trend Following system on CFDs. If you don't mind, i have a couple of quick questions for you.
1. Are you just using RE for backtesting or are you using RE for live trading too?
2. What is your experience? are the CFD interest charges not eating away must of your profit?
3. May i know which CFD broker you use? so, i'm looking at OANDA.
Thanks and cheers,

Posted Saturday August 19 2017
Hey Lampalork,

1) I don´t connect RightEdge to my broker. I make RightEdge write the equity curve, positions and orders (RightEdge´s Scan section in the results) to a database. Then I use a batch command that kicks off with Windws task scheduler every 8 hours. The system ultimately sends me an email to tell me what to do and I manage my orders and positions manually. The batch command does this:
     a) Get futures data from CSI data. Save from CSI CSVs to SQL Server database
     b) Get currency conversion rates from Quandl and save to SQL database
     c) Refresh the data in my RightEdge watchlist from SQL Server using a Right Edge plugin
     d) Run RightEdge full backtest. RightEdge saves results automatically to database
     e) Send HTML email with today´s orders, last 5 closed positions and current positions
     (I manage all my systems using these emails... It makes it easy to trace and gives me peace of mind... but that´s just me.. everyone is different)

2) I don´t use cash-based CFDs for long term systems. I run only futures-based CFDs from Saxo Bank. These don´t charge overnight interest on the nominal value. They did start charging interest in July for the margin collateral in futures and CFDs.. which pissed me off, but it´s still significantly better than being charged interest for the full notional value. Depending on your account size, you can add some futures in your portfolio. I run my strategy in two brokers. Interactive Brokers for futures, and Saxo for CFDs and a couple of futures not available in IB. I also have a few cash instruments and looking forward to also add crypto currencies to my portfolio.

3) Answered above

Another note: If you do standard trend following without cash instruments, then it doesn´t matter that your estimate of margin from RightEdge is a bit wrong... Your margin use will  be very low (mine is less than 10-15%. My system is mostly cash) and you are far away from a margin call, so no problem. There is also no historical data available on margin requirements I think, so backtest would be invariably wrong on margin estimates.

I learned most of the stuff above from Andreas Clenow and his website . Andreas, if you see this... many thanks!!
Posted Sunday August 20 2017
Hi Carlos,

Thank you very much for these very valuable information. I have read the 2 books of Andreas Cleanow which got me started an i have also spent some time on I have an interactive broker account but I'm looking at first starting a trend following system with only 50K usd (start small to see how it goes); so based on my initial estimates - if i want to be really diversified and not take too much risk - futures are out of my league because of the large size of many futures. But futures CFDs of Saxo might be a good alternative. I'll have to assess this. 
Again, thanks s lot for all this info. Really appreciate.
Posted Thursday November 23 2017
The most terrible of traders’ nightmares is a margin call.

So what is a margin call? Well, it is a broker’s demand to you as a client to bring margin deposits up to the initial margin level in order to keep holding current positions open. The margin call most frequently happens with a move to close your positions.

Technically, it is important to keep the value of the account higher than the maintenance margin level, otherwise your positions will simply be closed and this will result in a loss for you. Sometimes giving up on your trade and facing a loss is the right thing to do, but if your vision is different – you can avoid a margin call by adding more funds to your trading account.

Unfortunately, many brokers can issue the margin call without informing you about their intentions. Thus, they automatically close the respective trade(s).
Posted Thursday June 14 2018
I am forex market investor and would appreciate your discussion and learned a lot of from your post. Is writing essays your favourite activity? Then has a great deal for you. Becoming an online essay writer has never been so easy before!  Just visit our website and find all the job opportunities available.

Similar Topics

Reading This Topic

2005-2021 © RightEdge Systems