Some optimize for code ..please help

#1
Hi all friends

I'm trying the code below but I need some helps for code

I want to add one of EMA for histogram and buy , sell , optimize codes.Ema cross up histogram buy and Ema cross down histogram sell.Please help for this code..

_SECTION_BEGIN("SINI");
r = Param( "SINI period 'R':", 12, 1, 100, 1 );
s = Param( "SINI period 'S':", 26, 1, 100, 1 );
u = Param( "SINI period 'U':", 10, 1, 100, 1 );
sig = Param( "Signal period:", 9, 1, 100, 1 );

Mtm = C - Ref ( C, -1 );
AbsMtm = abs ( Mtm );
Num_T = EMA ( EMA( EMA ( Mtm, r ), s ), u );
Den_T = EMA ( EMA( EMA ( AbsMtm, r ), s ), u);

SINI = 100 * Nz ( Num_T / Den_T );
TSIL = 100 * Nz ( Num_T / Den_T );

//Green TSIL Line=Rising; Red TSIL Line=Falling
col = IIf( TSIL > Ref( TSIL, -1 ), colorLime, colorRed );
Plot( TSIL, "SINI("+r+","+s+","+u+")", col, styleLine | styleThick);
//Green EMA SINI,sig Line=Rising; Red EMA SINI,sig Line=Falling
col = IIf( EMA(SINI,sig) > Ref( EMA(SINI,sig), -1 ), colorBrightGreen,

colorRed );
Plot( EMA(SINI,sig), "", col, styleThick);
Histcol= IIf(SINI>0,colorIndigo,colorDarkRed) ;


Plot( SINI-sig, "SINI Histogram", colorWhite, styleHistogram );
Plot(0,"",ParamColor( "ColorZero", colorDarkRed ),styleLine);

P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );




//Title = "SINI";
_SECTION_END();

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//FORMULA
Cuptop1= C>BBandTop( C,20,1 ) ;
top1up= BBandTop( C,20,1 )>=Ref(BBandTop( C,20,1 ),-1) ;
top2up= BBandTop( C,20,2 )>=Ref(BBandTop( C,20,2 ),-1) ;
MACDup= MACD()>Signal() ;
Hist= MACD()-Signal() ;
Histup= Hist>Ref(Hist,-1) ;
stochup= StochK()>StochD() ;
stoch80= StochK()<80 ;
MFIup= MFI()>EMA(MFI(),5) AND MFI()>20 ;
ma21up= MA(C,21)>=Ref(MA(C,21),-1) ;
ma55up= MA(C,55)>=Ref(MA(C,55),-1) ;
EMA89up= EMA(C,89)>=Ref(EMA(C,89),-1) ;
Cupma21= C>MA(C,21) ;
Cupma55= C>MA(C,55) ;
cupema89= C>EMA(C,89) ;
Vup50= V>50000 ;
CCIup0= CCI()>0 ;
Cupo= C>O ;
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





_SECTION_END();
 
Last edited:
#2
please help for backtest..I am new amibroker.

this is histogram

Plot( SINI-sig, "SINI Histogram", colorWhite, styleHistogram );

I want to backtest

when Ema cross up "SINI Histogram" buy
when Ema cross up "SINI Histogram" sell

this ema is average of "SINI Histogram"

I tried

buy = cross( ema(), "SINI Histogram" );
sell = cross( "SINI Histogram", ema() );

short = sell;
cover = buy;


but it is not true

I know this is very simple for you but I cant
 

Similar threads