Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 08-23-2007, 04:35 AM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 2,000
fxbs is on a distinguished road
Quote:
//| please, keep your code tidy. mladen |
//+--------------------------------------------------------------------------------+
// The base for this indicator was orginal RSI attached with Metatrader.
// ^^ removed ^^ : )|-< Hornet
ok, we'll try
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 08-23-2007, 07:13 AM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 2,000
fxbs is on a distinguished road
here's how magic was done:
code before:
.......
double marsioma[];
double marsiomaXSig[];

string short_name;
//+------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------+
........
SetIndexLabel(2,"TrendUp");
SetIndexLabel(6,"Up/DnXsig");

IndicatorShortName(short_name);

SetIndexDrawBegin(0,RSIOMA);
SetIndexDrawBegin(1,RSIOMA);
SetIndexDrawBegin(2,RSIOMA);
SetIndexDrawBegin(3,RSIOMA);
SetIndexDrawBegin(4,RSIOMA);
SetIndexDrawBegin(5,RSIOMA);
SetIndexDrawBegin(6,RSIOMA);
SetIndexDrawBegin(7,RSIOMA);

//----
drawLine(BuyTrigger,"BuyTrigger", BuyTriggerColor);
..............

//+----------------------------------------------------+
//| Relative Strength Index |
//+-----------------------------------------------------+
int start()
{
int i, ii;
int counted_bars=IndicatorCounted();
double rel,negative,positive;
//----
if(Bars<=RSIOMA) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=RSIOMA;i++) {RSIBuffer[Bars-i]=0.0;}
//----
ii=Bars-RSIOMA-1;
if(counted_bars>=RSIOMA) ii=Bars-counted_bars-1;
i = ii;
while(i>=0)
{ MABuffer1[i]=iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE, i);
i--; }
i=ii;
while(i>=0)
{ RSIBuffer[i]=iRSIOnArray(MABuffer1,0,RSIOMA,i);


if(RSIBuffer[i]>50) bup[i] = 6;
if(RSIBuffer[i]<50) bdn[i] = -6;

Last edited by fxbs; 08-23-2007 at 07:54 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 08-23-2007, 07:17 AM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 2,000
fxbs is on a distinguished road
code after:
..................
datetime lastBarTime;
string short_name;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+

SetIndexLabel(2,"TrendUp");
SetIndexLabel(6,"Up/DnXsig");

for (int i=0;i<indicator_buffers;i++) SetIndexDrawBegin(i,RSIOMA);
//
// additional buffer(s)
ArraySetAsSeries(MABuffer1,true);
ArrayResize(MABuffer1,Bars);
ArrayInitialize(MABuffer1,EMPTY_VALUE);
lastBarTime = EMPTY_VALUE;

//

drawLine(BuyTrigger,"BuyTrigger", BuyTriggerColor);
..............

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+

int start()
{
int counted_bars=IndicatorCounted();
int i, limit;

if(Bars<=RSIOMA) return(0);
if(counted_bars<1) for(i=1;i<=RSIOMA;i++) RSIBuffer[Bars-i]=0.0;
if (lastBarTime != Time[0]) {
lastBarTime = Time[0];
ArrayResize(MABuffer1,Bars);
ArrayInitialize(MABuffer1,EMPTY_VALUE);
counted_bars=0;
}
limit=Bars-RSIOMA-1;
if(counted_bars>=RSIOMA) limit=Bars-counted_bars-1;
for(i=limit;i>=0;i--)
MABuffer1[i]=iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE, i);
for(i=limit;i>=0;i--)
{
RSIBuffer[i]=iRSIOnArray(MABuffer1,0,RSIOMA,i);


if(RSIBuffer[i]>50) bup[i] = 6;
if(RSIBuffer[i]<50) bdn[i] = -6;

Last edited by fxbs; 08-23-2007 at 07:57 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 08-23-2007, 07:31 AM
Kalenzo's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 696
Kalenzo is on a distinguished road
Quote:
Originally Posted by fxbs View Post
Rsioma (RSI of MA) needs one more buffer 4 signals
may be if some wizard have nothing better to do...
i know somehow it possible avoid 8 buff restriction through Maonarray, but i couldn't - didn't finish wizard's school
plus one buffer used only 4 RSI calc... (code, link and indi below)

PS very nice little indi - rsioma
more: Thread RSI of MA pos126 http://www.forex-tsd.com/138096-post126.html
Well, it is like that:
we have 8 buffers avaliable in metatrader, but buffers are special arrays that allows us to draw something on the chart. So we could use them to draw:
1) rsioma
2) marsiona
3) green histogram
4) red histogram
5) pink histogram
6) blue histogram
7) short signal dot (up or down)
8) long signal dot (up or down)

