Hello,

You should probably start reading the MANUAL:
http://www.amibroker.com/guide/afl/afl_view.php?writeif

Read the Second comment !!!
===================


You should use this instead

trendText = WriteIf(trendup , "Trend UP", "Trend Down");
  AddColumn( IIF( trendup, Asc("U"), Asc("D") ) , "Trend", formatChar );

Best regards,
Tomasz Janeczko
amibroker.com

On 2010-03-13 19:29, googool123123 wrote:


that is how I am running it, against all quotes of the _*same stock
*_


--- In [email protected], "j0etr4der" <j0etr4...@...> wrote:
>
> I tried on a watchlist with 60 stocks. There were both Trend UP and Trend Downs, BUT for any one stock, the results were the same (either all Up or all down Down.) Something else is wrong other than WriteIf.
>
> Good luck.
>
> --- In [email protected], "googool123123" bfallahi@ wrote:
> >
> > could someone please tell me why in the following code
> >
> > the line
> >
> > trendText = WriteIf(trendup , "Trend UP", "Trend Down");
> >
> > always returns the same value regardless of the values of Coppock and
> > CoppockMinusN
> >
> > it always returns "Trend UP"
> >
> > Thanks
> >
> >
> > here's the code
> >
> > TimeFrameSet( inMonthly ); // switch now to hourly
> >
> >
> > //Returns the array with months(1-12)
> > monthArray = Month();
> >
> > closeCurrentMonth = C;
> > closeLatMonth = Ref(C, -1);
> >
> > Coppock =
> > (ROC(Close,14 )*10 + ROC(Close,11)*10 +
> > ROC(Ref(Close,-1),14)*9 + ROC(Ref(Close,-1),11)*9 +
> > ROC(Ref(Close,-2),14)*8 + ROC(Ref(Close,-2),11)*8 +
> > ROC(Ref(Close,-3),14)*7 + ROC(Ref(Close,-3),11)*7 +
> > ROC(Ref(Close,-4),14)*6 + ROC(Ref(Close,-4),11)*6 +
> > ROC(Ref(Close,-5),14)*5 + ROC(Ref(Close,-5),11)*5 +
> > ROC(Ref(Close,-6),14)*4 + ROC(Ref(Close,-6),11)*4 +
> > ROC(Ref(Close,-7),14)*3 + ROC(Ref(Close,-7),11)*3 +
> > ROC(Ref(Close,-8),14)*2 + ROC(Ref(Close,-8),11)*2 +
> > ROC(Ref(Close,-9),14) + ROC(Ref(Close,-9),11))/2;
> >
> > N = 1;
> >
> > CoppockMinusN =
> > (ROC(Ref(Close, -N),14 )*10 + ROC(Ref(Close, -N),11)*10 +
> > ROC(Ref(Ref(Close, -N),-1),14)*9 + ROC(Ref(Ref(Close, -N),-1),11)*9 +
> > ROC(Ref(Ref(Close, -N),-2),14)*8 + ROC(Ref(Ref(Close, -N),-2),11)*8 +
> > ROC(Ref(Ref(Close, -N),-3),14)*7 + ROC(Ref(Ref(Close, -N),-3),11)*7 +
> > ROC(Ref(Ref(Close, -N),-4),14)*6 + ROC(Ref(Ref(Close, -N),-4),11)*6 +
> > ROC(Ref(Ref(Close, -N),-5),14)*5 + ROC(Ref(Ref(Close, -N),-5),11)*5 +
> > ROC(Ref(Ref(Close, -N),-6),14)*4 + ROC(Ref(Ref(Close, -N),-6),11)*4 +
> > ROC(Ref(Ref(Close, -N),-7),14)*3 + ROC(Ref(Ref(Close, -N),-7),11)*3 +
> > ROC(Ref(Ref(Close, -N),-8),14)*2 + ROC(Ref(Ref(Close, -N),-8),11)*2 +
> > ROC(Ref(Ref(Close, -N),-9),14) + ROC(Ref(Ref(Close, -N),-9),11))/2;
> >
> > trendUp = IIf(Coppock > CoppockMinusN, True, False);
> >
> >
> > trendText = WriteIf(trendup , "Trend UP", "Trend Down");
> > AddTextColumn(trendText , "Trend");
> >
>



Reply via email to