how to hard code initial capital
Forums › ProRealTime English forum › ProOrder support › how to hard code initial capital
- This topic has 6 replies, 4 voices, and was last updated 3 months ago by robertogozzi.
Tagged: allocate, allocation, capital, loss, Money, quit, strategyprofit, treshold
-
-
08/21/2024 at 10:00 AM #236561
Good morning to the PRT community!
Can anyone help me with hard coding the initial capital that is to be allocated to a trading system?
I assume one has to do this if they plan to use a % based profit target or stop loss, other wise a specified % will be based on the total capital. Is this correct?
It would also be interesting to experiment with a trailing % based stop loss, but maybe that is for another topic.
Best regards
J
08/21/2024 at 10:07 AM #236562The percentages of stop loss, take profit and trailing refer to the underlying value, i.e. the index such as DAX, NASDAQ etc.
1 user thanked author for this post.
08/21/2024 at 11:36 AM #236566Hi,
Stop loss, take profit and trailing are all calculated from the (average) position price…
Simple example:
Initial capital = 10,000 euros
Risk 1% (of the initial capital) =100 euros
(Index point value=1, number of contracts=1)
SL=100 (1% of initial capital)
Set Stop pLoss SL
Or in percentages:
SL=Risk/PositionPrice*100
Set Stop %Loss SL
If you want to make use of your total equity:
Equity=Capital + StrategyProfit
Risk 1% (of the Equity) = (Capital + StrategyProfit) * 1/100
Etc…
2 users thanked author for this post.
08/21/2024 at 11:39 AM #236567You can’t allocate different slices of your Capital among strategies, as they are unaware of each other.
You need to manage that allocation within your code.
In this example I assume this strategy has an initial Capital allocated of 10K euros (or whatever currency unit it is), no matter if your account has more, and I have set a 10% treshold, so that when my loss reaches that treshold, my strategy is stopped with QUIT:
1234567891011121314151617ONCE myCapital = 10000ONCE myTreshold = myCapital * 0.9 //Exit when only 10% of my initial Capital is leftIF StrategyProfit <= -myTreshold THENQUITENDIFSma10 = average[20,0](close)Xup = close CROSSES OVER Sma10Xdn = close CROSSES UNDER Sma10IF Not OnMarket THENIF Xup THENBUY 1 CONTRACT AT MARKETELSIF Xdn THENSELLSHORT 1 CONTRACT AT MARKETENDIFSET STOP pLOSS 100SET TARGET pPROFIT 200ENDIFit’s just the first 5 lines that you need to use at the beginning of your code.
1 user thanked author for this post.
08/21/2024 at 11:39 AM #236568As I always say “two is better than none!” 🙂
2 users thanked author for this post.
08/21/2024 at 9:57 PM #23659108/21/2024 at 10:25 PM #236592 -
AuthorPosts
Find exclusive trading pro-tools on