Kama crossing

 

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?

 
  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

 
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.

 

Hello! I'm trying to do it in Meta Trader 5. I am from Brazil and I work in the B3 Stock Exchange. Can you help me?

I did not understand: 

if(KamaSellBuffer[0]<KamaBuyBuffer[0] && KamaSellBuffer[0]>KamaBuyBuffer[0])

Thank you!

 
LordVinicius: I did not understand: 

if(KamaSellBuffer[0]<KamaBuyBuffer[0] && KamaSellBuffer[0]>KamaBuyBuffer[0])

What part of "look in the journal tab, you would know why - Array exceeded." was unclear? The arrays have no size. They are not buffers.

double         KamaSellBuffer[];
double         KamaBuyBuffer[];
 
LordVinicius:

Hello! I'm trying to do it in Meta Trader 5. I am from Brazil and I work in the B3 Stock Exchange. Can you help me?

I did not understand: 

if(KamaSellBuffer[0]<KamaBuyBuffer[0] && KamaSellBuffer[0]>KamaBuyBuffer[0])

Thank you!

Sorry LordVinicius if I answer only now, I abandoned the project I have been working on. As soon as I have time I'm going to review.