Customized Trading session
Forums › ProRealTime English forum › ProOrder support › Customized Trading session
- This topic has 11 replies, 4 voices, and was last updated 5 years ago by solar.
-
-
05/24/2019 at 9:36 AM #99319
Hi everyone,
I am new to prorealcode.
I have an strategy which trades on price levels using previous trading session’s open, high, low, close. The CFD market may trade 24hrs a day, yet i would only use price information between 0915-0100 (1 complete session)to calculate my price levels.
I wonder if there is anyway on coding that could help me automatically store the values using the concept of “previous session”and tackle the issues during weekend(price level on monday would be based on Friday’s OHLC)
05/24/2019 at 9:41 AM #9932005/24/2019 at 10:03 AM #99324I am sorry. is the coding charts based? which means if I display 0915-0100 on the chart then my orders would only be able to execute during 0915-0100?
If so the next question are there any keywords/ functions (e.g.similar to dhigh[0]) for me to store previous 0915-0100 session’s OHLC.
Many thanks!
05/24/2019 at 10:27 AM #99330Do you want this as an indicator or as part of a auto strategy?
I have moved your topic to the ProOrder forum which is for auto-trading questions. You posted in the General Trading Discussion forum which is not the right place for these sort of questions. Please try to post in the correct forum with future topics. 🙂
05/24/2019 at 10:34 AM #9933505/24/2019 at 11:25 AM #99348You can do something like:
123456789101112131415161718192021starttime = 091500endtime = 130000if time = starttime thenop = openlo = lowhi = highendifif time = endtime thenlastop = oplastcl = cllasthi = hilastlo = locl = closeendifif time >= starttime and time < endtime thenhi = max(hi,high)lo = min(lo,low)endifNot tested.
Use lastop, lastcl, lasthi and lastlo in your code to get the open, close, high and low for the previous session.
make sure the chart you use has candles that represent any time that you choose. So you need a 15 minute chart or faster to see 0915.
05/25/2019 at 4:10 AM #99405Thanks for your idea.
However, when a new trading day begins (i.e. 0915), lastop, lasthi, lastlo, lastcl would be replaced by new OHLC of the new trading day.
Let’s say the market run from 0915-0100 the next day, from monday to saturday, and let’s call monday 0915-tuesday 0100 as day1, …., until friday 0915 – saturday 0100 as day 5.
What I want to do is:
day2 would trade on OHLC of day1
day3 would trade on OHLC of day2
day4 would trade on OHLC of day3
day5 would trade on OHLC of day4
day1 would trade on OHLC of previous day5
in this case I need a set of functions to read OHLC of the previous “day”.
05/25/2019 at 7:21 AM #99406Which is exactly what the code I wrote should do. At the endtime it stores the sessions OHLC as lastop, lastcl, lasthi, lastlo whereas op, cl, hi and lo are the current sessions OHLC.
It needs just a small modification to be certain that it avoids any Sunday data but if your start time does not exist on a Sunday chart then it will ignore them any way.
I’ve not tested it but I can’t see any reason why it would not be doing what you want.
05/29/2019 at 5:58 PM #99680I finally had a chance to test it and there was a minor error. This code does what you asked for:
123456789101112131415161718192021222324252627starttime = 090000endtime = 130000if opentime = starttime thenop = openlo = lowhi = highendifif opentime = endtime thenlastop = oplasthi = hilastlo = lolastcl = closeendifif opentime >= starttime and opentime < endtime thenhi = max(hi,high)lo = min(lo,low)endifbuy at -close stopgraphonprice lastop as "open"graphonprice lastcl as "close"graphonprice lasthi as "high"graphonprice lastlo as "low"Remove the ‘buy at -close stop’ when you adapt it for your strategy as that code is just for testing to prove the values are correct.
1 user thanked author for this post.
05/30/2019 at 1:16 AM #99686hi
Thanks a lot for your effort. I will definitely try it out.
However I want to catpure the price movement (OHLC) from 915am to 1am the next day . On this regard , line 17 would not function as time could not be larger than 091500 and smaller than 010000 at the same time . Any solution to it ?
Many thanks !
05/30/2019 at 1:21 AM #99688Replace AND with OR.
1 user thanked author for this post.
05/31/2019 at 2:15 AM #99736 -
AuthorPosts
Find exclusive trading pro-tools on