Seniors please help to plot the levels in complete chart instead of only current period
Hi
below afl plot level only for current period, i want to plot level for old period too as shown in snap shot, please help me to plot level on complete data
below afl plot level only for current period, i want to plot level for old period too as shown in snap shot, please help me to plot level on complete data
Code:
_SECTION_BEGIN("Trading");
pShowtradeLines = ParamToggle("Show Trade Lines", "No|Yes", 1);
PerctakeProfit=Param("Take Profit Percent Set",0.6,0.3,30,0.1);
PercStoploss=Param("StopLoss Percent Set",0.25,0.2,5,0.1);
PlotOHLC(Open,High,Low,Close,"",colorWhite,styleCandle);
Bars = 0;
xpdh = 90;
Plot_Range = DayOfWeek() > 0;
FH_Range = DayOfWeek() > 1;
FH_Prices = High * FH_Range;
FH_Marker = BarsSince(FH_Range>0);
Num_Bars = 5;
TimeFrameSet(inWeekly);
TOP_ = Open;
PDH_ = Ref(High,-1);
PDL_ = Ref(Low,-1);
PDO_ = Ref(Open,-1);
PDC_ = Ref(Close,-1);
PDM_ = (PDH_+PDL_)/2;
TimeFrameRestore();
isAll = True;
isRth = DayOfWeek() <= 1; // monday
isdRth = DayOfWeek() > 1; // Tuesday to saturday
aRthL = IIf(isRth, L, 1000000);
aRthH = IIf(isdRth, H, Null);
aRthLd = IIf(isdRth, L, 1000000);
TOP = TimeFrameExpand(TOP_,inWeekly,expandFirst);
PDH = TimeFrameExpand(PDH_,inWeekly,expandFirst);
PDL = TimeFrameExpand(PDL_,inWeekly,expandFirst);
PDO = TimeFrameExpand(PDO_,inWeekly,expandFirst);
PDC = TimeFrameExpand(PDC_,inWeekly,expandFirst);
PDM = TimeFrameExpand(PDM_,inWeekly,expandFirst);
FHH = Ref(HHV(High*FH_Range,Num_Bars),-FH_Marker);
FHL = TimeFrameCompress( aRthL, inWeekly, compressLow );
FHL = TimeFrameExpand( FHL, inWeekly, expandFirst );
DayH = TimeFrameCompress( aRthH, inWeekly, compressHigh );
DayH = TimeFrameExpand( DayH, inWeekly, expandFirst );
DayL = TimeFrameCompress( aRthLd, inWeekly, compressLow );
DayL = TimeFrameExpand( DayL, inWeekly, expandFirst );
FC1=((PDH-PDL)*0.433);
FC2=((PDH-PDL)*0.7666);
FC3=((PDH-PDL)*1.355);
FC4=(FHH-FHL);
A=IIf((FC4<=FC1+PDH*0.005),FC1,0);
B=IIf((FC4<=FC2+PDH*0.005 AND FC4>FC1+PDH*0.005),FC2,0);
Cl=IIf((FC4<=FC3 AND FC4>FC2+PDH*0.005),FC3,0);
AF=(A+B+Cl);
BuyPrice=(DayL+AF);
BuyTP1=(BuyPrice+(BuyPrice*(PerctakeProfit/100)));
BuyTP2=(C>=BuyTP1);
SellPrice=(DayH-AF);
SellTP1=(SellPrice-(SellPrice*(PerctakeProfit/100)));
SellTP2=(C<=SellTP1);
percchange=(((C-TOP)/TOP)*100);
BuyStop1=(BuyPrice-(BuyPrice*(PercStoploss/100)));
BuyStop2=IIf((BuyStop1<=SellPrice) AND SellPrice<=BuyPrice,SellPrice,BuyStop1);
SellStop1=(SellPrice+(SellPrice*(PercStoploss/100)));
SellStop2=IIf((SellStop1>=BuyPrice) AND SellPrice<=BuyPrice, BuyPrice,SellStop1);
BuyStop=IIf((NOT BuyTP2),BuyStop2,Null);
BuyTP=IIf(NOT BuyStop,BuyTP2,Null);
Bars = DayOfWeek(); // day of week is equal to bars since new week.
x0 = BarCount-LastValue(Bars);
x1 = BarCount-1;
TOP_Line = LineArray(x0,LastValue(TOP),x1,LastValue(TOP),0);
PDH_Line = LineArray(x0,LastValue(PDH),x1,LastValue(PDH),0);
PDL_Line = LineArray(x0,LastValue(PDL),x1,LastValue(PDL),0);
PDC_Line = LineArray(x0,LastValue(PDC),x1,LastValue(PDC),0);
PDM_Line = LineArray(x0,LastValue(PDM),x1,LastValue(PDM),0);
FHH_Line = LineArray(x0,LastValue(FHH),x1,LastValue(FHH),0);
FHL_Line = LineArray(x0,LastValue(FHL),x1,LastValue(FHL),0);
BuyPriceline=LineArray(x0,LastValue(BuyPrice),x1,LastValue(BuyPrice),0);
BuyStopline=LineArray(x0,LastValue(BuyStop2),x1,LastValue(BuyStop2),0);
BuyTPline=LineArray(x0,LastValue(BuyTP1),x1,LastValue(BuyTP1),0);
SellPriceline=LineArray(x0,LastValue(SellPrice),x1 ,LastValue(SellPrice),0);
SellStopline=LineArray(x0,LastValue(SellStop2),x1, LastValue(SellStop2),0);
SellTPline=LineArray(x0,LastValue(SellTP1),x1,LastValue(SellTP1),0);
DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0);
DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0);
Plot(IIf(pShowtradeLines,BuyStopline,Null),"BuyStop",colorBrightGreen,styleDots|styleNoRescale| styleNoLine);
Plot(IIf(pShowtradeLines,SellPriceline,Null),"Short Here",colorRed,styleDots|styleNoRescale);
_SECTION_END();