Simple Coding Help - No Promise.

amitrandive

Well-Known Member
Thanks a lot amit for caring so much ...

afl is now ok ....

But agin 1 request only if it is possible ...


image url

When i squeeze chart is it possible to increase number of bars to view high more backwards ?
..

Regards ...
Sumit Lama
Sumit

I have modified the AFL for the text location to be on top of the line.Attached image shows the code.You can change the number"25" to get the desired location of text horizontally and change the number"1" to get the desired location vertically.



The chart can be compressed and parameters can be selected to be logarithmic as shown.




Please clarify if I have interpreted your requirement in red bold,correctly.Here is the final AFL.

Code:
_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_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() ); 
_SECTION_END();

//Previous Days HI LO CL//

DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); DayCI = LastValue (DayC,1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
DayH2= TimeFrameGetPrice("H", inDaily, -2); DayH2I = LastValue (DayH2,1); // Two days before high
DayL2= TimeFrameGetPrice("L", inDaily, -2); DayL2I = LastValue (DayL2,1); // Two days before low
DayC2= TimeFrameGetPrice("C", inDaily, -2); DayC2I = LastValue (DayC2,1); // Two days before close
DayH3= TimeFrameGetPrice("H", inDaily, -3); DayH3I = LastValue (DayH3,1); // Three days before high
DayL3= TimeFrameGetPrice("L", inDaily, -3); DayL3I = LastValue (DayL3,1); // Three days before low
DayC3= TimeFrameGetPrice("C", inDaily, -3); DayC3I = LastValue (DayC3,1); // Three days before close
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;

YHL = ParamToggle("Yesterday HI LO CL ","Show|Hide",1);
if(YHL==1) {
Plot(DayL,"YL",colorRed,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH,"YH",colorBlue,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayC,"YC",colorDarkYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" YH " , LastValue(BarIndex())-25, DayHI+1, colorBlue);
PlotText(" YL " , LastValue(BarIndex())-25, DayLI+1, colorRed);
PlotText(" YC " , LastValue(BarIndex())-25, DayCI+1, colorDarkYellow);
}

TDBHL = ParamToggle("2/3Days before HI LO CL","Show|Hide",1);
if(TDBHL==1) {
Plot(DayL2,"2DBL",colorOrange,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH2,"2DBH",colorGreen,styleDots|styleNoLine |styleNoRescale|styleNoTitle);
Plot(DayC2,"2DBC",colorWhite,styleDots|styleNoLine |styleNoRescale|styleNoTitle);
Plot(DayL3,"3DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH3,"3DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayC3,"3DBC",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" 2DBH " , LastValue(BarIndex())-25, DayH2I+1, colorGreen);
PlotText(" 2DBL " , LastValue(BarIndex())-25, DayL2I+1, colorOrange);
PlotText(" 2DBC " , LastValue(BarIndex())-25, DayC2I+1, colorWhite);
PlotText(" 3DBH " , LastValue(BarIndex())-25, DayH3I+1, colorTurquoise);
PlotText(" 3DBL " , LastValue(BarIndex())-25, DayL3I+1, colorTurquoise);
PlotText(" 3DBC " , LastValue(BarIndex())-25, DayC3I+1, colorTurquoise);
}

// Pivot Levels //
PP = (DayL + DayH + DayC)/3; PPI = LastValue (PP,1); // Pivot
R1 = (PP * 2) - DayL; R1I = LastValue (R1,1); // Resistance 1
S1 = (PP * 2) - DayH; S1I = LastValue (S1,1); // Support 1
R2 = PP + R1 - S1; R2I = LastValue (R2,1); // Resistance 2
S2 = PP - R1 + S1; S2I = LastValue (S2,1); // Support 2
R3 = PP + R2 - S1; R3I = LastValue (R3,1); // Resistance 3
S3 = PP - R2 + S1; S3I = LastValue (S3,1); // Support 3

ppl = ParamToggle("Pivot Levels","Show|Hide",1);
if(ppl==1) {
Plot(PP, "PP",colorYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R1, "R1",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S1, "S1",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R2, "R2",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S2, "S2",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R3, "R3",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S3, "S3",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);

PlotText(" Pivot ", LastValue(BarIndex())-25, PPI+1, colorYellow);
PlotText(" R1 " , LastValue(BarIndex())-25, R1I+1, colorViolet);
PlotText(" S1 " , LastValue(BarIndex())-25, S1I+1, colorViolet);
PlotText(" R2 " , LastValue(BarIndex())-25, R2I+1, colorViolet);
PlotText(" S2 " , LastValue(BarIndex())-25, S2I+1, colorViolet);
PlotText(" R3 " , LastValue(BarIndex())-25, R3I+1, colorViolet);
PlotText(" S3 " , LastValue(BarIndex())-25, S3I+1, colorViolet);
}
// Camerilla Levels //

rg = (DayH - DayL);

H5=DayC+1.1*rg; H5I = LastValue (H5,1);
H4=DayC+1.1*rg/2; H4I = LastValue (H4,1);
H3=DayC+1.1*rg/4; H3I = LastValue (H3,1);
H2=DayC+1.1*rg/6; H2I = LastValue (H2,1);
H1=DayC+1.1*rg/12; H1I = LastValue (H1,1);
L1=DayC-1.1*rg/12; L1I = LastValue (L1,1);
L2=DayC-1.1*rg/6; L2I = LastValue (L2,1);
L3=DayC-1.1*rg/4; L3I = LastValue (L3,1);
L4=DayC-1.1*rg/2; L4I = LastValue (L4,1);
L5=DayC-1.1*rg; L5I = LastValue (L5,1);

pcl = ParamToggle("Camerilla Levels","Show|Hide",0);
if(pcl==1) {
Plot(H5,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(H4,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(H3,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(H2,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(H1,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L1,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L2,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L3,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L4,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(L5,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" H5 = " , LastValue(BarIndex())-25, H5I +0.05, colorRose);
PlotText(" H4 = " , LastValue(BarIndex())-25, H4I +0.05, colorRose);
PlotText(" H3 = " , LastValue(BarIndex())-25, H3I +0.05, colorRose);
PlotText(" H2 = " , LastValue(BarIndex())-25, H2I +0.05, colorRose);
PlotText(" H1 = " , LastValue(BarIndex())-25, H1I +0.05, colorRose);
PlotText(" L1 = " , LastValue(BarIndex())-25, L1I +0.05, colorRose);
PlotText(" L2 = " , LastValue(BarIndex())-25, L2I +0.05, colorRose);
PlotText(" L3 = " , LastValue(BarIndex())-25, L3I +0.05, colorRose);
PlotText(" L4 = " , LastValue(BarIndex())-25, L4I +0.05, colorRose);
PlotText(" L5 = " , LastValue(BarIndex())-25, L5I +0.05, colorRose);
}

// Current Days Hi Lo //
THL = ParamToggle("Todays Hi Lo","Show|Hide",1);
if(THL==1) {
isRth = TimeNum() >= 084500 & TimeNum() <= 085959;
isdRth = TimeNum() >= 084500 & TimeNum() <= 235900;
aRthL = IIf(isRth, L, 1000000);
aRthH = IIf(isdRth, H, Null);
aRthLd = IIf(isdRth, L, 1000000);
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
Bars = BarsSince(TimeNum() >= 94500 AND TimeNum() < 095959);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum());
x0 = BarCount-LastValue(Bars);
x1 = BarCount-1;
DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0);
DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0);
DayHlineI = LastValue (DayHline,1);
DayLlineI = LastValue (DayLline,1);
Plot(DayHline,"DayH",colorYellow,styleBar|styleNoRescale|styleNoTitle);
Plot(DayLline,"DayL",colorYellow,styleBar|styleNoRescale|styleNoTitle);
PlotText(" Day Hi " , LastValue(BarIndex())-25, DayHlineI +0.05, colorYellow);
PlotText(" Day Lo " , LastValue(BarIndex())-25, DayLlineI +0.05, colorYellow);
}
 

toughard

Well-Known Member
Dear all....

I am using this set up in an other plat form but tried to create an AFL and failed as it look like advanced job...



ita simple hourly pivots getting plotted permanently...


can some one help?
 

amitrandive

Well-Known Member
Dear all....

I am using this set up in an other plat form but tried to create an AFL and failed as it look like advanced job...



ita simple hourly pivots getting plotted permanently...


can some one help?
Try this
Code:
SetChartBkColor(ParamColor("Panel color ", colorWhite));
Plot(C, "close", ParamColor("Chart color", 11), styleCandle);
 
Titledisplay = ParamToggle("Display pivot stats", "No|Yes", 1);
 
//---- pivot points 
HourH = TimeFrameGetPrice("H", inHourly,  - 1); // yesterdays high 
HourL = TimeFrameGetPrice("L", inHourly,  - 1); //low 
HourC = TimeFrameGetPrice("C", inHourly,  - 1); //close 
HourO = TimeFrameGetPrice("O", inHourly); // current day open 
 
//------------------------------------moje MODES
Mode = Param("Mode (0-wooFib,1-woodies,2-regular,3-Camarilla)", 2, 0, 3, 1);
// woodies FIB pivots
if (Mode == 0)
{
  R = HourH - HourL; // range
  PP = (HourH + HourL + hourO + hourO) / 4;
  R1 = PP + (R *0.38);
  R2 = PP + (R *0.62);
  S1 = PP - (R *0.38);
  S2 = PP - (R *0.62);
  R3 = PP + (R *0.786); //experimental
  S3 = PP - (R *0.786); //experimental
}
 
// woodies pivots
else if (Mode == 1)
{
 
  PP = (HourH + HourL + HourO + HourO) / 4;
  R1 = (2 *PP) - HourL;
  S1 = (2 *PP) - HourH;
  R2 = PP + R1 - S1;
  S2 = PP + S1 - R1;
  R3 = R2 + (R1 - PP);
  S3 = S2 - (PP - S1);
}
 
// regular pivots
else if (Mode == 2)
{
  PP = (HourL + HourH + HourC) / 3;
  R1 = (2 *PP) - HourL;
  S1 = (2 *PP) - HourH;
  R2 = (PP - S1) + R1;
  S2 = PP - (R1 - S1);
  R3 = R1 + (HourH - HourL);
  S3 = S1 - (HourH - HourL);
}
 
//Camarilla Pivots
else if (Mode == 3)
{
  PP = (HourL + HourH + HourC) / 3;
  R4 = (HourH - HourL) *1.1 / 2+HourC;
  R3 = (HourH - HourL) *1.1 / 4+HourC;
  R2 = (HourH - HourL) *1.1 / 6+HourC;
  R1 = (HourH - HourL) *1.1 / 12+HourC;
  S1 = HourC - (HourH - HourL) *1.1 / 12;
  S2 = HourC - (HourH - HourL) *1.1 / 6;
  S3 = HourC - (HourH - HourL) *1.1 / 4;
  S4 = HourC - (HourH - HourL) *1.1 / 2;
}
 
//koniec moje MODES 
style = styleLine | styleDashed | styleThick + styleNoRescale;
rcolor = colorLime;
scolor = colorCustom10;
pcolor = colorPink;
Plot(R1, "R1", rcolor, style);
Plot(S1, "S1", scolor, style);
Plot(R2, "R2", rcolor, style);
Plot(S2, "S2", scolor, style);
Plot(PP, "PP", pcolor, style);
Plot(S3, "S3", scolor, style);
Plot(R3, "R3", rcolor, style);
 
 
Titledisplaycode = "\n" + "" + EncodeColor(colorBlack) +  //Date() + "\n" + "\n" +
//EncodeColor(colorBlack) + "O " + EncodeColor(colorBlack) + O + 
//EncodeColor(colorBlack) + "     H " + EncodeColor(colorBlack) + H + 
//EncodeColor(colorBlack) + "     L " + EncodeColor(colorBlack) + L + 
//EncodeColor(colorBlack) + "     C " + EncodeColor(colorBlack) + C + "\n" + 
EncodeColor(rcolor) + "R3= " + EncodeColor(colorBlack) + R3 + "\n" + EncodeColor(rcolor) + "R2= " + EncodeColor(colorBlack) + R2 + "\n" + EncodeColor(rcolor) + "R1= " + EncodeColor(colorBlack) + R1 + "\n" + EncodeColor(pcolor) + "PP= " + EncodeColor(colorBlack) + PP + "\n" + EncodeColor(scolor) + "S1= " + EncodeColor(colorBlack) + S1 + "\n" + EncodeColor(scolor) + "S2= " + EncodeColor(colorBlack) + S2 + "\n" + EncodeColor(scolor) + "S3= " + EncodeColor(colorBlack) + S3 + "\n";
 
 
Title = WriteIf(Titledisplay == 1, Titledisplaycode, "");
 

toughard

Well-Known Member
Try this
Code:
SetChartBkColor(ParamColor("Panel color ", colorWhite));
Plot(C, "close", ParamColor("Chart color", 11), styleCandle);
 
Titledisplay = ParamToggle("Display pivot stats", "No|Yes", 1);
 
//---- pivot points 
HourH = TimeFrameGetPrice("H", inHourly,  - 1); // yesterdays high 
HourL = TimeFrameGetPrice("L", inHourly,  - 1); //low 
HourC = TimeFrameGetPrice("C", inHourly,  - 1); //close 
HourO = TimeFrameGetPrice("O", inHourly); // current day open 
 
//------------------------------------moje MODES
Mode = Param("Mode (0-wooFib,1-woodies,2-regular,3-Camarilla)", 2, 0, 3, 1);
// woodies FIB pivots
if (Mode == 0)
{
  R = HourH - HourL; // range
  PP = (HourH + HourL + hourO + hourO) / 4;
  R1 = PP + (R *0.38);
  R2 = PP + (R *0.62);
  S1 = PP - (R *0.38);
  S2 = PP - (R *0.62);
  R3 = PP + (R *0.786); //experimental
  S3 = PP - (R *0.786); //experimental
}
 
// woodies pivots
else if (Mode == 1)
{
 
  PP = (HourH + HourL + HourO + HourO) / 4;
  R1 = (2 *PP) - HourL;
  S1 = (2 *PP) - HourH;
  R2 = PP + R1 - S1;
  S2 = PP + S1 - R1;
  R3 = R2 + (R1 - PP);
  S3 = S2 - (PP - S1);
}
 
// regular pivots
else if (Mode == 2)
{
  PP = (HourL + HourH + HourC) / 3;
  R1 = (2 *PP) - HourL;
  S1 = (2 *PP) - HourH;
  R2 = (PP - S1) + R1;
  S2 = PP - (R1 - S1);
  R3 = R1 + (HourH - HourL);
  S3 = S1 - (HourH - HourL);
}
 
//Camarilla Pivots
else if (Mode == 3)
{
  PP = (HourL + HourH + HourC) / 3;
  R4 = (HourH - HourL) *1.1 / 2+HourC;
  R3 = (HourH - HourL) *1.1 / 4+HourC;
  R2 = (HourH - HourL) *1.1 / 6+HourC;
  R1 = (HourH - HourL) *1.1 / 12+HourC;
  S1 = HourC - (HourH - HourL) *1.1 / 12;
  S2 = HourC - (HourH - HourL) *1.1 / 6;
  S3 = HourC - (HourH - HourL) *1.1 / 4;
  S4 = HourC - (HourH - HourL) *1.1 / 2;
}
 
//koniec moje MODES 
style = styleLine | styleDashed | styleThick + styleNoRescale;
rcolor = colorLime;
scolor = colorCustom10;
pcolor = colorPink;
Plot(R1, "R1", rcolor, style);
Plot(S1, "S1", scolor, style);
Plot(R2, "R2", rcolor, style);
Plot(S2, "S2", scolor, style);
Plot(PP, "PP", pcolor, style);
Plot(S3, "S3", scolor, style);
Plot(R3, "R3", rcolor, style);
 
 
Titledisplaycode = "\n" + "" + EncodeColor(colorBlack) +  //Date() + "\n" + "\n" +
//EncodeColor(colorBlack) + "O " + EncodeColor(colorBlack) + O + 
//EncodeColor(colorBlack) + "     H " + EncodeColor(colorBlack) + H + 
//EncodeColor(colorBlack) + "     L " + EncodeColor(colorBlack) + L + 
//EncodeColor(colorBlack) + "     C " + EncodeColor(colorBlack) + C + "\n" + 
EncodeColor(rcolor) + "R3= " + EncodeColor(colorBlack) + R3 + "\n" + EncodeColor(rcolor) + "R2= " + EncodeColor(colorBlack) + R2 + "\n" + EncodeColor(rcolor) + "R1= " + EncodeColor(colorBlack) + R1 + "\n" + EncodeColor(pcolor) + "PP= " + EncodeColor(colorBlack) + PP + "\n" + EncodeColor(scolor) + "S1= " + EncodeColor(colorBlack) + S1 + "\n" + EncodeColor(scolor) + "S2= " + EncodeColor(colorBlack) + S2 + "\n" + EncodeColor(scolor) + "S3= " + EncodeColor(colorBlack) + S3 + "\n";
 
 
Title = WriteIf(Titledisplay == 1, Titledisplaycode, "");
Excellence in Excellent span of time:thumb::thumb:

:thanx::thanx::thanx:
 

toughard

Well-Known Member
Try this
Code:
SetChartBkColor(ParamColor("Panel color ", colorWhite));
Plot(C, "close", ParamColor("Chart color", 11), styleCandle);
 
Titledisplay = ParamToggle("Display pivot stats", "No|Yes", 1);
 
//---- pivot points 
HourH = TimeFrameGetPrice("H", inHourly,  - 1); // yesterdays high 
HourL = TimeFrameGetPrice("L", inHourly,  - 1); //low 
HourC = TimeFrameGetPrice("C", inHourly,  - 1); //close 
HourO = TimeFrameGetPrice("O", inHourly); // current day open 
 
//------------------------------------moje MODES
Mode = Param("Mode (0-wooFib,1-woodies,2-regular,3-Camarilla)", 2, 0, 3, 1);
// woodies FIB pivots
if (Mode == 0)
{
  R = HourH - HourL; // range
  PP = (HourH + HourL + hourO + hourO) / 4;
  R1 = PP + (R *0.38);
  R2 = PP + (R *0.62);
  S1 = PP - (R *0.38);
  S2 = PP - (R *0.62);
  R3 = PP + (R *0.786); //experimental
  S3 = PP - (R *0.786); //experimental
}
 
// woodies pivots
else if (Mode == 1)
{
 
  PP = (HourH + HourL + HourO + HourO) / 4;
  R1 = (2 *PP) - HourL;
  S1 = (2 *PP) - HourH;
  R2 = PP + R1 - S1;
  S2 = PP + S1 - R1;
  R3 = R2 + (R1 - PP);
  S3 = S2 - (PP - S1);
}
 
// regular pivots
else if (Mode == 2)
{
  PP = (HourL + HourH + HourC) / 3;
  R1 = (2 *PP) - HourL;
  S1 = (2 *PP) - HourH;
  R2 = (PP - S1) + R1;
  S2 = PP - (R1 - S1);
  R3 = R1 + (HourH - HourL);
  S3 = S1 - (HourH - HourL);
}
 
//Camarilla Pivots
else if (Mode == 3)
{
  PP = (HourL + HourH + HourC) / 3;
  R4 = (HourH - HourL) *1.1 / 2+HourC;
  R3 = (HourH - HourL) *1.1 / 4+HourC;
  R2 = (HourH - HourL) *1.1 / 6+HourC;
  R1 = (HourH - HourL) *1.1 / 12+HourC;
  S1 = HourC - (HourH - HourL) *1.1 / 12;
  S2 = HourC - (HourH - HourL) *1.1 / 6;
  S3 = HourC - (HourH - HourL) *1.1 / 4;
  S4 = HourC - (HourH - HourL) *1.1 / 2;
}
 
//koniec moje MODES 
style = styleLine | styleDashed | styleThick + styleNoRescale;
rcolor = colorLime;
scolor = colorCustom10;
pcolor = colorPink;
Plot(R1, "R1", rcolor, style);
Plot(S1, "S1", scolor, style);
Plot(R2, "R2", rcolor, style);
Plot(S2, "S2", scolor, style);
Plot(PP, "PP", pcolor, style);
Plot(S3, "S3", scolor, style);
Plot(R3, "R3", rcolor, style);
 
 
Titledisplaycode = "\n" + "" + EncodeColor(colorBlack) +  //Date() + "\n" + "\n" +
//EncodeColor(colorBlack) + "O " + EncodeColor(colorBlack) + O + 
//EncodeColor(colorBlack) + "     H " + EncodeColor(colorBlack) + H + 
//EncodeColor(colorBlack) + "     L " + EncodeColor(colorBlack) + L + 
//EncodeColor(colorBlack) + "     C " + EncodeColor(colorBlack) + C + "\n" + 
EncodeColor(rcolor) + "R3= " + EncodeColor(colorBlack) + R3 + "\n" + EncodeColor(rcolor) + "R2= " + EncodeColor(colorBlack) + R2 + "\n" + EncodeColor(rcolor) + "R1= " + EncodeColor(colorBlack) + R1 + "\n" + EncodeColor(pcolor) + "PP= " + EncodeColor(colorBlack) + PP + "\n" + EncodeColor(scolor) + "S1= " + EncodeColor(colorBlack) + S1 + "\n" + EncodeColor(scolor) + "S2= " + EncodeColor(colorBlack) + S2 + "\n" + EncodeColor(scolor) + "S3= " + EncodeColor(colorBlack) + S3 + "\n";
 
 
Title = WriteIf(Titledisplay == 1, Titledisplaycode, "");
NOW trying to replace hourly OHLC with n bars

tried this----

NB=Param( "BARS", 12, 1, 55 );
HourH = HHV(H,NB); should be giving high from last 12 bars
HourL = LLV(L,NB); should be giving low from last 12 bars
HourC = Ref(C,NB); should be giving close of teh12th bar
HourO = Ref(O,-NB); should be giving open of 1st of these 12 bars


something wrong as I am not expert at these....
 
Last edited:

amitrandive

Well-Known Member
NOW trying to replace hourly OHLC with n bars

tried this----

NB=Param( "BARS", 12, 1, 55 );
HourH = HHV(H,NB); should be giving high from last 12 bars
HourL = LLV(L,NB); should be giving low from last 12 bars
HourC = Ref(C,NB); should be giving close of teh12th bar
HourO = Ref(O,-NB); should be giving open of 1st of these 12 bars


something wrong as I am not expert at these....
No idea about this.Will need some expert to guide.
 

ocil

Well-Known Member
Hi experts can you help me on this issue. Is there way in Amiboker to restrict intraday max 2 to 3 signal generated? After 3 signal no signal will generated for that day?
 

trash

Well-Known Member
Hi experts can you help me on this issue. Is there way in Amiboker to restrict intraday max 2 to 3 signal generated? After 3 signal no signal will generated for that day?
Yes, of course there are multiple ways. Create a newday variable and a cum(Buy) variable.Then in new variable SignalNum subtract the cumbuy that has been at newday from the overall cum(Buy) variable.

And in entry rule add:
Buy = Buy AND SignalNum <= 2; for example.

You can also start counting from a specific time within day. But that is bit more code than starting from day start.

Anyway both is possible as seen below. In both ones only 2 signals are allowed. In first chart pane it starts counting from Day start and in second one it starts counting from specific intra-day time. Red stepped lines show number of overall intraday signals and triangles show actual entries (maxsig = 2).

 
Last edited:

ocil

Well-Known Member
Thanks Trash for your help. :thumb:
i am using below code. pls advice if this is correct :-

CloseAtEnd = ParamToggle("Close Positions EOD", "Yes|No");
ForceCloseTradesAfter =151500;

NextBarOutsideRTH = ( Ref(TimeNum(), 1) > ForceCloseTradesAfter);

NextBarNotToday = (Ref(DateNum(), 1) > DateNum());

dtnum = DateNum();
Buysig =Buy condition AND TimeNum() < 150000 ;
Shortsig =short condition AND TimeNum() < 150000 ;

Buysum = Sum( Buysig, BarsSince( dtnum != Ref(dtnum, -1)) + 1);
Buy = Buysum AND Ref(Buysum, -1) == 0;

shortsum = Sum( shortsig, BarsSince( dtnum != Ref(dtnum, -1)) + 1);
Short = shortSum AND Ref(shortSum, -1) == 0;

Sell =IIf(CloseAtEnd==True, Short, Short OR NextBarOutsideRTH OR NextBarNotToday);

Cover=IIf(CloseAtEnd==True, Buy, Buy OR NextBarOutsideRTH OR NextBarNotToday);


no trading after 3 pm and trade close at 3.15 pm


Yes, of course there are multiple ways. Create a newday variable and a cum(Buy) variable.Then in new variable SignalNum subtract the cumbuy that has been at newday from the overall cum(Buy) variable.

And in entry rule add:
Buy = Buy AND SignalNum <= 2; for example.

You can also start counting from a specific time within day. But that is bit more code than starting from day start.

Anyway both is possible as seen below. In both ones only 2 signals are allowed. In first chart pane it starts counting from Day start and in second one it starts counting from specific intra-day time. Red stepped lines show number of overall intraday signals and triangles show actual entries (maxsig = 2).

 

trash

Well-Known Member
Thanks Trash for your help. :thumb:
i am using below code. pls advice if this is correct :-

You should not use Sum(). It is too slow for this.
Also your code looks into the future.

As for limiting signals since day start the following one is the way to go, for example. And it is orders of magnitude faster than using Sum().

Code:
// limit number of intraday signals since Day start
// by trash

SetBarsRequired( 10000, 0 );

Buy = Cross( MACD(), Signal() );

dn = DateNum();
NewDay = dn != Ref( dn, -1 );
NewDayBuy = NewDay AND Buy;
CumSig = Cum( Buy );

IntradaySigNum = CumSig - ValueWhen( NewDay, CumSig - NewDayBuy );

Buy = Buy AND IntradaySigNum <= 2; // change the number of signals you want to limit

Plot( IntradaySigNum, "Signal num", colorRed, styleStaircase ); // for test only

Buycolor = colorGreen;
Colorborder = colorLightGrey;

PlotShapes( Buy*shapeSmallUpTriangle, Buycolor, 0, IntradaySigNum, -15 );
PlotShapes( Buy*shapeHollowSmallUpTriangle, Colorborder, 0, IntradaySigNum, -15 );
PlotShapes( Buy*shapeHollowSmallCircle, Buycolor, 0, IntradaySigNum, 0 );
 

Similar threads