Problem with basic code

#1
I am having problems with this most basic bit of coding. I am trying to compare conditions between various bars previous to the current bar. I tried the following and it plots price bars but not any of the Sells.

Plot( C, "Close", ParamColor("Color", colorBlack ), styleBar | ParamStyle("Style") | GetPriceStyle() );


Sell = (C-4 > C-1) AND (C-2 > C-4) AND (C-3 > C-2) AND (C-5 > C-3);

IIf( (Sell),PlotShapes(shapeDownArrow*Sell,colorRed),0);

Any ideas where I'm going wrong?
 
#2
try this one

Sell = (C-4>C-1) AND (C-2>C-4) AND (C-3>C-2) AND (C-5>C-3);

_SECTION_BEGIN("db411");

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

PlotShapes( shapeDownArrow * Sell, colorRed,0,H,-12);

_SECTION_END();
 
#3
db411

you can write as follows

Plot(C,"",colorBlack,styleCandle);
Sell = Ref(C,-4) > Ref(C,-1) AND Ref(C,-2) > Ref(C,-4) AND Ref(C,-3) > Ref(C,-2) AND Ref(C,-5) > Ref(C,-3);
PlotShapes(shapeDownArrow*Sell,colorRed,0,H,-12);

vidyasagar
 

colion

Active Member
#4
I am having problems with this most basic bit of coding. I am trying to compare conditions between various bars previous to the current bar. I tried the following and it plots price bars but not any of the Sells.

Plot( C, "Close", ParamColor("Color", colorBlack ), styleBar | ParamStyle("Style") | GetPriceStyle() );


Sell = (C-4 > C-1) AND (C-2 > C-4) AND (C-3 > C-2) AND (C-5 > C-3);

IIf( (Sell),PlotShapes(shapeDownArrow*Sell,colorRed),0);

Any ideas where I'm going wrong?
Your basic error is improper use of IIF(). Check the Users Guide for the proper syntax and also the section called "Common Coding Mistakes in AFL".