convert this to lua

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

convert this to lua

Postby virtualtrader » Thu Nov 11, 2021 1:44 am

//------------------------------------------------------------------
//RSI TMA BAND
//------------------------------------------------------------------

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Blue
#property indicator_color2 FireBrick
#property indicator_color3 Green
#property indicator_color4 Black
#property indicator_color5 Black
#property indicator_color6 Black
#property indicator_color7 Maroon
#property indicator_color8 DarkGreen
#property indicator_level1 80.0
#property indicator_level2 90.0
#property indicator_level3 50.0
#property indicator_level4 20.0
#property indicator_level5 10.0
#property indicator_levelstyle 2
#property indicator_levelcolor Black

//
//
//

extern int RsiLength = 14;
extern int RsiPrice = PRICE_CLOSE;
extern int HalfLength = 12;
extern int DevPeriod = 100;
extern double DeviationInt = 1;
extern double DeviationExt = 1.5;

double buffer1[];
double ExtMapGreen[];
double ExtMapRed[];
double buffer2[];
double buffer3[];
double buffer4[];
double buffer5[];
double buffer6[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------

int init()
{
HalfLength=MathMax(HalfLength,1);
SetIndexBuffer(0,buffer1);
SetIndexStyle(0,DRAW_LINE,0,2);
SetIndexBuffer(1,ExtMapGreen);
SetIndexStyle(1,DRAW_LINE,0,2);
SetIndexBuffer(2,ExtMapRed);
SetIndexStyle(2,DRAW_LINE,0,2);
SetIndexBuffer(3,buffer3);
SetIndexStyle(3,DRAW_LINE,0,1);
SetIndexBuffer(4,buffer4);
SetIndexStyle(4,DRAW_LINE,0,1);
SetIndexBuffer(5,buffer2);
SetIndexStyle(5,DRAW_NONE);
SetIndexBuffer(6,buffer5);
SetIndexStyle(6,DRAW_LINE,2,1);
SetIndexBuffer(7,buffer6);
SetIndexStyle(7,DRAW_LINE,2,1);



return(0);
}
int deinit() { return(0); }

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//

int start()
{
int i,j,k,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=MathMin(Bars-1,Bars-counted_bars+HalfLength);

//
//
//
//
//

for (i=limit; i>=0; i--) buffer1[i] = iRSI(NULL,0,RsiLength,RsiPrice,i);
for (i=limit; i>=0; i--)
{
double dev = iStdDevOnArray(buffer1,0,DevPeriod,0,MODE_SMA,i);
double sum = (HalfLength+1)*buffer1[i];
double sumw = (HalfLength+1);
for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
{
sum += k*buffer1[i+j];
sumw += k;
if (j<=i)
{
sum += k*buffer1[i-j];
sumw += k;
}
}
buffer2[i] = sum/sumw;




ExtMapGreen[i] = buffer2[i];
ExtMapRed[i] = buffer2[i] ;


double ext1 = buffer2[i] ;
double ext2 = buffer2[i+1];
double ext3 = buffer2[i+2] ;

if(ext1 > ext2 && ext2 > ext3)
{
ExtMapGreen[i+1] = EMPTY_VALUE ;
}
else if(ext1 < ext2 && ext2 < ext3)
{
ExtMapRed[i+1] = EMPTY_VALUE ;
}




buffer3[i] = buffer2[i]+dev*DeviationExt;
buffer4[i] = buffer2[i]-dev*DeviationExt;
buffer5[i] = buffer2[i]+dev*DeviationInt;
buffer6[i] = buffer2[i]-dev*DeviationInt;
}
return(0);
}
virtualtrader
 
Posts: 6
Joined: Sun Jul 04, 2021 9:17 pm

Re: convert this to lua

Postby Apprentice » Thu Nov 11, 2021 3:41 am

Your request is added to the development list.
Development reference 978.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36476
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Re: convert this to lua

Postby virtualtrader » Sun Nov 28, 2021 8:00 am



can you highlight the main formula? just the RSI and TMA band formula without var/ par or plot code please
coz i want to remake it into another lua script version
virtualtrader
 
Posts: 6
Joined: Sun Jul 04, 2021 9:17 pm

Re: convert this to lua

Postby Apprentice » Mon Nov 29, 2021 3:57 am

I'm not sure I understand.
Can you clarify?
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36476
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 40 guests