+91-0000000000

}

Monday – Friday : 9:00 AM – 6:30 PM

Elder Auto Envelope

Elder Auto Envelope in Amibroker creates dynamic channels around price movements. Using the Amibroker data feed, this tool assists traders in identifying potential overbought or oversold market conditions.

/_SECTION_BEGIN("Elder's AutoEnvelope");
// User inputs
// pds=Input("EMA periods",1,252,21); // MetaStock code ("name",min,max,default)
pds = Param("EMA periods",21,2,252,1);

// pdsBak=Input("lookback periods",1,252,42);
pdsBak=Param("lookback periods",42,2,252,1);

// Price field
WC = TimeFrameGetPrice( "C", inWeekly, -1 ); // gives you previous week Open price

// x=IIf(x=1,O,IIf(x=2,H,IIf(x=3,L,IIf(x=5,WC,C)))); // is this incorrect?
//x=IIf(x==1,O,IIf(x==2,H,IIf(x==3,L,IIf(x==5,WC,C))));
// x=Input("use: Open=1, High=2, Low=3, Close=4, WClose=5",1,5,4);
//x=Param("use: Open=1, High=2, Low=3, Close=4, WClose=5",4,1,5,1);

sX = ParamList("Use Price Field:", "Open|High|Low|Close|Weekly Close", 3);

if (sX == "Open")
      x = O;
else if (sX == "High")
      x = H;
else if (sX == "Low")
      x = L;
else if (sX == "Close")
   x = C;
else if (sX == "Weekly Close")
      x = WC;

// Plot1=Input("[1]AutoEnvelope, [2]Long signals, [3]All signals",1,3,1);
//Plot1=Param("[1]AutoEnvelope, [2]Long signals, [3]All signals",1,1,3,1);

sPlot1 = ParamList("Plot Signals:", "AutoEnvelope|Long signals|All signals", 0);

if (sPlot1 == "AutoEnvelope")
      Plot1 = 1;
else if (sPlot1 == "Long signals")
      Plot1 = 2;
else if (sPlot1 == "All signals")
      Plot1  = 3;

// delay=Input("Entry/Exit signals delay",0,5,0);
delay=Param("Entry/Exit signals delay",0,0,5,1);
 

// Envelope bands
AvgX=EMA(x,pds);
hiAvg=HHV(H,pdsBak);
loAvg=LLV(L,pdsBak);
shift= EMA(IIf(hiAvg > AvgX, hiAvg - AvgX, AvgX - loAvg),pds);
UpperBand=AvgX+shift;
LowerBand=AvgX-shift;

// Envelope signals
In=Cross(x,LowerBand);
Out=Cross(x,UpperBand);
Init=Cum(In + Out > - 1)==1;
InInit=Cum(In)==1;
flag=BarsSince(Init OR In) < BarsSince(Init OR Out)+InInit;
signals=Ref((InInit AND Hold(InInit=0,2) OR flag AND Hold (flag=0,2)) -(flag=0 AND Hold(flag,2)),-delay);

// Plot envelope on price chart
//UpBand = IIf(Plot=1,UpperBand,IIf(Plot1=2,signals,In- Out));
//MidBand = IIf(Plot=1,AvgX,IIf(Plot1=2,0,0));
//LowBand = IIf(Plot=1,LowerBand,IIf(Plot1=2,signals,In- Out));
UpBand = IIf(Plot1==1,UpperBand,IIf(Plot1==2,signals,In- Out));
MidBand = IIf(Plot1==1,AvgX,IIf(Plot1==2,0,0));
LowBand = IIf(Plot1==1,LowerBand,IIf(Plot1==2,signals,In- Out));

if (Plot1 == 1)
      iStyleScale = 0;
else
      iStyleScale = styleOwnScale;
 
Plot(UpBand ,"UpperBand",colorBlueGrey, styleLine | iStyleScale);
Plot(MidBand , "MidleBand", colorGreen, styleLine | iStyleScale);
Plot(LowBand, "LowerBand", colorViolet, styleLine | iStyleScale);
Plot(C, "Price", colorDarkYellow, styleCandle);
_SECTION_END();

Open chat
1
Hi, how can I help you?