Пользовательские индикаторы > MIDAS Top/Bottom finder

Дополнительные индикаторы от пользователей Альфа-Директ 4. Готовые решения от пользователей.
Сообщения: 14
Зарегистрирован: 14 янв 2021, 14:47
Благодарил (а): 1 раз
Поблагодарили: 1 раз

MIDAS Top/Bottom finder

Непрочитанное сообщение ifinch » 16 сен 2021, 16:05

Может кто-нибудь переписать код с TradeStation?

Код: Выделить всё

Input: Vol_D(0), //Input Volume ("D" from Levine’s //formula)
TBF_Price(L), //Bar Price to use; suggest "L" for
//TopFinder and "H" for BottomFinder;
//Alternatively, "(H+L+C)/3"
//may be used for an average price

MyVolume(Ticks), //Bar Volume information to use;
//suggest "Ticks", or "1"
//if no volume information
//"Ticks" yields total volume,
//and "Volume" yields only
//up volume on intraday charts

StartingDate(1120101), //Start Date in TradeStation date
//format: YYYMMDD, where YYY
//is years since 1900
//Example date is January 1, 2012

StartingTime(1530), //Start Time in military time with no
//punctuation; example time is 3:30 pm

StartColor(Yellow), //Color of TBF curve will start with
//StartColor and end with EndColor ...
EndColor(Red); //... and changes according to %
//D completion

Vars: running(false), //whether or not TBF calculation has
//started and not ended
pv(0), //cumulative price ∗ volume
vol(0), //cumulative volume
_D(0), //variable that holds input volume, D
pvInt(0), //interpolated pv
j(0), //loop iterator
e(0), //same as Levine’s "e" variable
eT(0), //temporary copy of "e" used for
tbf(0), //current calculated price of TBF curve
pct_D(0); //percent completion of TBF curve
//begin at user specified date and time
if (date = StartingDate and time = StartingTime) or running then begin
running = true;
pv = pv + TBF_Price ∗ MyVolume; //add current bar’s price ∗
//volume to cumulative total
vol = vol + (MyVolume); //running total of volume
//begin calculation of TBF price
if Vol_D <> 0 then begin
_D = Vol_D; //store copy of input volume
e = vol ∗ (1 - vol / _D); //calculate "e" per
//Levine’s formula
//if "e" greater than zero, continue to
//calculate TBF price
//otherwise, TBF is completed
if e > 0 then begin
eT = e; //temporary
//copy of "e"
j = -1; //used for iteration
//iterate backwards until the cumulative
//displaced volume is greater than or
//equal to "e"
while eT > 0 begin
j = j + 1;
eT = eT - MyVolume[j];
//If displaced volume is greater than "e"
//(nearly always),
//an interpolated pv amount is calculated
//for "j" bars ago using only that part of
//"j" bar’s volume needed to make cumulative
//displaced volume equal to "e".
//Note that at this point, "eT" is negative
//and contains the partial volume
//of "j" bars ago that should be excluded.
if eT < 0 then pvInt = TBF_Price[j] ∗
(MyVolume[j] + eT) else pvInt = 0;
tbf = (pv - pv[j] + pvInt) / e; //calculate
//TBF curve
//price for
//this bar
pct_D = vol / _D ∗ 100; //calculate
//percent TBF
plot1(tbf, "TBF");
//Set Plot Color based on gradient between two
//Input colors
SetPlotColor(1, GradientColor(pct_D, 0, 100,
//StartColor, EndColor));
else running = false; //TBF curve is completed; do
//not run anymore

Вернуться в «Пользовательские индикаторы»

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 6 гостей