Whats wrong here? - Thanks for help

// Setze die Handelsregeln
Buy = BarIndex() == Year() AND BarIndex() == 0;
Sell = BarIndex() == Year() AND BarIndex() == 8;

// Setze die Handelsgröße und andere Parameter
PositionSize = -1; // Eine Position gleich dem gesamten Kapital
SetOption("MaxOpenPositions", 1); // Nur eine Position gleichzeitig erlauben

// Definiere das Open-Preis-Kriterium für den Kauf

// Definiere das Close-Preis-Kriterium für den Verkauf
SellPrice = Close;

// Drucke die Trades auf dem Chart
EnableTextOutput(True);

// Plotte Buy-Signale auf dem Chart
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone), colorGreen, 0, Low, -15);
// Plotte Sell-Signale auf dem Chart
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone), colorRed, 0, High, -15);

For starters, this makes no sense at all and will never be true:

``````Buy = BarIndex() == Year() AND BarIndex() == 0;
Sell = BarIndex() == Year() AND BarIndex() == 8;
``````

However, there's really no way to tell what's "wrong", because you've given us no idea what you are trying to do. Please see How to ask a good question

2 Likes

Sorry - my idea is to buy at the first tradingday (not the first day of a year) and to sell at XX-tradingday like tradingday 8

Therefore i think i have to work with BarIndex.

No, you don't need BarIndex for that. Something similar to this should work:

``````// isStartOfYear will be true on the first trading day of each year
yr = Year();
isStartOfYear = yr != Ref(yr, -1);

// Buy on 1st trading day of the year, Sell on 8th (not 7th!) trading day of the year
``````
4 Likes

Thanks a lot I will try -

I did not get running this system!

Again you have provided no details, nor any updated code, so there is no way for anyone to help you. I suggest you review this post: How do I debug my formula?

1 Like

When posting the formula, please make sure that you use Code Tags (using `</>` code button) as explained here: How to use this site.

Code tags are required so formulas can be properly displayed and copied without errors.