Simple Coding Help - No Promise.

Code:
Plot(HTF_MA,"30MIN_MA200",IIf(HTF_UP,colorBlue,colorRed),styleThick|styleNoRescale);
The plot uses styleNoRescale to avoid compression of chart . . .

remove i.e. delete |styleNoRescale from the above line . . . . to see both even if the HTF MA value is far away

Code:
Plot(HTF_MA,"30MIN_MA200",IIf(HTF_UP,colorBlue,colorRed),styleThick);
:) Happy
hello,
I deleted the "stylenoscale", but no sucess. I saw the MA for a fraction of second, when the rates got refresh it got vanished.
I also tried "atyleownscale", but again the same thing.
 
hello,
I deleted the "stylenoscale", but no sucess. I saw the MA for a fraction of second, when the rates got refresh it got vanished.
I also tried "atyleownscale", but again the same thing.
Put this on a new chart . . .

Code:
_SECTION_BEGIN("Price");
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() ); 

TimeFrameSet(in1Minute*30);	
	HTFMA = MA(Close,200);	
	HTFUP = Close > HTFMA;
	HTFDN = Close < HTFMA;
TimeFrameRestore();
HTF_MA = TimeFrameExpand(HTFMA,in1Minute*30);
HTF_UP = TimeFrameExpand(HTFUP,in1Minute*30);
HTF_DN = TimeFrameExpand(HTFDN,in1Minute*30);
MA200  = MA(Close,200);
Buy   = Close > MA200 AND HTF_UP; 	
Sell  = Close < MA200;
Buy   = ExRem(Buy,Sell);						
Sell  = ExRem(Sell,Buy);
Short = Close < MA200 AND HTF_DN; 	
Cover = Close > MA200;
Short = ExRem(Short,Cover);						
Cover  = ExRem(Cover,Short);
SetPositionSize(1,4);	
Plot(HTF_MA,"30MIN_MA200",IIf(HTF_UP,colorBlue,colorRed),styleThick);
Plot(MA200,"MA200",IIf(C>MA200, colorBlue,colorRed),styleLine);
PlotShapes(Buy+2*Short,colorWhite,0,IIf(Buy,L,H));
PlotShapes(Cover*3+4*Sell,colorWhite,0,IIf(Cover,L,H));
_SECTION_END();
:) Happy
 
Hello Happy_Singh....you are doing wonderful work here by helping people.

I also need your help for following task.
I've added email alert in one of my afl and it's working great. I am getting emails as I wanted.
Now the problem is amibroker only sends email alerts from only open tab/chart from multiple tab/chart.
How can I configure amibroker or afl so that I can receive email alerts from all tabs/charts?
 

pratapvb

Well-Known Member
Hello Happy_Singh....you are doing wonderful work here by helping people.

I also need your help for following task.
I've added email alert in one of my afl and it's working great. I am getting emails as I wanted.
Now the problem is amibroker only sends email alerts from only open tab/chart from multiple tab/chart.
How can I configure amibroker or afl so that I can receive email alerts from all tabs/charts?
it could be because amibroker may be optimizing update by only refreshing the open sheet....

one possibility is to see if you put timedrefresh function if it helps
 
Hello Happy_Singh....you are doing wonderful work here by helping people.

I also need your help for following task.
I've added email alert in one of my afl and it's working great. I am getting emails as I wanted.
Now the problem is amibroker only sends email alerts from only open tab/chart from multiple tab/chart.
How can I configure amibroker or afl so that I can receive email alerts from all tabs/charts?
Hello

I am not sure if you can do that for a WatchList . . .

But have you tried the built in Easy alerts window


:) Happy
 
it could be because amibroker may be optimizing update by only refreshing the open sheet....

one possibility is to see if you put timedrefresh function if it helps
Hello Pratap . . . .

nothing much to do . . . Nice trend today . . :)

:) Happy
 
Hi all,

I would like to calculate upper band and lower band based on the difference of the MA 5 and MA 35.

Herewith I have attached the sample calculation that I am able to do in excel spreadsheet.

For the first bar, if the difference between two MA is positive – then the difference will be the first value for upper band. For the second bar, if the difference is positive, the difference between two MA will be multiply by 0.05 and add this value to 0.95 of previous upper band value and the total will be value of upper band for 2nd bar.

I try this logic using looping in AmiBroker – however I am unable to get the upper band and lower band.



_SECTION_BEGIN("5-35 OSCILLATOR");

A2 = EMA((H+L)/2,5);
B2 = EMA((H+L)/2,35);
D2 = A2-B2;


Plusbars = BarsSince(D2 > 0);
Minusbars = BarsSince(D2 < 0);


val[ 0 ] = D2[ 0 ]; // initialize first value

