Simple Coding Help - No Promise.

dear all amibroker expert i have one question i am trading with amibroker software with 14 period cci in nse stocks and mcx also.
my question is that i have done time setting in amibroker 9.30 to 4 pm the cci value is different and again i change my intraday time setting in ami 9.15 to 3.30 then cci value again change pls give me solution what time i have to set in stocks and mcx for both.
pls help me
thanks
 
dear all amibroker expert i have one question i am trading with amibroker software with 14 period cci in nse stocks and mcx also.
my question is that i have done time setting in amibroker 9.30 to 4 pm the cci value is different and again i change my intraday time setting in ami 9.15 to 3.30 then cci value again change pls give me solution what time i have to set in stocks and mcx for both.
pls help me
thanks
How much difference are we talking? How does it impact your trading?


Since both markets have different start times and times are aligned, you cannot come up with one figure that will keep both aligned. Still, if in doubt, deal keep it at 9:00 AM to 12 AM (MCX market does not close at 4PM)

Also, try computing CCI on EOD data (and then expand it) to your viewing time-frame.
 

Dawood

Active Member
PHP:
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_BEGIN("Flower_HA_Normal Candle");

Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
r1 =5; //Param( "ColorFast avg", 5, 2, 200, 1 ); 
r2 =10; //Param( "ColorSlow avg", 10, 2, 200, 1 ); 
r3 =5; //Param( "ColorSignal avg", 5, 2, 200, 1 ); 

Prd1=4; //Param("ATR Period",4,1,20,1);
Prd2=7; //Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);

HaClose =EMA((O+H+L+C)/4,3); // Woodie 
//HaClose =(O+H+L+C)/4; 
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); 
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
HaLow = Min( L, Min( HaClose, HaOpen ) ); 
//HaClose = ( HaClose + HaOpen + HaHigh + HaLow )/4; 
Temp = Max(High, HaOpen);
Temp = Min(Low,HaOpen);

//////////
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, ColorRGB(230,230,0),IIf(m1>0 AND m1>s1,colorWhite,IIf(m1>0 AND m1<s1,colorOrange,colorDarkRed)));
if(Show_color)

{
ColorHighliter = mycolor;
SetBarFillColor( ColorHighliter );
}

barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorYellow));
barColor2=IIf(Close > Open, colorYellow, colorRed);

if( ParamToggle("Plot Normal Candle", "Yes,No", 1 ) )
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, " " , barcolor, styleCandle | styleThick );
else
PlotOHLC( Open, High, Low, Close, " " , barcolor2, styleCandle | styleThick );

_SECTION_END();




_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
Sellperiods=Param("Exit Breakout",5,1,100,1,1);
Buy= C>Ref(HHV(High,Buyperiods),-1);
Sell= C<Ref(LLV(Low,Sellperiods),-1);

/* exrem is one method to remove surplus trade signals. It removes excessive signals of arrow */
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -15);
//PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -8);

PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorBlue, layer = 0, yposition = HaHigh, offset = -15);
//PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = 8);

_SECTION_END();
Dear members I need to get a horizontal line at high of the candle that generates buy signal and it should extend for next five candles.

same I need to get a horizontal line at low of the candle that generates sell signal and it should extend for next five candles.

This afl is a part of nirvana.

Somebody please modify the code.

Thanks in advance.
Dawood
Anybody to help....please
 
Need help to find error in intraday AFL

Hi,

I am new user of amibroker and trying to write AFL based on some rules i am trading since last 2 year.I tried hard to write afl to match my trading strategy i use to trade manually but it still not exactly what i wanted.

This is intraday trading strategy AFL,which open 4 trades at opening bell based on ROC and position score. (I am using 15 min. time frame)

It seems that there is error in reversetrade code,When freshbuy signal generate and trade get open ..the SL is buycandle's low..at where i want to go short if sl triggers.. else will close the trade at closing bell..

Error: under portfolio backtesting, i am facing 3 problem

-Reversetrade signals generates by considering any previous fresh trade's low/high crossover.while valid crossover is fresh buy/short must be in current day.

-How to code this afl so that under portfolio backtest,Reverse trade take place only in those stock are selected and traded current day with fresh buy/fresh short signal.

-at closing bell i need to close all active trade,But this AFL open new 4 trade at a time of closing bell and close the trade next day.not getting where m i making mistake.:confused:

it would be great help if someone can guide me to solve errors:(

HTML:
FreshTradeTime=TimeNum() >= 091500 AND TimeNum() <= 094500 ;
ReverseTradeTime=TimeNum() >= 091500 AND TimeNum() <= 144500;
CloseALL = TimeNum() >=152500;	

FreshBuy=ROC(C,1)> 1;
FreshShort=ROC(C,1)< -1;
ReverseBuy=  Cross(C,ValueWhen(FreshShort,H));
ReverseShort=Cross(ValueWhen(FreshBuy,L),C);

Buy = FreshBuy OR ReverseBuy;
BuyStop=IIf(FreshBuy, Cross(ValueWhen(FreshBuy,L),C),Cross(ValueWhen(FreshShort,L),C)); 
Sell= BuyStop==1 OR CloseALL;

Short=  FreshShort OR ReverseShort ;
ShortStop=IIf(FreshShort, Cross(C,ValueWhen(FreshShort,H)),Cross(C,ValueWhen(FreshBuy,H)));
Cover= ShortStop==1 OR CloseALL ;

BuyPrice=IIf(FreshBuy,ValueWhen(FreshBuy,C),ValueWhen(FreshShort,H));
ShortPrice=IIf(Freshshort,ValueWhen(Freshshort,C),ValueWhen(Freshbuy,L));


Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

/////////////////////////
e= 100000;
PositionSize= -25;
PositionScore=abs(ROC(C,1));
SetOption("MaxOpenPositions", 4 );
 

casoni

Well-Known Member
Hello,
Like this !!!
if Buy , then line will be plotted on high of the Buy Bar ,
and line will stop, if sell signal is fired .
vice versa for short ..


:confused:
 
PHP:
SetChartOptions(0,chartShowArrows|chartShowDates);
Dear members I need to get a horizontal line at high of the candle that generates buy signal and it should extend for next five candles.

same I need to get a horizontal line at low of the candle that generates sell signal and it should extend for next five candles.

This afl is a part of nirvana.

Somebody please modify the code.

Thanks in advance.
Dawood[/QUOTE]

You can incorporate something like this into the code:

Buy = Cross( MA( C, 5 ), MA( C, 21 ) );//Use your own buy/sell conditions
Sell = Cross( MA( C, 21 ), MA( C, 5 ) );

hiBuy = ValueWhen( Buy, H );
loSell = ValueWhen( Sell, L );

Plot( IIf( BarsSince( Buy ) < 6, hiBuy, Null ), "", colorWhite, styleLine );
Plot( IIF( BarsSince( Sell ) < 6, loSell, Null ), "", colorWhite, styleline );
 

Similar threads