//@Name:3 Bar Inside Pattern //@Description:Displays buy and sell signals based on the Three-Bar Inside Bar Pattern. As described on Stocks & Commodities, March 2011. // Care has been taken in preparing this code but it is provided without guarantee. // You are welcome to modify and extend it. Please add your name as a modifier if you distribute it. var defaultCol = Colour.White; var buyCol = Colour.Green; var sellCol = Colour.Red; var SL = 0.75; var PT = 0.75; function init(status) { if (status == Loading || status == Editing) { buyCol = storage.getAt(0); sellCol = storage.getAt(1); defaultCol = storage.getAt(2); } if (status == Adding || status == Editing) { dlg = new Dialog("Settings...", 150, 60); dlg.addOkButton(); dlg.addCancelButton(); dlg.addColPicker("COL1",8,-1,-1,-1,"","Buy colour",buyCol); dlg.addColPicker("COL2",8,-1,-1,-1,"","Sell colour",sellCol); dlg.addColPicker("COL3",8,-1,-1,-1,"","Default colour",defaultCol); if (dlg.show()==Dialog.Cancel) return false; buyCol = dlg.getValue("COL1"); sellCol = dlg.getValue("COL2"); defaultCol = dlg.getValue("COL3"); storage.setAt(0, buyCol); storage.setAt(1, sellCol); storage.setAt(2, defaultCol); } } function onNewChart() { bars[0].colour = defaultCol; bars[1].colour = defaultCol; bars[2].colour = defaultCol; var buyBar = 0; var sellBar = 0; setFontColour(Colour.Black); for (var i=3;iopenPrice*(1+PT/100))) { setBrushColour(Colour.Green); drawSymbol(buyBar, bars[buyBar].high*1.005, Symbol.Circle, "P", BoxAlign.Centre|BoxAlign.Below); buyBar = 0; } else if (buyBar && bars[i].lowopenPrice*(1+SL/100)) { setBrushColour(Colour.Red); drawSymbol(sellBar, bars[sellBar].high*1.005, Symbol.Circle, "L", BoxAlign.Centre|BoxAlign.Below); sellBar = 0; } else if (!buyBar && !sellBar && bars[i-1].high < bars[i-2].high && bars[i-1].low > bars[i-2].low) { if (bars[i].close>bars[i-1].close && bars[i-2].close > bars[i-3].close) { bars[i-2].colour = buyCol; bars[i-1].colour = buyCol; bars[i].colour = buyCol; buyBar = i; if (i+1