Understanding Runtime Code Execution

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #196023 quote
    PeterSt
    Participant
    Master

    Indeed there is still more in this one …

    The mistake I made is thinking that the “hit” just depends on the price, and when the price is met, you have the order (out or in). You actually steer us in the same direction with your last post. But it is different …

    Where it gets exciting is how the price is known at whatever level because *that* is what causes the trailing. Thus within your 1 hour etc. bar length there’s trailing up and it should be at the point or pip(ette) level (the minimum step of the instrument).

    If all the trades are known, the price changes are also known. And that is sufficient to do it (I think it is allowed to call that ticks). But this is different from forming bar sizes of e.g. 1 second or a tick (or 5 ticks etc.).

    In the end this also relates to the time (processing power) required to build all those bars, which are max 1million bars, regardless the length of them. Thus, PRT just limits it to 1M while more is available of course.

    Is this getting somewhere now ?

    #196784 quote
    NacoNaco
    Participant
    New

    Hello, sorry for the late response. Been a bit busy.
    So I think I got the thing regarding tick data in backtests, but with the understanding of code execution I am still a bit unsure.
    Pls see this example:

    // Festlegen der Code-Parameter
    DEFPARAM CumulateOrders = True // Kumulieren von Positionen deaktiviert
    defparam preloadbars = 0
    // Das Handelssystem wird um 0:00 Uhr alle pending Orders stornieren und
    //alle Positionen schließen. Es werden vor der "FLATBEFORE"-Zeit keine
    //neuen Orderaufträge zugelassen.
    DEFPARAM FLATBEFORE = 090000
    // Stornieren aller pending Orders und Schließen aller Positionen zur
    //"FLATAFTER"-Zeit
    DEFPARAM FLATAFTER = 173000
    
    // Verhindert das Trading an bestimmten Wochentagen
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    //if close > open then
    //BUY 1 LOT AT close-20 LIMIT
    //endif
    
    BUY 1 LOT AT market

    As you can see it is a super simple example, basically between 0900 and 1730 every 15minutes a long position is opened. At 1730 all open positions are closed.
    What confuses me is that it does buy a long position already at 0900 even though I declared flatbefore 0900, so this makes me think that the code is constantly running and constantly “calling” the “BUY” function, but as long as it is before 0900 the order is not accepted, but once it strikes 0900 the order is accepted even though it comes from the run regarding the 0845 bar.
    Am I correct with this assumption? If so this is a bit problematic, because by calling FLATBEFORE I actually plan on not including data updates from before 0900.
    Thank you 🙂

    CapturePRT.png CapturePRT.png
    #196791 quote
    PeterSt
    Participant
    Master

    Your assumption is quite right.

    Put an If like this around all of your code (under the DefParam commands) :

    If Time >= 090000 and Time <= 173000 then
    
      // your code.
    
    endif

    You won’t avoid the data updates with that, but your code will not execute as a whole. And what you want to execute after all, you put outside of that If.

    NacoNaco thanked this post
Viewing 3 posts - 16 through 18 (of 18 total)
  • You must be logged in to reply to this topic.

Understanding Runtime Code Execution


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
NacoNaco @naconaco Participant
Summary

This topic contains 17 replies,
has 4 voices, and was last updated by PeterSt
3 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/22/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...