Can anyone help with this code???

This is a discussion on Can anyone help with this code??? within the Trading Software forums, part of the Commercial category; Hey people, Below is the code for one of the indicators I have downloaded. I just wondered if anyone who ...

Reply
 
LinkBack Thread Tools Search this Thread
Old Jan 29, 2010, 12:21am   #1
 
Rossini's Avatar
Joined May 2008
Can anyone help with this code???

Hey people,

Below is the code for one of the indicators I have downloaded. I just wondered if anyone who is familiar with MT4 code could tell me if this indicator repaints its self after the fact?

I don't know much about it, or what it is based on but would be interested in any info you can give!!

As always, many thanks.

R

.................................................. .................................................. .


//+------------------------------------------------------------------+
//| CoeffofLine.mq4 |
//| Ramdass - Conversion only |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int ndot=30;
extern int CountBars=10000;
//---- buffers
double cfl[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,cfl);
//----
return(0);
}
//+------------------------------------------------------------------+
//| CoeffofLine_v1 |
//+------------------------------------------------------------------+
int start()
{

if (CountBars>=Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars+ndot+1);
int i,shift,cnt,ndot1,counted_bars=IndicatorCounted();
double TYVar,ZYVar,TIndicatorVar,ZIndicatorVar,M,N,AY,AIn dicator;
//----
if(Bars<=ndot) return(0);

//----
shift=CountBars-ndot-1;


while(shift>=0)
{

TYVar=0;
ZYVar=0;
N=0;
M=0;
TIndicatorVar=0;
ZIndicatorVar=0;
ndot1=ndot;
if (shift+1<ndot1) ndot1=shift+1;
for (cnt=ndot; cnt>=1; cnt--)
{
N=N+cnt*cnt;
M=M+cnt;
}
for (cnt=ndot1; cnt>=1; cnt--)
{
ZYVar=ZYVar+(High[shift-cnt+1]+Low[shift-cnt+1])/2*(ndot+1-cnt);
TYVar=TYVar+(High[shift-cnt+1]+Low[shift-cnt+1])/2;
ZIndicatorVar=ZIndicatorVar+iMA(NULL,0,5,3,MODE_SM MA,PRICE_MEDIAN,shift-cnt+1)*(ndot+1-cnt);
TIndicatorVar=TIndicatorVar+iMA(NULL,0,5,3,MODE_SM MA,PRICE_MEDIAN,shift-cnt+1);
}
AY=(TYVar+(N-2*ZYVar)*ndot/M)/M;
AIndicator=(TIndicatorVar+(N-2*ZIndicatorVar)*ndot/M)/M;
if (Symbol()=="EURUSD" || Symbol()=="GBPUSD" || Symbol()=="USDCAD" || Symbol()=="USDCHF"
|| Symbol()=="EURGBP" || Symbol()=="EURCHF" || Symbol()=="AUDUSD"
|| Symbol()=="GBPCHF")
{cfl[shift]=(-1000)*MathLog(AY/AIndicator);}
else {cfl[shift]=(1000)*MathLog(AY/AIndicator);}
shift--;
}
return(0);
}
//+------------------------------------------------------------------+
__________________
Do, or do not, there is no such thing as try.
__________________
I'm easily pleased with perfection, and if trading is an art, then I'm painting my masterpiece.
__________________
If the margin between your goal and failure is too small then any shortfall will inevitably lead to failure.
It's far better to aim high because if you don't quite achieve your ambition you may very well be left with something worthwhile.

__________________
Rossini is offline   Reply With Quote
Old Jan 29, 2010, 12:28pm   #2
 
Rossini's Avatar
Joined May 2008
Re: Can anyone help with this code???

Rossini started this thread Does anyone know? I would appreciate any comments...
__________________
Do, or do not, there is no such thing as try.
__________________
I'm easily pleased with perfection, and if trading is an art, then I'm painting my masterpiece.
__________________
If the margin between your goal and failure is too small then any shortfall will inevitably lead to failure.
It's far better to aim high because if you don't quite achieve your ambition you may very well be left with something worthwhile.

__________________
Rossini is offline   Reply With Quote
Old Jan 29, 2010, 1:11pm   #3
 
1Pipped's Avatar
Joined Nov 2007
Re: Can anyone help with this code???

I dont think it does, you can see where it stores the indicator value, here:
Code:
cfl[shift]=(-1000)*MathLog(AY/AIndicator);
or here:
Code:
cfl[shift]=(1000)*MathLog(AY/AIndicator);
...and its using "shift" for the index, it would use shift+something if it were recalculating the past values.

These bits could make it look into the future:
Code:
High[shift-cnt+1]
but then there is this bit which will stop it doing that as far as I can tell:
Code:
if (shift+1<ndot1) ndot1=shift+1;
I have not ran it, and Im not sure what it is, so I could be wrong!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!
__________________
Grrrind & chop.
1Pipped is offline   Reply With Quote
Old Jan 29, 2010, 1:18pm   #4
 
Rossini's Avatar
Joined May 2008
Re: Can anyone help with this code???

Rossini started this thread Cheers 1pipped.

What do you mean by ''make it look into the future''??

R
__________________
Do, or do not, there is no such thing as try.
__________________
I'm easily pleased with perfection, and if trading is an art, then I'm painting my masterpiece.
__________________
If the margin between your goal and failure is too small then any shortfall will inevitably lead to failure.
It's far better to aim high because if you don't quite achieve your ambition you may very well be left with something worthwhile.

__________________
Rossini is offline   Reply With Quote
Old Jan 29, 2010, 3:33pm   #5
 
1Pipped's Avatar
Joined Nov 2007
Re: Can anyone help with this code???

Hi Rossini,
I dont mean future as such, just that for example when its calculating the indicator value for say 16 bars ago(from NOW), it is possible to look at data that is only 14 bars ago(from now)... it would be looking 2 bars into the future from its perspective. Hope you know what I mean!
Im pretty sure it isnt doing that though.
__________________
Grrrind & chop.
1Pipped is offline   Reply With Quote
Old Feb 1, 2010, 3:44pm   #6
 
Rossini's Avatar
Joined May 2008
Re: Can anyone help with this code???

Rossini started this thread I have been told by a mate that this indicator may re-paint. If this is correct, would anyone be willing to have a go at changing the code for me so it doesn't repaint?
__________________
Do, or do not, there is no such thing as try.
__________________
I'm easily pleased with perfection, and if trading is an art, then I'm painting my masterpiece.
__________________
If the margin between your goal and failure is too small then any shortfall will inevitably lead to failure.
It's far better to aim high because if you don't quite achieve your ambition you may very well be left with something worthwhile.

__________________
Rossini is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with code sai20_2000 Trading Software 1 Jan 11, 2011 3:11pm
learning to code shadowninja Trading Software 16 Nov 26, 2008 9:17pm
Easylanguage code help intradaybill Trading Software 6 Feb 26, 2008 12:57am
Code help please Trdr Trading Software 0 May 9, 2005 12:08am
TS 2000 code Trdr Trading Software 2 Apr 22, 2005 8:52pm

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)