Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 05-31-2011, 11:37 PM   #1

Join Date: May 2011
Posts: 2
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

AltrTrend_Signal_v2_2.mq4 to Tradestation .eld

Can someone please convert this MQ4 indicater code to a tradestation eld.
I found this and would really like to use it.
Thanks in advance for the help.
Code:
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2.mq4 
//| Ramdass - Conversion only
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Crimson

//---- input parameters
extern int K=30;
extern double Kstop=0.5;
extern int Kperiod=150;
extern int PerADX=14;
extern int CountBars=999999;

//---- buffers
double val1[];
double val2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,108);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,108);
   SetIndexBuffer(0,val1);
   SetIndexBuffer(1,val2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2                                            |
//+------------------------------------------------------------------+
int start()
  {   
   if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars+PerADX);
   SetIndexDrawBegin(1,Bars-CountBars+PerADX);
   int i,shift,counted_bars=IndicatorCounted();
   int i1,i2;
   double Range,AvgRange,smin,smax,SsMax,SsMin,SSP,price;
   bool uptrend,old;
//----
   if(Bars<=PerADX+1) return(0);
//---- initial zero
   if(counted_bars<PerADX+1)
   {
      for(i=1;i<=PerADX;i++) val1[CountBars-i]=0.0;
      for(i=1;i<=PerADX;i++) val2[CountBars-i]=0.0;
   }
//----


for (shift = CountBars-PerADX; shift>=0; shift--) 
{ 

SSP=MathCeil(Kperiod/iADX(NULL,0,PerADX,PRICE_CLOSE,MODE_MAIN,1));
	Range=0;
	AvgRange=0;
	for (i1=shift; i1<=shift+SSP; i1++)
		{AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]);
		}
	Range=AvgRange/(SSP+1);

SsMax=High[shift]; SsMin=Low[shift]; 
   for (i2=shift;i2<=shift+SSP-1;i2++)
        {
         price=High[i2];
         if(SsMax<price) SsMax=price;
         price=Low[i2];
         if(SsMin>=price)  SsMin=price;
        }
 
smin = SsMin+(SsMax-SsMin)*K/100; 
smax = SsMax-(SsMax-SsMin)*K/100; 
	val1[shift]=0;
	val2[shift]=0;
	if (Close[shift]<smin)
		{
		uptrend = false;
		}
	if (Close[shift]>smax)
		{
		uptrend = true;
		}
   if (uptrend!=old && uptrend==true) {val1[shift]=Low[shift]-Range*Kstop;}
   if (uptrend!=old && uptrend==false) {val2[shift]=High[shift]+Range*Kstop;}
   old=uptrend;

}
   return(0);
  }
//+------------------------------------------------------------------+
Attached Files
File Type: mq4 AltrTrend_Signal_v2_2.mq4 (2.7 KB, 13 views)
JT_Trader is offline  
Reply With Quote
Old 06-01-2011, 03:42 AM   #2

zapisy's Avatar

Join Date: Jan 2009
Location: New York
Posts: 81
Ignore this user

Thanks: 6
Thanked 26 Times in 17 Posts

Re: AltrTrend_Signal_v2_2.mq4 to Tradestation .eld

can you post pictures of how the indicator looks?
zapisy is offline  
Reply With Quote
Old 06-01-2011, 08:32 PM   #3

Join Date: May 2011
Posts: 2
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Re: AltrTrend_Signal_v2_2.mq4 to Tradestation .eld

Picture posted.
The indicator detects and display trend exhaustion (dark red or dark blue dots) to take possibly profits.

Quote:
Originally Posted by zapisy »
can you post pictures of how the indicator looks?
JT_Trader is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


All times are GMT -4. The time now is 03:31 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.