Coding help - page 61

 
mladen:
That indicator is using "snake force" (centered TMA) for smoothing and it can not be changed not to recalculate and to stay the same. The "non-repainting" (end-pointed) version of centered TMA is a simple LWMA, but do not expect to have the same results with it as with the centered TMA. Some more about centered TMA you can read here : https://www.mql5.com/en/forum/181241 As of changing or improving that code : basis of it is a decompiled code. I doubt that somone will change a decompiled code

Thank you much Mladen for the info it was very helpful

 

Hi,

i downloaded this indicator from the web but when i attach it appear the separate windows with 2 level but not appear the bars.

Can you help me to fix it?

Thank you

oscillator.mq4

Files:
 

dasio,

That is just another solar wind indicator (someone tried to change something in it).

dasio:
Hi,

i downloaded this indicator from the web but when i attach it appear the separate windows with 2 level but not appear the bars.

Can you help me to fix it?

Thank you

oscillator.mq4
 
mladen:
dasio, That is just another solar wind indicator (someone tried to change something in it).

Thank you. But when i start the backtest the bars appear. How it can be possible?

Thank you

 

dasio

Check the experts and journal tab if some error is written out there. On my broker data it works so I can not tell what is happening on your broker data (maybe zero divide or something similar)

dasio:
Thank you. But when i start the backtest the bars appear. How it can be possible? Thank you
 

Mladen ,

When you write a code or looking in to someones'code how do you assess the code's quality?When you write a code how do you test the robustness of the code?Thanks.

 

:)

My two main criteria are :

- simplicity (making a code simple makes it easier to develop, enhance and debug)

- tidiness (whoever thinks that a code can be just thrown on a pile and it will work never had to look at its own code after some period of time. Also, debugging an untidy code is a story for itself)

When those 2 are fulfilled only then I take a second look and only then I "read" it, but then it is a very long story what can be done to access quality - I guess the process is much more subjective than objective ...

nevar:
Mladen , When you write a code or looking in to someones'code how do you assess the code's quality?When you write a code how do you test the robustness of the code?Thanks.
 
drofwarc:
Hi,

I'm trying to adapt an indicator that calls iFractals and instead call a custom fractal indicator that has an adjustable period feature. The indicator I'm trying to adapt is attached. It's called "closesrelativejtozpreviousofractal."

closesrelativejtozpreviousofractal.mq4

The code plots an up arrow if price breaks the previous fractal high and a down arrow for the reverse.

The indicator I'm trying to call with iCustom is also attached. It's called "Fractals – adjustable."

fractal_-_adjustable.mq4

Below is my attempt to modify the original indicator so that it calls Fractals – adjustable. The code successfully plots dots on the high and low fractals and the fractal period is adjustable, as I wanted. The problem is with the arrows intended to plot the breaks of the prior high and low fractal levels. I can't get them to plot correctly.

Any help with this would be greatly appreciated.

Kind regards,

drofwarc

int start()

{

int counted_bars = IndicatorCounted();

if (counted_bars > 0) counted_bars--;

int limit = Bars - counted_bars;

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

{

UpFractalsBuffer=iCustom(NULL,0,"Fractal - Adjustable", dist, arrowPosition, 0, i); //-Draw the high fractal

if (UpFractalsBuffer!=0) //-If it is available, put in the array of fractals for higher levels

HighLevel=iCustom(NULL,0,"Fractal - Adjustable", dist, arrowPosition, 2, i);

if(Close>HighLevel)

UpArrowBuffer=(Low-(PipBuffer)*Poin); //Arrows

DownFractalsBuffer=iCustom(NULL,0,"Fractal - Adjustable", dist, arrowPosition, 1, i); //-Draw the low fractal

if(DownFractalsBuffer!=0) //- If it is available put in the array of lower levels

LowLevel=iCustom(NULL,0,"Fractal - Adjustable", dist, arrowPosition, 3, i);

if(Close<LowLevel)

DownArrowBuffer=(High+(PipBuffer)*Poin);//Arrows

}

return(0);

}

Eventually solved this. Problem was a buffer mixup.

 

Code to make an indicator skip n bars between signals

Hi all,

I know that it's possible to make an EA pause between trades, either by using Sleep() or by recording a timestamp and waiting for n seconds after the timestamp before permitting another signal.

But is it possible to do the same for an indicator.

For example, I would like to be able to cause an indicator that plots arrows at the cross of two moving averages to skip n bars after a cross before plotting another arrow. In other words, if another cross occurred before n bars had gone by, the indicator would ignore the cross and not plot an arrow.

I've searched extensively to find an indicator that does this but have not had any luck.

Could someone either post an indicator that has this feature already so that I can study the code? Or perhaps provide me an example of code that works for this propose so that I can try to implement it.

Many thanks,

drofwarc

 

it can not display normally, anybody can help me to fix it?

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 Red

#property indicator_maximum 100

#property indicator_level1 70

#property indicator_level2 50

#property indicator_level3 30

#property indicator_minimum 0

//---- input parameters

extern int rsiperiod = 14 ;

extern int Shortperiod = 5 ;

extern int Middleperiod = 8;

extern int Longperiod = 13;

extern int mamode = 2 ;

//---- buffers

double RSI[];

double ShortRSI[];

double MiddleRSI[];

double LongRSI[];

double SMRSI[];

int period ;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

IndicatorBuffers(5);

SetIndexBuffer(0,SMRSI);

SetIndexBuffer(1,RSI);

SetIndexBuffer(2,ShortRSI);

SetIndexBuffer(3,MiddleRSI);

SetIndexBuffer(4,LongRSI);

//---- name for DataWindow and indicator subwindow label

IndicatorShortName("SMRSI("+rsiperiod+","+Shortperiod+","+Middleperiod+","+Longperiod +","+mamode+")");

SetIndexDrawBegin(0,rsiperiod+Longperiod);

period=Shortperiod+Middleperiod+Longperiod;

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted();

int i,limit;

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

limit = Bars-counted_bars;

for( i=limit; i>=0; i--) RSI=iRSI(NULL,0,rsiperiod,0,i);

for( i=limit; i>=0; i--) ShortRSI=iMAOnArray(RSI,0,Shortperiod,0,mamode,i);

for( i=limit; i>=0; i--) MiddleRSI=iMAOnArray(RSI,0,Middleperiod,0,mamode,i);

for( i=limit; i>=0; i--) LongRSI=iMAOnArray(RSI,0,Longperiod,0,mamode,i);

for( i=limit; i>=0; i--) { if(period!=0) SMRSI=(Shortperiod/period)*ShortRSI+(Middleperiod/period)*MiddleRSI+(Longperiod/period)*LongRSI;}

return(0);

}

//+------------------------------------------------------------------+

Reason: