|
Kiran
2015-06-29 09:17:13
|
|
I'm trying to build a custom Volume indicator that is aggregated from 1-minute timeframes and used in a 10-minute timeframe strategy. I'm using the following code to (1) Plot on a 10-minute chart (2) use as a condition in my strategy
- I couldn't figure out how to align the 1min plot and 10min plot in the Chart window vertically in order to visually compare the two plots and confirm the formula is correct - To draw the 1min plot, i'm simply deleting the TimeframeCompress command (hope that's correct)
- Appreciate if you could confirm that the code in (1) and (2) below is correct? (Hope i'm not missing a ref(1) offset or something else.
///// 1) To plot on chart
TimeframeSet(60);
dirVol = iff(close>open && (close-open)>0.35*(high-low),volume,iff(close<open && (open-close)>0.35*(high-low),-volume,0));
avgVol = avg(dirVol,10);
dirVol = TimeframeCompress(dirVol);
avgVol = TimeframeCompress(avgVol);
TimeframeRestore();
plot(dirVol, "dir Volume", colorred, ChartBar, stylesymbolnone);
plot(avgVol, "avg Volume", colorblue, ChartLine, stylesymbolnone);
///// 2) Use in the strategy
VolumeInd = TimeframeCompress(TimeframeApply(60,avg(iff(close>open && (close-open)>0.35*(high-low),volume,iff(close<open && (open-close)>0.35*(high-low),-volume,0)),10);
buy = <Buy condition> && VolumeInd >0;
sell = <Sell condition>
|
|