Setting highest of several bars
Forums › ProRealTime English forum › ProOrder support › Setting highest of several bars
- This topic has 1 reply, 2 voices, and was last updated 5 years ago by
robertogozzi.
-
-
04/12/2020 at 5:02 AM #125747
One of the example systems in the PRT manual uses simple 2 bar breakout by setting the high and low of the first two bars of a trading day. How would I change that to using the first 4 bars from the given start time? Any help would be greatly appreciated as my programming skills are still very basic!
The relevant part of the code from their manual is as follows (itf is attached):
2 bar breakout1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374DEFPARAM PreLoadBars = 0// The position is closed at 9:45 p.m., local market time (France).DEFPARAM FlatAfter = 234500// No new position is taken after the candlestick that closes 5:15 p.m.LimitEntryTime = 201500// The market analysis strats at the 15-minute candlestick which closes at 9:30 a.m.StartTime = 133000// Some holidays such as the 24th and 31st of December are excludedIF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day =31)) THENTradingDay = 0ELSETradingDay = 1ENDIF// Variables which can be adapted based on your preferencesPositionSize = 1AmplitudeMax = 58AmplitudeMin = 11OrderDistance = 4MinPercent = 30// We initialize this variable once at the beginning of the trading system.ONCE StartTradingDay = -1// The variables which can change during the day are initialized// at the beginning of each new trading day.IF (Time <= StartTime AND StartTradingDay <> 0) OR IntradayBarIndex = 0 THENBuyLevel = 0SellLevel = 0BuyPosition = 0SellPosition = 0StartTradingDay = 0ELSIF Time >= StartTime AND StartTradingDay = 0 AND TradingDay = 1 THEN// We store the index of the first bar of the trading dayIndexStartDay = IntradayBarIndexStartTradingDay = 1ELSIF StartTradingDay = 1 AND Time <= LimitEntryTime THEN// For each trading day, the highest and lowest price of the instrument// are recorded every 15 minutes since StartTime// until the buy and sell levels can be definedIF BuyLevel = 0 OR SellLevel = 0 THENUpperLevel = Highest[IntradayBarIndex - IndexStartDay + 1](High)LowerLevel = Lowest [IntradayBarIndex - IndexStartDay + 1](Low)// Calculation of the difference between the highest// and lowest price of the instrument since StartTimeDayDistance = UpperLevel - LowerLevel// Calculation of the minimum distance between the upper level and lower level// to consider a breakout of the upper or lower level to be significantMinDistance = DayDistance * MinPercent / 100// Calculation of the buy and sell levels for the day if the conditions are metIF DayDistance <= AmplitudeMax THENIF SellLevel = 0 AND (Close - LowerLevel) >= MinDistance THENSellLevel = LowerLevel + OrderDistanceENDIFIF BuyLevel = 0 AND (UpperLevel - Close) >= MinDistance THENBuyLevel = UpperLevel - OrderDistanceENDIFENDIFENDIF// Creation of buy and sell short orders for the day if the conditions are metIF SellLevel > 0 AND BuyLevel > 0 AND (BuyLevel - SellLevel) >= AmplitudeMin THENIF BuyPosition = 0 THENIF LongOnMarket THENBuyPosition = 1ELSEBUY PositionSize CONTRACT AT BuyLevel STOPENDIFENDIFIF SellPosition = 0 THENIF ShortOnMarket THENSellPosition = 1ELSESELLSHORT PositionSize CONTRACT AT SellLevel STOPENDIFENDIFENDIFENDIF04/12/2020 at 8:58 AM #125752There are some simple rules that everyone using the forums is expected to follow. Your post has broken one or more of these rules (highlighted).
The forum rules are as follows. I have HIGHLIGHTED in bold the rule/rules that you have not followed:
• Post your topic in the correct forum:
ProRealTime Platform Support (only platform related issues)
ProOrder (only strategy topics)
ProBuilder (only indicator/oscillator topics)
General Discussion (any other trading related topics)
Welcome New Members (for new forum members to introduce themselves.
• Only post in the language of the forum that you are posting in. English only in the English speaking forums and French only in the French speaking forums, etc…. for example.
• Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
• Do not double post. Ask your question only once and only in one forum once you have chosen your preferred language. All double posts will be deleted anyway so posting the same question multiple times (eben using
different languages) will just be wasting your own (and moderators’) time and will not get you an answer any quicker. Double posting would imply spreading answers across multiple topics making it more difficult
searching them.
• Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if
there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
• Do not post personal info (email address, website, home/office address, phone number, etc…). Should you need to contact someone or anyone interested in contacting shall use the contact form to ask Admin’s permit.
• Be polite and courteous to others.
• I have edited your post. Please ensure that your future posts meet these few simple forum rules.
• Have fun.
Thank you 🙂
-
AuthorPosts
Find exclusive trading pro-tools on