NexusFi: Find Your Edge


Home Menu

 





How to fix the data offset with Timeframeset


Discussion in Platforms and Indicators

Updated
    1. trending_up 996 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

How to fix the data offset with Timeframeset

  #1 (permalink)
pradeep5344
San Diego
 
Posts: 1 since Sep 2019
Thanks Given: 0
Thanks Received: 0

Hello,

I am trying to have a strategy where i want to access daily/hourly TF data on a 5 mins chart.
While doing so, i am seeing incorrect data its fetching.
Can you let me know how can i fix it within the code?



when i mean highest and lowest of candle in 5 mins chart.
High has to be hhv of current day only when in daily timeframe and Highest of current hour only when in hourly timeframe
Low has to be llv of current day only when in daily timeframe and Lowest of current hour only when in hourly timeframe
Close has to be latest 5 min candle close value

Daily data has to be:



I did try the TimeFrameSet function for this, and tried to fetch data with Timeframeexpand to verify data in explorations. I might be missing lot of things while doing so, so wanted some help to get it right.

Here is full code.
Descriptions: having the code to display strength of the price action. Added custom timeframe calculation to enable higher timeframe plot on 5 mins chart, but its not showing me same data when i used custom timeframe(hourly/daily) in 5 mins chart,as i use custom(in hourly/ in daily) timeframe on separate chart or standalone

HTML Code:
SetOption( "WarningLevel", 1 );

Plot(100,"Upper Limit",colorBlack,styleDashed);
Plot(-100,"Lower Limit",colorBlack,styleDashed);
debug			= ParamToggle( "Enable Debug Mode"	, "False|True"	, 1);
show_mtf		= ParamToggle( "Show both Mutiple-Timeframe + Current TF plots"		, "False|True"	, 1);
use_same_period		= ParamToggle( "Use same period for all timeframes"	, "False|True"	, 1);

_SECTION_BEGIN("Current Timeframe");
potential_period = Param      ("Periods", 9, 1, 200, 1 );
current_style 	 = ParamStyle ("Style of Current TF");
gainPotential 	 = ParamColor ("Gaining Potential" , colorGreen);
loosPotential 	 = ParamColor ("Loosing Potential" , colorRed  );
changePotential  = ParamColor ("Changing Potential", colorBlue );

ys1	=	(High+Low+Close*2)/4;
rk3	=	EMA(ys1,potential_period);
rk4	=	StDev(ys1,potential_period);
rk5	=	(ys1-rk3)*100/rk4;
rk6	=	EMA(rk5,potential_period);
UP	=	EMA(rk6,potential_period);
DOWN 	=  	EMA(up,potential_period);
Oo	=	IIf(up<down,up,down);
Hh	=	Oo;
Ll	=	IIf(up<down,down,up);
Cc	=	Ll;
barcolor2		=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1),changePotential,  IIf(up>down,gainPotential,loosPotential ));
ribbon_color 	=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1),changePotential , IIf(up>down,gainPotential,IIf( down>up, loosPotential , changePotential )));

if (show_mtf) {
	PlotOHLC(Oo,hh,ll,Cc, "Current" + Name(), barcolor2, current_style );
	Plot(1,"ribbon",ribbon_color,styleOwnScale|styleArea|styleNoLabel, -01, 50 );
}

_SECTION_END();

_SECTION_BEGIN("Custom Timeframe");

potential_tf 	 	= ParamList  ("Custom TimeFrames (default is Daily)", "in1Minute|in5Minute|in15Minute|in30Minute|inHourly|in75Minute|in90Minute|inDaily|inWeekly|inMonthly", 7);
tf_potential_period = Param      ("Custom TimeFrame Periods", 9, 1, 200, 1);
custom_plot_width   = Param      ("Custom Plot Width"       , 2, 1,  15, 1);
custom_style 	 	= ParamStyle ("Style Custom TF");
tf_gainPotential 	= ParamColor ("Gaining Potential" , colorDarkGreen);
tf_loosPotential 	= ParamColor ("Loosing Potential" , colorDarkRed  );
tf_changePotential 	= ParamColor ("Changing Potential", colorDarkBlue );

switch (potential_tf) {
    case "in1Minute"	: tf = in1Minute	; break;
    case "in5Minute"	: tf = in5Minute	; break;
    case "in15Minute"	: tf = in15Minute	; break;
    case "in30Minute"	: tf = 2*in15Minute	; break;
    case "in45Minute"	: tf = 3*in15Minute	; break;
    case "inHourly"		: tf = inHourly		; break;
    case "in75Minute"	: tf = 5*in15Minute	; break;
    case "in90Minute"	: tf = 6*in15Minute	; break;
    case "inDaily"		: tf = inDaily		; break;
    case "inWeekly"		: tf = inWeekly		; break;
    case "inMonthly"	: tf = inMonthly	; break;
    default				: tf = inDaily		; break;
}

