//@Name:Elder-Ray //@Description:From Alexander Elder's book: Trading for a Living // Buy if trend is up i.e. the 13 day EMA is increasing // + Bear Power (lower line) is negative but rising // + (desirable) Latest peak in Bull Power is higher than previous peak // + (desirable) Bear power is rising from a bullish divergence // Sell signal is the reverse // See 'Trading for a Living' for more details // 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 bullCol = Colour.Blue; var bullPen = Pen.Solid; var bullWidth = 1; var bearCol = Colour.Green; var bearPen = Pen.Solid; var bearWidth = 1; var lineCol = Colour.Grey; var linePen = Pen.Solid; var lineWidth = 0; var lineVal = 0; var store; function init(status) { if (status == Loading || status == Editing) { store = storage.getAt(0); bullCol = storage.getAt(1); bearCol = storage.getAt(2); lineCol = storage.getAt(3); //lineVal = storage.getAt(4); store = store.toString(); bullPen = parseInt(store.substr(0,1),10)-1; bullWidth = parseInt(store.substr(1,1),10); bearPen = parseInt(store.substr(2,1),10); bearWidth = parseInt(store.substr(3,1),10); linePen = parseInt(store.substr(4,1),10); lineWidth = parseInt(store.substr(5,1),10); } if (status == Adding || status == Editing) { dlg = new Dialog("Elder-Ray settings...",160,70); dlg.addOkButton(); dlg.addCancelButton(); dlg.addColLinePicker("BULL",8,5,-1,-1,"","bullish line",bullCol,bullPen,bullWidth); dlg.addColLinePicker("BEAR",8,25,-1,-1,"","bearish line",bearCol,bearPen,bearWidth); dlg.addColLinePicker("HLINE",8,45,-1,-1,"","centre line",lineCol,linePen,lineWidth); if (dlg.show()==Dialog.Cancel) return false; bullCol = dlg.getValue("BULL").colour; bullPen = dlg.getValue("BULL").pen; bullWidth = dlg.getValue("BULL").width; bearCol = dlg.getValue("BEAR").colour; bearPen = dlg.getValue("BEAR").pen; bearWidth = dlg.getValue("BEAR").width; lineCol = dlg.getValue("HLINE").colour; linePen = dlg.getValue("HLINE").pen; lineWidth = dlg.getValue("HLINE").width; store = (bullPen+1)*100000+bullWidth*10000+bearPen*1000+bearWidth*100+linePen*10+lineWidth; storage.setAt(0, store); storage.setAt(1, bullCol); storage.setAt(2, bearCol); storage.setAt(3, lineCol); } setTitle("Elder-Ray"); setSeriesColour(0, bullCol); setSeriesLineStyle(0, bullPen, bullWidth); setSeriesColour(1, bearCol); setSeriesLineStyle(1, bearPen, bearWidth); setSeriesColour(2, lineCol); setSeriesLineStyle(2, linePen, lineWidth); } function getGraph(share, data) { var period=13; var BullPower = new Array(); var BearPower = new Array(); var horizontal = new Array(); var ma1 = new MA(period, MA.Exponential); for (var i=0; i