Maximize profit based on the price move
Forums › ProRealTime English forum › ProOrder support › Maximize profit based on the price move
- This topic has 9 replies, 6 voices, and was last updated 2 years ago by RichardVeen.
-
-
12/08/2021 at 7:44 AM #182979
Hi , Anyone can help with the below code please??
the idea is to not exit a position if it is still going your way. So if longonmarket and it is in profit (+15 points) then update the target profit to 50 and only exit when the candle finishes lower than the previous candle.
123456if longonmarket and close[0]-positionprice>15 thenset target profit 40if close[0]<lowest[1] thensell countofposition contracts at marketendifendifNot sure what is wrong, but it only changes the target profit and the second condition doesnt work.
12/08/2021 at 9:43 AM #182986Try this:
12345678910if not OnMarket thenflag = 0endifif longonmarket and close[0]-positionprice>15 thenset target profit 40flag = 1endifif close[0]<lowest[1] and flag thensell countofposition contracts at marketendif12/08/2021 at 10:33 AM #18299412/08/2021 at 12:45 PM #183006Hi Roberto. Still not working. I try to only add the second part to test and it just doesnt make any difference to the result which is impossible.
if not OnMarket then
flag = 0
endif
if longonmarket and close[0]-positionprice>15 thenflag = 1
endif
if close[0]<lowest[1] and flag then
sell countofposition contracts at market
endif12/08/2021 at 12:46 PM #18300712/08/2021 at 3:38 PM #183020Hi, “candle finishes lower than previous candle” is close[0]<low[1], not close[0]<lowest[1]
1 user thanked author for this post.
12/08/2021 at 11:19 PM #18304801/06/2022 at 11:26 AM #184743Hi,
The code above is a great idea but it is not working for me.
Below the code I testen and the target is not moving despite of the fact that the close(0) – positionprice > 5
What is wrong with the code?
//profit & loss
SET TARGET PROFIT 40
SET STOP pLOSS 20if not OnMarket then
flag = 0
endif
if longonmarket and close[0]-positionprice>5 then
set target profit 50
flag = 1
endifif close[0]<low[1] and flag then
sell countofposition contracts at market
endif01/06/2022 at 1:35 PM #184755Hi @RichardVeen
Remove the “Set Target Profit 40” at the top of your code.
(Otherwise it will reset every time to 40)
01/06/2022 at 3:44 PM #184766 -
AuthorPosts
Find exclusive trading pro-tools on