I have a simple indicator I use for a strategy. I draw the high and low of a 30 min candle on a 1 min chart at the close of the 30min candle.
If the price action is closer to the bottom/top of the range I draw an arrow pointing to the line it is Furthest from. This works brilliantly in the indicator debugger and in Marketscope. However in the back-tester I get some odd behaviour. I would say it works 95% of the time. Please NOTE: The strategy in the backtester uses the correct value from the indicator, it is only the display of the indicator that doesn't work from time to time, which makes it hard to validate results.
I have attached an example of the sample screenshots from marketscope and the backtester. Note the same 1min candle validates too different sides of the range, in the backtester display this is incorrect.
can you see what I am doing wrong from the code sample below? or am I missing some setting in the backtester?
- Code: Select all
h = (high - close)/source:pipSize(); -- distance from top range
l = (close - low)/source:pipSize(); -- distance from bottom range
p = (high - low)/source:pipSize(); -- pip range
c = p*(instance.parameters.Percentage/100); -- pip amount of percentage of range
-- added to record at current candle close if we are near the top or the bottom of the range (not both)
-- at end of range time see if we are nearer the top or the bottom set one - verify the opposite of the one its closest too
if (neartop == false) and (nearbottom == false) and (source:date(period) >= adjustedtime) and extended == nil and not(rangeverified) then
-- furthest from the top than bottom
-- distance from bottom must be greater than retrace percentage
if (l > h) and (l > c) then
-- its near the top, so bottom verified
neartop = true;
--nearbottom = false;
if not(instance.parameters.RunningInStrategy) then
-- NOTE: paste the picture on the previous closed candle as this is the one its based on.
Short:set(period-1, source[period-1], "\234"); --change the symbol to something else
end
end
-- furthest from the bottom than top
-- distance from top must be greater than retrace percentage
if (h > l) and (h > c) then
-- if its not near top it must be near bottom
--neartop = false;
nearbottom = true;
if not(instance.parameters.RunningInStrategy) then
-- NOTE: paste the picture on the previous closed candle as this is the one its based on.
Long:set(period-1, source[period-1], "\233"); --change the symbol to something else
end
end
end