Nicolas

Internal bar strength QQQ strategy

Category: Strategies By: Nicolas Created: February 8, 2016, 1:59 PM
February 8, 2016, 1:59 PM
Strategies
8 Comments
Internal bar strength QQQ strategy

Here is a simple “long only” automated strategy built upon the mean reversion behaviour of the QQQ ETF. It uses the Internal Bar Strength indicator which represent the weight of the closing price related to the day’s range. It is a simple indicator that point the fact that deepest close would regain on the few next days. This indicator is the same as a stochastic oscillator with only 1 period = short term deviation from the price mean would expect that price will came back to it.

When the IBS (or stochastic oscillator) fall below the 10 level, buy at next open. Close the trade if a candle close above the previous day high.

I also add a dynamic lot calculation made upon the strategyprofit. You can change the value of the “initial lot” (100 shares at start) and the “step profit” which add more shares whenever the strategy gain a new stepprofit (50$ by default).

This strategy would be adapted to other indices, i will certainly go forward on it.

//indicator
STO =  (Close - Low) / (High - Low) * 100

//initial lot 
initLOT = 100 

//profit step of the strategy to increase lot
stepPROFIT = 50

myLOT = max(initLOT,initLOT+ROUND((strategyprofit-stepPROFIT)/stepPROFIT))

IF NOT LongOnMarket AND STO<10 THEN
  BUY myLOT CONTRACTS AT MARKET
ENDIF

If LongOnMarket AND Close>High[1] THEN
  SELL AT MARKET
ENDIF

 

 

 

Download
Filename: Internal-Bar-Strength-QQQ.itf
Downloads: 170
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

NA
NA
6 years ago
#

I find this strategy interesting even if the qqq in question etf does not have much transaction volume but to improve the original code, I know nothing about it, would you nicolas or alfredo can be kind when you have time to integrate your proposed changes to the original code, to benefit everyone? is it possible NA

NA
NA
6 years ago
#

je trouve cette stratégie interessante même si le qqq en question etf n'a pas beaucoup de volume de transaction toutefois pour améliorer le code originel, j'y connais rien, aurriez vous nicolas ou alfredo peut la gentillesse quand vous aurez le temps d'intégrer vos modifications proposés au code d'origine, pour en faire bénéficier tous le monde ? est ce possible NA

Nicolas
11 years ago
#

I think it's because of price gaps and/or quote interrupt. Anyway, be aware that this strategy were made to work on a daily basis and not in intraday, but if you can make it better, do it! 

alfredo
11 years ago
#

thank for the council, when i do start the strategie on Italy at 1h some mornings happen that i find the sistem interrupt with the error, but I' think that in the night the graph does not form some candle, maybe I'should make the strategy work from the 09:00 to 17:00 because the results are better, what do you think? 

Nicolas
11 years ago
#

I do not have any error Alfredo, even while testing on 150000 bars in the past. By the way, you should use EXITSHORT : http://www.prorealcode.com/documentation/exitshort/ to exit a short position. I have change your code accordingly :

 

defparam cumulateorders=false

STO = (Close - Low) / (High - Low) * 100

IF NOT LongOnMarket AND STO<10 THEN
  BUY 2 CONTRACTS AT MARKET
ENDIF

If LongOnMarket AND Close>High[1] THEN
  SELL AT MARKET
ENDIF

if not shortonmarket and sto>90 then
  sellshort 2 contracts at market
endif

if shortonmarket and close<low[1] then
  exitshort at market
endif

set stop $loss 250

 

Where does your error appear? Is it a ProRealTime window?

alfredo
11 years ago
#

Yes, thi is code modified

defparam cumulateorders=false

STO = (Close - Low) / (High - Low) * 100


IF NOT LongOnMarket AND STO<10 THEN
BUY 2 CONTRACTS AT MARKET
ENDIF

If LongOnMarket AND Close>High[1] THEN
SELL AT MARKET
ENDIF

if not shortonmarket and sto>90 then
sellshort 2 contracts at market
endif

if shortonmarket and close<low[1] then
buy at market
endif

set stop $loss 250

Nicolas
11 years ago
#

Hello alfredo, there are only 2 divisions in the code, that may cause crash of the script. Have you made any modifications to the original code strategy? Thank you.

alfredo
11 years ago
#

Ciao Nicolas, how said on fb I'have a problem with this strategie, some times go in crash in time frame at 1 hour because need of a protection by a division of zero for last candle, you can help me? Thank for all.

ProRealCode ProRealCode
Loading...