Simple Coding Help - No Promise.

dell

Well-Known Member
i recently bought 4 yrs ieod data of cash , fno ,and mcx ............make a new database .......now feeding with manshirt datafeed..........all symbols..............problem now arises that frequently my amibroker get hanging , not responding and gets run time memory error
..........is it due to 9 gb database size ...or ...because i am feeding all symbols of fno , cash , mcx ..........? or my ram is small .........or is it due to any hardware issue ..........?
how i can solve this problem ?

i am running it on desktop with 8gb ram ....and with windows8
also how to increase it's memory..
 
Last edited:

pratapvb

Well-Known Member
i recently bought 4 yrs ieod data of cash , fno ,and mcx ............make a new database .......now feeding with manshirt datafeed..........all symbols..............problem now arises that frequently my amibroker get hanging , not responding and gets run time memory error
..........is it due to 9 gb database size ...or ...because i am feeding all symbols of fno , cash , mcx ..........? or my ram is small .........or is it due to any hardware issue ..........?
how i can solve this problem ?

i am running it on desktop with 8gb ram ....and with windows8
also how to increase it's memory..
Try keeping a separate database for live trading with say 3months data and keep this database for backtesting. You can keep this database up-to-date now by backfilling it periodically
 

pratapvb

Well-Known Member
If I have to find/write Volume at Highest High over last 21 period, what is right syntax/formula for this?
I understand that for for previous day vol, i can write Vp = ref(V, -1)
and for highest volume in last last 21 days HiV21 = HHV(V,21).
But for volume at Highest High point when I write Vh = Ref (V, Ref(HHV(H,21)), it draws a blank. Something wrong in my syntax. Please guide me about right syntax and from where can I learn AFL syntax as I find user guide so confusing at times. Thanks & Regards

Edit: I understand my mistake a little now.. I can't write Vh = Ref (V, Ref(HHV(H,21)) because ref(array, number).
So it should be Vh = Ref(V, n) // where n = number of back bar when it was Highest High.
LIke: if nifty is today at 6020 and last highest high over 21 days period was on 7th nov .. then n=5
But how to programmatically calculate this n? Using PeakValue formula? like PeakBars(ARRAY, change, n = 1) .. Please guide.
 
Last edited:

pratapvb

Well-Known Member
If I have to find/write Volume at Highest High over last 21 period, what is right syntax/formula for this?
I understand that for for previous day vol, i can write Vp = ref(V, -1)
and for highest volume in last last 21 days HiV21 = HHV(V,21).
But for volume at Highest High point when I write Vh = Ref (V, Ref(HHV(H,21)), it draws a blank. Something wrong in my syntax. Please guide me about right syntax and from where can I learn AFL syntax as I find user guide so confusing at times. Thanks & Regards

Edit: I understand my mistake a little now.. I can't write Vh = Ref (V, Ref(HHV(H,21)) because ref(array, number).
So it should be Vh = Ref(V, n) // where n = number of back bar when it was Highest High.
LIke: if nifty is today at 6020 and last highest high over 21 days period was on 7th nov .. then n=5
But how to programmatically calculate this n? Using PeakValue formula? like PeakBars(ARRAY, change, n = 1) .. Please guide.
Check barssince related functions
 
Hi Pratap, Happy Singh and other experienced members

I am trying to create MTF Super Trend as mentioned in previous threads. I was able to get the trend line from HTF to LTF as mentioned by happy Singh (i.e. from 30 min to 10 min).

I want the cancle color for the following condition.

In 10 min chart -

candle color Blue when C > Trend Line based on HTF i.e. 30 min
candle color Red when C < Trend Line based on HTF i.e. 30 min

Also how can I get Buy and Sell arrow for above mentioned condition?

Following is the code I have.


_SECTION_BEGIN("SuperTrend");

Factor=Param("Factor",4,1,10,1);
Pd=Param("ATR Periods",10,1,100,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;

for (i = 1; i <BarCount-1; i++) {
TrendUp = Null;
TrendDown = Null;

trend=1;


if (Close>Up[i-1]) {
trend=1;
if (trend[i-1] == -1) changeOfTrend = 1;

}
else if (Close<Dn[i-1]) {
trend=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend=-1;
changeOfTrend = 0;
}

if (trend<0 && trend[i-1]>0) {
flag=1;
}
else {
flag=0;
}

if (trend>0 && trend[i-1]<0) {
flagh=1;
}
else {
flagh=0;
}

if (trend>0 && Dn<Dn[i-1]){
Dn=Dn[i-1];
}

if (trend<0 && Up>Up[i-1])
{ Up=Up[i-1];
}

if (flag==1)
{ Up=(H+L)/2+(Factor*iATR);;
}
if (flagh==1)
{ Dn=(H+L)/2-(Factor*iATR);;
}
if (trend==1) {
TrendUp=Dn;
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend==-1) {
TrendDown=Up;
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}
UP = trend==1;
DN = trend==-1;

kol=IIf(UP,colorBlue,colorRed);
Plot( C, "Close", kol, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_END();

//////////////////////////////////////////////

myTF = in1Minute*Param("Time Frame Minutes",30,15,60*60*24,15);
TimeFrameSet(myTF);
Factor=Param("Factor",4,1,10,1);
Pd=Param("ATR Periods",10,1,100,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;

for (i = 1; i <BarCount-1; i++) {
TrendUp = Null;
TrendDown = Null;

trend=1;


if (Close>Up[i-1]) {
trend=1;
if (trend[i-1] == -1) changeOfTrend = 1;

}
else if (Close<Dn[i-1]) {
trend=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend=-1;
changeOfTrend = 0;
}

if (trend<0 && trend[i-1]>0) {
flag=1;
}
else {
flag=0;
}

if (trend>0 && trend[i-1]<0) {
flagh=1;
}
else {
flagh=0;
}

if (trend>0 && Dn<Dn[i-1]){
Dn=Dn[i-1];
}

if (trend<0 && Up>Up[i-1])
{ Up=Up[i-1];
}

if (flag==1)
{ Up=(H+L)/2+(Factor*iATR);;
}
if (flagh==1)
{ Dn=(H+L)/2-(Factor*iATR);;
}
if (trend==1) {
TrendUp=Dn;
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend==-1) {
TrendDown=Up;
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}
UP = trend==1;
DN = trend==-1;

TimeFrameRestore();

HTF_UP = TimeFrameExpand(UP,myTF);
HTF_DN = TimeFrameExpand(DN,myTF);

HTF_TU = TimeFrameExpand(TrendUp,myTF);
HTF_TD = TimeFrameExpand(TrendDown,myTF);


Plot(TimeFrameExpand(TrendDown,myTF),"",colorRed,styleThick|styleNoRescale);
Plot(TimeFrameExpand(TrendUp,myTF),"",colorBlueGrey,styleThick|styleNoRescale);



GfxSetBkMode(0);
GfxSetOverlayMode(1);
x=Param("X",5,0,1500,10);
y=Param("Y",175,0,1000,10);
GfxSelectFont( "Arial", 15, 700, False );
GfxSetTextColor( colorWhite);

if (SelectedValue(HTF_UP))
{
GfxSelectSolidBrush( colorBlue );
GfxRoundRect( x, y, x+270, y+80,0,0);
GfxTextOut( ( "Supertrend on "+ myTF/60 +" Minutes"),x+5,y+5);
GfxTextOut( "THE TREND IS UP", x+35, y+45);
}
else
{
GfxSelectSolidBrush( colorRed );
GfxRoundRect( x, y, x+270, y+80 , 7, 7 ) ;
GfxTextOut( ( "Supertrend on "+ myTF/60 +" Minutes"),x+5,y+5);
GfxTextOut( "THE TREND IS DOWN", x+25, y+45);
}
_SECTION_END();




Thanks
Amruta
 

Similar threads