Strategyprofit on fixed tp
Forums › ProRealTime English forum › ProOrder support › Strategyprofit on fixed tp
- This topic has 31 replies, 4 voices, and was last updated 1 year ago by JohnScher.
-
-
02/23/2023 at 4:45 PM #210307
How can 1.5% TP be reached if the trade was lost?
For the next trade to come.
Then it must be applied toWINNING trades, AFTER a losing one?
02/26/2023 at 1:26 PM #210524How can I explain it what should be coded.
If I lose 1 trade, then the position size should be calculated, which leads to the capital growing by 1% when the take profit of the trade is reached.
Example
Capital = 100%
1.trade ordersize = 1
Trade won, capital = 100.2%
set capital 100.2% to capital 100%Capital = 100%
2nd Trade Ordersize = 1
2.trade won, capital = 100.7%
set capital 100.7% to capital 100%capital = 100%
3rd Trade Ordersize = 1
3. trade lost, capital = 99.2%capital 99.2%
4th trade calculate order size for the 4th trade so that when the take profit of the trade (1.5%) is reached, the capital rises to 101%.
4th trade lost, capital = 88.9%capital 88.9%
5th trade calculate order size for the 5th trade so that when the TakeProfit of the trade (1.5%) is reached, the capital rises to 101%.
5th trade won, but capital only 99.1%capital 99.1%
6th trade calculate order size for the 6th trade so that when the TakeProfit of the trade (1.5%) is reached, the capital rises to 101%.
6th trade won, capital 100.4%
set capital 100.4% = 100%capital = 100%
7.Trade Ordersize = 1
……general:
as long as capital > capital [1] should capital = 100%
as long as capital < last 100% order size is to be calculated in such a way that with this order size and with reaching the TakeProfit of the trade here = 1.5% the capital rises on 101%.Translated with http://www.DeepL.com/Translator (free version)
02/26/2023 at 1:34 PM #210525correction
general:
as long as capital > last 100% should capital = 100%
as long as capital < last 100% order size is to be calculated in such a way that with this order size and with reaching the TakeProfit of the trade here = 1.5% the capital rises on 101%.02/26/2023 at 1:53 PM #210527Then it must be applied toWINNING trades, AFTER a losing one?
No … BUT, John by now made it clear. I suppose it is clear to you too now, Roberto ?
It is the goal to always trade as much in order to get back to a set level (this is the 101% for John).Maybe superfluously :
set capital 100.4% = 100%
This is now the new base line, as if the Trading System just started. Thus, we act as if we made no profit by resetting all to zero (meanwhile having that 1% in the pocket).
For John : John, IMHO this is nothing for someone who is not involved really apart from finding it great to help others (Roberto) to solve until the end (when it works). This is because it will require numerous if not infinite re-iterations, you (John) always finding new culprits to solve (Roberto always helping).
In your Martingale-like idea this will be very soon about more protective means, because your backtest will show more and more loss because that is the way it’s setup (please trust me). So my biggest tip I can give you is : First make a strategy which is winning (and recognize that your idea is about Money Management and nothing more) and then apply this system, which is difficult to do yourself (coding stuff and such).
So … Roberto may come up with something which does what you want. Next it goes way under – which is upon something which is a Strategy (unvisible to us) – which next must be turned into something winning or else it is only extra losing.
Edit : I did not read the “correction” post from John, at composing my previous post.
02/27/2023 at 10:34 AM #210585I came up with this code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344//-------------------------------------------------------// late noon trade// instrument dax40// timezone europe, berlin// timeframe 30m// created and coded by JohnScher//-------------------------------------------------------defparam cumulateorders = falsedefparam flatafter = 213000once Capital = 10000once Equity = Capitalonce BaseEquity = Equityonce CapitalInc = Equity / 200 //0.5% increaseonce ordersize = 1once LotSize = ordersizetd = opendayofweek >= 1 and opendayofweek <= 6tt = time = 133000 //AND time <= 17000013c = close > exponentialaverage[6](close)IF (StrategyProfit <> StrategyProfit[1]) AND IsLastBarUpdate THENmyProfit = StrategyProfit - StrategyProfit[1]TempEquity = BaseEquity * 1.01 //101%Temp = 1 - ((TempEquity - StrategyProfit) / TempEquity)LotSize = ordersize + (ordersize * Temp)IF myProfit > 0 THEN// when Equity exceeds the previous one, reset it to 100%IF (StrategyProfit + Capital) >= BaseEquity THENBaseEquity = StrategyProfit + CapitalLotSize = ordersizeENDIFENDIFENDIFif td and tt and c AND not OnMarket thenbuy max(ordersize,LotSize) contracts at marketEndifset target %profit 1.5set stop %loss 0.5//graph Temp//graph BaseEquitylet me know whether I understood your request correctly, or not.
1 user thanked author for this post.
02/28/2023 at 10:55 PM #210686Hello Roberto-
A big thank you for being on the road for me again and doing work.
It looks quite excellent, but it seems to me to be a bug that I can’t program away. But we are already very close to the solution.With lines 28-33 we at myProfit set > 0 the equity to 100%. Clear.
But we also need to check whether myProfit >0 and the new capital exceeds 100%. We must not set the capital to 100% after each trade won, but only when we have won the trade and the last reached 100% are exceeded!
I think I have caught all imaginable combinations with the following example.
Example
Capital = 100%
1st trade ordersize = 1
Trade won, capital = 100.2%
set capital 100.2% to newCapital 100%newCapital = 100%
2nd Trade Ordersize = 1
2.trade won, capital = 100.7%
set capital 100.7% to newCapital 100%newCapital = 100%
3rd Trade Ordersize = 1
3. trade lost, capital = 99.2%
// do not set to 100%newCapital 99.2%
4th trade calculate order size for the 4th trade so that when the take profit of the trade (1.5%) is reached, the capital rises to 101%.
4th trade lost, capital = 88.9%
// do not set to 100%newCapital 88.9%
5th trade calculate order size for the 5th trade so that when the TakeProfit of the trade (1.5%) is reached, the capital rises to 101%.
5th trade won, but capital only 99.1%
// do not set to 100%newCapital 99.1%
6th trade calculate order size for the 6th trade so that when the TakeProfit of the trade (1.5%) is reached, the capital rises to 101%.
6th trade won, capital 100.4%
set capital 100.4% to newCapital = 100%newCapital = 100%
7th Trade Ordersize = 1
7th trade lost, capital = 99.5%newCapital 99.5%
8th trade calculate order size for the 8th trade so that when the TakeProfit of the trade (1.5%) is reached, the capital rises to 101%.
8th trade won, TakeProfit is reached, capital now 101%
set capital 101% to newCapital = 100%newCapital = 100%
9th Trade Ordersize = 1
….03/03/2023 at 11:00 AM #210839This version seems to be working fine, let me know if some glitches are still left:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162//-------------------------------------------------------// late noon trade// instrument dax40// timezone europe, berlin// timeframe 30m// created and coded by JohnScher//-------------------------------------------------------defparam cumulateorders = falsedefparam flatafter = 213000once Capital = 10000once Equity = Capitalonce BaseEquity = Equityonce TempEquity = BaseEquityonce CapitalInc = Equity / 200 //0.5% increaseonce ordersize = 1once LotSize = ordersizetd = opendayofweek >= 1 and opendayofweek <= 6tt = time = 133000 //AND time <= 17000013c = close > exponentialaverage[6](close)IF (StrategyProfit <> StrategyProfit[1]) AND IsLastBarUpdate THENmyProfit = StrategyProfit - StrategyProfit[1]IF myProfit > 0 THENTP = 1// when Equity exceeds the previous one, reset it to 100%IF (StrategyProfit + Capital) >= BaseEquity THENBaseEquity = StrategyProfit + CapitalLotSize = ordersizeENDIFELSIF MyProfit < 0 THENTP = 0ENDIFENDIFif td and tt and c AND not OnMarket thenIF TP = 0 THENTempEquity = BaseEquity * 1.01 //101%TP = close * 1.015 //+1.5%Temp = TempEquity / ((StrategyProfit + Capital + abs(close - TP)))IF Temp > 0 THENLotSize = ordersize * TempELSELotSize = ordersizeENDIFENDIFbuy max(ordersize,LotSize) contracts at marketEndifset target %profit 1.5set stop %loss 0.5//graph Temp//graph MyProfit//graph BaseEquity//graph LotSize//graph StrategyProfit + Capital//graph TempEquity//graph TP//graph close - TP1 user thanked author for this post.
03/04/2023 at 6:13 PM #210898Hello Roberto.
Thank you for your work. Your code unfortunately does not work yet in the sense I wanted. It is hard for me to express correctly and for you it is guaranteed not easy to understand me. Therefore I ask you, that we create the code piece by piece. Maybe the other one from here can help too.
The task is: We code a money management system for a trading system that works with time stop.
We first hide everything else. We only want to calculate the position size needed to increase the initial capital in 1% when the trade reaches the TakeProfit of 1.5%.
Can you code this or is someone else from here trying first.
(It has time, Rome was not built in a day either. Maybe weekend to weekend. I look in once every 2nd,3rd day).)123456789101112131415161718192021// late lunch trade with money management systemdefparam cumulateorders = falsedefparam flatafter = 213000once Capital = 10000once OrderSize = 1once LotSize = ordersizetd = opendayofweek >= 1 and opendayofweek <= 5tt = time = 133000c = close > exponentialaverage[6](close)lotsize = ??? // that´s the questionIf td and tt and c thenbuy lotsize at marketendifset target %profit 1.503/04/2023 at 6:41 PM #210900Ok, there you go:
1234567891011121314151617181920212223242526// late lunch trade with money management systemdefparam cumulateorders = falsedefparam flatafter = 213000once Capital = 10000once Equity = Capitalonce OrderSize = 1once LotSize = ordersizetd = opendayofweek >= 1 and opendayofweek <= 5tt = time = 133000c = close > exponentialaverage[6](close)IF StrategyProfit > StrategyProfit[1] THENEquity = Equity * 1.01LotSize = Equity / CapitalENDIFIf td and tt and c thenbuy lotsize contract at marketendifset target %profit 1.5//graph lotsize1 user thanked author for this post.
03/05/2023 at 5:30 PM #210937Hello Roberto.
You did it in seconds! Thank you very much!But it is not what you are looking for! Line 15 comes too early!
We do not check yet whether the StrategyProfit > StrategyProfit[1] is! !!No, we want to calculate only first the position size, which is needed to increase the Capital by 1%, if the TakeProfit of the trade of 1.5% is reached.
It is (first) (completely) irrelevant whether StrategyProfit>StrategyProfit[1] is.I am very sorry that we have misunderstood each other so far.
03/05/2023 at 6:40 PM #210941StrategyProfit > StrategyProfit[1] just tells us when 1.5% is reached.
There’s only 1,5% target profit, why should any profit be less than that?
1 user thanked author for this post.
03/05/2023 at 8:42 PM #21094303/05/2023 at 9:29 PM #210945We work with a time stop, the TakeProfit is not always necessarily reached. Therefore, we would like to develop a money management system that allows us to continuously increase our capital.
Step 1
For a first trade we calculate the position size so that when the trade reaches the TakeProfit of 1.5% our capital increases by 1%.Step 2
After this first trade we check if the capital is bigger than the 100% we started with or if the capital has become smaller.Step 3 if after the first trade the capital is > capital [1].
We set the (now new, bigger) capital = 100% capital and calculate the position size for increase of this (new 100%) capital by 1% as in step 1.
We do this again and again as long as after a trade the newcapital > newcapital [1].
So as long as NewCapital>NewCapital[1], we set NewCapital= 100% Capital after each trade and start with step 1.Step 3 for the case that after the first trade the capital is < capital[1].
Now it becomes complicated.
Let’s calculate the position size so that with the next trade when we reach the TakeProfit of the trade 1.5% the capital[1] (!!!) increases by 1%.
And
We do this again and again until at some point the nth capital is > the last 100% capital[1].
Then we set this NewCapital[n] = 100% capital and start step 1.Clear?
Question?Can you programm it?
03/05/2023 at 9:53 PM #21095403/05/2023 at 10:00 PM #210956 -
AuthorPosts
Find exclusive trading pro-tools on