// 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
BuyPrice = Open;
// Definiere das Close-Preis-Kriterium für den Verkauf
SellPrice = Close;
// Drucke die Trades auf dem Chart
EnableTextOutput(True);
Filter = Buy OR Sell;
//AddTextColumn("BarNum", BarIndex(), 1.0, colorDefault, colorDefault);
AddColumn(DateTime(), "Trade Time", 1.0, colorDefault, colorDefault);
AddColumn(ROC(C,1), "Daily Performance", 1.2);
// 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
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
Buy = isStartOfYear;
Sell = BarsSince(isStartOfYear) == 7;
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?