Kama crossing

To add comments, please log in or register
Antonello74
40
Antonello74  

Hello I created an expert advisor, to open long and short positions at the intersection of two KAMA, can anyone help me figure out why I don't get results?

whroeder1
18071
whroeder1  
  1. If you bothered to look in the journal tab, you would know why - Array exceeded.
    double         KamaSellBuffer[];
    double         KamaBuyBuffer[];
    void OnTick(){ if(NewBar()){ EseguiOrdineLong();
    :
    void EseguiOrdineLong(){
         if(KamaSellBuffer[0]<KamaBuyBuffer[0] && KamaSellBuffer[0]>KamaBuyBuffer[0]){
    
    These arrays (they are not buffers) have zero size.

  2. void CalcoloKama1(const int rates_total1,
                    const int prev_calculated,
                    const datetime &time[],
                    const double &open[],
                    const double &high[],
                    const double &low[],
                    const double &close[],
                    const long &tick_volume[],
                    const long &volume[],
                    const int &spread[])    
    There is no prev_calculated (or buffers) in EAs. Don't try do that. No way to know if older bars have changed or been added (history update.)
    Just get the value(s) of the indicator(s) into the EA using iCustom and do what you want with it.
    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum

Antonello74
40
Antonello74  
whroeder1:
  1. If you bothered to look in the journal tab, you would know why - Array exceeded.These arrays (they are not buffers) have zero size.

  2. There is no prev_calculated (or buffers) in EAs. Don't try do that. No way to know if older bars have changed or been added (history update.)
    Just get the value(s) of the indicator(s) into the EA using iCustom and do what you want with it.
    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum

Thank you now I am going to show you.

To add comments, please log in or register