Find Highs and Lows in a specific time period
Forums › ProRealTime English forum › ProBuilder support › Find Highs and Lows in a specific time period
- This topic has 11 replies, 3 voices, and was last updated 4 years ago by Vonasi.
-
-
04/13/2020 at 1:53 PM #125934
Hi I am wanting to develop a strategy that works manually but requires a specific time period to be monitored, but I amd not sure how to do this. For example:
Period to monitor (GMT) 10.00am to 11.00am
During that period I want to establish the highest point and the lowest point10am – 11am Highest Price
I would then enter the market long (If the trend is up) any time after 11am up until market close at the break of the highest price.
So in summary I need to find the highest and lowest prices between a specified time period and then set the entry points at the low or the high once these levels are broken after the end onf the monitoring period e.g. after 11am (say) and before market close.
Please see the annotated screen shot attached.
I hope this makes sense?
Thanks in anticiapation
04/14/2020 at 2:05 PM #126093Hi,
Unfortunately I cannot test it with realtime data since I don’t have it, but this indicator does just that. You select a start day of the month and a span on how many days it should monitor, once the monitor is over finds the highest and lowest and creates and indicator of those two values. You can probably try changing from Day to Hours and have a look if it works for you.
Once you have the indicator it is pretty easy to backtest it. Hope this helps.
1 user thanked author for this post.
04/14/2020 at 2:15 PM #126098Something like this perhaps.
1234567891011121314151617181920starttime = 100000endtime = 110000if opentime = starttime thenhh = highll = lowendifif time > starttime and time <= endtime thenhh = max(high,hh)ll = min(low,ll)endifif not onmarket and time > endtime and (your long filter is true) thenbuy 1 contract at hh stopendifif not onmarket and time > endtime and (your short filter is true) thensellshort 1 contract at ll stopendif1 user thanked author for this post.
04/14/2020 at 4:36 PM #12612804/14/2020 at 5:39 PM #126134Hi Vonassi
This seems to work ok, thanks. However it forgot (apologies my fault!) to say that I only want it to trade once per day after 11am and vilid entry until the FTSE close. it then needs to reset for the following day.
Please see my initial code for a long trade below(Please note I run it on 1 min timeframe to enter):
Highest High & Lowest Low FTSE Test312345678910111213141516171819202122232425262728293031323334353637383940414243// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 110000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 161500timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0//To Determine an Uptrend using fitkers// Filter 1 - 4 Hour Chart High > 20 EMATIMEFRAME(1 Day,updateonclose)indicator1 = ExponentialAverage[8](close)indicator2 = ExponentialAverage[20](close)c1 = (indicator1 > indicator2)TIMEFRAME(default)//Define period between 10am & 11amstarttime = 100000endtime = 110000if opentime = starttime thenhh = highll = lowendif//determines the highest high & lowest low during the periodif time > starttime and time <= endtime thenhh = max(high,hh)ll = min(low,ll)endifif not onmarket and time > endtime and c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENbuy 1 contract at hh+1 stopendif// Stops and targetssl=ll-(hh-ll)SET STOP pLOSS slSET TARGET pPROFIT 3004/14/2020 at 7:15 PM #126147Perhaps like this? Not tested and I’ve had a couple of glasses of wine!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 110000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 161500timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0//To Determine an Uptrend using fitkers// Filter 1 - 4 Hour Chart High > 20 EMATIMEFRAME(1 Day,updateonclose)indicator1 = ExponentialAverage[8](close)indicator2 = ExponentialAverage[20](close)c1 = (indicator1 > indicator2)TIMEFRAME(default)//Define period between 10am & 11amstarttime = 100000endtime = 110000if opentime = starttime thenhh = highll = lowendif//determines the highest high & lowest low during the periodif time > starttime and time <= endtime thenhh = max(high,hh)ll = min(low,ll)endifif not flag and time > endtime and c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENbuy 1 contract at hh+1 stopendifif onmarket or strategyprofit<>strategyprofit[1] thenflag = 1endifif dayofweek <> dayofweek[1] thenflag = 0endif// Stops and targetssl=ll-(hh-ll)SET STOP pLOSS slSET TARGET pPROFIT 301 user thanked author for this post.
04/15/2020 at 8:54 AM #12620804/15/2020 at 3:35 PM #12628604/15/2020 at 3:51 PM #12628904/15/2020 at 3:54 PM #12629104/22/2020 at 9:45 AM #127410I’ve developed this code further using different conditions for detecting trends, hence confirming entry over different timeframe. However looking at the results it seems that the 1 hour momentum filter I have used seems to take a precedence i.e. several of the trades start exactly on the hour?
You will also note that I have used the “Starttime & Endtime” twice one on the default timeframe and once on the 4 hour timeframe. These conditions define the period when I want to determine the Highest Point or Lowest Point (hh &ll) during that period for my entry levels. I have done this twice as I had an anomaly where the code entered into a trade much later in the day, not at the previously defined price entry level (ll) but when the 8 ema crossed under the 20ema? This seemed to be a fix, although I didn’t understand why it would do that in the first place.
So my question to you good people is:
- Is there a preferential order in which conditions for entry observe
- Is there a better way for my trend detection filters to determine downtrend i.e.
- Check 4 Hour period for 8EMA < 20 EMA
- Check 20 hour OBV > 20 EMA
- 3 Check 1 Hour Momentum >horizontal zero line
- THEN enter at previously determined entry level at ll ONCE per day only
Hope this makes sense and I have loaded up my current FTSE code (running on 1 min chart) and the screenshot of the results
Steve
FTSE Short Trade On Downtrend and LL of 10am - 11am Period123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172//-------------------------------------------------------------------------// Main code : BBO FTSE Short 200420 - Trend filters and entry on Lowest Point within 10am to 11am Period//-------------------------------------------------------------------------// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATBEFORE = 110000// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 174500// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 110000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 161500timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0//Period during which the hh & ll are determinedstarttime = 100000endtime = 110000//Filters to determin downtrendtimeframe (4 hour ,updateonclose)starttime1 = 100000endtime1 = 110000if opentime = starttime1 thenendifif time > starttime1 and time <= endtime1 thenendifindicator1 = ExponentialAverage[8](close)indicator2 = ExponentialAverage[20](close)c1 = (indicator1 < indicator2+50)timeframe(20 hour,updateonclose)indicator9 = OBV(close)indicator10 = ExponentialAverage[16](OBV(close))c10 = (indicator9 < indicator10 -250 )timeframe (1 hour, updateonclose)indicator11 = Momentum[12](close)c11 = (indicator11 <= 0)indicator12 = Momentum[12](close)c12 = (indicator12 <= indicator12[1])timeframe (default, updateonclose)if opentime = starttime thenhh = highll = lowendif//determines the highest high & lowest low during the periodif time > starttime and time <= endtime thenhh = max(high,hh)ll = min(low,ll)endif//Long Entryif not flag and time > endtime and endtime1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry and c1 and c10 and c11 and c12 THENsellshort 1 contract at ll-1 stopendifif onmarket or strategyprofit<>strategyprofit[1] thenflag = 1endifif dayofweek <> dayofweek[1] thenflag = 0endif// Stops and targets//sl=ll-(hh-ll)sl = 55//62//x1tp = 55//70//y1SET STOP pLOSS slSET TARGET pPROFIT tp04/22/2020 at 10:19 AM #127416I’ve only glanced at it but this does not look right:
123timeframe (4 hour ,updateonclose)starttime1 = 100000endtime1 = 110000The four hour chart will have candles at 000000 040000 080000 120000 and so there is no 100000 candle.
-
AuthorPosts
Find exclusive trading pro-tools on