// chart-with-include.afl
// Part 11 - Include Files and Building a Library
//
// GOAL
//   Show a formula that is mostly other people's code - specifically, your own
//   code, kept in one place. Everything the chart needs beyond price comes from
//   chart-defaults.afl.
//
// WHAT IT DRAWS
//   The candle body as a percentage of the whole bar's range. A high reading is
//   a bar that closed a long way from where it opened relative to how far it
//   travelled; a low reading is a bar with long wicks and little net movement.
//   It is a description of one bar, not a signal.
//
// PREREQUISITE
//   chart-defaults.afl must be reachable. Either put it in the folder named in
//   Tools -> Preferences -> AFL as the standard include path and keep the line
//   below, or replace the line with a full path in quotes and SINGLE
//   backslashes. If you get Error 42, the file is not where you said it is.

#include <chart-defaults.afl>

_SECTION_BEGIN( "Body size" );

Plot( Close, "Close", colorDefault, styleCandle );

BodySize  = abs( Close - Open );
BarRange  = High - Low;
BodyShare = DemoPercentOf( BodySize, BarRange );

Plot( BodyShare, "Body as % of range", colorBlue, styleLine | styleOwnScale );

_N( Title = DemoHeaderText( "candle body as a percentage of the bar's range" ) + "\n" +
    WriteIf( IsNull( BodyShare ),
             "No reading at the selected bar: the bar has no range.",
             "Selected bar body is " + NumToStr( BodyShare, 1.1 ) + "% of its range." ) );

_SECTION_END();
