View Single Post
  #1 (permalink)  
Old 01-23-2008, 10:51 PM
fxbs fxbs is offline
Senior Member
 
Join Date: Jan 2007
Location: not so remote
Posts: 1,984
fxbs is on a distinguished road
Best way to add MaxBarsToCount (History) to the limit?

Dear Admin, would be great if we didn't merge this thread and leave it separate -
question (problem) very common and specific thread much easier for Search
(plus this question allready in general thread, but no answer...)
--------------------------------------------------------------------


When we limit MaxBarsToCount (History) sometimes it require to add Correction, etc

is the best (safest, easiest, universal) way exist? (rule of tumb? dirty triks?)
----------------------

like here we have light fisher 4 stoch smothing:
----------

int start()
{
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
int limit=Bars-counted_bars;
if(limit>maxbars)limit=maxbars;
if (limit>Bars-lenth-1)limit=Bars-lenth-1;
//----
for (int shift = limit; shift>=0;shift--)
{
AuxBuffer[shift]=(iStochastic(NULL,0,lenth,2,1,MODE_SMA,0,MODE_MAI N,shift)/100-0.5)
+0.5*AuxBuffer[shift+1];

FishBuffer[shift]= 0.25* MathLog((1+AuxBuffer[shift])/(1-AuxBuffer[shift]))+
0.5*FishBuffer[shift+1];
SignalBuffer[shift]=FishBuffer[shift+1];

}

//----
return(0);
}
------------------------

for fisher limit f-la:

int limit;
int counted_bars=IndicatorCounted();

if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

for(int i=limit; i>=0; i--)
{
....

for Stoch:


int start()
{
int i,k;
int counted_bars=IndicatorCounted();
double price;
//----
if(Bars<=draw_begin2) return(0);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0;
for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0;
}
//---- minimums counting
i=Bars-KPeriod;
if(counted_bars>KPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double min=1000000;
k=i+KPeriod-1;
while(k>=i)
{
price=Low[k];
if(min>price) min=price;
k--;
}
LowesBuffer[i]=min;
i--;
}
....


p.s. in attached indicator, based on clean fisher transform and Stoch; MaxBars (tail) needs to be straighten-up a bit... (when MaxBars out - no problem)

pps. same thing with many others; try to add maxBars to regular (stoc) macd and look on the tail...
Attached Files
File Type: mq4 test_Trans_Stoch_smz_limitMaxBars_test.mq4 (2.8 KB, 12 views)

Last edited by fxbs; 01-23-2008 at 10:58 PM.
Reply With Quote