Update Target Price after each candle
Forums › ProRealTime English forum › ProOrder support › Update Target Price after each candle
- This topic has 12 replies, 4 voices, and was last updated 3 years ago by robertogozzi.
Tagged: gain, loss, Money, Pips, PipSize, PipValue, positionperf, POSITIONPRICE, Profit, tradeprice
-
-
08/27/2021 at 11:54 AM #176372
Hi,
Would like to find a way to update a target price value after each candle. For example, the TP is set to be close – moving average[10]. How can I update the TP once the position is on, so if the MA drops then the TP is also lowered?
Thought there might be something in the “summation” but not had any luck yet.
Thanks
08/27/2021 at 1:36 PM #176378Try this:
123456If LongOnMarket thenTP = Close - average[10,0](close)If TP > 0 thenSELL AT average[10,0](close) STOPEndifEndif2 users thanked author for this post.
08/27/2021 at 2:56 PM #176382Thanks Roberto – you star!
08/27/2021 at 3:29 PM #176383Try this:
123456If LongOnMarket thenTP= Close – average[10,0](close)If TP > 0 thenSELL AT average[10,0](close) STOPEndifEndifHi robertogozzi,
Thanks for the idea. I am trying this out where the 20 period moving average is set as the Target Profit. However, this will be lower than the Entry price where the market drops, so TP would not be greater than zero. I have tried “<> 0” and other variations, but I can’t get this to work. Hope that the attached image will help explain.
Thanks very much as always
08/27/2021 at 3:56 PM #176385Replace line 1 with this one:
1If LongOnMarket and PositionPerf > 0 then08/30/2021 at 8:24 AM #176462Replace line 1 with this one:
1If LongOnMarket and PositionPerf > 0 thenHi robertogozzi
Will PRT allow you to change the TP once the trade is on (up or down)? Thanks very much
08/30/2021 at 10:17 AM #176475Yes, you can.
On limited risk accounts you can only reduce it, though.
09/09/2021 at 8:12 AM #177085Hello!
I find this method for profit target very interesting and have been dabbling with it for a week. I’m trying to combine in with a hard stoploss, but can’t seem to make it work. Let’s say I’d like to use this code and a percentage stop loss of 0.5%. Would this be possible? I’ve tried many variations, but none seem to work. The challenge is of course that if you use this and the market instantly goes against you, the loss is theoretically higher than your solvency.
Here are two examples, neither of which work.
Any ideas?
1234567891011121314151617181920212223242526272829303132333435indicator1 = MA 50indicator2 = MA 100c1 = if indicator1 crosses over indicator2 thenbuy at marketset stop %loss 0.2endifIf longOnMarket and PositionPerf > 0 thenTP = Close - average[50](close)If TP > 0 thensell AT average[50](close) STOPEndifEndif//Orindicator1 = MA 50indicator2 = MA 100c1 = if indicator1 crosses over indicator2 thenbuy at marketendifIf longOnMarket and PositionPerf > 0 thenTP = Close - average[50](close)If TP > 0 thensell AT average[50](close) STOPEndifEndifIf longOnMarket and PositionPerf < 0 thenTP = Close - average[10](close)If TP > 0 thensell AT average[10](close) STOPEndifEndif09/09/2021 at 8:54 AM #177092Line 5 is correct (then code contains many syntax and logical errors, but I think this is just an example as you would have been returned some error messages), just replace it sith 0.5.
IF…THEN must be on a line of its own and can’t be assigned to variables as it does NOT return any value, it just checks whether conditions are met or not.
09/09/2021 at 9:43 AM #177105Yes, it’s just an example and I noticed I wrote a completely faulty code, but was only able to edit the post once. Guess there is a limit on that? In any case, the actual code is not the issue, but I see I also explained it poorly. Optimally I would like to make it so that the profit target function is activate when the position is in profit, but that set stop loss activates if say the market moves against me and I’m down x points on my position.
Something like this,
1234567891011121314151617181920DefParam CumulateOrders = falsepositionsize = 1indicator1 = MA 50indicator2 = MA 100c1 = indicator1 crosses over indicator2If longOnMarket and PositionPerf > 0 thenTP = Close - average[50](close)If TP > 0 thensell AT average[50](close) STOPEndifEndifIf longOnMarket and PositionPerf < -50 thenTP = Close - average[10](close)If TP > 0 thensell AT average[10](close) STOPEndifEndifDoes this make sense?
09/09/2021 at 10:01 AM #177107You have a 5-minute time to edit your post.
PositionPerf is a factor, to make it a percentage multiply it by 100. To convert it into Pips:
1Pips = PositionPrice * PositionPerf / PipSizeto get the same value in currency:
1Money = PositionPrice * PositionPerf / PipSize * PipValue1 user thanked author for this post.
09/09/2021 at 11:49 AM #177131Thank you, Roberto! That is very useful information. I reckon I’m getting closer, but am not quite there. I tried to do it like this, but it seems to not take effect only when I’m down x points. Have I misunderstood how this works? Any ideas for how to make it work?
12345678910111213Pips = PositionPrice * PositionPerf / PipSize * PipValueIf shortOnMarket and PositionPerf > 0 thenTP = Close - average[50](close)If TP > 0 thenexitshort AT average[50](close) STOPElsif shortOnMarket and pips <-50 thenSL = Close - average[20](close)If SL > 0 thenexitshort AT average[20](close) STOPEndifEndifendif09/09/2021 at 12:14 PM #177139Sorry, my fault, I wrote my second line incorrectly.
Now I edited it with the variable MONEY.
Use the first line with PIPS (you just need to remove the multiplication by PIPVALUE at the end of line 1 in your code). -
AuthorPosts
Find exclusive trading pro-tools on