Discover margin for each trade?
Forums › ProRealTime English forum › ProRealTime platform support › Discover margin for each trade?
- This topic has 4 replies, 2 voices, and was last updated 6 years ago by Vonasi.
-
-
08/24/2018 at 10:17 AM #78918
How can I know what margin is needed before I confirm a trade on ProRealTime?
08/24/2018 at 10:32 AM #78921It is not possible to know this directly in PRT.
IG provide a good description of how to calculate your margin:
https://www.ig.com/uk/learn-to-trade/margin-explained
Although they do not mention there how margin is effected by having stops with your trade.
It should be quite easy to create a simple indicator that calculates your required initial margin and even one that shows your initial margin and maintenance margin as a graph in a back test – I may have a go at doing this later if I find time.
1 user thanked author for this post.
08/24/2018 at 12:06 PM #78927I wrote this indicator that will display current initial margin requirements to open positions with no stop, a non guaranteed stop and a guaranteed stop:
12345678910111213141516171819202122DEFPARAM calculateonlastbars = 1Size = 1 //Your Trade SizeMarginFactor = 5 //Margin Factor in %SlippageFactor = 50 //Slippage Factor in %StopDistance = 100 //Stop Distance in pipsLimitedRiskPremium = 1 //Limited Risk PremiumNoStopMargin =(Size * close) * (MarginFactor / 100)NoStopMargin = Round(NoStopMargin * 100) / 100StopMargin = (Min((NoStopMargin * (Slippagefactor / 100)) + (Size * StopDistance),NoStopMargin))StopMargin = Round(StopMargin * 100) / 100GStopMargin = (Size * StopDistance) + (Size * LimitedRiskPremium)GStopMargin = Round(GStopMargin * 100) / 100DRAWTEXT("No Stop Margin #nostopmargin#",barindex,0,SansSerif,Bold,16)coloured(0,0,255)DRAWTEXT("Stop Margin #stopmargin#",barindex,-0.5,SansSerif,Bold,16)coloured(0,0,255)DRAWTEXT("Guaranteed Stop Margin #gstopmargin#",barindex,-1,SansSerif,Bold,16)coloured(0,0,255)return 0.5,-1.5The calculations are taken from IG’s information on the charts on their platform.
You will need to put in the correct values for each of the factors involved in the calculation for whichever instrument you apply it to.
I have not found any information yet saying what the values for the Limited Risk Premium used in the guaranteed stops calculation are and IG do not list it in the chart information.
ITF file also attached.
3 users thanked author for this post.
08/24/2018 at 1:50 PM #78942Here is another version. You can enter your buy or sell price of a trade that you have open and your stop price and it will calculate a running margin taking into account any gains or losses (the maintenance margin).
1234567891011121314151617181920212223242526272829303132333435DEFPARAM CalculateOnLastBars = 1BuySell = 1 // 1 = Buy 0 = SellPrice = 25720 // The Price you bought or sold atSize = 1 //Quantity bought or soldStopType = 1 //1 = No Stop 2 = Non G Stop 3 = G StopMarginFactor = 5 //Margin Factor in %SlippageFactor = 50 //Slippage Factor in %StopPrice = 25800 //Stop PriceLimitedRiskPremium = 1 //Limited Risk PremiumNoStopMargin =(Size * close) * (MarginFactor / 100)InitialMargin = Round(NoStopMargin * 100) / 100If StopType = 2 thenStopMargin = (Min((NoStopMargin * (Slippagefactor / 100)) + (Size * (ABS(close - StopPrice))),NoStopMargin))InitialMargin = Round(StopMargin * 100) / 100endifIf StopType = 3 thenGStopMargin = (Size * (ABS(close - StopPrice))) + (Size * LimitedRiskPremium)InitialMargin = Round(GStopMargin * 100) / 100endifIf BuySell <> 1 thenMaintenanceMargin = (Size * Price) - (Size * close)elseMaintenanceMargin = (Size * close) - (Size * Price)endifTotalMargin = InitialMargin + MaintenanceMarginDRAWTEXT("Total Running Margin #totalmargin#",barindex,0,SansSerif,Bold,16)coloured(0,0,255)return 0.5, -0.51 user thanked author for this post.
08/24/2018 at 3:30 PM #78970I wrote this snippet that can be added to long only strategies with no stops to graph the maximum margin required in a back test. It could be adapted to short and with stops using the calculations in the indicators but I will let someone else do that as I would never use it!
1234567891011121314MarginFactor = 5 //Margin Factor in %NoStopMargin = (CountOfPosition * low) * (MarginFactor / 100)InitialMargin = Round(NoStopMargin * 100) / 100MaintenanceMargin = (CountOfPosition * PositionPrice) - (CountOfPosition * low)TotalMargin = 0 - (InitialMargin + MaintenanceMargin)if not onmarket or TotalMargin > 0 thenTotalMargin = 0endifGraph TotalMarginI think it works correctly but if any one spots a bug or error in it or any of the other codes here then please correct them as none of them have really been tested properly.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on