Sie sind auf Seite 1von 3

// Copyright Fipertec

// Version 1.5

Express Forecast_Oscillator

Vars
series line, line_signal, price, senti(50);
series tsf, res1, Ema1;
numeric sumX, sumX2, sumXY, sumY, a, b, r;
numeric i, sumX0, sumX20, sumXY0, sumY0, LinReg1, LinRegSlope1;

input $period(1, 100, 5);


input $Price("Open;Close;High;Low",1);
input $signal_period (1, 100, 3);
input $spanLeft(1,10, 1);
input $spanRight(1,10, 1);
input $MessageBox("No;Yes",0);
input $PlaySound("No;Yes",0);
input $SendEmail("No;Yes",0);

Calculation

if IsFirstBar() then
begin
CalculateAtEveryTick(false);
SetYscaleFormat(GetPriceFormat());
for i = 0 to FinalBarIndex()
begin
if $Price = 3 then price[-i] = l[-i];
else
if $Price = 2 then price[-i] = h[-i];
else
if $Price = 1 then price[-i] = c[-i];
else
if $Price = 0 then price[-i] = o[-i];
end
end

//======================================
// Function LinReg
//======================================
if $period < CurrentBarIndex() then
begin
sumx = 0;
sumy = 0;
sumx2 = 0;
sumxy = 0;
for i = 0 to $period - 1
begin
r = i - 1;
sumx = sumx + r ;
sumy = sumy + price[i];
sumx2 = sumx2 + r * r;
sumxy = sumxy + r * price[i];
end
b = (($period * sumXY) - (sumX * sumY)) / (($period * sumX2) - (sumX * sumX));
a = (sumY - (b * sumX)) /$period;
LinReg1 = a - b;
end
//======================================
// Function LinRegSlope
//======================================
if $period < CurrentBarIndex() then
begin
sumx0 = 0;
sumy0 = 0;
sumx20 = 0;
sumxy0 = 0;
for i = 0 to $period - 1
begin
r = i - 1;
sumx0 = sumx0 + r ;
sumy0 = sumy0 + price[i];
sumx20 = sumx20 + r * r;
sumxy0 = sumxy0 + r * price[i];
end
LinRegSlope1 = (($period * sumXY0) - (sumX0 * sumY0)) / (($period * sumX20) -
(sumX0 * sumX0)) * -1;
end

line = void;
line_signal = void;
//------------------------------------------------------------
if ($period + $signal_period ) < CurrentBarIndex() then
begin
tsf = LinReg1 + LinRegSlope1;
res1 = 100 * (price - tsf[ 1]) / price;

if IsFinalBar() then
begin
line[i] = void;
line_signal[i] = void;
ExpMovingAverage( res1, Ema1, $signal_period);
for i = CurrentBarIndex() downto 0
begin
if i < (CurrentBarIndex() - ($period + $signal_period + $period +
$signal_period)) then
begin
line[i] = res1[i] ;
line_signal[i] = Ema1[i];
end

if (line[i+1] < line_signal[i+1]) and (line[i] > line_signal[i]) then


begin
senti[i] = 100;
if ($SendEmail = 1) then SendEmail("Buy signal","Buy signal
Forecast_Oscillator: " + SymbolName());
if ($PlaySound = 1) then Playsound("ring");
if ($MessageBox = 1) then MessageBox("Buy signal Forecast_Oscillator: " +
SymbolName());
end

if (line[i+1] > line_signal[i+1]) and (line[i] < line_signal[i]) then


begin
senti[i]= 0;
if ($SendEmail = 1) then SendEmail("Sell signal","Sell signal
Forecast_Oscillator: " + SymbolName());
if ($PlaySound = 1) then Playsound("ring");
if ($MessageBox = 1) then MessageBox("Sell signal Forecast_Oscillator: " +
SymbolName());
end
end
end
end

SetYscaleFormat("%.3f");

interpretation
begin
sentiment = senti;
end

plot (line, lightblue, 1);


plot (line_signal, lightred, 1);//@@@cs:1284381-3943163-1079546_cs@@@

Das könnte Ihnen auch gefallen