Coding help - page 333

 

Just one observation :

Code like this :

DayLow = iff(dayofmonth != dayofmonth[1], low, min(low, nz(DayLow[1])))

Means : DayLow is a minimum of a current day or previous lowest day low )same for highs). Now, it looks harmless when described, but if you think about what "previous lowest day low" means, soon you will understand that it is taking into account all the bars of the chart. That is the same error that some step indicators had, that Mark Jurik made in his calculation of one of the stochastic (I then called it an "infinite length stochastic") and some other indicators have ... and it leads to two things : calculated data deformation (lows and highs are always just lower or just higher, never the reverse) and ultimately repainting (when you change time frames or symbols, some bars that were the oldest before are lost, and that can influence the final result)

 

I gave it a try. Don't have much time right now, so feel free to correct it.

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

//| Magarto |

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

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 DimGray

double all4[];

double ma[];

double maslopeB[];

double candleOver[];

double bothElder[];

int init()

{

IndicatorBuffers(5);

SetIndexBuffer(0,all4);

SetIndexBuffer(1,ma);

SetIndexBuffer(2,maslopeB);

SetIndexBuffer(3,candleOver);

SetIndexBuffer(4,bothElder);

IndicatorShortName("Magarto");

return(0);

}

int deinit()

{

return(0);

}

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

//| |

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

int start()

{

int counted_bars = IndicatorCounted();

int i,limit;

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

if(counted_bars>0) counted_bars--;

limit = MathMin(Bars-counted_bars,Bars-1);

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

{

ma = iMA(NULL,0,30,0,MODE_SMA,PRICE_CLOSE,i);

double maslope = ma - ma;

if(maslope < 0) maslopeB = -1;

else if(maslope > 0) maslopeB = 1;

else maslopeB = 0;

if(((Open + Close + High + Low) / 4) > ma) candleOver = 1; else candleOver = -1;

double xMA = iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,i);

double DayLow = 0;

if(iTime(NULL,PERIOD_D1,i) != iTime(NULL,PERIOD_D1,i+1)) DayLow = iLow(NULL,PERIOD_D1,i);

else DayLow = MathMin(iLow(NULL,PERIOD_D1,i),iLow(NULL,PERIOD_D1,i+1));

double bearpower = DayLow - xMA;

double DayHigh = 0;

if(iTime(NULL,PERIOD_D1,i) != iTime(NULL,PERIOD_D1,i+1)) DayHigh = iHigh(NULL,PERIOD_D1,i);

else DayHigh = MathMax(iHigh(NULL,PERIOD_D1,i),iHigh(NULL,PERIOD_D1,i+1));

double bullpower = DayHigh - xMA;

if (bearpower > 0 && bullpower > 0) bothElder = 1;

else if(bearpower < 0 && bullpower < 0) bothElder = -1;

else bothElder = 0;

all4 = maslopeB + candleOver + bothElder;

}

return(0);

}

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

//| |

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

 

Hi i just wanted to ask a thing that is in my mind form a very long time about multi time frame indicators.

Look at the picture: This is a range bars 6 pip chart of dow jones with blau ergodic indicator, I highlighted the moment of that sell signal. It occurs at the end of that candle. This candle opens at 14,43 and closes at 14,57.

I plotted the indicator in the range bars 2 pip chart, with same settings, pointing it on 6 pip range bars chart.

It shows the start of sell signal when the 6 pip chart candle is not closed yet. I know this is THE NORMAL mtf indicator behavior, it couldn't be otherwise.

My goal is just to create 2 more colors, light pink for sell signals and the light green for buy signals when the higher tf candle is not closed yet .

So, it should be like this:

My question is: is it possible to do that? How should i approach the thing?

thanks

Files:
my.jpg  114 kb
2_pip.jpg  102 kb
6_pip.jpg  87 kb
 
thefxpros:
Hi i just wanted to ask a thing that is in my mind form a very long time about multi time frame indicators.

