Buy at next bar that exceeds the high after a 3-bar pullback
Author: RodrigoAcioli
Creation Date: 11/29/2020 1:18 AM
profile picture

RodrigoAcioli

#1
I would like some help, as I am unable to complete my strategy. My idea is: Buy the NEXT candle that exceeds the maximum of the previous one, as long as we have the following sequence: minimum lower than the previous + minimum higher than the previous, we bought the exceedance of this, but the order is being executed in the current candle and not in overcoming this.


CODE:
Please log in to see this code.





Thank you very much for your help!
profile picture

Eugene

#2
I have trouble understanding your rules. The highlighted fragment is contradictory and cannot be achieved in real life:

QUOTE:
Buy the NEXT candle that exceeds the maximum of the previous one, as long as we have the following sequence: minimum lower than the previous + minimum higher than the previous, we bought the exceedance of this, but the order is being executed in the current candle and not in overcoming this.
profile picture

RodrigoAcioli

#3
Eugene,

Sorry my English, but can you understand the attached image?
I would like to buy when the prices exceed the maximum of this third candle.
profile picture

Cone

#4
Hi Rodrigo,
In a Rules-based Strategy you can use the Condition > Price (or Volume) Action > Price turns up: Low

In code either of these rules would work:

CODE:
Please log in to see this code.
profile picture

RodrigoAcioli

#5

Hi Cone,
I can't really apply any of the rules (condition or code). Because I need the sequence of "minimums" to be respected.
Did you understand the entry rule?

Thank you very much for your attention!
profile picture

Eugene

#6
WL's TurnUp function precisely matches your screenshot.
profile picture

Cone

#7
The CumUp.Value equals 1 also precisely matches.
It works because it looks for the first time the series moves up, which means it was previously moving down.

But if you're using rules-base code, just add the Price Turns Up condition, click on it, and select "Low" for the price that turns up.
profile picture

RodrigoAcioli

#8
Cone,

thank you very much for your help!
I have programmed my rule, but I need a supplement.
My stop gain would be the ranger between the minimum of candle 2 and the maximum between 3 candles, could you help me in this execution?


CODE:
Please log in to see this code.
profile picture

Eugene

#9
QUOTE:
the minimum of candle 2 and the maximum between 3 candles,

Given that your bar #2 is EntryBar - 1 and bar #3 is EntryBar, it's apparently something like this:
CODE:
Please log in to see this code.
profile picture

RodrigoAcioli

#10
Good morning Eugene,

I would like the ranger to be the largest among the 3 bars (automatically) as there will always be a variation of who is the largest in the backtest, as shown in the attached image. it would be possible?

I really appreciate your attention!
profile picture

Eugene

#11
QUOTE:
the largest among the 3 bars (automatically)


Of course it's possible. The range here is defined as the difference between the highest and lowest prices of the 3-day range from the bar preceding the signal bar:

CODE:
Please log in to see this code.
profile picture

RodrigoAcioli

#12
Eugene, perfect!

Once again, I appreciate the help!
profile picture

Eugene

#13
Glad I could help you Rodrigo!
profile picture

RodrigoAcioli

#14
I would like help in creating the rule, with the following conditions:

1 - Closing below the previous 2 candles;
2 - Its closure is greater than its opening (Candle current is green);
3 - Previous candle is red;


How can I ensure the last 2 conditions?
(It can be by rules or code)

Attached example!


CODE:
Please log in to see this code.
profile picture

Eugene

#15
Here you go
CODE:
Please log in to see this code.
profile picture

RodrigoAcioli

#16
Thanks again Eugene, I managed to complete the cod!
profile picture

Eugene

#17
Glad I could be of assistance!
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).