First, print the values in your Expert and then check the Journal (or Experts) tab.
Print("CCI 1 ", CCI1, " CCI2 ", CCI2, " CCILow ", CCILow);
Also, the expert is getting it's data on each tick, so the CCI1 may fluctuate as the price moves. It may have been at your level at some point during the bar, while if you checked later it may have a different (final) value.
To only trade on full bars do a check like
if (Volume[0]>1) return;
and then check CCI with shift value 1 (recently completed bar) and shift value 2.
Markus
Print("CCI 1 ", CCI1, " CCI2 ", CCI2, " CCILow ", CCILow);
Also, the expert is getting it's data on each tick, so the CCI1 may fluctuate as the price moves. It may have been at your level at some point during the bar, while if you checked later it may have a different (final) value.
To only trade on full bars do a check like
if (Volume[0]>1) return;
and then check CCI with shift value 1 (recently completed bar) and shift value 2.
Markus
Thank you Shimodax, you help me a lot :)
You're welcome
Markus
Markus
I guess this is related. If you look at the chart versus the journal, 10am is completely different. On the chart the SAR is below but in the journal, it claims above. Every other hour is exactly the same. Tried different days and it always seems to happen on the reversal of the SAR.
New to metatrader, but not programming. Any help would be appreciated. Thanks.
Files:
meta-screwed_up.PNG
49 kb
Forex Trader: To only trade on full bars do a check like
if (Volume[0]>1) return; |
Bars is unreliable (a refresh/reconnect can change number of bars on chart,)
volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The
== operand. - MQL4 forum.) Always use time. New candle - MQL4
forum
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times. |

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
I start to write a program that basically use codes from "macd example-step by step",
instead of macd I use CCI indicator.
At first I use:
CCI1=iCCI(NULL,0,CCIperiod,PRICE_CLOSE,0);
CCI2=iCCI(NULL,0,CCIperiod,PRICE_CLOSE,1);
Then I asked "if" question:
if(CCI2<CCILow && CCI1>CCILow)
and if the condition is accept I order:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"MyTest",16384,0,Green);
Now to my problem:
When testing the program I notice that the expert makes an orders that shouldn't occur, the CCI indicator for example hasn't reach to specific level but the expert does (and makes an order).
What am I doing wrong?
Thanks