Set session start and end times for OHLC indicator

funk101

Member
Joined
Nov 19, 2023
Posts
11
Likes
0
I'm a Java newbie and I'm currently modifying the OHLC study:
The OHLC study has presets for sessions. Reg, Chart, and Ext sessions. How would I go about modifying the study to accept session start/end times? ie: New York 9:30-16:15, London 3:00 - 11:00, etc.
setStartime() or something?
Not sure of Java syntax yet, I would appreciate being pointed in the right direction. ;-)
Cheers.
 

Spin

Well-known member
Joined
May 22, 2019
Posts
480
Likes
192
I would:

  1. First ask a user for a Tiimeframe (somewhere in "Initialize", by using a 'TimeframeDescriptor'):
    Java:
    asianSession.addRow(new TimeFrameDescriptor(ASIAN_TIMEFRAME, get("Asian Session"), 01 * 60 * 60 * 1000, 9 * 60 * 60 * 1000, true, false));
  2. Use that Timeframe in one of my functions (or in CalculateValues ?) to define integers (for barIndexes) or longs (for strfTimes) for both the start- and endTimes of that Timeframe
  3. Use Java-math kungfu to have the Study iterate over all bars from startIndex to endIndex or iterate over all bars, but only take into account bars that start between startTime and endTime





EDIT: you will probably need this line too, for debugging:
Java:
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

;)
 
Last edited:

funk101

Member
Joined
Nov 19, 2023
Posts
11
Likes
0
How does MW loop? Does every study loop every bar by default? In Sierra, you have to set this explicitly with "AutoLoop=1".
 

Spin

Well-known member
Joined
May 22, 2019
Posts
480
Likes
192

danielputra

Active member
Joined
Jul 22, 2021
Posts
29
Likes
53
Hi Funk101, it seems to you looking e.g. for the opening range like the first 18 bars of the US open and related measured moves. I have coded such a study and called it "Indicate Time Frame". You can change the 18-bar range on my study via the start and end date fields and that way get the full US session too. It as options to show the midpoint and/or swap out the high/low with the highest close / lowest close.

You can find a link and guide for my studies at: https://support.motivewave.com/forum/index.php?threads/al-brooks-price-action-trading-studies.1214/
Each study has its own screenshot and explanation in the guide and the source code so you can further customise it to your needs.
 
Top