millionchart
فارسی

Sample programs

Complete programs to copy into the editor, from a plain average to sessions and tables, each one tested on real bars and explained in a few lines.

These are complete programs, written for this guide: indicators, and on the last page strategies. Each one is compiled and run on real bars of the chart every time the guide is built, so a program that stops working is found and fixed. Copy one into a new script, press Save and Add to chart, then change it: changing a working program is the quickest way to learn.

ProgramWhat it teachesPage
Simple moving averagethe header, an input, a plotMoving averages and trend
Two averages with cross markscrossings and marksMoving averages and trend
Trend backgrounda colour per bar, the backgroundMoving averages and trend
Trend candlesrecolouring the candlesMoving averages and trend
Distance from the averagearithmetic, a histogramMoving averages and trend
An average from a higher timeframedata.seriesMoving averages and trend
RSI written outearlier bars, running means, levelsOscillators
RSI with zones and marksa shaded zone, marks on a levelOscillators
MACDthree values from one functionOscillators
Stochastic oscillatorhighest and lowest over a windowOscillators
Bars since a highstate, a value kept between barsOscillators
Bollinger bandsstandard deviation, a shaded bandChannels and levels
ATR channelthe average true rangeChannels and levels
Donchian channelthe extremes of a windowChannels and levels
Daily pivot levelsyesterday's high, low and closeChannels and levels
Key levelsyesterday's range and the week's openChannels and levels
Recent range drawingboxes, lines and labelsChannels and levels
Session range boxesa named session and its membersSessions, patterns and volume
Opening rangea range built during a sessionSessions, patterns and volume
Inside barsa candle patternSessions, patterns and volume
Swing pivotsswings and labelsSessions, patterns and volume
On-balance volumea running total of volumeSessions, patterns and volume
Volume spikesvolume against its averageSessions, patterns and volume
Status tablea table in the cornerSessions, patterns and volume
Moving average crossoversetup:, enter and close by keyStrategies
RSI reversionentry and exit on two conditionsStrategies
Donchian breakouta pending stop entry, expires, an exit stopStrategies
ATR stop and targeta stop and a limit placed with the entryStrategies
Risk guardsrisk.max_daily_orders, risk.max_losing_daysStrategies
Opening range breakouttwo sessions, state, long and short, closing at the session endStrategies
Inside bar breakoutexpires, profit_ticks and loss_ticksStrategies
Trend pullbackcosts, a protective stop, a time exitStrategies
Band reversion, both sidesside.short, two keysStrategies
Engulfing barsthe body of a bar, comparing with the bar beforeCandle patterns
Dojia share as an input, a guard against an empty rangeCandle patterns
Hammer and shooting starshadows, one input for two patternsCandle patterns
Bars in a rowtech.bars_sinceCandle patterns
Gapsboxes drawn inside an ifCandle patterns
Outside barscolouring only some candlesCandle patterns
Close position in the bara guarded division, columnsCandle patterns
Z-scorestandard deviation, a signed histogramStatistics and tools
Percent ranktech.percent_rank, the true rangeStatistics and tools
Change and volume correlationtech.correlation, a named argumentStatistics and tools
Day range usedcurrent(day) and prior(day, n)Statistics and tools
ATR position sizearithmetic with inputs, a tableStatistics and tools
Round numbersrounding to a step, stepsStatistics and tools
Last week's rangeprior(week)Statistics and tools
Session average pricestate sums inside a sessionStatistics and tools
Regression linetech.linreg and its slopeStatistics and tools
Market dashboardseveral readings in one tableStatistics and tools

If you are new to scripts, start with the tutorial: it explains every part these programs use.