QUIT function when profit is reached
Forums › ProRealTime English forum › ProOrder support › QUIT function when profit is reached
- This topic has 5 replies, 4 voices, and was last updated 4 years ago by Albaran.
Tagged: quit
-
-
06/26/2020 at 5:53 AM #13719906/26/2020 at 7:44 AM #137206
QUIT is the function to stop the strategy. It has nothing to deal with the way you are calculating your profit!
If you have used STRATEGYPROFIT, it is indeed the realized profit.
The floating profit could be calculated as with this snippet:
1floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gainsCode is read at bar close, so if your strategy is running on a 5-minutes timeframe and you want it to be read more times during a bar for orders management, use the TIMEFRAME instruction with a lower timeframe and place all your desired functions you want to act faster below it.
06/29/2020 at 10:56 AM #137476Want to stop the system once stop is moved12345678910111213141516171819202122232425262728293031323334353637383940414243DEFPARAM CumulateOrders = Falsebuy .5 contract at marketset stop loss 50set target profit 300ret=.1//ret1=.1//ret2=.4IF Not OnMarket THENy = 0ENDIFIF LongOnMarket AND close > (TradePrice + (y * pipsize)) THENx = (close - tradeprice) / pipsize //convert price to pipsIF x >= 10 and x<=12.5 THEN //go ahead only if 30+ pipsy = max(x * ret, y) //y = 66.6% of max profitENDIFENDIFIF y THEN //Place pending LIMIT (not STOP) order when y>0SELL AT Tradeprice + (y * pipsize) stop //convert pips to priceENDIFif x>12 thenquitendifI am using the above code stop the system once profit >10 , I have asked the system stop once x>12 , as I am running this code in 1 second. here I am hoping that by the time program reached line 41 system has already moved my stop . Is there any way to stop system only after stop is moved?
I am using the option “when trading system is stopped – Remain open” I want to keep my position when I am in profit
12/15/2020 at 6:08 PM #153860I suppose I’m doing something wrong because the system stops as soon as it detects the quit function in the code. It doesn’t even enter the market, it stops the system right away with the following code as a test run (it’s not my strategy, let’s be clear about that 😀 ):
123456789IF NOT LongOnMarket THENBUY 1 CONTRACTS AT MARKETElsif longonmarket and barindex - tradeindex > 1 thensell at marketendifIf strategyprofit < 100 thenquitendifI get the following message from PRT: “this trading system has been stopped because of the presence of the quit function in the code.”
How about that?
12/15/2020 at 6:30 PM #153865When the strategy starts STRATEGYPROFIT is zero, so line 7 is immediately TRUE and line 8 executed to stop the strategy.
I suggest modifying line 7 so that it checks the strategy has entered at least one trade:
1If strategyprofit < 100 AND strategyprofit[1] <> 0 thenbut this will exit immediately if the first trade is a losing one.
1 user thanked author for this post.
12/15/2020 at 8:09 PM #153871 -
AuthorPosts
Find exclusive trading pro-tools on