SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
_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(), Null, Null, 0, 1, 1);
OneMinute=in1Minute*1;
TimeFrameSet(OneMinute);
global n1, n2, n3, TenkanSen, KijunSen, ChinkouSpan, Cks, SenkouSpanA, SpA, SenkouSpanB, SpB;
n1 = 9;//Param("TenkanSen",9,1,200,1);
n2 = 26;//Param("KijunSen",26,1,400,1);
n3 = 52;//Param("Senkou",52,1,600,1);
TenkanSen =(HHV(H,n1)+LLV(L,n1))/2;
KijunSen =(HHV(H,n2)+LLV(L,n2))/2;
ChinkouSpan =Ref(C,-n2);
Cks = Close;
SenkouSpanA =Ref((KijunSen+TenkanSen)/2,-n2);
SpA =(KijunSen+TenkanSen)/2;
SenkouSpanB =Ref((HHV(H,n3)+LLV(L,n3))/2,-n2);
SpB =(HHV(H,n3)+LLV(L,n3))/2;
TenkanSen=TimeFrameExpand(TenkanSen, OneMinute);
KijunSen=TimeFrameExpand(KijunSen, OneMinute);
ChinkouSpan=TimeFrameExpand(ChinkouSpan, OneMinute);
Cks=TimeFrameExpand(Cks, OneMinute);
SenkouSpanA=TimeFrameExpand(SenkouSpanA, OneMinute);
SpA=TimeFrameExpand(SpA, OneMinute);
SenkouSpanB=TimeFrameExpand(SenkouSpanB, OneMinute);
SpB=TimeFrameExpand(SpB, OneMinute);
TimeFrameRestore();
Plot (TenkanSen, "Tenkan-sen",colorOrange, styleNoLabel+styleNoTitle,Null,Null,0,0,.05);
Plot (KijunSen, "Kijun-sen", colorRed, styleNoLabel+styleNoTitle,Null,Null,0,0,.05);
PlotOHLC (SenkouSpanA, SenkouSpanA, SenkouSpanB, SenkouSpanB, "Cloud", IIf (SenkouSpanA>SenkouSpanB, ColorBlend( colorBlue, colorWhite, 0.65 ),
ColorBlend(colorPink, colorWhite, 0.65 )), styleCloud+ styleNoTitle, 10, 10, 0, 0,.05);
TimeFrameSet(OneMinute);
I1 = TenkanSen;
I2 = KijunSen;
I3 = SenkouSpanA;
I4 = SenkouSpanB;
NearestAboveDiff = 1e9;
NearestBelowDiff= 1e9;
for( n = 1; n <= 4; n++ )
{
i = Ref(VarGet( "I"+ n), -1);
Diff = i - Ref(C, -1);
Above = IIF( Diff > 0, Diff, 1e9);
Below = IIF( Diff < 0, -Diff, 1e9);
NearestAboveDiff = Min(NearestAboveDiff, Above);
NearestBelowDiff = Min( NearestBelowDiff, Below);
}
NearestAboveInd=NearestAboveDiff+Ref(C, -1);
NearestBelowInd=Ref(C, -1)-NearestBelowDiff;
TimeFrameRestore();
confirmationLevelForCloudSupport=TimeFrameExpand(NearestAboveInd, OneMinute);
confirmationLevelForCloudResistance=TimeFrameExpand(NearestBelowInd, OneMinute);
_TRACE("!CLEAR!");
_TRACE("confirmationLevelForCloudResistance="+confirmationLevelForCloudResistance+" confirmationLevelForCloudSupport="+confirmationLevelForCloudSupport);
I expect the values to be same in a 1 minute chart and a 1 second chart but I am getting different values. I don’t understand I did all the calculations inside timeframeset() but still not getting the correct values. You would need 1 second data to debug this.