Candle Size Ranges

1 replies

mjran

Subscriber, bbp_participant, community, 1 replies.

Visit profile

11 years ago #111267

Hi,

 

Does anyone know how I would define a rule in Strategy Quant which uses an average of the size range of a set of candlesticks? For example, if I wanted to buy if the 11th candle was 10% greater in size than the average of the range of the preceeding 10 candles, rather than simply buying on the high of a 10 candle period, then how would I define that rule using Strategy Quant?

 

Thanks

 

Mark

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

11 years ago #121901

Hi,

 

getting average range of previous X candles would be possible only using a custom function, see on the bottom.

But you can use Average True Range (ATR), it is very similar. ATR(10) means average true range of last 10 candles.

 

The condition that range of current candle is 10% bigger than ATR(10) would be:

BarRange(0) > 1.1 * ATR(10)

 

1.1 means 10% more. 1.2 is 20% more and so on.

 

But I expect this condition will be true very often.

 

double sqAverageRange(int period, int shift) {
    double avg = 0;

    for(int i=shift; i<shift+period; i++) {
        avg = avg + iHigh(NULL, 0, i) – iLow(NULL, 0, i);
    }

    return(avg / period);
}

Mark
StrategyQuant architect

0

Viewing 1 replies (of 1 total)