Перейти к содержимому


Amibroker Afl Code Verified -

// --- 7. VISUAL VERIFICATION TOOL --- Plot(C, "Price", colorBlack, styleCandle); Plot(PrevHigh, "Breakout High (Prev)", colorGreen, styleDots); Plot(PrevLow, "Breakout Low (Prev)", colorRed, styleDots); PlotShapes(IIf(Buy, shapeUpArrow, shapeNone), colorGreen, 0, L, -30); PlotShapes(IIf(Short, shapeDownArrow, shapeRed), colorRed, 0, H, -30);

// Short Exit: Close above entry price plus ATR multiple Cover = C > (ValueWhen(Short, C, 1) + (ATR_Mult * ATR_Val));

Plot(Equity(1), "Recalculated Equity", colorRed, styleOwnScale); If this red line deviates significantly from your backtest equity, your code is leaking future information. Professional verifiers add timestamps: amibroker afl code verified

// --- 3. CALCULATIONS (Using Ref() to kill future bias) --- // Verified: We use PREVIOUS bar's high/low to generate TODAY's signal PrevHigh = Ref(HHV(H, Periods), -1); PrevLow = Ref(LLV(L, Periods), -1);

Notice how the verified version explicitly zeros out all action arrays at the top of the bar. If your code uses PositionScore (for ranking), verified code ensures it never produces Null : // --- 7

// --- 5. EXITS (Volatility stop - Verified to prevent re-entry) --- Sell = Buy = 0; // Reset overrides Cover = Short = 0;

// --- 6. POSITION SCORING (Null-safe) --- PositionScore = Nz(RSI(), 50); // If RSI is Null, default to 50 PositionScore = IIf(PositionScore < 0, 10, PositionScore); // Sanity check CALCULATIONS (Using Ref() to kill future bias) ---

By applying the verification checklist in this article—syntax, logic, future leaks, and position management—you transform from a code collector into a disciplined quantitative trader.