how to get index of bar pointed by mouse

All posts which do not fit into any other sections of the forum.

Moderator: admin

how to get index of bar pointed by mouse

Postby davidxiao » Fri Sep 07, 2018 2:03 pm

Hi all,

I am writing an indoctor, in the indictor, I need the parameters of candle when I use mouse to point it. How can I get the index of bar pointed by mouse?

Thanks,
David Xiao
davidxiao
 
Posts: 51
Joined: Tue Jul 15, 2014 9:37 am


Re: how to get index of bar pointed by mouse

Postby davidxiao » Sat Sep 15, 2018 12:43 pm

Hi Apprentice,

thanks for your fast reply, I referred to the code, but I cannot get the index of the bar pointed by mouse, could you please check out what's wrong with my codes? I got massege"core.findDate ". in this indictor, I need the index and the parameters of a bar pointed by my mouse. some of codes are as following:
function Prepare(nameOnly)
Period = instance.parameters.Period;
source = instance.source;
first = source:first();

SD=0; --SD means starting bar date
ED=0; --ED means ending bar date
local name = profile:id() .. "(" .. source:name() .. ")";
instance:name(name);


instance:ownerDrawn(true);

require("storagedb");
db = storagedb.get_db(tradeItem .. name);

core.host:execute("addCommand", 1, "Start Date");
core.host:execute("addCommand", 2, "End Date");
core.host:execute("addCommand", 3, "Reset");

core.host:execute("setTimer", 10, 1);

Tlabel= instance:createTextOutput ("", "TG", "Arial", 10, core.H_Center, core.V_Bottom, instance.parameters.clr1, 0);

SD=db:get( "SD", 0);

ED=db:get( "ED", 0);

index1=core.findDate (source, SD, false);
index2=core.findDate (source, ED, false);

local o1=source.open[index1];
local h1=source.high[index1];
local L1=source.low[index1];
local c1=source.close[index1];
[code][/code]

function AsyncOperationFinished(cookie, success, message)

if cookie== 1 or cookie == 2 or cookie == 3 then
level, date = string.match(message, pattern, 0);

if cookie == 1 then
db:put("SD", tostring(date));

elseif cookie == 2 then
db:put("ED", tostring(date));

elseif cookie == 3 then
db:put("ED", tostring(0));
db:put("SD", tostring(0));
end

end

if cookie == 10 then
SD=tonumber(db:get( "SD", 0));
ED=tonumber(db:get( "ED", 0));
end


end

Could you please help me out?

Thanks and Regards,
David Xiao
davidxiao
 
Posts: 51
Joined: Tue Jul 15, 2014 9:37 am


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests