Escolar Documentos
Profissional Documentos
Cultura Documentos
_SECTION_BEGIN("The_Beast_2");
SetBarsRequired(10000,10000); /* this ensures that the charts include all bars
AND NOT just those on screen */
Prd1=Param("ATR Period 1-20",4,1,20,1);//{Default = 4 Because most traders use
5}
Prd2=Param("LookBack Period 1-20",7,1,20,1);//{Default = 11 Because most traders
use 10}
//{Green} {Start Long position when Close>Green}
Green=HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
//{Red} {Stop loss when Close<Red}
RED=LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Color = IIf(C>Green ,colorBrightGreen,IIf(C < RED,colorRed,colorWhite));
SetChartOptions(0,chartShowArrows|chartShowDates);
_SECTION_END();
_SECTION_BEGIN("Trailing_Stop_Short");
stoplossPercentage = Param("Stoploss Percentage", 5, 2, 10);
lookbackPeriod = Param("Lookback period", 10, 5, 30);
Plot(HHV(C,lookbackPeriod) - HHV(C,lookbackPeriod) * (stoplossPercentage / 100),
"Trailing stoploss", ParamColor( "Color", colorCycle ),ParamStyle("Style",styleLine|
Stylehidden ,maskAll));
_SECTION_END();
_SECTION_BEGIN("Trailing_Stop_Long");
//ATR values can be changed from 1 to 3 multiplications in steps of 0.25
//ATR value or the last low pivot value can be selected. This feature can be
overridden from the parameter window. It is recommended to use only ATR Value
//Choice of plots line or just dots from the parameter window is also possible
mf = Param("ATR multiplier",3,1,3,0.25);
ap=Param("ATR Period",10,5,30,1);
Lb=Param("Lookback Period",20,10,40,1);
ps=ParamToggle("Use last low pivot","Use,Dont",1);
//Thick = Param("Thick" , 0.02, 0.01, 0.2, 0.01);
t1=HHV(C,Lb);
t2=(mf*ATR(ap));
t3=Trough(C,2,1);
t4=t1-t2;
t5=Min(t4,t3);
if(ps)
{
t6 = t1-t2;
}
else
{
t6=t5;
}
initial=t6;
stop[ 0 ] = Close[ 0 ];
_SECTION_END();
_SECTION_BEGIN("Trailing_Lines");
Plot(LLV(HHV(H,5)-ATR(5),8),"",ParamColor( "Color Line 0",
colorDarkGreen ),ParamStyle("Style Line 0",styleLine,maskAll));
Plot(LLV(HHV(H,5)-ATR(5),7),"",ParamColor( "Color Line 1",
colorDarkGrey),ParamStyle("styleLine 1",styleLine,maskAll));
Plot(LLV(HHV(H,5)-ATR(5),6),"",ParamColor( "Color Line 2",
colorDarkGrey ),ParamStyle("Style Line 2",styleLine,maskAll));
Plot(LLV(HHV(H,5)-ATR(5),5),"",ParamColor( "Color Line 3",
colorDarkGrey),ParamStyle("Style Line 3",styleLine,maskAll));
Plot(LLV(HHV(H,5)-ATR(5),4),"",ParamColor( "Color Line 4",
colorDarkGrey ),ParamStyle("Style Line 4",styleLine,maskAll));
Plot(LLV(HHV(H,5)-ATR(5),3),"",ParamColor( "Color Line 5",
colorDarkYellow ),ParamStyle("Style Line 5",styleLine,maskAll));
_SECTION_END();
/*_SECTION_BEGIN("Stop_loss");
}
SPlot(StopLoss,"" ,ParamColor( "Color", colorCycle ), 2) ;
_SECTION_END();*/
_SECTION_BEGIN("Pivot_Finder");
/* **********************************
********************************** */
GraphXSpace=7;
aHPivs = H - H;
aLPivs = L - L;
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;
nHPivs = 0;
nLPivs = 0;
lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;
// n bars, etc.?
// last visible bar to make it easy to "go back" and see the pivots
aVisBars = Status("barvisible");
curBar = (BarCount-1);
curTrend = "";
if (aLLVBars[curBar] <
aHHVBars[curBar]) {
curTrend = "D";
else {
curTrend = "U";
// in future version
curBar = (BarCount - 1) - i;
if (curTrend == "U") {
curTrend = "D";
aLPivs[curPivBarIdx] = 1;
aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;
nLPivs++;
// -- or current trend is up
} else {
if (curTrend == "D") {
curTrend = "U";
aHPivs[curPivBarIdx] = 1;
aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;
nHPivs++;
// -- If curTrend is up...else...
curBar = (BarCount-1);
candIdx = 0;
candPrc = 0;
lastLPIdx = aLPivIdxs[0];
lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];
lastHPH = aHPivHighs[0];
candPrc = aHHV[curBar];
if (
aHPivs[candIdx] = 1;
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-
(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];
aHPivHighs[0] = candPrc ;
aHPivIdxs[0] = candIdx;
nHPivs++;
} else {
candPrc = aLLV[curBar];
if (
aLPivs[candIdx] = 1;
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
aLPivLows[0] = candPrc;
aLPivIdxs[0] = candIdx;
nLPivs++;
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
PlotShapes(
PlotShapes(
_SECTION_BEGIN("Graphics");
GrpPrm=Param("Graphic Space",1,0,10);
GraphXSpace=GrpPrm;
_SECTION_END();