> For the complete documentation index, see [llms.txt](https://fto-2.gitbook.io/fto-indicators-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fto-2.gitbook.io/fto-indicators-docs/tutorial-create-indicator-with-cursor/step-5-start-building.md).

# Step 5: Build your first indicator

Implement a complete moving average, compile it, and upload the result to FTO.

## What you will have when finished

* A moving-average indicator using inputs, one buffer, and one plot
* A successful `npm run build`
* `dist/my-indicator-project.js` ready for [Upload indicator to FTO](/fto-indicators-docs/open-and-upload-indicator/upload-indicator-to-fto.md)

## Reference implementation

```typescript
import {
    Indicator,
    IndexBuffer,
    InputNumber,
    PenStyle,
    PlotType
} from 'forex-tester-custom-indicator-api'

export default class MovingAverageIndicator extends Indicator {
    public Period!: InputNumber
    public Buffer!: IndexBuffer

    public override OnInit(): void {
        this.api.SetIndicatorShortName('Moving Average')
        this.Period = this.api.CreateIntegerInput('Period', 14, 1, 500)
        this.Buffer = this.api.CreateBuffer()
        this.api.SetPlotCount(1)
        this.api.CreatePlot(
            0, this.Buffer, 'MA', PlotType.LINE, PenStyle.SOLID, 1, '#2962FF'
        )
        this.api.SetPlotDrawBegin(0, this.Period.value - 1)
    }

    public override OnParamsChange(): void {
        this.api.SetPlotDrawBegin(0, this.Period.value - 1)
    }

    public override OnCalculate(index: number): void {
        if (index + this.Period.value > this.api.Bars()) return
        let sum = 0
        for (let offset = 0; offset < this.Period.value; offset += 1) {
            sum += this.api.Close(index + offset)
        }
        this.Buffer.setValue(index, sum / this.Period.value)
    }
}
```

Bar index `0` is the newest bar, so lookback uses `index + offset`. Read [bar indexing](/fto-indicators-docs/api-reference/current-symbol/bar-indexing.md) before adapting the loop.

## Build and upload

```bash
npm run build
```

Then follow [Upload indicator to FTO](/fto-indicators-docs/open-and-upload-indicator/upload-indicator-to-fto.md).

## Next step

Review [recommendations](/fto-indicators-docs/tutorial-create-indicator-with-cursor/recommendations.md) before starting a second indicator.
