function preMain(){ setPriceStudy(true); setStudyTitle("Stochastic Bar Painter") setColorPriceBars(true); setDefaultPriceBarColor(Color.grey); } function main(){ if(getBarState() == BARSTATE_ALLBARS) nStochDifference = null; if(getCurrentBarCount() < 14 + 3 + 3) return; nStochDifference = stochK(14,3,3) - stochD(14,3,3); if(nStochDifference > 0) setPriceBarColor(Color.green); else setPriceBarColor(Color.RGB(192, 0, 0)); if(nStochDifference > 0) drawTextAbsolute(0, TopRow1, nStochDifference.toFixed(3), Color.RGB(0,192,0), null, Text.PRESET|Text.CENTER, "Courier New", 12, "StochDiff"); else drawTextAbsolute(0, TopRow1, nStochDifference.toFixed(3), Color.RGB(192,0,0), null, Text.PRESET|Text.CENTER, "Courier New", 12, "StochDiff"); return; } /* NOTE: You could add another number next to it if you wanted to. The key is for "StochDiff"and "Var2" to have different names that are static...unlike "StochDiff"+rawtime(0) which will put a value on every bar. if(nStochDifference > 0) drawTextAbsolute(-15, TopRow1, AnotherVar.toFixed(2), Color.RGB(0,192,0), null, Text.PRESET|Text.CENTER, "Courier New", 12, "Var2"); else drawTextAbsolute(-15, TopRow1, AnotherVar.toFixed(2), Color.RGB(192,0,0), null, Text.PRESET|Text.CENTER, "Courier New", 12, "Var2"); */