Breakout after 5 candles
Forums › ProRealTime English forum › ProOrder support › Breakout after 5 candles
- This topic has 14 replies, 5 voices, and was last updated 1 year ago by robertogozzi.
-
-
11/13/2022 at 2:42 PM #204107
Dear ones.
I need your help again. I’m sorry, but that’s the way it is. Please. Maybe one or the other can shake it from the sleeve.We have for the sake of simplicity an Outside.
Now I would like to set the buy stop 5 points above the high of the candles. But the buy stop should only be executed within 5 candles (n -candles).
This kind of stops after trigger candles can be found in the strategies of e.g. the Hikkake here
https://www.prorealcode.com/prorealtime-indicators/hikkake-pattern/.Please, do anyone help?
11/15/2022 at 4:20 AM #204186There you go:
1234567891011121314151617ONCE Tally = 0OutSideBAR = (high > high[1]) AND (low < low[1])IF OutSideBAR AND Not OnMarket THENTally = 1Entry = high + 5 * PipSize //Entry price = HIGH + 5 pipsENDIFIF Tally > 5 OR OnMarket THENTally = 0ELSIF Tally[1] > 0 THENTally = Tally + 1ENDIFIF Tally AND Not OnMarket THENBUY 1 CONTRACT AT Entry STOPSET STOP pLOSS 20SET TARGET pPROFIT 20ENDIF//graph Tally1 user thanked author for this post.
11/19/2022 at 1:52 PM #204467Hello Roberto.
Thank you very much for the code. I just got around to looking at it today and ! – I want to say your code really helps me a lot. Now I can implement it in several (known) strategies. I will offer the strategies here if done. Thank you very much.
As I see the program performs the buy stop several times within the 5 candles provided the conditions are met. See the screenshot and more detailed there after the 2.Outside.
Can you change me the code so that it enters only 1 position within the predefined 5 candles? “not onmarket” does not help because the SL/TP is very low and new positions can be entered again and again. If I set the SL/TP on my 200 points, then it works, but is not in my sense. One ( first) position should be opened and then no more within the 5 candles.
very kind regards to you
11/19/2022 at 3:28 PM #204470Thank you! It should be like this?
countofposition1234567891011121314151617181920212223ONCE Tally = 0OutSideBAR = (high > high[1]) AND (low < low[1])IF OutSideBAR AND Not OnMarket THENTally = 1Entry = high + 5 * PipSize //Entry price = HIGH + 5 pipsENDIFIF Tally > 5 OR OnMarket THENTally = 0ELSIF Tally[1] > 0 THENTally = Tally + 1ENDIFMaxShares = abs(COUNTOFPOSITION) <= 1IF Tally AND Not OnMarket AND MaxShares THENBUY 1 CONTRACT AT Entry STOPSET STOP pLOSS 20SET TARGET pPROFIT 20ENDIF//graph Tally11/20/2022 at 6:32 PM #204521I tried it to optimize this setup, but the results are in all timeframes with tick-by-tick backup, horrible.
11/20/2022 at 7:20 PM #204527with tick-by-tick backup, horrible.
Any ideas why this is so and / or any ideas for improvement?
1 user thanked author for this post.
11/20/2022 at 7:36 PM #204528with tick-by-tick backup, horrible.
Any ideas why this is so and / or any ideas for improvement?
Well, I think SL/TP are to close
1 user thanked author for this post.
11/20/2022 at 10:06 PM #204540Please excuse me. It was not about the strategy of trading exactly this breakout. It was about the coding itself, how the code can look like – to trade the breakout after n candles after one candle.
1 user thanked author for this post.
11/20/2022 at 10:19 PM #204541Examples
We have a new 20 candle high that is immediately sold. We want to buy on a breakout above the high candle, but only within 10 candles.
We are trading an IDNR4 and want to buy/sell on a breakout (long/short) within the next 2 candles.
The same with PopGuns.
Or finer. We buy on a breakout above a bearish divergence within the next n candles.
Etc etcI miss the basic programming skills, I’m sorry, thanks for your help
11/20/2022 at 11:53 PM #204543Hi @f1_maik
I tried Roberto’s first code and don’t see that the code opens multiple positions within 5 candles…
In your answer #204467 you talk about a screenshot and more details but unfortunately this screenshot has not been uploaded…
Can you post it again?11/21/2022 at 9:28 AM #20455011/23/2022 at 11:36 AM #204681Try replacing line 9 with this one, to account for trades opened and closed on the same bar:
1IF Tally > 5 OR OnMarket OR (StrategyProfit <> StrategyProfit[1]) THEN1 user thanked author for this post.
11/23/2022 at 6:18 PM #20469502/14/2023 at 9:12 PM #209690Hello Roberto.
Again me and again on the subject of breakout in the next 5 candles.The problem is as follows.
Above we have the SL and TP with 20 points and the trade starts directly in the 1.candle after the Outside and wins.
Then the price immediately falls below the StopBuy and in the next candle we trigger the StopBuy and a 2nd trade is started within the 5 candles. This 2nd or 3rd or 4….. Trade I would like to prevent.How to code that the breakout is traded only once within the 5 candles? Cumulateorders false does not work sufficiently, dito not onmarket and the like. It must be ensured that the trade starts only 1x.
Can it solve countofposition? Countofposition <= 1 within the last 5 candles? Something like that? Can this be programmed in PRT, what would be the code for it?
lg
02/23/2023 at 4:18 PM #210296This should work (I added the OTD check, One Trade per Day):
1234567891011121314151617181920212223ONCE Tally = 0OTD = (Barindex - TradeIndex(1) > IntradayBarIndex)OutSideBAR = (high > high[1]) AND (low < low[1])IF OutSideBAR AND Not OnMarket THENTally = 1Entry = high + 5 * PipSize //Entry price = HIGH + 5 pipsENDIFIF Tally > 5 OR OnMarket OR (StrategyProfit <> StrategyProfit[1]) THENTally = 0ELSIF Tally[1] > 0 THENTally = Tally + 1ENDIFMaxShares = abs(COUNTOFPOSITION) <= 1IF Tally AND Not OnMarket AND MaxShares AND OTD THENBUY 1 CONTRACT AT Entry STOPSET STOP pLOSS 20SET TARGET pPROFIT 20ENDIF//graph Tally2 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on