Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arCountInDay = yes; #input
- def EnableBarCountInDay = Enable_BarCountInDay and Market_Hours_USED;
- def Estimate_bar_numbers_in_day =if !EnableBarCountInDay then 1 else 86400 / BarFrameInSeconds;
- def Seconds_From_00__WhenDayStarts___initial =if !EnableBarCountInDay then 0 else if IsZeroFirstBar then 9999999 else
- if Seconds_From_00< Seconds_From_00__WhenDayStarts___initial[1] then Seconds_From_00 else Seconds_From_00__WhenDayStarts___initial[1];
- def Seconds_From_00__WhenDayEnds___initial = if !EnableBarCountInDay then 0 else if IsZeroFirstBar then 0 else
- if Seconds_From_00> Seconds_From_00__WhenDayEnds___initial[1] then Seconds_From_00 else Seconds_From_00__WhenDayEnds___initial[1];
- def futured_Seconds_From_00__WhenDayStarts =if !EnableBarCountInDay then 0 else if IsZeroFirstBar then 0 else
- if (futured_Seconds_From_00__WhenDayStarts[1]!=0) then futured_Seconds_From_00__WhenDayStarts[1] else
- fold DS_indx=1 to Estimate_bar_numbers_in_day*2 with DS_start=0 while DS_start==0 do
- if getvalue(Day,-DS_indx+1) != getvalue(Day,-DS_indx) then getvalue(Seconds_From_00__WhenDayStarts___initial,-DS_indx+1) else 0;
- def futured_Seconds_From_00__WhenDayEnds = if !EnableBarCountInDay then 0 else if IsZeroFirstBar then 0 else
- if (futured_Seconds_From_00__WhenDayEnds[1]!=0) then futured_Seconds_From_00__WhenDayEnds[1] else
- fold DE_indx=1 to Estimate_bar_numbers_in_day*2 with DE_start=0 while DE_start==0 do
- if getvalue(Day,-DE_indx+1) != getvalue(Day,-DE_indx) then getvalue(Seconds_From_00__WhenDayEnds___initial,-DE_indx+1) else 0;
- def Seconds_From_00__WhenDayStarts = if !EnableBarCountInDay then 0 else if IsZeroFirstBar then 9999999 else
- if !DaysPassed then futured_Seconds_From_00__WhenDayStarts else Seconds_From_00__WhenDayStarts[1];
- def Seconds_From_00__WhenDayEnds = if !EnableBarCountInDay then 0 else if IsZeroFirstBar then 0 else
- if !DaysPassed then futured_Seconds_From_00__WhenDayEnds else Seconds_From_00__WhenDayEnds[1];
- def Difference_between_START_And_END = if !EnableBarCountInDay then 0 else if !One_Day_Passed_in_Chart then 0 else
- (Seconds_From_00__WhenDayEnds - Seconds_From_00__WhenDayStarts)/60/60; #example: 8.4 - 8
- def HoursInDay___rounded = if !EnableBarCountInDay then 0 else
- rounddown(Difference_between_START_And_END,0);
- def Difference_between_rounded_and_original = if !EnableBarCountInDay then 0 else if !One_Day_Passed_in_Chart then 0 else
- (Difference_between_START_And_END - HoursInDay___rounded) * 100; #example: (8.4 - 8)*100 = 40 minutes
- def minutes_remaining = if !EnableBarCountInDay then 0 else
- if (Difference_between_rounded_and_original <= 60 ) then Difference_between_rounded_and_original else Difference_between_rounded_and_original-40; #because it swims from 0 to 100 minutes...
- def ConvertTradingPeriodIntoMilliSeconds = if !EnableBarCountInDay then 0 else if !One_Day_Passed_in_Chart then 0 else
- ( minutes_remaining * 60 + HoursInDay___rounded * 60 *60) * 1000;
- def Bars_Amount_In_1_day = if !EnableBarCountInDay then 0 else if !One_Day_Passed_in_Chart then 0 else
- roundup(ConvertTradingPeriodIntoMilliSeconds / AggrPeriod , 0 );
- #new interesting variables: detect the last bar:
- def now_Is_Last_Bar_of_day =if !EnableBarCountInDay then no else
- if !DaysPassed then no else Seconds_From_00__WhenDayEnds == secondsTill00;
- def now_Is_LastPrevious_Bar_of_day =if !EnableBarCountInDay then no else
- if !DaysPassed then no else Seconds_From_00__WhenDayEnds == Seconds_From_00 - BarFrameInSeconds;
- ### ************************************************************* ###
- def use_pre_lastdaybar_detection = yes;
- def THIS_Is_Last_Bar_of_day = EnableBarCountInDay AND (now_Is_Last_Bar_of_day OR Last_Bar_Of_Market OR (use_pre_lastdaybar_detection and (!IsNan(close[-1]) and !IsNan(IsNewDay[-1]) and IsNewDay[-1])));
- def THIS_Is_LastPrevious_Bar_of_day = EnableBarCountInDay AND (now_Is_LastPrevious_Bar_of_day OR LastPrevious_Bar_Of_Market);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement