TradingView
EduardoMattje
Oct 3, 2020 5:20 PM

IFR2 

Amazon.com, Inc.NASDAQ

Description

The IFR2 strategy is based on the RSI indicator.

If the two period RSI is less than the overbought level (25 is the default, but you can configure it to be lower), a long position is placed at the close of the candle. If you are doing it live, you'd have to enter the market ~ 10 minutes before it closes, check the RSI, and buy if it is lower than your overbought level. This generates a discrepancy in the backtesting, but since it is a very small difference, it can be disregarded. Higher overbought levels generate more signals, but they mostly are unreliable. Lower values generates better yields, but they won't occur very often. This strategy is designed to be used in a daily graph, and I don't recommend using it in intraday periods, since you'll make too little money to compensate for the operational cost.

The strategy exits when the high price of two previous candles is reached. If the exit price is higher than the closing price of when you entered, you'll be at a profit, otherwise you'll be at a loss. The exit price is plotted in the graph and it's colors depends on the current open profit: positive values will be green, negative will be red.

This strategy completely disregards the current trend. Long orders will be placed even if you are at a strong down trend. This may seem odd, but you have to keep in mind that this is a volatility based strategy, not a trend following one.

This setup was designed by Alexandre Wolwacz, a.k.a. Stormer.

Release Notes

Updated the strategy to include different types of exit points. Now you can choose to exit on the highest of previous candles (the default setting), when the RSI is oversold, or when the price closes above the short moving average.

You can also configure to take trades only when the moving averages are trending. This kinda defeats the purpose of the strategy, since it is not a trend following strategy, but I found that is some assets it may work better to filter the trades.

Release Notes

Added the ability to go short.

Release Notes

I simplified the script and added a starting date as requested by a user.

Release Notes

Now it uses the new time entry function, so it is much more accurate. In addition, you can define a custom ATR period.

Release Notes

I made use of the new inline and group features on the input functions, so now they should be clearer and better organized.

Release Notes

I've been showing the wrong oscillator since the last update, now it should be corrected.

Release Notes

I made some changes to the code to make the script load faster.
Comments
GrowthAlgorithmTrading
IFR2 é um sistema muito bom, porém o que me incomoda é o drawdown, tive testanto em Forex e funciona bem, o problema é quando vem noticias, isso engole seu capital. Estou a um tempo raxando a cabeça para encontrar uma melhor forma de saída para proteger o capital, sem alterar significamente no RR.

Você já testou soluções mais eficientes @EduardoMattje ?
contatowilliamzanelatto
Não entendo muito para incluir essa regra e salvar, fiz o Ctrl C e V mas não deu certo, alguem teria somente os dados a serem inclusos, por favor.
thithibands
Parabéns demais pelo script. O melhor que ja vi aqui. Será que teria como colocar um filtro opcional para testes? Ex: só ativa a operação se o preço estiver acima de uma media movel customizada. Seria mto legal ter essa opção para backtests. Obrigado!
andrelucast3
Você fez o script com o canddle encostando na media móvel de 7 e vendendo?
EduardoMattje
@cacasor não pude responder pelo chat porque agora o TV necessita de 5 pontos de reputação pra que eu possa usar o chat. Regra completamente retardada.

Enfim, as configs do ATR servem pra aumentar ou diminuir o alvo baseando-se no ATR, ou seja: se o ATR está em 0.1, usando a saída dos 2 últimos candles, ele pega a máxima deles e aumenta com o valor do ATR multiplicado por 0.1.
illuminnatti
bom dia, Eduardo. Acho que é o scrip do IFR2 Stormer mais preciso que já encontrei. Estive batendo cabeça pra fazer eu mesmo esse scrip mas não tenho conhecimento do pine. Vc aprendeu Pine Sozinho? Qual a melhor maneira de dominar essa linguagem para eu poder construir meus próprios backtests?
EduardoMattje
@illuminnatti, Sim, aprendi sozinho. O mais fácil é começar aprendendo Python, as duas linguagens são bem parecidas. Basicamente eu fui olhando outros scripts e vendo o que cada parte fazia o quê, mas a questão das sintaxe e tudo mais eu aprendi com o Python.
EduardoMattje
@illuminnatti, O Pine também tem uns "janks" que tu só aprende testando mesmo, por exemplo neste script tem que comprar no fechamento, e tem que botar o argumento process_orders_on_close=true na parte da estratégia. No meu outro script do preço de fechamento de reversão eu sofri em algumas partes por causa do jeito com que ele calcula as coisas.
losrspoa
Bom dia Eduardo, agradeço por compartilhar o scrip que tem ajudado muito no backtest. Teria como disponibilizar um script para o Mínimas e Máximas do Stormer ( compra na mínima dos últimos 2 dias e saída na máxima dos últimos dois dias ) ?
More