Simple CCI with MA Filter EA - page 2

 
Hi Agent,

Your are right. I am new to this language. And I have just finished reading till lesson # 12 in those fores-tsd lessons to which you referred me, and written my first indicator which is described in there experimenting with different options in it, although I did not understand every thing in them.

Based on what I understand from functions, switch statement and some other stuff, I have remove the global variable Err and the whole switch statement which related to it. Here is the updated code.

tapo

Files:
cci2_1.txt  7 kb
 

Доброго времени суток уважаемые форумчане!

Меня зовут Герман, мне 23 года, я являюсь трейдером компании "Инстафорекс"

Помогите в поиске нужного скрипта! Скрипт нужен для сетки отложенных ордеров.

 
tapo:
Hi Agent,

Your are right. I am new to this language. And I have just finished reading till lesson # 12 in those fores-tsd lessons to which you referred me, and written my first indicator which is described in there experimenting with different options in it, although I did not understand every thing in them.

Based on what I understand from functions, switch statement and some other stuff, I have remove the global variable Err and the whole switch statement which related to it. Here is the updated code.

tapo


Can someone tell me what is the difference between CCI_Per and CCI_close_Per?

Thanks,

 
They appear to be the same to me, and I don't see them being used differently in this code either

Other then CCI being used in the MA variable I don't really understand why without looking into it a little deeper
 
Hi programmers,

This is a fresh question. It can be disconnected from all the above.

I have been reading some programming lesson and I know now how to code a trade order and MA crossover triger. Now the missing piece is CCI. So I've read about iCCI function here https://docs.mql4.com/indicators/iCCI

Can someone expain the little questions below regarding iCCI parameters?

1. symbol: what's the difference between using symbol(), NULL and EURUSD?

2. timeframe: clear

3. period: like we have a moving average for price on the main chart, is this parameter a moving average of the CCI itself?

4. applied_price: is it that CCI can be calculated in different ways, among which the typical way is (high+low+close)/3, so with this parameter we can choose another way if we like?

5. shift: I have not got this one.

Thank you for your invaluable explanation.

tapo
 

1. NULL means the current symbol. Symbol() returns a text string with the name of the current financial instrument. These are essentially the same in the context of iCCI()

3, I read this as saying . . the avaeraging calculation within the CCI will use this many bars

4. just like a SMA can be applied to the Open values or Close values, the CCI can be applied to differnt bar values too . . i have no idea of the maths behind it but that is what is implied.

5. shift is the value for the bar number that you want the CCI value for . . . so for the current bar it would be 0, for a H1 bar 1 day ago it would be 24

 

Thanks Raptor.

3. and what is this average calculation within the CCI?

5. so, for example, if you want to code CCI crossing under 100, you could do

if (iCCI(NULL, 0, CCI_Per, PRICE_TYPICAL, 0) < 100 && iCCI(NULL, 0, CCI_Per, PRICE_TYPICAL, 1) > 100;

is that correct?

tapo

PS: WRT the math behind CCI, I don't know if you have seen this https://docs.mql4.com/constants/prices. This is what I meant by #4.

 

I don't use technical Indicators . . . I had no idea what CCI was until I just looked it up . . .

3. there is a MA calculation as part of the CCI calculation http://tradingsim.com/blog/commodity-channel-index/

5. for the CCI to cross something there has to be something else for it to cross . . . your code says if the CCI is currently below 100 and was above 100 for the last bar

re: 4. there is a MA in the CCI calculation and that MA can use various candle values OHLC, media, typical or weighted close

 
5. yes. That's what I meat my code to say. CCI to crosses below something (like 100) means it gets below it after it was above it at the immediate previous bar. Are we talking about the same thing?
 
tapo:
5. yes. That's what I meat my code to say. CCI to crosses below something (like 100) means it gets below it after it was above it at the immediate previous bar. Are we talking about the same thing?
Yes I think we are . . . just be careful if your use of CCI means it "repaints" . . it might be going back and forth over the 100 many times during a bar
Reason: