[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: TimeFrames: Is their use flawed?



PureBytes Links

Trading Reference Links

Hi AF!

Very interesting code and way to calculate the Higher TF without using loops!!!

However, as far as I can see there are some small problems in there and if you change the following you will see that it will be correct:

HTF_Min = Param("Haw many minutes if HTM in minutes ?",1,10,60,1);
TO:
HTF_Min = Param("Haw many minutes if HTM in minutes ?",1,1,60,1);

HTF = in1Minute * 60 * HTF_Min;
TO:
HTF = in1Minute * HTF_Min;

AND:
Plot(TimeFrameExpand(MA_HTF,HTF),"MA(C,"+NumToStr(HTF_Period,1.0)+")", Traditional_Color);
TO:
Plot(TimeFrameExpand(MA_HTF,HTF, expandFirst),"MA(C,"+NumToStr(HTF_Period,1.0)+")", Traditional_Color);

Saying that, I have to study this very interesting code in detail. But would your solution also work for more complex indicator calculations? Because if it does this would be a faster and more effective code than mine- since I used 2 loops.

Regards,

Jorgen

--- In amibroker@xxxxxxxxxxxxxxx, "af_1000000" <af_1000000@xxx> wrote:
>
> Sorry for not paying enough attention. This is the correct code version which plots MA values from a higher timeframe chart (as you see it) on the current timeframe chart.
> 
> HTF_Sel = ParamList("Higher Timeframe","inMinutes|Weekly|Daily|Monthly|Quaterly|Yearly");
> HTF_Min = Param("Haw many minutes if HTM in minutes ?",1,10,60,1);
> HTF_Period = Param("Higher TimeFrame MA Period",3,2,200,1);
> Plot_Traditional = ParamToggle("Plot MA using Traditional Higher TimeFrame?","No|Yes",defaultval=1);
> Plot_Close = ParamToggle("Plot Close of Higher TimeFrame?","No|Yes",defaultval=1);
> Plot_HTM_Bars = ParamToggle("Plot Higher TimeFrame Bars?","No|Yes",defaultval=1);
> Resolution_Color = ParamColor("MA color using lower resolution TimeFrame ",colorBrightGreen);
> Traditional_Color = ParamColor("MA color using Traditional Higher TimeFrame ",colorYellow);
> Close_Color = ParamColor("Close of Higher TimeFrame color",colorRed);
> Bar_Color = ParamColor("Higher TimeFrame Bar color",colorBlue);
> 
> switch (HTF_Sel)
> {
> 	case "inMinutes":
> 		HTF = in1Minute * 60 * HTF_Min;
> 		break;
> 	case "Daily":
> 		HTF = inDaily;
> 		break;
> 	case "Weekly":
> 		HTF = inWeekly;
> 		break;
> 	case "Monthly":
> 		HTF = inMonthly;
> 		break;
> 	case "Quaterly":
> 		HTF = inQuarterly;
> 		break;
> 	case "Yearly":
> 		HTF = inYearly;
> 		break;
> }
> 
> Chart_Interval = Interval();
> if (Chart_Interval >= HTF)
> {
> 	Font_Size = 12;
> 	X_Text = floor(Status("pxwidth") * 0.01);
> 	Y_Text = floor(Status("pxheight") / 2 - Font_Size / 2);
> 
> 	GfxSetOverlayMode( 0); 
> 	GfxSelectFont("Tahoma",Font_Size,800);
> 	GfxSetTextColor(colorRed);	
> 	Error = "!!! THE HIGHER TIMEFRAME HAS TO BE GREATER THAN THE CURRENT CHART INTERVAL !!!";	
> 	GfxTextOut(Error,X_Text,Y_Text);
> }
> else
> {
> 	// the essential code - calculation of MA(Close,HTF_Period) of the Higher Timeframe using the resulution of the current chart TimeFrame
> 	TimeFrameSet(HTF);
> 	BI_HTF = BarIndex();	
> 	Close_HTF = Close;
> 	MA_HTF = MA(Close_HTF,HTF_Period);
> 	Sum_HTF = Sum(Close_HTF,HTF_Period);
> 	Sum_NO_HTF = Sum(Close_HTF,HTF_Period - 1);
> 
> 	TimeFrameRestore();
> 	BI_HTF_in_Base = TimeFrameExpand(BI_HTF,HTF);
> 	HTF_Bar_in_Base = IIf(BI_HTF_in_Base != Ref(BI_HTF_in_Base,-1),1,0);
> 
> 	Jorgen_MA = IIf(HTF_Bar_in_Base,TimeFrameExpand(Sum_HTF,HTF) / HTF_Period,(TimeFrameExpand(Sum_NO_HTF,HTF) + Close) / HTF_Period);
> 	Plot(Jorgen_MA,"JMA(C,"+NumToStr(HTF_Period,1.0)+")",Resolution_Color);
> 	// end of the essential code
> 
> 
> 
> 	// ###################     This is for illustration purposes only  ###################################
> 
> 	if (Plot_Traditional)
> 		Plot(TimeFrameExpand(MA_HTF,HTF),"MA(C,"+NumToStr(HTF_Period,1.0)+")", Traditional_Color);
> 
> 	if (Plot_Close)
>  		Plot(TimeFrameExpand(Close_HTF,HTF),"C_TF",Close_Color ); 
> 
> 	if (Plot_HTM_Bars)
> 	{
> 		Height = Param("Higher TimeFrame Bar Height as % of Y axis",10, 2, 90, 1) ;
> 		Min_Y = Status("axisminy");
> 		Max_Y = Status("axismaxy");
> 		HTF_B = IIf(HTF_Bar_in_Base,  Min_Y + 0.01 * Height * (Max_Y - Min_Y),Null);
> 		Plot(HTF_B,"",Bar_Color,styleHistogram);
> 	}
> }
> 
> AF
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/