Setting highest of several bars

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #125747 quote
    Jabezz
    Participant
    Average

    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):

    DEFPARAM 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 excluded
    IF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day =31)) THEN
    TradingDay = 0
    ELSE
    TradingDay = 1
    ENDIF
    // Variables which can be adapted based on your preferences
    PositionSize = 1
    AmplitudeMax = 58
    AmplitudeMin = 11
    OrderDistance = 4
    MinPercent = 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 THEN
    BuyLevel = 0
    SellLevel = 0
    BuyPosition = 0
    SellPosition = 0
    StartTradingDay = 0
    ELSIF Time >= StartTime AND StartTradingDay = 0 AND TradingDay = 1 THEN
    // We store the index of the first bar of the trading day
    IndexStartDay = IntradayBarIndex
    StartTradingDay = 1
    ELSIF 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 defined
    IF BuyLevel = 0 OR SellLevel = 0 THEN
    UpperLevel = 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 StartTime
    DayDistance = 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 significant
    MinDistance = DayDistance * MinPercent / 100
    // Calculation of the buy and sell levels for the day if the conditions are met
    IF DayDistance <= AmplitudeMax THEN
    IF SellLevel = 0 AND (Close - LowerLevel) >= MinDistance THEN
    SellLevel = LowerLevel + OrderDistance
    ENDIF
    IF BuyLevel = 0 AND (UpperLevel - Close) >= MinDistance THEN
    BuyLevel = UpperLevel - OrderDistance
    ENDIF
    ENDIF
    ENDIF
    // Creation of buy and sell short orders for the day if the conditions are met
    IF SellLevel > 0 AND BuyLevel > 0 AND (BuyLevel - SellLevel) >= AmplitudeMin THEN
    IF BuyPosition = 0 THEN
    IF LongOnMarket THEN
    BuyPosition = 1
    ELSE
    BUY PositionSize CONTRACT AT BuyLevel STOP
    ENDIF
    ENDIF
    IF SellPosition = 0 THEN
    IF ShortOnMarket THEN
    SellPosition = 1
    ELSE
    SELLSHORT PositionSize CONTRACT AT SellLevel STOP
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    2-Bar-breakout-Original.itf
    #125752 quote
    robertogozzi
    Moderator
    Master

    There 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 🙂

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Setting highest of several bars


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Jabezz @jabezz Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
5 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/12/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...