Hi, I'm just finishing my own brand new EA which i build my self and i'm looking for pointer if there is something wrong with it or simplifying it.
Although not that important, I feel that it is a good idea to use enums instead of strings.
//+------------------------------------------------------------------+ I normally place enums above the inputs enum enumSignal { BuySignal, //Buy Signal SellSignal, //Sell Signal NoSignal //No Signal }; //+------------------------------------------------------------------+ //in OnTick { //String signals--use enum instead enumSignal Signal=NoSignal; //Buy Signal with moving average is lower than price close and CCI is higher than zero if ((MovingAverage<Close[0])&&(CCI>0)) { //Set the signal variable to buy Signal=BuySignal; } //Sell Signal with moving average is higher than price close and CCI is lover than zero if ((MovingAverage>Close[0])&&(CCI<0)) { //Set the signal variable to sell Signal=SellSignal; } }
Doing it this way saves having to type the quotes and auto_complete will work with enums in the compiler but not with strings.
I note that you are using values for the current open bar. This can lead to many false signals intrabar and is why the last closed bar is often used.
You may want to use an opposite signal to exit, or simply the opposite condition for either the MA or CCI. If you do opt for this method, it is another good reason to only use closed bars as you could be opening and closing multiple trades in the same bar if using the current bar.
Although not that important, I feel that it is a good idea to use enums instead of strings.
Doing it this way saves having to type the quotes and auto_complete will work with enums in the compiler but not with strings.
I note that you are using values for the current open bar. This can lead to many false signals intrabar and is why the last closed bar is often used.
You may want to use an opposite signal to exit, or simply the opposite condition for either the MA or CCI. If you do opt for this method, it is another good reason to only use closed bars as you could be opening and closing multiple trades in the same bar if using the current bar.
Hi Keith, thanks for the advice. I will implement it immedietly.
Do you mind if you explain more about this part "I note that you are using values for the current open bar."?
Do you mind if you explain more about this part "I note that you are using values for the current open bar."?
You are checking values for the current open bar, that is shift [0].
The values can change every tick while the bar is still open and this could give you false signals. This is why many people prefer to only use closed bars for signals.
You are checking values for the current open bar, that is shift [0].
The values can change every tick while the bar is still open and this could give you false signals. This is why many people prefer to only use closed bars for signals.
Wait, that isn't closed bars? I thought that is already using closed bars
Do you mind tell me what to change for it uses the closed bars?
Wait, that isn't closed bars? I thought that is already using closed bars
Do you mind tell me what to change for it uses the closed bars?
Shift[0] is the current open bar
Shift[1] is the most recent closed bar
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Now this is my code
I scrap it from some tutorials in youtube which then i shape as i wish. The point of this EA is that i want to buy when price close above MA and 0 CCI and sell when price below MA and 0 CCI. I also need some help with closing order because i do realize that this system of mine is only to open the order.