Is it possible to code a Fixed Time Period?

Forums ProRealTime English forum ProOrder support Is it possible to code a Fixed Time Period?

Viewing 15 posts - 1 through 15 (of 25 total)
  • #166273

    Hello everyone!

    I trade the EUR/USD pair on a 1 Minute time scale.
    Could someone please let me know if it is possible to insert some code that will restrict a Back Test to always only go back for a Fixed Time period without having to reset the Time Period window each time – for example, say 30 minutes (or 30 bars) at a time up to real time? I use a crossover model to trade with and Walk it Forward one minute at a time by using Back Test in real time. But the problem is that I must quickly change the Time Period Window for every minute that passes, which takes a lot of time and effort when doing it for a few hours at a time. I will insert a simple crossover code below in case anyone might be able to show me how to add such a function – if its possible! I hope this is clear.

    Many Thanks!

    #166280

    I’m probably misunderstanding … 1 min TF 0ver 30 bars giving you what you describe above?

    No adjustment needed for each Walk Forward??

    #166282

    Btw your code gives attached … I’m setting it going on Demo Forward Test! 🙂

    #166303

    Many thanks for your quick reply GraHal!

    I like that backtest curve you show….. I have not tried it on those 10-min charts yet!
    But to be clearer, what I meant is that lets say I start my BT (or Forward Tests) at 1230 each day for example. In that case at 1230, I would set the Start time in the Time Period window to 1200 to get my 30 minutes covered for the first back test.
    Thereafter, as the next bar completes at 1231, I would need to set the Start Time to 1201 to maintain the 30-min BT period.
    Then as the next bar completes at 1232, I would have to set the Start Time to 1202….. and so on.
    This means that as each minute passes I need to open the Time Period window and must reset the start time a minute later in order to maintain the 30 mins BT period.
    So I was wondering if someone might know of a coding piece that would always maintain a 30-min period behind me as the minutes tick by? This would save me a lot of fast fiddling on the treadmill……
    Thanks.

    #166305

    To add a bit more, the W/F method I describe above is really just a Back Test and I press the BT button each time, but I was just hoping there was a way to maintain the 30-min gap (Start to Real Time) to avoid the frantic time setting in the Time Period window each time……

    #166307

    Yeah well why not use 30 bars / units at 1 minute … see attached.

    Then it would always be 30 minutes no matter what tme you start the BT or FT??

    #166310

    Thanks for that suggestion. I tried it, but it still gave me 8 hours of price data…… I even took it down to 1 unit as you can see…..

     

     

    #166319

    Ah yeah I see what you mean now!

    Another anomaly with PRT.

    #166325

    You don’t think maybe there is a way using (close)-(close) code or something else to keep the 30-min period constant as one goes forward minute by minute?

    #166329

    Yes it needs exploring, I’m not the best at coding, sorry.

    Have you tried using barindex = 0 and bar index = 30 and QUIT (on 1 min TF).

    As you are starting the BT manually (?) I think I am right in saying that the first bar would be barindex = 0.

    You can use GRAPH anyway to see a count of bars.

    Hopefully Roberto or Vonasi may read this and put us straight? 🙂

    #166333

    Thanks Grahal, I will give your ideas a play and if no joy, then I will re-post and ask those coding fundis for help.

    Many thanks!

    #166335

    Why can’t or dont you just not look at any backtest earlier than 30 mins ago and just let the BT run on in realtime?

    You could have a 30 bar ruler that you move to the right every bar if you need to?

    Or have a 30 bar horizontal line (coded in) that moves automatically to the right?

    I am intrigued why you need this strict 30 minute moving window and any bars prior to 30 min ago  must be excluded?

    I just ran a random 30 unit BT of 1 min TF and the results a are shown over the last 30 minutes. It is 19:30 now as I write this and the BT goes back to 19:00 (see red arrowheads on attached) … so we do get to see only the bars / units that we select … in this case we see 30 x 1 min bars??

    #166345

    Thanks GraHal. Now I understand what you mean about the units setting. This is a useful feature that I might use in the future, however I don’t think it will help to move afixed period forward in a W/F manner. I think I need to try some of your other ideas too. The reason I use  a moving fixed period (not always 30 mins – sometimes a few hours), is because some models can skip potential trigger points, (or they can be too sensitive) if the BT period is not optimal. Also, I have noticed that where some good models do well on the main swings, they do badly in tight ranges, losing all the time while they see-saw. In some of those cases, I increase the range of the BT variables (and its steps) to enable them to glide over the tight ranges without making too many trades, but then they need smaller fixed periods (such as 30 mins) to avoid missing triggers on the main swings. I hope that answers your questions about why I need the moving fixed period.

    1 user thanked author for this post.
    #166352

    A agree with what you say above, I’m glad I asked!  🙂

    I try and compensate by optimising often.  I’ll have a think around your methods!

    I take it you run your Algos in Backtest Real Time, but you execute trades manually?

    #166364

    Morning Gra!

    Sorry, I forgot to mention:
    One of the main reasons I sometimes use a short period of say 30 mins for BT’s is to shorten the BT duty cycle time if I need to use a wider range of variables – or when adding more variables. When using the 1-min bars time scale, its no good if each BT takes more than 30 seconds, because by the time I am ready to trigger a trade, the price sometimes has moved quite far. Yes, this method is for manual trading, but that brings me to another subject that I would like to discuss with you soon if you don’t mind – and that is how to convert the system to AUTO trading…….. that would be the ultimate. If there is any way to get this moving-forward fixed period coded, it could also possibly be used in an auto trading code.

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 25 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login