Hey guys does anyone have a nice function they can share which can be used for tracking/storing the value within a time period window? For example highest close, Highest High/Low etc. The issue I can see already with the way EL/PL uses time in a 24:00 manner is the use of 100 for 01:00 and the fact the time window can span 2 different dates.
Haven't seen a built in function yet would be great if there was one.
nice function for recording value with time period? MC staff?
-
- Posts: 47
- Joined: 03 Jan 2023
- Been thanked: 3 times
- Polly MultiCharts
- Posts: 220
- Joined: 20 Jul 2022
- Has thanked: 1 time
- Been thanked: 59 times
Re: nice function for recording value with time period? MC staff?
Hello ScottishSpeculator,
You might try using these functions for your purpose: Here is the example of usage:
You will see the bar date and time in the Output tab in the PowerLanguage Editor.
You might try using these functions for your purpose: Here is the example of usage:
Code: Select all
once cleardebug;
if LastBarOnChart then
print (datetimetostring_ms(datetime)," | ", FormatDate("yyyy-MM-dd",datetime)+" "+FormatTime("HH:mm:ss",datetime));
-
- Posts: 47
- Joined: 03 Jan 2023
- Been thanked: 3 times
Re: nice function for recording value with time period? MC staff?
Hey, Polly how does printing these out help me? I am trying something like the code below(part of a larger strategy) but it's not really working and if your times cross dates it's getting a bit messy. Would be good if others shared their solutions or you guys could just build a function which returns a value you want within a given date and time period.
Code: Select all
inputs:myHighesthigh(0), myLowestlow(0);
vars: Pre_afternoon(False), Afternoon(False), pre_afternoon_range(0);
IF time >100 and time < 1100 then Pre_afternoon = true;
if time >1100 then Afternoon = true;
// Want to record the high and low from the pre_afternoon phase then range high-low
if Date <> Date[1] and Pre_afternoon then begin
If High > myHighesthigh then myHighesthigh = High;
If Low < myLowestlow then myLowestlow = Low;
End;
pre_afternoon_range= myHighesthigh - myLowestlow
- Polly MultiCharts
- Posts: 220
- Joined: 20 Jul 2022
- Has thanked: 1 time
- Been thanked: 59 times
Re: nice function for recording value with time period? MC staff?
ScottishSpeculator,
The possible reason might be the fact that Pre_afternoon and/or Afternoon never get the ‘False’ value.
Please try adjusting your script using this sample:
Then you can add traces in your code (print, fileappend) to find out why your strategy decided to place an order, (or not to place) in a particular case.
A general example is available in our Wiki.
The possible reason might be the fact that Pre_afternoon and/or Afternoon never get the ‘False’ value.
Please try adjusting your script using this sample:
Code: Select all
IF time >100 and time < 1100 then Pre_afternoon = true else Pre_afternoon = False;
if time >1100 then Afternoon = true else Afternoon = False
A general example is available in our Wiki.
-
- Posts: 47
- Joined: 03 Jan 2023
- Been thanked: 3 times
Re: nice function for recording value with time period? MC staff?
Polly OK ill try this out but still a function from one of your development /coding staff would be nice to post here. One which takes in a date range/ time period and variable like high/low/highesthigh/lowestlow/highestclose/lowestclose//indicator value and outputs the desired value
- Polly MultiCharts
- Posts: 220
- Joined: 20 Jul 2022
- Has thanked: 1 time
- Been thanked: 59 times
Re: nice function for recording value with time period? MC staff?
ScottishSpeculator,
You might try creating such a function yourself or contact our developer partners for their coding services.
Our users can also share their tips and experience on that matter.
You might try creating such a function yourself or contact our developer partners for their coding services.
Our users can also share their tips and experience on that matter.