Please fix this indicator or EA - page 6

 

Need Help With A Custom Indicator

I created a custom indicator that is not updating correctly as I would like/expect it to. When the indicator is loaded on to the chart, it has the correct value. But after that the indicator line stays flat at constant value of 50 with every tick the chart moves (50 is the default value that my indicator returns whenever the denominator of the fraction used in the calculation has a value of 0)

The only way to get the indicator to display the correct value again is to either change the chart timeframe or delete and then re-attach the indicator to the chart. After the new chart is loaded, the indicator line goes flat again.

My indicator is trying to calculate the following formula:

[ [MovingAverage(Open - Close) / MovingAverage(Range)] * 50] + 50

I use a period of 8 in the two averages above.

Would somebody please be kind enough to look at my indicator code and point out to me what I am doing wrong?

I have attached my code to this message.

Thanking you in advance.

Files:
 

...

If you look at the code (starting at line 69):

ArrayResize(open_close_buffer, pos); //resize the array to the number of bars

ArraySetAsSeries(open_close_buffer,true); //reverse the array direction.

ArrayResize(range_buffer, pos); //resize the array to the number of bars

ArraySetAsSeries(range_buffer,true); //reverse the array direction.[/php]you will notice that posdoes equal the number of bars in any pass except the first pass (the initial that it is loaded at - even than it contains Bars-1) It is visible from the code just above these lines (this code)

[php] int pos = Bars - counted_bars;

int limit = pos;

But, even when you correct that, you wil have errors (due to how metatrader works with arrays) If you are not familiar with how to do it as arrays, the simplest solution is to declare open_close_buffer and range_bufferas buffers (in the init section)

forex-tsd2009:
I created a custom indicator that is not updating correctly as I would like/expect it to. When the indicator is loaded on to the chart, it has the correct value. But after that the indicator line stays flat at constant value of 50 with every tick the chart moves (50 is the default value that my indicator returns whenever the denominator of the fraction used in the calculation has a value of 0)

The only way to get the indicator to display the correct value again is to either change the chart timeframe or delete and then re-attach the indicator to the chart. After the new chart is loaded, the indicator line goes flat again.

My indicator is trying to calculate the following formula:

[ [MovingAverage(Open - Close) / MovingAverage(Range)] * 50] + 50

I use a period of 8 in the two averages above.

Would somebody please be kind enough to look at my indicator code and point out to me what I am doing wrong?

I have attached my code to this message.

Thanking you in advance.
 

Need some help on a simple indy please!

Hello All

I need a little help from someone more knowledgeable than I at coding.

I am trying to place a line at the high and the low of the last 20 candles and keep the line moving as the charts flows. I thought it would be a simple task. The result I have now is a line on the current candle high and low. Cant seem to get past it.

I knew absolutely nothing about coding when I found this forum! Thanks to all, I have learned a lot over the last few months. Thank you all for your input and sharing!

I have posted the code and if I can figure out how to do it I will post the file.

Any help would be greatly appreciated!

Thanks for looking!

gever17

Coded as follows:

#property indicator_chart_window

extern int BarsToLookBack = 20;

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

//| Custom indicator initialization function |

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

int init()

{

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

ObjectDelete("highline");

ObjectDelete("lowline");

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int i, c;

ObjectDelete("highline");

ObjectDelete("lowline");

double HighPrice=High[c],

LowPrice =Low[c];

for( i=0, c=0; i<BarsToLookBack; i++, c++)

{

if(High>HighPrice) HighPrice=High[c];

ObjectCreate("highline",OBJ_HLINE,0,0,HighPrice);

ObjectSet("highline",OBJPROP_COLOR,DeepPink);

ObjectSet("highline",OBJPROP_WIDTH,1);

ObjectSet("highline",OBJPROP_STYLE,4);

if(Low>LowPrice) LowPrice=Low[c];

ObjectCreate("lowline",OBJ_HLINE,0,0,LowPrice);

ObjectSet("lowline",OBJPROP_COLOR,Chartreuse);

ObjectSet("lowline",OBJPROP_WIDTH,1);

ObjectSet("lowline",OBJPROP_STYLE,4);

}

return(0);

}

Files:
 

Help me remove the black line on the chart

 
gever17:
Hello All

I need a little help from someone more knowledgeable than I at coding.

I am trying to place a line at the high and the low of the last 20 candles and keep the line moving as the charts flows. I thought it would be a simple task. The result I have now is a line on the current candle high and low. Cant seem to get past it.

I knew absolutely nothing about coding when I found this forum! Thanks to all, I have learned a lot over the last few months. Thank you all for your input and sharing!

I have posted the code and if I can figure out how to do it I will post the file.

Any help would be greatly appreciated!

Thanks for looking!

gever17

Hi Gever17,

I'm just learning myself and this may not be the answer, but it may get you pointed in the right direction.

It sounds like you need the "Average of the last 20 bars" - both High and Low averages...then plot these values and the High/Low lines should move.

Right now it looks like it is just getting the most recent values of the current bar and drawing lines on that bar.

Also, you have ObjectDelete in two places. The ones under 'int start()' is not needed as the one under 'int deinit()' should work fine.

Hope this helps,

Robert

 

who can fixe this EA ,it the best one

Dear,

Hedging lot strategy was profitable on my manual trading. Any one can help me to create Expert Advisor to automatically the trading.

*

Discription of Hedging strategy on file attachment.

*

Here the example trading on EUR/USD pair:

---------------------------------------------------------------

*

First position*1 Lot LONG 1.5471, TP = 1.5501 (30 pips), SL = 1.5411 (60 pips).

But the price againts my position, so i take second position 3 Lot SHORT 1.5441 (30 pips below first position), TP = 1.5411 (30 pips) SL = 1.5501 (60 pips).

*

Look, that TP second position = SL first position than if second position reach TP, first position closed too and i have profit.

*

But if the price againt my second position, i take thirth position BUY *30 PIPS above (at 1.5471 same as my first position) but volume order 6 Lot, TP=30, SL=60.

*

Rule:

All of orders TP=30, SL=60

Volume orders: 1, 3, 6, 12, 24, 48, ...( first to second position > 2x, thirth=2x second, ...)

*

I was download EA from another group that work based on this strategy but not perfect.

Second order error 130.with other broker it ok ,first order 1 lot,second order 3 lots,but the third order is not ok 1 lot, it shoud be 6 lots

*

Any one can help me....!!!! thanks.

*

Regard,

Files:
 

who can fixe this EA,it is very profitable,i will give donation if it is work with me

Dear,

Hedging lot strategy was profitable on my manual trading. Any one can help me to create Expert Advisor to automatically the trading.

*

Discription of Hedging strategy on file attachment.

*

Here the example trading on EUR/USD pair:

---------------------------------------------------------------

*

First position*1 Lot LONG 1.5471, TP = 1.5501 (30 pips), SL = 1.5411 (60 pips).

But the price againts my position, so i take second position 3 Lot SHORT 1.5441 (30 pips below first position), TP = 1.5411 (30 pips) SL = 1.5501 (60 pips).

*

Look, that TP second position = SL first position than if second position reach TP, first position closed too and i have profit.

*

But if the price againt my second position, i take thirth position BUY *30 PIPS above (at 1.5471 same as my first position) but volume order 6 Lot, TP=30, SL=60.

*

Rule:

All of orders TP=30, SL=60

Volume orders: 1, 3, 6, 12, 24, 48, ...( first to second position > 2x, thirth=2x second, ...)

*

I was download EA from another group that work based on this strategy but not perfect.

Second order error 130.with other broker it is ok ,first order 1 lot,second order 3 lots,but the third order is not ok 1 lot, it shoud be 6 lots

now the EA does not work with any broker ,it give me error 130

*

Any one can help me....!!!! thanks.

*

Regard,

 

please help fixe this EA,i will pay for it

Dear,

Hedging lot strategy was profitable on my manual trading. Any one can help me to create Expert Advisor to automatically the trading.

*

Discription of Hedging strategy on file attachment.

*

Here the example trading on EUR/USD pair:

---------------------------------------------------------------

*

First position*1 Lot LONG 1.5471, TP = 1.5501 (30 pips), SL = 1.5411 (60 pips).

But the price againts my position, so i take second position 3 Lot SHORT 1.5441 (30 pips below first position), TP = 1.5411 (30 pips) SL = 1.5501 (60 pips).

*

Look, that TP second position = SL first position than if second position reach TP, first position closed too and i have profit.

*

But if the price againt my second position, i take thirth position BUY *30 PIPS above (at 1.5471 same as my first position) but volume order 6 Lot, TP=30, SL=60.

*

Rule:

All of orders TP=30, SL=60

Volume orders: 1, 3, 6, 12, 24, 48, ...( first to second position > 2x, thirth=2x second, ...)

*

I was download EA from another group that work based on this strategy but not perfect.

Second order error 130.with other broker it is ok ,first order 1 lot,second order 3 lots,but the third order is not ok 1 lot, it shoud be 6 lots

now the EA does not work with any broker ,it give me error 130

*

Any one can help me....!!!! thanks.

*

Regard,

please see the EA at https://www.mql5.com/en/forum/179479

Files:
 

Help with StockMarketCloseLevel.mq4

Updated indicator code

 

Can Be Done

I don't think I have the necessary priviledge to PM you and I don't want to post my email address. I am interested. I just finished writing a similar EA. Please PM me with your email.