Look at the picture: This is a range bars 6 pip chart of dow jones with blau ergodic indicator, I highlighted the moment of that sell signal. It occurs at the end of that candle. This candle opens at 14,43 and closes at 14,57.

I plotted the indicator in the range bars 2 pip chart, with same settings, pointing it on 6 pip range bars chart.

It shows the start of sell signal when the 6 pip chart candle is not closed yet. I know this is THE NORMAL mtf indicator behavior, it couldn't be otherwise.

My goal is just to create 2 more colors, light pink for sell signals and the light green for buy signals when the higher tf candle is not closed yet .

So, it should be like this:

My question is: is it possible to do that? How should i approach the thing?

thanks

It can be done - just add 2 more buffers for the current bar

 
assassin:
I was send first link for this

if you went on to the function with cursor, you will see what is it

like this

mladen:
Just one observation :

Code like this :

DayLow = iff(dayofmonth != dayofmonth[1], low, min(low, nz(DayLow[1])))

Means : DayLow is a minimum of a current day or previous lowest day low )same for highs). Now, it looks harmless when described, but if you think about what "previous lowest day low" means, soon you will understand that it is taking into account all the bars of the chart. That is the same error that some step indicators had, that Mark Jurik made in his calculation of one of the stochastic (I then called it an "infinite length stochastic") and some other indicators have ... and it leads to two things : calculated data deformation (lows and highs are always just lower or just higher, never the reverse) and ultimately repainting (when you change time frames or symbols, some bars that were the oldest before are lost, and that can influence the final result)
airquest:
I gave it a try. Don't have much time right now, so feel free to correct it.

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

//| Magarto |

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

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 DimGray

double all4[];

double ma[];

double maslopeB[];

double candleOver[];

double bothElder[];

int init()

{

IndicatorBuffers(5);

SetIndexBuffer(0,all4);

SetIndexBuffer(1,ma);

SetIndexBuffer(2,maslopeB);

SetIndexBuffer(3,candleOver);

SetIndexBuffer(4,bothElder);

IndicatorShortName("Magarto");

return(0);

}

int deinit()

{

return(0);

}

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

//| |

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

int start()

{

int counted_bars = IndicatorCounted();

int i,limit;

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

if(counted_bars>0) counted_bars--;

limit = MathMin(Bars-counted_bars,Bars-1);

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

{

ma = iMA(NULL,0,30,0,MODE_SMA,PRICE_CLOSE,i);

double maslope = ma - ma;

if(maslope < 0) maslopeB = -1;

else if(maslope > 0) maslopeB = 1;

else maslopeB = 0;

if(((Open + Close + High + Low) / 4) > ma) candleOver = 1; else candleOver = -1;

double xMA = iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,i);

double DayLow = 0;

if(iTime(NULL,PERIOD_D1,i) != iTime(NULL,PERIOD_D1,i+1)) DayLow = iLow(NULL,PERIOD_D1,i);

else DayLow = MathMin(iLow(NULL,PERIOD_D1,i),iLow(NULL,PERIOD_D1,i+1));

double bearpower = DayLow - xMA;

double DayHigh = 0;

if(iTime(NULL,PERIOD_D1,i) != iTime(NULL,PERIOD_D1,i+1)) DayHigh = iHigh(NULL,PERIOD_D1,i);

else DayHigh = MathMax(iHigh(NULL,PERIOD_D1,i),iHigh(NULL,PERIOD_D1,i+1));

double bullpower = DayHigh - xMA;

if (bearpower > 0 && bullpower > 0) bothElder = 1;

else if(bearpower < 0 && bullpower < 0) bothElder = -1;

else bothElder = 0;

all4 = maslopeB + candleOver + bothElder;

}

return(0);

}

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

//| |

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

Good morning to all

First I want to apologize, for not being attentive to their work, mia is a request and I have not been watching your questions

Magarto is a Spanish user as you said mladen

The working platform using and have you seen

I'm trying to translate its strategy to MQL4

