|
AmiSite.ru
Форум по Ами |
Автор |
Сообщение |
AntColonel
Зарегистрирован: 03.05.2011
Сообщения: 213
Откуда: Новосибирск
|
Олег и другие знающие товарищи, большая просьба помочь написать один индюк для Ами. Его код привожу ниже. Код этот для TradeStation. В целом все понятно, но как дохожу до расчета цикла - ступор. Пытался сделать в экселе для понимания расчета - не получается.
Вроде пояснения есть в комментариях.
Прошу помочь.
Заранее благодарю!
Код: |
Input: Vol_D(0), //Input Volume ("D")
TBF_Price(L), //Bar Price to use (L or H or (O+H+L)/3)
MyVolume, //Bar Volume information to use;
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 nopunctuation; ample 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), //"e" variable
eT(0), //temporary copy of "e" used for iteration
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"
//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];
end;
//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
//completion
plot1(tbf, "TBF");
//Set Plot Color based on gradient between two
//Input colors
SetPlotColor(1, GradientColor(pct_D, 0, 100,
//StartColor, EndColor));
end
else running = false; //TBF curve is completed; do
//not run anymore
end;
end;
|
Да, забыл сказать - сам параметр D должен задаваться вручную через меню. |
|
|
Посмотреть профиль Отправить личное сообщение |
|
|
|
Следующая тема
Предыдущая тема
Вы не можете начинать темы Вы не можете отвечать на сообщения Вы не можете редактировать свои сообщения Вы не можете удалять свои сообщения Вы не можете голосовать в опросах Вы не можете вкладывать файлы Вы не можете скачивать файлы
|
| |