This is some bits of code from other EFS by Garth Doverspike and Steve Hare. I'm trying to draw a horizontal line at the High or Low of a bar without hitting it right on with the mouse click. I couldn't find any documentation on how the CheckNear function works..
The line draws but the magnet part does not work..
TXs to anyone who has a suggestion! Don
function preMain()
{
setPriceStudy(true);
}
function main() {
}
function onLButtonDblClk(barIndex, yValue)
{
// CheckNear function - return the OHLC value closest to the mouse click
function CheckNear(yValue, nOpen,nClose,nHigh,nLow)
{
// Is click closer to High or Low?
if (Math.abs(yValue-nHigh) <= Math.abs(yValue-nLow))
// High Wins!
yValue==nHigh;
else // Low Wins!
yValue==nLow;
}
drawLineRelative( barIndex, yValue, 10, yValue, PS_SOLID, 2, Color.blue, "Testline");
}
The line draws but the magnet part does not work..
TXs to anyone who has a suggestion! Don
function preMain()
{
setPriceStudy(true);
}
function main() {
}
function onLButtonDblClk(barIndex, yValue)
{
// CheckNear function - return the OHLC value closest to the mouse click
function CheckNear(yValue, nOpen,nClose,nHigh,nLow)
{
// Is click closer to High or Low?
if (Math.abs(yValue-nHigh) <= Math.abs(yValue-nLow))
// High Wins!
yValue==nHigh;
else // Low Wins!
yValue==nLow;
}
drawLineRelative( barIndex, yValue, 10, yValue, PS_SOLID, 2, Color.blue, "Testline");
}
Comment