i'm trying to delete a line i draw but canot seem to do it.
Basically the code allows the user to double left click on a point and it will draw a horizontal line there, while exporting some information to a text file. then i am trying to double right click to delete the line....this is the part that i cannot seem to get to work.
is there some thing obvious i am missing in the updateRDblClickInfo(barIndex, yValue) function.
thanks.
the code is below
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
Basically the code allows the user to double left click on a point and it will draw a horizontal line there, while exporting some information to a text file. then i am trying to double right click to delete the line....this is the part that i cannot seem to get to work.
is there some thing obvious i am missing in the updateRDblClickInfo(barIndex, yValue) function.
thanks.
the code is below
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
PHP Code:
function preMain() {
setPriceStudy(true);
setStudyTitle("DbleClk draw line");
setShowCursorLabel(false);
}
var linename="buyline" //give the line a name
function main() {
}
function onLButtonDblClk( barIndex, yValue) {
debugPrintln("LeftDblClk: " + barIndex + ", " + yValue);
updateLDblClickInfo(barIndex, yValue);
}
function onRButtonDblClk( barIndex, yValue) {
updateRDblClickInfo(barIndex, yValue);
}
function updateLDblClickInfo(barIndex, yValue) {
drawTextAbsolute(5, 35, "Double Clicked bar " + barIndex + " at " + yValue.toFixed(2),
Color.white, Color.navy, Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.BOLD, null, 14, "DblClickInfo");
addLineTool( LineTool.HORZ, yValue, 2, Color.blue, linename );
writetoFile(yValue);
}
function updateRDblClickInfo(barIndex, yValue) {
drawTextAbsolute(5, 35, "Double Clicked bar " + barIndex + " at " + yValue.toFixed(2),
Color.white, Color.navy, Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.BOLD, null, 14, "DblClickInfo");
removeline(linename);
}
function writetoFile(yValue){
var a = new File("myfileii.txt"); //the file will be created in: eSignal/FormulaOutput/
sSymbol = getSymbol();
a.open("at+"); // Opens and appends the file
//a.open("wt+"); // Opens and overwrites the file
if(!a.isOpen()) {
debugPrintln("Could not open file!");
} else {
a.writeln(sSymbol +","+ yValue.toFixed(2)+linename );
}
a.close();
}
Comment