Backtest Trade entry exit lagging on daily chart
Forums › ProRealTime English forum › ProOrder support › Backtest Trade entry exit lagging on daily chart
- This topic has 10 replies, 3 voices, and was last updated 1 month ago by
NeoTrader.
-
-
05/14/2025 at 10:05 PM #247142
Backtest Trade entry exit lagging on daily chart?
Hey there coders…
I am seeing a delay in the triggered trade entry / exit logic vs the actual entry or exit…. see attached.
You can see on the attached as the vertical line is aligned to the entry/exit logic (crossing), and the actual entry on the price chart is the next bar!
Using BARINDEX reduced the lag from 2 bars to 1 bar!!!
I wonder if this is the norm, when using a daily chart, or the code needs tweaking ?Code attached in txt file…
As always, all comments welcome 🙂
NT
BTW: stop loss issues resolved. See 3 panel (Variables) aligns with entry exit types, happy days 🙂
05/15/2025 at 8:47 AM #247148I think the short answer here is that the backtest module only uses the closed OHLC values, this puts it approximately 1 bar behind the price to start off with. This can be observed , if I remember right, with the lines drawn from the backtest using the GRAPH commands, they only draw to the last closed bar.
Additionally, the code only updates once a bar, so if the last closed bar has the true entry condition in it, then it’s not until the opening of the next bar the order is executed. This though doesn’t get drawn till the execution bar becomes closed. If you graph the ‘ONMARKET’ variable. you will see that this aligns with the actually execution of the entry not the true condition point.
I can’t recall if the EQUITY and/or POSISTION plots mimic the timing and graphing of the strategy GRAPH’s or align with the price.
On a high time frame, this can be a big problem if the first minute of the day the condition is ‘true’ but the entry is delay until the next bar. Only way to counteract this is to use a lower time frame for the faster update period. This means recreating the higher time frame indicators in the lower time frame. This is were the TIMEFRAME command comes in. However, big lookback bar sizes can go beyond the capacity of the maximum 10k bars of the PRELOADBARS of the default time frame. If they do they, I can’t recall if you get a error message, or it works but give an incorrect value since there is not enough bars to do the calculation correctly.
Anyway, that’s part of the model I currently have in my head and I update it if I come across new info or get corrected by others.
05/15/2025 at 8:50 AM #24714905/15/2025 at 8:55 AM #247150I can’t recall if you get a error message,
Yes, we get an error message, something like … ‘insufficient historical data to calculate an Indicator’.
05/15/2025 at 12:13 PM #247154I think the short answer here is that the backtest module…
Hey there druby,
That makes a lot of sense… and nicely explained
I can’t recall if the EQUITY and/or POSISTION plots mimic the timing and graphing of the strategy GRAPH’s or align with the price. <<< I’ll explore this, and see if this changes anything…I’ll stick with the Daily, for now…
and i might code another template version of the backtest to look at other time frames…
Thank you, for you input, it is much appreciated….
NT05/15/2025 at 12:26 PM #247155GraHal
Hey GraHal,
Yep, that was/is my thinking, as I am using the daily….
I thought I should ask those (you and druby) for your experience with this platform, to save me from code entanglement!!!
Thank you for your valid and appreciated input!Aside.
AIM code support wise….
I fed system instructions and the PRT PBC A-Z glossary to Amazon Q (AIM) yesterday, and I have crossed checked the code output examples, via CGPT, and a specialist AIM:ProRealTime Code, By autotrading.ee….
So far, the code output results are interesting, and as of yet, there are no conflicts in the code either…Onwards I go…Thank you for your support, as always, it is much appreciated.
NT1 user thanked author for this post.
05/15/2025 at 12:26 PM #247156I can’t recall if you get a error message,
Yes, we get an error message, something like … ‘insufficient historical data to calculate an Indicator’.
Noted…. Thank you….
NT05/15/2025 at 12:42 PM #247158ProRealTime Code, By autotrading.ee…. So far, the code output results are interesting, and as of yet, there are no conflicts in the code either…
- So are you quoting above from a statement on autotrading.ee ??
OR
2. Are you saying you obtained code from autotrading.ee?
1 user thanked author for this post.
05/15/2025 at 1:40 PM #247160ProRealTime Code, By autotrading.ee…. So far, the code output results are interesting, and as of yet, there are no conflicts in the code either…
So are you quoting above from a statement on autotrading.ee ??- OR
2. Are you saying you obtained code from autotrading.ee?
Hey GraHal,
I have just looked thru my AIM DB, and I have engaged the AI.ee directly = useless.
But, via the CGPT website: https://chatgpt.com/g/g-6WBXOWXx2-prorealtime-code < you might have to search for said code (prorealtime code) in the CGPT models (far left).the code results are pretty amazing…. plus i am running the code thru AmazonQ via VS Code interface, and AQ, confirms the coding, and explains clearly the syntax and code process in use .
Happy days….NT
05/15/2025 at 3:36 PM #247168plus i am running the code thru AmazonQ via VS Code interface,
So does above mean you are running PRT code through / on AmazonQ website via a Visual Studio Code interface?
If Yes to above, is it all free or are you paying subscription fees?
1 user thanked author for this post.
05/15/2025 at 3:48 PM #247169plus i am running the code thru AmazonQ via VS Code interface,
So does above mean you are running PRT code through / on AmazonQ ……………
Yep.
AQ via VS Code…. no cost to use VC Code, and currently AQ is not charging me !!!
It is a good AIM, and useful as you can preload the A-Z glossary into the file explorer in VS Code, and explicit AI instructions also….BUT, Better than that, is the PRC via CGPT.
The freebie session is great as a taster….
I have just signed back up to CGPT (£20) P/M, cancel anytime….
This PRC version is, currently, mighty impressive…. no code syntax errors, some minor tweaks.
I have also discovered the AIM to also have the code syntax for ProBuilder, ProScreener also….As with all AIM, I await to see how soon the model begins to hallucinate, which all models do…
But, so far, so dam good !!Hit me back with any Q&A,
NT - So are you quoting above from a statement on autotrading.ee ??
-
AuthorPosts
Find exclusive trading pro-tools on