Position size variable to calculate £ per point
Forums › ProRealTime English forum › ProOrder support › Position size variable to calculate £ per point
- This topic has 5 replies, 3 voices, and was last updated 4 years ago by LG Mcgavin.
-
-
03/23/2020 at 6:59 PM #123041123456789101112Equity=10000Risk=0.01//Position sizePositionsize= round(Equity*Risk)/SL //** SL should be the number of pips i.e the variable based on the entry price and stop to calculate the £ per pip based on the equity and risk. **** //appreciate any thoughts on this.///Stop LossHH = Highest [5] (high)+2SL = HH - TradePrice ////Returns the number of pips between entry price and Higher High to set stoploss at prev highIf ShortOnMarket thenSet stop ploss SL ///stop loss set at prev high based on SLendif
Hi all, I am very new to PRT coding. I am struggling with the ‘position size’. This is based on the equity of 10,000 and risk of 0.01, giving the max risk per trade. The variable is the number of pips between the entry pice and the stop.
I would like to divide the max risk per trade by the variable to calculate the £’s per point .
However the formula i have written PRT does not seem to be returning a variable for the position size.Positionsize= round(Equity*Risk)/SL
Appreciate any thoughts on this. Thank you and please find code attached.
03/23/2020 at 9:53 PM #123056LG Mcgavin – Welcome to the forums. Your topic is strategy related and not indicator related so you posted it in the wrong forum. I have moved it to the ProOrder forum. Please try to post in the correct forum with any future topics.
03/24/2020 at 8:53 AM #123097Hi Vonasi,
Thank you and my apologies.
03/24/2020 at 11:50 AM #123123You can’t use TRADEPRICE in a calculation for position size. TRADEPRICE returns the price of the last trade whether that is opening a position or closing a position. You can’t know an opening price until you actually have opened a position. You should use CLOSE to calculate your position size and hope that there is not a massive gap to the open of the next candle when your order will actually be filled and then TRADEPRICE updated.
Also in your code you calculate using SL before SL has a value so on the first run through the code you are dividing by zero.
1 user thanked author for this post.
03/24/2020 at 4:01 PM #123155I wrote the code below a couple of years ago based on a Van Tharp blog, I had it in a number of my strategies but I no longer use it, hopefully someone can make use of it. I extended it to do prices in .25 increments, no idea what the constant TF does it came from the original.
12345678910111213141516171819202122232425262728293031323334equity = 10000+STRATEGYPROFITrisk=0.025TF=4//if OpenDayofWeek = 0 then//OkToTrade = 0elsif OpenDayofWeek = 1 then // MondayDailyRange=max(abs(Dhigh(2)-Dlow(2)),max(abs(Dhigh(2)-Dclose(3)),abs(Dlow(2)-Dclose(3))))elsif OpenDayofWeek = 2 then // TuesdayDailyRange=max(abs(Dhigh(1)-Dlow(1)),max(abs(Dhigh(1)-Dclose(3)),abs(Dlow(1)-Dclose(3))))elseDailyRange=max(abs(Dhigh(1)-Dlow(1)),max(abs(Dhigh(1)-Dclose(2)),abs(Dlow(1)-Dclose(2))))endifDailyRange=max(abs(Dhigh(0)-Dlow(0)),DailyRange)DailyATR=wilderaverage[20*TF](DailyRange)a = (equity*risk)/(DailyATR)t = a * 100x = 0// .25 decimal position sizesincrementsize = 25while x < t dox = x + incrementsizeif x > t thenif x - t > incrementsize/2 thenx = x - incrementsizeendifPositionSize = (x/100)breakendifwendMaxStopValue = round(equity*risk)2 users thanked author for this post.
03/25/2020 at 9:46 AM #123230Thank you Vonasi that explains why PRT is not returning a value. Auto Strategist thank you for the code above to reference. Cheers!
-
AuthorPosts
Find exclusive trading pro-tools on