How to use multi-time frame and RANGE Bars (20 and 50)

I am still struggling in figuring out how to use indicators from a LARGER RANGE size.

I have set the database to TICK and have a decent amount of real time TICK data

image

Here is what I want to do:
On my RANGE 20 chart, I want to display, and calculate the Stochastic %K from the RANGE 50 chart so I can use the value in my AFL programming (the value of the StochK from the 50)

ISSUE: Given the below code, the value calculated from the RANGE 50 chart isn't correct.

From the below chart, the left hand RANGE 20 chart, has my AFL code that is using multi-timeframe to calculate the StochK from the RANGE 50 chart.

This is NOT calculating the right value see the BLUE circles - I was expecting the RANGE 20 chart to have a value of: 92.3246 but it is calculating: 88.9946

image

I don't know where this is going wrong, from a previous post from Tomasz, I think this should work:
image

_SECTION_BEGIN("MJF-TEST-MTF");

STFMode=4;						// this sets it to RANGE BARS
STF=50;						// Tomasz, what value am I supposed to use if I want a RANGE bar of 50?

TimeFrameMode( STFMode ); 
TimeFrameSet( STF ); 

KArray = StochK( periods = 15, ksmooth=3 ) ;			
			
TimeFrameRestore(); 						// restore time frame to original for plotting
	
tempk = TimeFrameExpand(KArray, STF, mode=expandFirst);				// this is set to 30 here too

Plot( tempk, "DSK", ParamColor( "ColorK", colorRed ),styleLine);
Plot(85,"Overbought Level",colorGrey40, styleNoTitle |styleDashed );
Plot(15,"Oversold Level",colorGrey40, styleNoTitle |styleDashed );
_SECTION_END();

Hi. in AFL, can someone confirm that using the following will give me the same range bar chart as typing in 50R in the interval box on my screen.

TimeFrameMode( 4 );

  • switches time frame functions to N-Range bar operation (positive values passed to TimeFrameSet are treated now as N-range bars) where N is expressed in TickSize units (this is default mode of operation of range bars in 5.14 and above).

TimeFrameMode( 4);
TimeFrameSet( 50 );

is the same as typying in

image

From the Manual, this is expressed in TickSize units.

From my Symbol information this is set to ZERO -

image

What do I put in this statement so I get the same as typing 50R in my interval?

TimeFrameSet( 50 );

Thanks in advance.

Hi Tomasz. I need to know if this is even possible or do I give up on RANGE bars in multiple time frames. Does this actually work in the product?

QUESTION: If I the current chart is on RANGE 20. Can I write AFL (included in post 1) to get a standard STOCHK indicator value from RANGE 50 ?

I'd very much appreciate instructions on exactly what settings I have to make to the code posted ode in Post #1 above.

I have read the manual and your posts 50,000 times and there isn't much on RANGE bars. I have it working for time based bars (the code above works in time based IE: 15 min and accessing a 30 min stochastic indicator) .

I do not fully understand the limitations of what you have in this chart below denoted by the ** circled in BLUE. Please describe how it works and what I can and can't do with RANGE bars.

Is the INPUT RANGE 20 and OUTPUT RANGE 50 ? or is it reversed? Would RANGE 20 and RANGE 40 (resulting in an integer work?)

Thanks

image

Everything was already explained in this thread: Can’t get Double Stochastic to work in Multi Time frame (RANGE BARS). I explained it there in most details possible and can’t be more detailed/specific/direct than this. If you don’t get that 50/20=5/2=2.5 is NOT integer, then sorry.

Thanks for this info Tomasz, it is a lot closer now .... (I may have gaps in my tick data...)

I set the chart to 20R and the one I want to calculate the STOCHK from at 40R

I get a value of 46.39 and the one the 40R chart is a value of 50.

Any ideas on why it would NOT be a value of 50? It should calculate the same value as the actual chart should it not?

Also: why does it have be multiples/integer? I don't really want to have a 30R 60R and 90R charts. I would be great if I had the same flexibility as the time based charts.

image