Hello,
I buy and sell based on weekly signals. If I set up a simple test system in the backtest I get buy and sell signals corresponding to Friday, at the opening price of the same day.
If the system is set to display these same signals in the explorer, they will be indicated in the same way, so buy and sell signal on Friday with the opening price of Friday itself.
The result of the backtest does not correspond to real life since we have to buy on Monday at the opening price and sell in the same way on the following Monday at the opening price.
How is it possible to correct this anomaly?
Hi Richard,
if I enter a delay condition in the code it moves everything by a week, and always buying at the opening price on Friday.
This is the code entered
the explorer indicates a buy on 3/5/2024 with the closing price
@tempera, please study this recent answer by @Tomasz to better understand what is "displayed" when using weekly or monthly bars, depending on your Amibroker settings.
now we have everything moved to Monday
buy
scan = buy Monday 4/29/2024 at 3.428 closing price
backtest = buy Monday 4/29/2024 at 3.37 opening price
sell
scan = sell 6/3/2024 at 3.38 closing price
backtest = sell 6/3/2024 at 3.4 opening price
now the backtest is correct what is missing now is how to have the signal on Friday since the scan signals me the buy/sell on Monday instead of Friday at the closing price.
how can I get the signal alert on Friday evening?
@Tomasz ' explanation, as well as many others, are difficult for me to understand 100%, since I am Italian and there is no translation of the documentation.
Automatic translators help up to a certain point, if the concepts expressed are not very simple, a sentence translated in a slightly different way is enough and the result becomes incomprehensible.
I apologize for this problem
I suggest you add a “artificial future bar” in portfolio tab of analysis settings. It works in backtest ( not sure about scan) and will show new weekly trades on Friday night in the artificial bar.
You could also set trade delays to 0 and get your signals on the Friday's close and place your trades Monday morning. (Set buy price and sell price to close.)
“artificial future bar” doesn't work, the results do not change
I tried changing the settings of:
tools - preferences - intraday - setting ON override: weekly/monthly bars etc
backtest signals move to friday, as well as scan and explorer results.
analysis settings - portfolio - add artificial bar
no changes.
"Afraid I dont use scan for trade signals."
what is the exact procedure to get buy/sell signals on friday?
Scan and explorer give the same results, which procedure should I use?
There is no anomaly at all. Dates are correct and represent WEEK boundaries
In WEEKLY BACKTEST:
the dates represent WEEKS (when week begins or ends depending on setting).
the entry and exit date represents the WEEK when trade happens. It does NOT represent actual day, because trades might happen anywhere inside bar (such as for example in the middle) and date column shows time in WEEKS, not days.
the unit of time is ONE WEEK, not individual day.
whenever entry occurred on monday, tuesday, wednesday, thursday or friday is NOT reflected in those dates, because those dates show WEEKS, not days.
As noted before you need carefully read this, use ChatGpt as a Translator to give you explanation in Italian
If you used ChatGPT as translator it would say this:
In Amibroker, la colonna Analysis Date rappresenta la data della barra di dati analizzata. Per una barra mensile, questa data può essere il 1° giorno o l'ultimo giorno del mese, a seconda delle impostazioni dell'utente. Tuttavia, indipendentemente dal fatto che venga mostrato il 1° o l'ultimo giorno, si riferisce comunque alla stessa barra mensile.
Questo significa che il timestamp descrive il mese nel suo insieme, non un giorno specifico. Ad esempio, la barra di dicembre copre tutto il periodo dal 1° al 31. Il numero del giorno indicato nella colonna Analysis Date non è rilevante per la barra mensile: serve solo a rappresentare l'intero mese. Che tu faccia trading sull'apertura o sulla chiusura del mese, resta comunque una barra mensile che riassume tutto il mese.
In Amibroker, la colonna Analysis Date rappresenta la data della barra di dati analizzata. Per una barra settimanale, questa data può essere il primo o l'ultimo giorno della settimana, a seconda delle impostazioni dell'utente. Tuttavia, indipendentemente dal fatto che venga mostrato il primo o l'ultimo giorno, si riferisce comunque alla stessa barra settimanale.
Questo significa che il timestamp descrive l'intera settimana, non un giorno specifico. Ad esempio, la barra settimanale copre tutto il periodo dal lunedì alla domenica (o in base alla configurazione della settimana). Il numero del giorno indicato nella colonna Analysis Date non è rilevante per la barra settimanale: serve solo a rappresentare l'intera settimana. Che tu faccia trading sull'apertura o sulla chiusura della settimana, resta comunque una barra settimanale che riassume tutta la settimana.
Again trying to help explain what Tomasz wrote in the Italian translated post.
In a Weekly Bar, there are "NO" days. So say current week 14-Oct-2024 to 18-Oct-2024.
This bar has only 4 Values
O = open which is surely the "Monday morning" first tick OPEN price
C = close is guaranteed last tick of "Friday evening"
But,
H and L that is, High and Low "can not" be known on which Day or which Time.
It is only guaranteed to happen from Monday morning to Friday evening.
So what we say in WEEKLY bar is Day can be anything,
This bar can be timestamp 2024-OCT (for sure) but then you can call it 14th or 15th upto 18th.
In back testing, if you choose BUY PRICE as Open, then it will be the Monday morning price. If you chose Close, it will be Friday evening closing price.
IF you use stoploss, then signal will hit if LOW went below the stoploss amount, BUT we cannot say if it was Mon/Tue/Wed/Thu/Fri.
IF you delay trade signal by 1 Bar and choose Close as Entry price, then next week (21st to 25th) the trade will be opened using Close price.
In any timeframe you choose, then you cannot "see" anything of lower timeframe from there. If you choose Daily(1 day), then you cannot see anything lower like 4-hour or 1-hour or 1 minute.
The signal to operate in weekly must arrive on Friday. If the signal arrives on Friday evening at the close I can only buy the following Monday morning, we avoid afterhours markets.
There are no other ways to operate weekly, so amibroker does not allow you to operate (buy/sell) in weekly mode
AmiBroker works just fine in weekly mode. A bar is a bar is a bar. It doesn't matter if it's a 1-minute bar, daily bar, or weekly bar. If you set your trade delays to 1, then you will enter on the bar following the Buy signal. And if your Periodicity is set to Weekly, that means your entry will occur on the next weekly bar. If your BuyPrice is set to Open, then your entry will occur at the Weekly Open price, which as @nsm51 already explained to you, will be the price at Monday's Open.
If you want more visibility into what's happening on each day, then set your Periodicity to Daily and use the TimeFrame* functions to generate weekly signals. There's lots of information in the Help files and on this forum on how to do that.
So if you trade weekly and get a buy signal on Friday do you wait until the following Friday to buy? Because that's how soft works and that's what you're telling me
That's not what I am saying, nor is it what everyone else attempting to help you is saying, and it is not how AmiBroker works.
Perhaps you are confused by the dates shown in the trade list. If you run with Weekly Periodicity in the Analysis Settings, then all the dates will correspond to Weekly bars. A bar has one and only one date, and by convention that date is the date for the end of the bar (Friday). So if you entered your Weekly trade at the open on Monday, October 7 (i.e. the Open of the Weekly Bar), then your trade list will show the date October 11, which is the date of the Weekly bar which covers October 7-11.