Page 1 of 1

Calculate week/day highest/lowest on minute bar chart

Posted: Sep 13 2013
by Lily
Hi,
I have a question that I hope I can get some help with.
I've used some other automated trading platforms before, and if I used minute bar chart but my trading signal depended on day/week highest/lowest line, I should use a built-in function to convert the time frame of the bar. The aim of this is to trade intraday.
I don't know whether I need to write some functions to reach it with multicharts. Does multicharts has a more convenient way to do that?

Thank you

Re: Calculate week/day highest/lowest on minute bar chart

Posted: Sep 13 2013
by JoshM
I've used some other automated trading platforms before, and if I used minute bar chart but my trading signal depended on day/week highest/lowest line, I should use a built-in function to convert the time frame of the bar. The aim of this is to trade intraday.
I don't know whether I need to write some functions to reach it with multicharts. Does multicharts has a more convenient way to do that?
I think you're overthinking it. Sure, you can write it in a function, but multiple functions or converting bars are not needed if you just want to track the daily (or weekly) high or low.

In pseudo-code, you could try something like:

Code: Select all

Variables:
weeklyHigh(0),
weeklyLow(99999);

// Reset variables on monday
if (DayOfWeek(Date) = 1 {Monday} ) begin
weeklyHigh = 0;
weeklyLow = 999999;
end;

weeklyHigh = MaxList(weeklyHigh, High);
weeklyLow = MinList(weeklyLow, Low);

Re: Calculate week/day highest/lowest on minute bar chart  [SOLVED]

Posted: Sep 13 2013
by Lily
Hello JoshM, your reply inspired me greatly, thank you. Your code indicates weekly high and low clearly.
Further, if I want to retreat a few weeks/days further in every different day, for example, if today is Wednesday, then I want to calculate the high/low from last Wednesday or the Wednesday a few weeks ago. Still using minute bar chart.
Will the code become more complicated?

Thank you!