Simple Coding Help - No Promise.

josh1

Well-Known Member
Can you check by changing following setting:
Tools > Preferences > Intraday

Default (radio button) is checked on START Time (recommended)

change it to:
Time of LAST TICK inside bar
Tried that. It si not working
 

lvgandhi

Well-Known Member
I want to plot some parameters only for today. For example I want to plot support and resistance only for today. I have the afl as follows.
Code:
_SECTION_BEGIN("Support and resistance levels");
x=LastVisibleValue(DateNum());
Cond=BarsSince(DateNum()<x);
y=Ref(DateNum(),-Cond);
Cond1=BarsSince(DateNum()<LastValue(y));
z=Cond1-Cond;
Hi0=HHV(H,Cond);
Hi0bar=HHVBars(H,Cond);

x20=BarCount-LastValue(Cond);
x21=BarCount-1;
y20=LastVisibleValue(Hi0);
y21=y20;
Line2 = LineArray( x20, y20, x21, y21, 1 );
Plot( Line2, "day high line", colorOrange,styleThick|styleNoTitle);

Li0=LLV(L,Cond);
Li0bar=LLVBars(L,Cond);
dr=Hi0-Li0;
Title += EncodeColor(colorPaleGreen)+"  Days Range:"+dr;

x30=BarCount-LastValue(Cond);
x31=BarCount-1;
y30=LastVisibleValue(Li0);
y31=y30;
Line3 = LineArray( x30, y30, x31, y31, 1 );
Plot( Line3, "day low line", colorTurquoise,styleThick|styleNoTitle );


PDH =  TimeFrameGetPrice("H", inDaily, -1); 
PDL =  TimeFrameGetPrice("L", inDaily, -1);
PDC =  TimeFrameGetPrice("C", inDaily, -1);
DH =  TimeFrameGetPrice("H", inDaily); 
DL =  TimeFrameGetPrice("L", inDaily);

PV=(PDH+PDL+PDC)/3;
R1=2*Pv-PDL;
R2=PV+PDH-PDL;
S1=2*PV-PDH;
S2=PV-PDH+PDL;
rd1=ParamToggle("rd1","Off|On",1);
rd2=ParamToggle("rd2","Off|On",1);
sd1=ParamToggle("sd1","Off|On",1);
sd2=ParamToggle("sd2","Off|On",1);
if(rd1==1)
Plot(R1, "R 1",colorPink,styleDots|styleNoLabel|styleNoTitle);
if(rd2==1)
Plot(R2, "R 2",colorRed,styleDots|styleNoLabel|styleNoTitle);
Plot(PV, "Pivot",colorWhite,styleDots|styleNoLabel|styleNoTitle);
if(sd1==1)
Plot(S1, "S 1",colorPaleGreen,styleDots|styleNoLabel|styleNoTitle);
if(sd2==1)
Plot(S2, "S 2",colorGreen,styleDots|styleNoLabel|styleNoTitle);
Cr=ATR(11);
Title += "  Atr :"+Cr;
_SECTION_END();
It plots for previous days also. How to modify to show plot for today only,.
 
@LV Gandhi

Replace the portion of PDH,PDL,PDC,DH,DL with the code given below. I think it should work.
Code:
TimeFrameSet(inDaily);
PDH =  Lastvalue(Ref(H,-1));
PDL =  Lastvalue(Ref(L,-1));
PDC =  Lastvalue(Ref(C,-1));
DH =   Lastvalue(Ref(H, 0));
DL =   Lastvalue(Ref(L,0));
TimeFrameRestore();
 

lvgandhi

Well-Known Member
@LV Gandhi

Replace the portion of PDH,PDL,PDC,DH,DL with the code given below. I think it should work.
Code:
TimeFrameSet(inDaily);
PDH =  Lastvalue(Ref(H,-1));
PDL =  Lastvalue(Ref(L,-1));
PDC =  Lastvalue(Ref(C,-1));
DH =   Lastvalue(Ref(H, 0));
DL =   Lastvalue(Ref(L,0));
TimeFrameRestore();
Thanks.
 

josh1

Well-Known Member
Can you provide code for DH, DL variables? AFL pasted here throws error.
Replace them with RGH and RGL. Also replace RGClrs with color of your choice. Thanks
 
This AFL gives me Initial Range High Low and also a crooked line at the EOD. I want to remove that Crooked line.

Code:
_SECTION_BEGIN("Initial Range HI-LO");

IRHL = ParamToggle("InitialRange HI LO","Show|Hide",1);

DayC = TimeFrameGetPrice("C", inDaily, -1);  DayCI = LastValue (DayC,1);    // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily);      DayOI = LastValue (DayO,1);   // current day open

beginTradeTime = ParamTime("Strt Time ", "9:15:00");
endRangeTime    = ParamTime("Range Time","9:30:00");

DaysBack = 0;

IRHigh = Max(deTimeRangeHHV(H,beginTradeTime ,endRangeTime ),deTimeRangeHHV(H,beginTradeTime ,endRangeTime ));
IRLow = Min(deTimeRangeLLV(L,beginTradeTime ,endRangeTime),deTimeRangeLLV(L,beginTradeTime ,endRangeTime ));

RGH = ValueWhen(deFlagLastBarOfDay(endRangeTime ),IRHigh ,DaysBack);
RGL = ValueWhen(deFlagLastBarOfDay(endRangeTime ), IRLow ,DaysBack);


RH = IRHigh;  RHI = LastValue (DH,1);// 15 Min high
RL = IRLow;  RLI = LastValue (DL,1);    // 15 Min low
 
Today = LastValue(Day());
 
numbars = LastValue(Cum(Status("barvisible")));
Hts  = -33.5;
Today = LastValue(DaysSince1900());


if(IRHL==1) {

//    Plot(IIf(Today==DaysSince1900(),RL,Null),"RL",RGClrs,styleLine|styleThick|styleNoRescale|styleNoTitle|styleNoLabel,0,0,0,BarLayer+1);
//    Plot(IIf(Today==DaysSince1900(),RH,Null),"RH",RGClrs,styleLine|styleThick|styleNoRescale|styleNoTitle|styleNoLabel,0,0,0,BarLayer+1);
//    Plot(IIf(Today==Day(),RGL,Null),"RL",RGClrs,styleLine|styleThick|styleNoRescale|styleNoTitle|styleNoLabel,0,0,0,BarLayer+1);
//    Plot(IIf(Today==Day(),RGH,Null),"RH",RGClrs,styleLine|styleThick|styleNoRescale|styleNoTitle|styleNoLabel,0,0,0,BarLayer+1);
    Plot(RL,"RL",RGClrs,styleLine|styleThick|styleNoRescale|styleNoTitle|styleNoLabel,0,0,0,BarLayer+1);
    Plot(RH,"RH",RGClrs,styleLine|styleThick|styleNoRescale|styleNoTitle|styleNoLabel,0,0,0,BarLayer+1);
}
https://imgur.com/a/OeCYH
Sir, I just replaced DH and DL with RH and RL and its working fine showing the last days resistance/support at the defined time and no crooked line. The code line that was changed is as below:
Code:
RH = IRHigh;  RHI = LastValue (RH,1);// 15 Min high
RL = IRLow;  RLI = LastValue (RL,1);    // 15 Min low
Hope it helps. Thnx
 

Similar threads