[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 603

 
41ckm39fi:
I removed everything related to PrevSignal but the message doesn't show up.

I didn't see the elephant in the room...

do a buffer initialization since it's an indicator...

#property indicator_chart_window

int init(){

IndicatorBuffers(2);

SetIndexBuffer(0,DeMarker_buffer0);

SetIndexBuffer(1,MA_buffer1);

SetIndexStyle(0,DRAW_NONE);

SetIndexStyle(1,DRAW_NONE);

}

remove ArraySetAsSeries call... and in

DeMarker_buffer0[i]=iDeMarker(NULL,0,14,1);

put the last parameter instead of 1 i

 
keekkenen:

I didn't see the elephant in the room...

do a buffer initialization since it's an indicator...

#property indicator_chart_window

int init(){

IndicatorBuffers(2);

SetIndexBuffer(0,DeMarker_buffer0);

SetIndexBuffer(1,MA_buffer1);

SetIndexStyle(0,DRAW_NONE);

SetIndexStyle(1,DRAW_NONE);

}

remove ArraySetAsSeries call... and in

put the last parameter instead of 1 i


Here's what you get:

#property  indicator_level1 0.3
#property  indicator_level2 0.7
#property indicator_chart_window
//---- 
extern int        period_MA            = 5,
                  period_DeMarker      = 14;
//---- 
double            DeMarker_buffer0[],
                  MA_buffer1[],
                  Signal_Buffer2[];       
#define SIGNAL_BAR 1
 //+------------------------------------------------------------------+
int init()
{

IndicatorBuffers(2);

SetIndexBuffer(0,DeMarker_buffer0);

SetIndexBuffer(1,MA_buffer1);

SetIndexStyle(0,DRAW_NONE);

SetIndexStyle(1,DRAW_NONE);

return(0);
  }
  //+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|   
//+------------------------------------------------------------------+
int start()
  {
  int    i,limit=ArraySize(DeMarker_buffer0);
        
  int    counted_bars=IndicatorCounted();
//----
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//----
  for(i=limit; i>=0; i--)
  DeMarker_buffer0[i]=iDeMarker(NULL,0,14,i);
//---- 
  for(i=limit; i>=0; i--)
  
  MA_buffer1[i]=iMAOnArray(DeMarker_buffer0,limit,5,0,MODE_LWMA,i);
//----  
                if(MA_buffer1[SIGNAL_BAR] - 0.3 > 0 && 0.3 - MA_buffer1[SIGNAL_BAR+1] >= 0)  
//---- 
                                Alert( "sMA(", Symbol(), ", ", Period(), ")  -  BUY!!!" );
//----
                if(0.7 - MA_buffer1[SIGNAL_BAR] > 0 && MA_buffer1[SIGNAL_BAR+1] - 0.7 >= 0)
//----               
                                Alert("sMA(", Symbol(), ", ", Period(), ")  -  SELL!!!");
                        
   return(0);
  }

But I am confused by this line

MA_buffer1[i]=iMAOnArray(DeMarker_buffer0,limit,5,0,MODE_LWMA,i);

Other composed indicators spell out Bars instead of limit.

 
41ckm39fi:


This is what came out:

But I am confused by this line

Other composed indicators spell out Bars instead of limit.




I'm confused too... this iMAOnArray() function, I'm not sure it can properly calculate averaging if the second parameter is different from 0, i.e. calculation over the entire DeMarker_buffer0 array, better put 0...
 
keekkenen:
I'm confused too... this iMAOnArray() function, I'm not sure it can properly calculate averaging if the second parameter is different from 0, i.e. calculation over the entire DeMarker_buffer0 array, better put 0...
I put Bars instead of limit and the program started giving messages!!! It seems to work the way I wanted it to. Only the messages go many times until the signal bar closes.
 
Good afternoon. Downloaded the EA, saved it, compiled it, reloaded the terminal. Can you tell me why the EA added to MT4 is not attached to the chart. Did I do something wrong?
 
41ckm39fi:

I prescribed Bars instead of ...

Only the messages go many times until the signal bar closes.

0 is still correct...

and bring back the time control...

static int  PrevTime = Time[0];
//---- 
if(PrevTime >= Time[0] ) return(0);
//---- 
PrevTime = Time[0];

// а здесь проверяйте условия на алерт
 

I forgot to mention that the line

int    i,limit=ArraySize(DeMarker_buffer0);

I replaced by

int    i,limit;

and replaced limit by Bars in the line

MA_buffer1[i]=iMAOnArray(DeMarker_buffer0,Bars,5,0,MODE_LWMA,i);

Now I will try to do as you say return PrevTime and replace the second parameter Bars with 0.

 

For example, I have an Expert Advisor running on mql4.

When I run it through extern variables, I set some values.

Question: Can I change at any time

some variables of the Expert Advisor during its operation (e.g., from the keyboard) and in such a case, it would not cause a restart of the Expert Advisor?

 
Jazzz:

For example, I have an Expert Advisor running on mql4.

When I run it through extern variables, I set some values.

Question: Can I change at any time

some variables of the Expert Advisor during its operation (e.g., from the keyboard) and in such a case, it would not cause a restart of the Expert Advisor?


You can if you use global level variables. To change their values from the keyboard without turning off the EA, press F3 in the terminal.
 
Thank you!