slider(int number, int pos, int min, int max, string name, string tooltip): var
Sets up an initial position, range, name, and tooltip for one of the three customizable sliders. Returns the current position of the slider. Depending on the selected asset or other conditions, different slider positions can be preset at the beginning.
slider(int number): var
Returns the position of the slider with the given number.
slider(int number, int pos)
Sets the slider with the given number to a new position.
This way the script can display numerical values to the user while running.
||The number of the slider: 0 for the Period slider, 1..3 for the 3 user-specific sliders.
||Position of the slider (default = 0). The
initial position is set when the script is run the first time.
||Minimum and maximum positions of the slider, left and right.
||Name for the slider that is displayed in the main panel (f.i.
||Tool tip text to describe the slider function, or 0 for no tool tip.
Current value of the slider.
- For defining a slider initial position, range, name, and tooltip, the slider function must be called in the first run of a strategy. The Period slider has fixed parameters and is hard-wired to the BarPeriod variable. The other three sliders can be freely set and redefined.
- The sliders are initialized to their default positions (pos parameter) when the script is started the first time, or when
the script was edited or a new [Script] was
selected. On subsequent starts of the same script the sliders keep their previous position. For testing a script with a certain slider position, click [Test], wait until the slider
names appear, then click [Stop], put the sliders to the desired position and click [Test] again. In [Trade] mode the slider
positions are stored in the .trd file and thus 'remember' their last position.
- In [Test] mode the sliders could be used to set up time periods, buy/sell thresholds, or stop/profit distances. In [Trade] mode, the sliders could be used for entering separate thresholds for buying long and short, or to set the number of lots per trade. This way the strategy can be adapted in real time to the expectation of rising or falling prices, or to the risk.
- Aside from the sliders, a panel with entry fields can also be used for user input.
Lots = slider(1,2,1,10,"Lots","Lots per Trade");
Stop = PIP*slider(2,15,0,30,"Stop","Stop Loss in PIPs");