if (use_same_period) {
	tf_potential_period = potential_period;
}

TimeFrameSet( tf ); // switch now to specified timeframes

	tf_close = Ref(C, 1);
	tf_ys1	=	(High+Low+tf_close*2)/4;
	tf_rk3	=	EMA(tf_ys1,		tf_potential_period);
	tf_rk4	=	StDev(tf_ys1,	tf_potential_period);
	tf_rk5	=	(tf_ys1-tf_rk3)*100/tf_rk4;
	tf_rk6	=	EMA(tf_rk5,		tf_potential_period);
	tf_UP	=	EMA(tf_rk6,		tf_potential_period);
	tf_DOWN =   EMA(tf_up,		tf_potential_period);
	tf_Oo	=	IIf(tf_up < tf_down, tf_up, tf_down);
	tf_Hh	=	tf_Oo;
	tf_Ll	=	IIf(tf_up < tf_down, tf_down, tf_up);
	tf_Cc	=	tf_Ll;
	tf_barcolor2 = IIf(Ref(tf_oo,-1)<tf_Oo AND tf_Cc<Ref(tf_Cc,-1), tf_changePotential, IIf( tf_up>tf_down, tf_gainPotential, tf_loosPotential ));
	tf_rib_color = IIf(Ref(tf_oo,-1)<tf_Oo AND tf_Cc<Ref(tf_Cc,-1), tf_changePotential, IIf( tf_up>tf_down, tf_gainPotential, IIf( tf_down>tf_up, tf_loosPotential, tf_changePotential )));
if (debug) {
	AddColumn(H			,"Inside High"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(L			,"Inside Low"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(C			,"Inside Close" 		,  1.2 , colorDefault , colorDefault);
	}
TimeFrameRestore(); 

mtf_Oo 		   	 = TimeFrameExpand (tf_Oo		, tf);
mtf_Hh 		  	 = TimeFrameExpand (tf_Hh		, tf);
mtf_Ll 		  	 = TimeFrameExpand (tf_Ll		, tf);
mtf_Cc 		  	 = TimeFrameExpand (tf_Cc		, tf);
mtf_close	  	 = TimeFrameExpand (Close		, tf);
mtf_barcolor2 	 = TimeFrameExpand (tf_barcolor2, tf);
mtf_ribbon_color = TimeFrameExpand (tf_rib_color, tf);

Plot(mtf_Cc, "TimeFrame" + Name(), mtf_barcolor2, custom_style, Null, Null, 0 , 0, custom_plot_width );
Plot(2,"ribbon", mtf_ribbon_color,styleOwnScale|styleArea|styleNoLabel, -300, 20 );

if (debug) {
	Filter = 1;
	AddColumn(H			,"High"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(L			,"Low"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(C			,"Close" 		,  1.2 , colorDefault , colorDefault);
	AddColumn(Cc		,"Pot Close"	,  1.2 , barcolor2	  , colorDefault);
	
	AddColumn(TimeFrameExpand(H, tf)			,"TF High"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(L, tf)			,"TF Low"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(C, tf)			,"TF Close" 		,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(H, tf)			,"EL TF High"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(L, tf)			,"EL TF Low"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(C, tf)			,"EL TF Close" 		,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_Close, tf)		,"TF1 Close" 		,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_ys1, tf)		,"TF ys1"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_rk3, tf)		,"TF rk3"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_rk4, tf)		,"TF rk4"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_rk5, tf)		,"TF rk5"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_rk6, tf)		,"TF rk6"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_UP, tf)		,"TF UP"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_DOWN, tf)		,"TF DOWN"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_Oo, tf)		,"TF Oo"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_Hh, tf)		,"TF Hh"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_Ll, tf)		,"TF Ll"			,  1.2 , colorDefault , colorDefault);
	AddColumn(TimeFrameExpand(tf_Cc, tf)		,"TF Pot Close"	,  1.2 , barcolor2	  , colorDefault);
	AddColumn(TimeFrameExpand(tf_barcolor2, tf)	,"TF Barcolor2"	,  1.2 , barcolor2	  , colorDefault);
	AddColumn(TimeFrameExpand(Ref(C, 1), tf)	,"TF Close"	 		,  1.2 , colorDefault , colorDefault);
	AddColumn(mtf_Cc	,"MTF Pot Close",  1.2 , mtf_barcolor2, colorDefault);
}

_SECTION_END();
-Thanks

Reply With Quote




Last Updated on September 24, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts