replacing TP with partial close
Forums › ProRealTime English forum › ProOrder support › replacing TP with partial close
- This topic has 7 replies, 5 voices, and was last updated 2 years ago by robertogozzi.
-
-
03/06/2022 at 8:56 PM #189457
So I’m thinking of a way to use a 3 stage partial close instead of a single profit target. This is what I have in mind:
- Run the TARGET %PROFIT as usual, let’s say it returns a value of 2.5
- Disable TP
- From an initial position size of 10, use partial close to sell 3 contracts at 2%, 5 at 2.5% and 2 at 2.7 % (or something like that)
This is the code I had intended to use:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546//partialcloseONCE partialclose = 1ONCE PerCent = pc //0.3 = 30% positions to closeONCE PerCent2 = pc2 //0.5 = 50% positions to closeONCE PerCent3 = pc3 //0.2 = 20% positions to closeONCE PerCentGain = pcg //.02 = 2% increaseONCE PerCentGain2 = pcg2 //.025 = 2.5% increaseONCE PerCentGain3 = pcg3 //.027 = 2.7% increaseONCE MinLotSize = 0.5 //0.5 lots minimumExitQuantity = abs(CountOfPosition) * PerCentLeftQty = max(MinLotSize,abs(CountOfPosition) - ExitQuantity)CloseQuantity = abs(CountOfPosition) - LeftQtyExitQuantity2 = abs(CountOfPosition) * PerCent2LeftQty2 = max(MinLotSize,abs(CountOfPosition) - ExitQuantity2)CloseQuantity2 = abs(CountOfPosition) - LeftQty2ExitQuantity3 = abs(CountOfPosition) * PerCent3LeftQty3 = max(MinLotSize,abs(CountOfPosition) - ExitQuantity3)CloseQuantity3 = abs(CountOfPosition) - LeftQty3IF Not OnMarket THENFlag = 1Flag2 = 1Flag3 = 1ENDIFIF partialclose AND LongOnMarket and close >= (PositionPrice * (1 + PerCentGain)) AND Flag THENSELL CloseQuantity Contracts AT MarketFlag = 0endifIF partialclose AND LongOnMarket and close >= (PositionPrice * (1 + PerCentGain2)) AND Flag2 THENsell CloseQuantity2 Contracts AT MarketFlag2 = 0endifIF partialclose AND LongOnMarket and close >= (PositionPrice * (1 + PerCentGain3)) AND Flag3 THENsell CloseQuantity3 Contracts AT MarketFlag3 = 0endifThis is a variation of a code I have used in the past but it doesn’t work in the way I want it to; optimization of the variables shows no change.
I realise there’s a problem using abs(CountOfPosition) as it’s not going to give me the original intended disposals of 3, 5, 2 as the CountOfPosition will change with each sale.
But presumably there is some bigger problem here as well that I don’t get? Or maybe a better method entirely?
Most grateful for any help 🤔🤔🤔
03/07/2022 at 2:09 AM #189459Can’t you describe what your issue is (apart from it not doing what you want it to) ?
I am not saying that I will have the solution, but I do know that I attempted similar which did not work out (the reason of why could help you).The main culprit will be the feature set of PRT which does not support this really.
You are not saying it, but I would agree with that this comes down to “an approach”; Some stupid theoretical thinking which could help. … I really attempted many of those and only after implementation (a lot of work) I could reason why the idea s*cked in the first place.
03/07/2022 at 10:20 AM #189472Try to graph the condition:
1GRAPH partialclose AND LongOnMarket and close >= (PositionPrice * (1 + PerCentGain)) AND Flagto know when it happens and if the partial closure is working correctly on the same candle.
1 user thanked author for this post.
03/07/2022 at 10:45 AM #189479Thanks Peter, I dont really have an issue as such, just an intuition that there ‘might’ be an advantage to treating profit target as a general area where it’s a good idea to start getting out … as opposed to a single price.
Maybe there’s no advantage at all, maybe it just averages out to the same result. But obviously most trades do not reach the target. Some will almost get there, then fall back all the way to the trail.
I’m hoping that this method might catch a bit more of the MFE
Then, maybe the inverse could be used in place of SL ?? gradually easing out of a position, instead of focussing your exit on one spot.
It’s just an idea I’d like to test, but the code is not cooperating and I don’t see why ???
03/07/2022 at 12:30 PM #189503mystery solved – aint nuthin wrong with the code, only my tired brain had a decimal in the wrong place (*groan*)
but just for the record, initial tests look as if it can actually yield a better result – worth exploring further…
1 user thanked author for this post.
06/04/2022 at 8:40 PM #194648This hybrid form of exit seems to yield better results
Can you help with code on how do I use the same concept to exit :
50% with 1:1 RRR
25% with 1:2 RRR
and the rest 25% wit 1:3 RRR
Thanks in advance
06/05/2022 at 4:30 AM #194657https://www.prorealcode.com/topic/help-please-to-code-a-one-shot-trading-system/
Notice that your 50, 25, 25 is the same as 50%, 50% of the remainder, plus the rest.
06/05/2022 at 12:15 PM #194694Try this one (I made a few tests on DAX, 1h TF:
1234567891011121314151617181920212223242526272829303132333435363738/*50% with 1:1 RRR25% with 1:2 RRRand the rest 25% wit 1:3 RRR*/ONCE SL = 200 * PipSizeONCE LotSize = 4ONCE TP1size = LotSize / 2ONCE TP2size = TP1size / 2Sma200 = average[200,0](close)MyLongConditions = close CROSSES OVER Sma200 AND Not OnMarketIF MyLongConditions THENBUY LotSize Contracts at MarketTP1 = close + SL //1:1 RRRTP2 = close + SL*2 //1:2 RRRTP3 = close + SL*3 //1:3 RRRSET STOP LOSS SLFlag = 0ENDIFIF LongOnMarket THENIF close >= TP1 AND Flag = 0 THENSELL TP1size Contracts at MarketFlag = 1ENDIFIF close >= TP2 AND Flag = 1 THENSELL TP2size Contracts at MarketFlag = 2ENDIFIF close >= TP3 AND Flag = 2 THENSELL TP2size Contracts at MarketENDIFENDIFgraphonprice TP1 coloured(255,0,0,255) //Redgraphonprice TP2 coloured(0,128,0,155) //Greengraphonprice TP3 coloured(0,0,255,255) //Blue3 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on