PDA

View Full Version : SafeZone


barabba
02-12-2008, 08:38 AM
Hi,

does anybody know if the Elder SafeZone indicator is available in NT, or downloadable somewhere in the Internet?


If not, I will program the indicator in NT and share here in the following weeks.

NinjaTrader_Josh
02-12-2008, 11:19 PM
I am unaware of this indicator being provided already. Thank you for offering the contribution though!

drdelco
06-18-2008, 11:13 PM
Barabba,
Did you program it yet? I'm browsing the web for it and can't find.
Thanks

lasater529
02-19-2009, 04:05 AM
Barabba,
Did you program it yet? I'm browsing the web for it and can't find.
Thanks
Here is the code in mq4. Sorry, I haven't gotten the hang of NT yet.


//+------------------------------------------------------------------+
//| Elders Safe Zone.mq4 |
//| Cubesteak |
//| www.cubesteak.net (http://www.cubesteak.net) |
//+------------------------------------------------------------------+
#property copyright "Cubesteak"
#property link "www.cubesteak.net (http://www.cubesteak.net)"
//----
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_chart_window
//----
extern int LookBack=10;
extern int StopFactor=2;
extern int EMALength=21;
extern color LineColor=Crimson;
//----
double ExtBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,ExtBuffer);
SetIndexStyle(0,DRAW_LINE,2,1,LineColor);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double SafeStop=0;
int counted_bars=IndicatorCounted();
int limit=Bars - LookBack - 3;
for(int shift=limit;shift>=0;shift--)
{
double EMA0=iMA(Symbol(),0,EMALength,0,MODE_EMA,0,shift);
double EMA1=iMA(Symbol(),0,EMALength,0,MODE_EMA,0,shift+1 );
double EMA2=iMA(Symbol(),0,EMALength,0,MODE_EMA,0,shift+2 );
double PreSafeStop=ExtBuffer[shift+1];
double Pen=0;
int Counter=0;
if (EMA0 > EMA1)
{
for(int value1=0;value1<=LookBack; value1++)
{
if (Low[shift+value1] < Low[shift+value1+1])
{
Pen=Low[shift+value1+1] - Low[shift+value1] + Pen;
Counter=Counter + 1;
}
}
if (Counter!=0) SafeStop=Close[shift] - (StopFactor * (Pen/Counter));
else SafeStop=Close[shift] - (StopFactor * Pen);
if ((SafeStop < PreSafeStop) && (EMA1 > EMA2)) SafeStop=PreSafeStop;
}
if (EMA0 < EMA1)
{
for(value1=0;value1<=LookBack; value1++)
{
if (High[shift+value1] > High[shift+value1+1])
{
Pen=High[shift+value1] - High[shift+value1+1] + Pen;
Counter=Counter + 1;
}
}
if (Counter!=0) SafeStop=Close[shift] + (StopFactor * (Pen/Counter));
else SafeStop=Close[shift] + (StopFactor * Pen);
if ((SafeStop > PreSafeStop) && (EMA1 < EMA2)) SafeStop=PreSafeStop;
}
PreSafeStop=SafeStop;
ExtBuffer[shift]=SafeStop;
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+



Here it is in MetaStock. I have stripped out the information headers to save space but the author is Jose Silva.

{ User inputs }
coefficient:=2;
bkpds:=10;
pds:=21;
adv:=1;
type:=1;
plot:=1;
{ Downside penetrations }
DwSidePen:=
If(type=1,Mov(C,pds,E)>Ref(Mov(C,pds,E),-1),1)
AND L<Ref(L,-1);
DwSideDiff:=If(DwSidePen,Ref(L,-1)-L,0);
DwPenAvg:=Sum(DwSideDiff,bkpds)
/Max(Sum(DwSidePen,bkpds),.000001);
StLong:=Ref(L-DwPenAvg*coefficient,-1);
StopLong:=If(C<PREV,StLong,Max(StLong,PREV));
{ Upside penetrations }
UpSidePen:=
If(type=1,Mov(C,pds,E)<Ref(Mov(C,pds,E),-1),1)
AND H>Ref(H,-1);
UpSideDiff:=If(UpSidePen,H-Ref(H,-1),0);
UpPenAvg:=Sum(UpSideDiff,bkpds)
/Max(Sum(UpSidePen,bkpds),.000001);
StShort:=Ref(H+UpPenAvg*coefficient,-1);
StopShort:=If(C>PREV,StShort,Min(StShort,PREV));
{ Stop signals }
entry:=Cross(Typical(),Ref(StopShort,-1));
exit:=Cross(Ref(StopLong,-1),Typical());
{ Clean signals }
Init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR Init,
entry-exit);
entry:=bin=1 AND (Alert(bin<>1,2) OR Init);
exit:=bin=-1 AND (Alert(bin<>-1,2) OR Init);

NinjaTrader_Bertrand
02-19-2009, 04:19 AM
Thanks for sharing lasater529! Hopefully somebody helps you convert it, for our custom indicator coding tutorials please follow this link - http://www.ninjatrader-support.com/HelpGuideV6/Overview18.html

Jonnyem
11-18-2009, 02:35 PM
Hello,

Is there SaveZone already avaible for Ninjatrader? I am still trying to find it. However, I wasn't successful so far. Please let me know as soon as it's avaible.

NinjaTrader_Josh
11-18-2009, 02:57 PM
Please check the file sharing section for what is publicly shared. If it is not there then you could try one of these 3rd party NinjaScript consultants to program what you are looking for: http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm