Thanks @mradtke
Sorry about just providing snippet instead of full code.
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 enamle 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
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();
Sure will verify the licence
-Thanks
Pradeep