for( i = 1; i < BarCount; i++ )
{

Factor = 0.05; // calculate the value of smoothing factor
val[ i ] = Factor * D2[ i ] + ( 1 - Factor ) * val[ i - 1 ];

}

Plot (val,"Upper", ParamColor( "Color", colorCycle ), ParamStyle("Style", styleLine));

Colorm=IIf(D2>0,colorBlue,colorRed);
Plot( D2, "535", Colorm, styleHistogram|styleNoLabel );
PlotOHLC( 0, D2, 0 , 0 , "535",Colorm, styleHistogram | styleThick| maskHistogram);

_SECTION_END();


Please help me.


Thanks
Amruta
 
Last edited:
Hi all,

I would like to calculate upper band and lower band based on the difference of the MA 5 and MA 35.

Herewith I have attached the sample calculation that I am able to do in excel spreadsheet.

For the first bar, if the difference between two MA is positive – then the difference will be the first value for upper band. For the second bar, if the difference is positive, the difference between two MA will be multiply by 0.05 and add this value to 0.95 of previous upper band value and the total will be value of upper band for 2nd bar.

I try this logic using looping in AmiBroker – however I am unable to get the upper band and lower band.



_SECTION_BEGIN("5-35 OSCILLATOR");

A2 = EMA((H+L)/2,5);
B2 = EMA((H+L)/2,35);
D2 = A2-B2;


Plusbars = BarsSince(D2 > 0);
Minusbars = BarsSince(D2 < 0);


val[ 0 ] = D2[ 0 ]; // initialize first value

for( i = 1; i < BarCount; i++ )
{

Factor = 0.05; // calculate the value of smoothing factor
val[ i ] = Factor * D2[ i ] + ( 1 - Factor ) * val[ i - 1 ];

}

Plot (val,"Upper", ParamColor( "Color", colorCycle ), ParamStyle("Style", styleLine));

Colorm=IIf(D2>0,colorBlue,colorRed);
Plot( D2, "535", Colorm, styleHistogram|styleNoLabel );
PlotOHLC( 0, D2, 0 , 0 , "535",Colorm, styleHistogram | styleThick| maskHistogram);

_SECTION_END();


Please help me.


Thanks
Amruta
Try this

Code:
var = D2; // initialize value
Factor = 0.05;	 // calculate the value of smoothing factor
//for( i = 1; i < BarCount; i++ )
//{
var =  D2 * Factor + Ref(var, - 1) * (1 - Factor ) ;
//}
Plot (Var,"Upper", ParamColor( "Color", colorCycle ), ParamStyle("Style", styleLine));
Not gone through the entire code, so not sure about the logic etc that you are using . . .

The above code should plot a line/curve around the histogram, and hopefully it is what you want as per your logic.


:) Happy
 
Happy

Thanks a lot for the prompt reply.

Yes you are right - your code plot an average on the histogram.

However, the logic I mentioned is for the ESignal Advanced Get - Get Oscillator which is plotting both upper band and lower band on the histogram.

So when the difference of the moving averages (5 and 35) is positive - the upper band value change and at that time, the lower band value remain constant based on previous negative value for the difference in the moving average and vice-versa for lower band.

You can see this calculatiuons in the attached image of excel spreadsheet.

Here I have attached the image of actual get oscillator from eSignal advanced get for your reference.


Thanks
Amruta
 
Last edited:
In that case we will need to go back to your looping :)

again not looking at indicator / logic, just syntactical inputs :)


Code:
_SECTION_BEGIN("5-35 OSCILLATOR");
A2 = EMA((H+L)/2,5);
B2 = EMA((H+L)/2,35);
D2 = A2-B2;

UP[0] = IIf(D2[0]>0,D2[0],0); // initialize first value
DN[0] = IIf(D2[0]<0,D2[0],0); // initialize first value

Factor = 0.05;	 // calculate the value of smoothing factor
for( i = 1; i < BarCount; i++ )
{
	UP[i] =  IIf(D2[i]>0,D2[i] * Factor + UP[i - 1] * (1 - Factor ), UP[i - 1]);
	DN[i] =  IIf(D2[i]<0,D2[i] * Factor + DN[i - 1] * (1 - Factor ), DN[i - 1]); ;
}

Plot (UP,"Upper", ParamColor( "Color 1", colorCycle ), ParamStyle("Style 1", styleThick));
Plot (DN,"Lower", ParamColor( "Color 2", colorCycle ), ParamStyle("Style 2", styleThick));

Colorm=IIf(D2>0,colorBlue,colorRed);
Plot( D2, "535", Colorm, styleHistogram|styleNoLabel );

_SECTION_END();


:) Happy
 

Similar threads