[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

System in EL



PureBytes Links

Trading Reference Links

Hi all,
Could somebody from the group help me in writing a system in Easy
Language.

I would like to write a system defined in following manner:

-buy when Linear Regression crosses above a Simple Moving Average and
today's Lin. Regression
is higher than yesterday's.
- sell when Lin. Reg. crosses below a Simple Moving Average and today's
Lin. Reg.
is lower than yesterday's.
The code for Lin. Reg is attached.

The help would be appreciated.
Best regards, Alex

{ *******************************************************************

 Study  : Linear Regression

 Last Edit : 1/19/96

 Provided By : Omega Research, Inc. (c) Copyright 1996

********************************************************************}
Inputs: Length(14);
Vars : LongTermTrend(0), ShortTermTrend(0), nocommentary(TRUE),
String1("");

Plot1(LinearRegValue(C,Length,0), "LinearReg");

#BeginCmtryOrAlert
 if Average(close,Length) >= Average(close,Length)[1] and close >=
Average(close,Length) then
  LongTermTrend = 1;
 if Average(close,Length) < Average(close,Length)[1] and close <
Average(close,Length) then
  LongTermTrend = -1;

 if AtCommentaryBar or CheckAlert
 then begin
  String1=String1+"Conventional Interpretation: ";   { Conventional
Interpretation }
  nocommentary = TRUE;
  if close >= plot1
  then begin
    String1=String1+"Price is above the regression value so the trend is

up. ";
    nocommentary = FALSE;
  end;
  if close < plot1
  then begin
    String1=String1+"Price is below the regression value so the trend is

down. ";
    nocommentary = FALSE;
  end;
  if nocommentary then
   String1=String1+"The regression value is inconclusive on this bar. ";



  String1=String1+NewLine;
  String1=String1+NewLine;
  { end of Conventional Interpretation }

  String1=String1+"Additional Analysis: ";
  if LongTermTrend = 1
  then begin
   ShortTermTrend = 1; { initialize variable every bar to Up }
   if LongTermTrend[1] <> 1
   then begin
    String1=String1+"CAUTION: The market trend has changed direction. ";

    String1=String1+"Now the trend is UP! ";
    alert = TRUE;
   end
   else
    String1=String1+"Market trend is UP. ";

   if close < plot1 and plot1 >= plot1[1]
   then begin
    String1=String1+"Even though the regression value is in an upward
slope from the previous ";
    String1=String1+"bar, the prices are trading below the regression
value line. ";
    String1=String1+"if prices trade above the regression value then the

trend will be ";
    String1=String1+"clearly established as up. For the time being, ";
    String1=String1+"we'll continue to call the market trend UP. ";
    String1=String1+"if your other indicators are \hbbullish\he, ";
    String1=String1+"this may be a good buying opportunity.";
    alert = TRUE;
   end;
   if close > plot1 and plot1 < plot1[1]
   then begin
    String1=String1+"Even though prices are trading above the regression

value, the ";
    String1=String1+"slope is down from the previous bar. if price
continues upwards";
    String1=String1+", the regression value will eventually follow and
then the up trend will be ";
    String1=String1+"more clearly established. For the time being, we'll

continue to call the market";
    String1=String1+" trend UP. ";
   end;
  end; { if LongTermTrend = 1 }

  if LongTermTrend = -1
  then begin
   ShortTermTrend = -1; { initialize variable every bar to Up }
   if LongTermTrend[1] <> -1 then begin
    String1=String1+"CAUTION: The market trend has changed direction. ";

    String1=String1+"Now the market trend is DOWN! ";
    alert = TRUE;
   end
   else
    String1=String1+"Market trend is DOWN. ";

   if close < plot1 and plot1 >= plot1[1]
   then begin
    String1=String1+"Even though prices are trading below the regression

value, the ";
    String1=String1+"regression value slope is up from the previous bar.

if price continues ";
    String1=String1+"downwards, the regression value will eventually
follow and then the down trend ";
    String1=String1+"will be more clearly established. For the time
being, we'll continue to call ";
    String1=String1+"the market trend DOWN. ";
   end;
   if close > plot1 and plot1 < plot1[1]
   then begin
    String1=String1+"Even though the regression value is in an downward
slope from the previous ";
    String1=String1+"bar, the prices are trading above the regression
value line. ";
    String1=String1+"if prices trade below the regression value then the

trend will be more ";
    String1=String1+"clearly established as down. For the time being, ";

    String1=String1+"we'll continue to call the market trend DOWN. ";
    String1=String1+"if your other indicators are \hbbearish\he, this
may be a good ";
    String1=String1+"\hbshort\he selling opportunity. ";
    alert = TRUE;
   end;
  end; { if LongTermTrend = -1 }
  String1=String1+NewLine;
  commentary(String1);
 End;
#End;