But my level of programming is too basic

I want to thank this development much

I can ask, please, if you can include the points when the indicator reaches the ends

Visualize something like that

Again, many thanks.

A hug to everyone fuerte

Hermo

Files:
 
Hermo:
Good morning to all

First I want to apologize, for not being attentive to their work, mia is a request and I have not been watching your questions

Magarto is a Spanish user as you said mladen

The working platform using and have you seen

I'm trying to translate its strategy to MQL4

But my level of programming is too basic

I want to thank this development much

I can ask, please, if you can include the points when the indicator reaches the ends

Visualize something like that

Again, many thanks.

A hug to everyone fuerte

Hermo

There you go, I've corrected some stuff. The code looks the same than the original, but on other timeframe than daily, the result values seem different than on tradingview. Not sure if this is due to differences between tradingview and MT4 or to an error. As it uses highs and lows of candles, I would say it's due to differences, because candles are hardly the same from one platform to another. Anyway, I don't think I can do better.

Files:
magarto.mq4  4 kb
 
airquest:
There you go, I've corrected some stuff. The code looks the same than the original, but on other timeframe than daily, the result values seem different than on tradingview. Not sure if this is due to differences between tradingview and MT4 or to an error. As it uses highs and lows of candles, I would say it's due to differences, because candles are hardly the same from one platform to another. Anyway, I don't think I can do better.

good morning

Thank you very much for your work and dedication

The indicator works perfectly now

Again, thank you very much

great job

With your permission, I will ask you to include a warning in the corresponding section.

Kind regards.

Hermo.

 

please help me......

spikebars_v3.ex4spikebars_v3.mq4Hi Everyone, i am hoping that someone could help me to set my mt4 expert advisor.I am not good in computing skills.But i would like to make and expert advisor

with a spike bar indicator which measures the size of the candlestick body.

I would like the ea to open a buy or sell position based on the size of the candlestick body.

ex; buy when= bull candlestick appears with the size of 30 pips(to be adjustable).

with adjustable stoploss and take profit.And adjustable position size.

sell when= bear candlestick appears with the size of ex.30 pips(to be adjustable)

with adjustable stoploss and take profit and adjustable position size.

So i am able to adjust the trade according to the current analysis and let the ea trade for me.

I here by attached a spike bar indicator.I hope anyone who are kind could assist me please because i am a beginner.

Thank you very much!

Files:
 

Hi Everyone, i am hoping that someone could help me to set my mt4 expert advisor.I am not good in computing skills.But i would like to make and expert advisor

with a spike bar indicator which measures the size of the candlestick body.

I would like the ea to open a buy or sell position based on the size of the candlestick body.

ex; buy when= bull candlestick appears with the size of 30 pips(to be adjustable).

with adjustable stoploss and take profit.And adjustable position size.

sell when= bear candlestick appears with the size of ex.30 pips(to be adjustable)

with adjustable stoploss and take profit and adjustable position size.

So i am able to adjust the trade according to the current analysis and let the ea trade for me.

I here by attached a spike bar indicator.I hope anyone who are kind could assist me please because i am a beginner.

Thank you very much!

 
faremie:
Hi Everyone, i am hoping that someone could help me to set my mt4 expert advisor.I am not good in computing skills.But i would like to make and expert advisor

with a spike bar indicator which measures the size of the candlestick body.

I would like the ea to open a buy or sell position based on the size of the candlestick body.

ex; buy when= bull candlestick appears with the size of 30 pips(to be adjustable).

with adjustable stoploss and take profit.And adjustable position size.

sell when= bear candlestick appears with the size of ex.30 pips(to be adjustable)

with adjustable stoploss and take profit and adjustable position size.

So i am able to adjust the trade according to the current analysis and let the ea trade for me.

I here by attached a spike bar indicator.I hope anyone who are kind could assist me please because i am a beginner.

Thank you very much!

faremie

Seems that the indicator you are talking about is not attached. Would you mind attaching it?

Reason: