Timbo618:
If you want anyone to do that you need to provide code that will compile and run . . . not just part of the code.
Hello everyone,
Happy New year to you all and all the best for 2014!!!
I have been working on the code for the high or low level of the market when the Moving Averages cross up or down, but it keeps recalculating the code for the previous bar when watching live. But when I refresh the chart by closing MT4 down and re-opening, or re-compiling the indicator it calculates the data historically correctly.
Please could you have a look for me. Place the code on a 1 minute chart, just for speed of signal, and you'll see that it looks right, untill it calculates a cross live and you will see what I mean.
int limit = Bars-counted_bars; for (int i=limit; i >= 0; i--) { // Binary Signal: static double Level; { if((iMA(NULL,0,4,0,MODE_EMA,PRICE_CLOSE,i+1)>iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,i+1)) && (iMA(NULL,0,4,0,MODE_EMA,PRICE_CLOSE,i+2)<iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,i+2))) Level =High[i+1]; if((iMA(NULL,0,4,0,MODE_EMA,PRICE_CLOSE,i+1)<iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,i+1)) && (iMA(NULL,0,4,0,MODE_EMA,PRICE_CLOSE,i+2)>iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,i+2))) Level =Low[i+1]; else Level=Level; } ExtMapBuffer1[i] = Level;
- Valid bars are Bars - counted_bars - 1. Your first bar is bogus.
- Your look back 1 bars (High[i+1]) and 4 bars (ima(4)) so your look back is 4. Don't look at non-existent bars.
int counted_bars=IndicatorCounted(); if(counted_bars < 4) counted_bars = 4; // Look back for (int i=Bars - 1 - counted_bars; i >= 0; i--)
- "else Level=level" Except for the first run (or recompiled) the loop only runs on i=0 so level is bogus. You must save level in a buffer, so you can get it the next time.
//wong static double Level; double Level = ExtMapBuffer1[i+1]; // Use previous level value
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello everyone,
Happy New year to you all and all the best for 2014!!!
I have been working on the code for the high or low level of the market when the Moving Averages cross up or down, but it keeps recalculating the code for the previous bar when watching live. But when I refresh the chart by closing MT4 down and re-opening, or re-compiling the indicator it calculates the data historically correctly.
Please could you have a look for me. Place the code on a 1 minute chart, just for speed of signal, and you'll see that it looks right, untill it calculates a cross live and you will see what I mean.
Below are the 2 charts.
The first chart is when I opened MT4 and let it generate the signal from the code live and you will see the indicator is on the low of the bar when it crossed, but it should only be equal the low of when the MA's crossed on the following bar.
The second chart is after recompiling the indicator and you'll see that it has now correctly displayed the indicator on bar "B".
Has anyone got any ideas on why it displays the indicator perfectly on historical data but pushes the indicator back a bar when it calculates the indicator live?
Thanks very much for your help...I am a bit baffled on this one.
Cheers,
Tim.