# Coding help required for simple formula

I have a Afl showing the momentum Ribbon, UP, Down, Sideways; I want to convert the same in Buy and Short signals. But making mistake in the writing code for Sell or Short Formula. Can any body help on this ?

Regards,

/////////////////////////////////////////////////////////////////////////
Formula as follows :

_SECTION_BEGIN("MultipleRibbon");
RibbonThickness = Param("RibbonThickness", 4, 1, 15, 0.1);
Font = ParamList("Font:","Arial|Calibri|Futura|Tahoma|Times New Roman");
"";
function GfxConvertBarToPixelX(Bar)
{
lvb = Status("lastvisiblebar"); fvb = Status("firstvisiblebar");
pxchartleft = Status("pxchartleft"); pxchartwidth = Status("pxchartwidth");
return pxchartleft + Bar * pxchartwidth / (Lvb - fvb + 1);
}

procedure MultiRibbon(RibbonColor, Position, Label)
{
LineColor = colorLightGrey;
Position = RibbonThickness * Position;
x2 = Status("pxchartright");
y2 = Status("pxchartbottom");

RibbonColor = IIf(GfxConvertBarToPixelX(BarIndex()-Status("firstvisiblebarindex")) > y2/1.5 * (RibbonThickness/100) * 18 ,
RibbonColor, colorYellow);

Plot(0, "", LineColor, styleOwnScale | styleNoLabel, 0, 100);
Plot(Position, "", LineColor, styleOwnScale | styleNoLabel, 0, 100);
Plot(Position, "", RibbonColor, styleArea | styleOwnScale | styleNoLabel, 0, 100);

GfxSetTextColor(colorBlack);
GfxSelectFont(Font, y2/1.5 * (RibbonThickness/100), 400);
GfxDrawText(Label, 8, y2 * 1.001 -(y2 * Position/100) , y2/1.5 * (RibbonThickness/100) * 17, y2, 2 + 32 + 256);

}
//
upsw = 0;
Hh = Lh = H[ 0 ];
Hl = Ll = L[ 0 ];

for( i = 0; i < BarCount; i++ )
{
Ch = H[ i ];
Cl = L[ i ];

if( upsw == 1 )
{
Hh = Max( Ch, Hh );
hL = Max( Cl, Hl );

``````if( Ch < Hl )
{
upsw = 0;
Ll = Cl;
Lh = Ch;
}
``````

}

if( upsw == 0 )
{
Ll = Min( Cl, Ll );
Lh = Min( Ch, Lh );

``````if( Cl > Lh )
{
upsw = 1;
Hh = Ch;
Hl = Cl;
}
``````

}

Hla[ i ] = Hl;
Lha[ i ] = Lh;
upswa[ i ] = upsw;
}

CpClear= upswa == 1 ;
VdClear= upswa == 0 ;

//FORMULE RIBBON TREND MOMENTUM

Stochup= StochK()>StochD() ;
StochDn80= StochK()<80 ;
macdup= MACD()>Signal() ;
macdup0= MACD()>0 ;
Hist= MACD()-Signal() ;
Histup= Hist>Ref(Hist,-1) ;
pdiupmdi= PDI()>MDI() ;
uptrend= ( MACD()>Signal() AND PDI()>MDI() ) ;
dntrend= ( MACD()<Signal() AND PDI()<MDI() ) ;
rsiupma7= RSI()>MA(RSI(),7) ;//
CCIUP0= CCI()>0 ;
CCIupMA7= CCI()>MA(CCI(),7) ;//
MFIUPMA7= MFI()>MA(MFI(),7) ;//
myup= (pdiupmdi AND macdup0 AND cciup0 AND histup AND stochup AND upswa == 1 ) ;
RSIup50= RSI()>50 ;

//=========================== MOMENTUM ======================================================
r2 = IIf( rsiupma7 AND rsiup50 OR cciupma7 AND cciup0 ,colorGreen ,
IIf( !rsiupma7 AND !rsiup50 AND stochdn80 OR !cciupma7 AND !cciup0 AND stochdn80 , colorRed,colorTan ) ) ;
MultiRibbon( r2, 2, "");

Buy=rsiupma7 AND rsiup50 OR cciupma7 AND cciup0 ;
//Sell= when ribbon change to pink or red
Short=!rsiupma7 AND !rsiup50 AND stochdn80 OR !cciupma7 AND !cciup0 AND stochdn80;
//Cover= when ribbon change colour to pink or green

//=======================================================================================
/*
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-25);