indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Tools > Software > MetaTrader

Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 30-12-2009, 06:20 PM
ashu1234 ashu1234 is offline
Regular
 
Join Date: Apr 2009
Posts: 36
Thanks: 61
Thanked 49 Times in 18 Posts
ashu1234 is on a distinguished road
Default Req: Metatrader to Amibroker Conversion - Trend Deviation Indicator

Hi all,
I'm wondering if we can code Trend deviation indicator aka TRD (mostly found in Java charts).
I have code for the same but its written in meta trader:

//---- indicator parameters
extern int MA_Period=20;
extern int MA_Method=0;
//---- indicator buffers
double ExtMapBuffer[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
string short_name;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
// SetIndexShift(0,MA_Shift);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
if(MA_Period<2) MA_Period=13;
draw_begin=MA_Period-1;
//---- indicator short name
switch(MA_Method)
{
case 1 : short_name="Trend deviation | EMA("; draw_begin=0; break;
case 2 : short_name="Trend deviation | SMMA("; break;
case 3 : short_name="Trend deviation | LWMA("; break;
default :
MA_Method=0;
short_name="Trend deviation | SMA(";
}
IndicatorShortName(short_name+MA_Period+")");
SetIndexDrawBegin(0,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| TRD - Trend Deviation |
//+------------------------------------------------------------------+
int start()
{
if(Bars<=MA_Period) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
//----
int i,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
if(pos<MA_Period) pos=MA_Period;
//---- main calculation loop
while(pos>=0)
{
ExtMapBuffer[pos]=Close[pos]/iMA(NULL,0,MA_Period,0,MA_Method,0,0);
pos--;
}
//---- done
return(0);
}

Would be glad if it can be coded for ami.
thnx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 19-04-2010, 06:30 PM
worldastro worldastro is offline
Regular
 
Join Date: Aug 2009
Posts: 92
Thanks: 0
Thanked 30 Times in 25 Posts
worldastro is on a distinguished road
Default

not work in ami plese see arror
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 19-04-2010, 06:49 PM
MurAtt's Avatar
MurAtt MurAtt is offline
indicator
 
Join Date: May 2009
Location: Kolkata
Posts: 9,750
Thanks: 35,207
Thanked 25,103 Times in 8,787 Posts
MurAtt has disabled reputation
Default

Originally Posted by worldastro View Post
not work in ami plese see arror

Of course it will not work in AMI. At least read the post before trying anything at all .. seedha cut and paste maar diya ...

Kya haal hai
__________________
Trade the Moves, not the Target
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 29-09-2013, 12:15 PM
AmiSmart AmiSmart is offline
Regular
 
Join Date: Sep 2013
Posts: 53
Thanks: 2
Thanked 79 Times in 37 Posts
AmiSmart is on a distinguished roadAmiSmart is on a distinguished road
Default

Originally Posted by ashu1234 View Post
Hi all,
I'm wondering if we can code Trend deviation indicator aka TRD (mostly found in Java charts).
I have code for the same but its written in meta trader:

//---- indicator parameters
extern int MA_Period=20;
extern int MA_Method=0;
//---- indicator buffers
double ExtMapBuffer[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
string short_name;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
// SetIndexShift(0,MA_Shift);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
if(MA_Period<2) MA_Period=13;
draw_begin=MA_Period-1;
//---- indicator short name
switch(MA_Method)
{
case 1 : short_name="Trend deviation | EMA("; draw_begin=0; break;
case 2 : short_name="Trend deviation | SMMA("; break;
case 3 : short_name="Trend deviation | LWMA("; break;
default :
MA_Method=0;
short_name="Trend deviation | SMA(";
}
IndicatorShortName(short_name+MA_Period+")");
SetIndexDrawBegin(0,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| TRD - Trend Deviation |
//+------------------------------------------------------------------+
int start()
{
if(Bars<=MA_Period) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
//----
int i,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
if(pos<MA_Period) pos=MA_Period;
//---- main calculation loop
while(pos>=0)
{
ExtMapBuffer[pos]=Close[pos]/iMA(NULL,0,MA_Period,0,MA_Method,0,0);
pos--;
}
//---- done
return(0);
}

Would be glad if it can be coded for ami.
thnx



PHP Code:

MA_Period
=Param("MA_Period"201999);
MA_Method=ParamList("MA_Method","SMA|EMA|SSMA|LWMA");

function 
iMA(PricePeriodMode)
{

  return 
IIf(Mode=="EMA",  EMA(PricePeriod),
             
IIf(Mode=="SSMA"Wilders(PricePeriod),
        
IIf(Mode=="LWMA"WMA(PricePeriod), 
                                   
MA(PricePeriod)))); 

}


TRD=Close/lastvalue(iMA(CMA_Period,MA_Method));

Plot(TRD"Trend Deviation | " MA_Method "("MA_Period+")"colorAqua); 

Last edited by AmiSmart; 29-09-2013 at 05:13 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

indiTraders - Forum for the Active Indian Trader > Tools > Software > MetaTrader


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 03:40 PM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2