close strategy after profit/ number of trades
Forums › ProRealTime English forum › ProBuilder support › close strategy after profit/ number of trades
- This topic has 11 replies, 2 voices, and was last updated 2 years ago by robertogozzi.
-
-
04/25/2022 at 9:16 AM #192176
how does one set up the strategy to stop trading after 1 profitable trade/ a certain number of trades?
04/25/2022 at 9:41 AM #192180To stop trading after 1 profitable trade:
12345678910ONCE TradeON = 1IF IntraDayBarIndex = 0 THENTradeON = 1ENDIFIF StrategyProfit > StrategyProfit[1] THENTradeON = 0ENDIFIF MyConditions AND TradeON THENBUY/SELLLSHORT....ENDIFTo stop after a certain number of trades:
1234567891011ONCE MaxTrades = 3ONCE Tally = 0IF IntraDayBarIndex = 0 THENTally = 0ENDIFIF StrategyProfit <> StrategyProfit[1] THENTally = Tally + 1ENDIFIF MyConditions AND Tally < MaxTrades THENBUY/SELLLSHORT....ENDIF04/25/2022 at 9:54 AM #192186awesome. thank you
05/11/2022 at 11:16 AM #193053how does one combine these 2 pieces of code so that the maximum number of trades is 2 but the system will stop after 1 profitable trade. So that if first trade is profitable, the second wont happen but if first is a loser then 1 more trade will be allowed
05/12/2022 at 9:05 AM #193088There you go:
12345678910111213141516171819ONCE TradeON = 1ONCE MaxTrades = 3ONCE Tally = 0IF IntraDayBarIndex = 0 THENTradeON = 1Tally = 0ENDIFIF StrategyProfit > StrategyProfit[1] THENTradeON = 0ENDIFIF StrategyProfit <> StrategyProfit[1] THENTally = Tally + 1ENDIFIF MyConditions AND Tally < MaxTrades AND TradeON THENBUY/SELLLSHORT....ENDIF05/31/2022 at 3:46 PM #194309roberto
thank you for this! i am learning fast!!
i applied the code to my strategy but it still does more than the maximum of 2 trades per day and it isnt stopping once profitable. have i put it in wrong?
attached is list of orders and code
alex
05/31/2022 at 5:10 PM #194327It open as many trades as MAXTRADES. It’s 3 now, but you can change it as needed.
05/31/2022 at 5:15 PM #194329…but on 12th , there were 6 trades, so not sure code is working
05/31/2022 at 6:05 PM #194340This code is working as expected on DAX, 1-min, 5-min, 15-min TFs, etc…
1234567891011121314151617181920212223242526DEFPARAM CumulateOrders = FalseONCE TradeON = 1ONCE MaxTrades = 3ONCE Tally = 0IF IntraDayBarIndex = 0 THENTradeON = 1Tally = 0ENDIFIF StrategyProfit > StrategyProfit[1] THENTradeON = 0ENDIFIF StrategyProfit <> StrategyProfit[1] THENTally = Tally + 1ENDIFMyConditions = (average[20] CROSSES UNDER average[100]) AND Not OnMarketIF MyConditions AND Tally < MaxTrades AND TradeON THENSELLSHORT 1 contract at MarketENDIFSET TARGET pPROFIT 60SET STOP pLOSS 60//graph TallyI suggest that you either post your code, or use mine, simply replacing MyConditions with yours.
06/01/2022 at 7:43 AM #194374amazing!! thank you for your time and patience!
alex
06/07/2022 at 12:59 PM #194846hi roberto
1 more question……!
i have 2 strategies that i have made/ am using with a degree of success and they are both good on back testing. I would like another set of eyes to have a look at them and see where i can improve them. Would be happy to pay for that service! is there anyone you could recommend? would you have a look? should i just post them on a forum and see what people say?! alex
06/07/2022 at 1:15 PM #194847You can either post your code or apply for paid services at https://www.prorealcode.com/trading-programming-services/
-
AuthorPosts
Find exclusive trading pro-tools on