To do something like that you need:
1) use an array instead of buffer array. This will require from you to define an double array in the global section for the moving average calculation, then at the begining of the start function - resize it to full buffer size, then fill it with iMA function and use like a buffer. In this way you will have one free buffer to draw.

OR

2) leave everything as it is, write a function that will draw ARROW OBJECT with code choosen by you (arrow, dot or something else from wingdings) and manage those arrows. It means that this function should draw arrow on right window with value that you would usualy assign to buffer.

Both solutions are very easy. I could do it if you could write when and which arrow/dot should be draw - and please attach screenshot (eg. draw in paint).
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................
http://www.fxservice.eu/
........................................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 08-23-2007, 07:40 AM
Kalenzo's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 696
Kalenzo is on a distinguished road
In fact, I see that Mladen done a good job. And modified this indicator already. In his version you have 1 buffer free to go (take a look that this indicator is using buffers from 0 to 6 and we can use from 0 to 7) so you can use it to generate the signal that you want just as a usual buffer.

BTW great hint Mlanden with that ArraySetAsSeries
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................
http://www.fxservice.eu/
........................................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 08-23-2007, 07:51 AM
mladen's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 312
mladen is on a distinguished road
...

Glad I could help a little bit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 08-23-2007, 08:09 AM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 2,000
fxbs is on a distinguished road
Quote:
Originally Posted by Kalenzo View Post
...... use an array instead of buffer array. This will require from you to define an double array in the global section for the moving average calculation, then at the begining of the start function - resize it to full buffer size, then fill it with iMA function and use like a buffer. In this way you will have one free buffer to draw.
Hi, Kalenzo! Could you show on simple example how to change buffer array to double array, please? (not like I'm going to add dozen more buffers to Rsioma - no way!)

Last edited by fxbs; 08-23-2007 at 08:17 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 08-23-2007, 08:18 AM
mladen's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 312
mladen is on a distinguished road
An addition to ArraySeAsSerries

Quote:
Originally Posted by Kalenzo
BTW great hint Mlanden with that ArraySetAsSeries
Actualy (unfortunately) there is an addition :

Metatrader obviously treats arrays declared as index and a simple array diferently:

ArrayResize fills the added cells with EMPTY_VALUE (if you did not declare differently by SetIndexEmptyValue)

But when, for example iMa references that cell from index it is returned 0, and from your array it gets EMPTY_VALUE (=2147483647) so anyone trying to use arrays as indexes must make sure that if array is going to be used in internal functions, all EMPTY_VALUEs are replaced with 0

So far this is what I found out abbout this issue
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 08-23-2007, 08:28 AM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 2,000
fxbs is on a distinguished road
This means - Kalenzo gives GreenLight on arsioma v3
your version, Mladen!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 08-23-2007, 08:35 AM
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 2,000
fxbs is on a distinguished road
And since it's your version, could you consider to add CountedBars and refreshing bufers options?
(autentic - by the author himself) (and I can do all the hard work - desiding on the colors?)
Quote:
Originally Posted by mladen
You might consider adding a bars number restriction (it would make the code faster)

and if you add
PHP Code:
   {
         
RSIBuffer[i]=iRSIOnArray(MABuffer1,0,RSIOMA,i);
         
         
//
         //
         //   this code
         //
         //

            
"bup[i] = EMPTY_VALUE; bdn[i] = EMPTY_VALUE;"
            "sup[i] = EMPTY_VALUE; sdn[i] = EMPTY_VALUE;"
            
            
if(RSIBuffer[i] > 50)               bup[i] =   6
you will avoid some repainting when changing time frames or accounts

glad that could help

regards
mladen

Last edited by fxbs; 08-23-2007 at 08:37 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
RSIOMA, RSIOMA INDICATOR

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 On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unauthorized Extra Charges on may credit statement Navid General Discussion 10 05-11-2007 04:12 PM
MT4 with extra weekend bar woteva Metatrader 4 3 04-30-2007 03:13 AM
Help with buffer limits and flatlining indicator lines iboersma Indicators - Metatrader 4 0 03-22-2007 06:27 PM


All times are GMT. The time now is 03:51 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.