Tradingday in the year

Hello,

I would like to be able to display a performance exploration for each trading day.
This exploration should start every year on the first trading day and finish on the last trading day.

In the new year this should start again at 1.

The idea is to look how was the performance on the 90 or the 110 trading day of the year in historical comparison.

Thanks a lot

yr = Year();
new_yr = yr != Ref(yr,-1);
dd = BarsSince(new_yr)+1;

Filter = dd == 90 OR dd == 110;

AddColumn(dd, "Trading Day of Year", 1);
AddColumn(ROC(C,1), "Daily Performance", 1.2);

Thank you very much - its working! I am Happy

Hello,
another question: I would like to measure the performance of the first 100 trading days or variable XX trading days, if it is greater than XX % then buy on 102 trading day or XX variable trading day and sell on the last trading day.

I think it is simple - but still too difficult for me as a beginner.

Thanks a lot

You already have 50% of your question as answer in upper code.

So something along these lines...

yr = Year();
new_yr = yr != Ref(yr,-1);// new year start
dd = BarsSince(new_yr)+1;// # of trading days

start_price = ValueWhen(new_yr, Open);// price at year start
performance = (Close - start_price) / start_price * 100;

SetTradeDelays(0,0,0,0);

Buy = Ref(dd == 100 AND performance > 10, -1);
Buyprice = Open;

Sell = Ref(new_yr, 1);// Sell at year end
Sellprice = Open;
2 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.