[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 143

 

There you go:

//+------------------------------------------------------------------+
extern string   _____= "Параметры Длинных позиций"; 
extern int     RSI_period  =20;
extern int     MA_period          =21;
extern int     TP=200;
extern int     SL=61;

extern string   ____= "Параметры Коротких позиций";
extern int     RSI_period_SELL  =20;          
extern int     MA_period_SELL          =21;
extern int     TP_=200;
extern int     SL_=61;

//------------------------------
extern string     ______= "Общие Параметры ";
extern double  Lot=0.1;
extern int     Slippage=3;
extern int    Low_lim=8;
extern int   Up_lim=8;

int ExpertBars;
int ticket;

//*********************************************************************
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
ExpertBars = Bars;
//----
   return(0);
  }

Next:





int start()
  {
bool isNewBar=false;
if ( ExpertBars !=Bars) { ExpertBars=Bars; isNewBar=true; }
if ( isNewBar) { //если есть новый бар
 
//===== Ищем возможность войти в рынок =========================================
if ( Long)                   {     //если "выключатель" включен
if (! ExpertOrder( MagicLong ))//если  нет открытых длинных позиций 
  {
 //------заполняем массив значениями RSI для длинных позиций --------
double RSI_array_buy[50];
int    j=0;
while ( j<50)
 {
RSI_array_buy[ j]= iRSI(NULL, 0, RSI_period, MODE_SMA, j);
j++;
 }
ArraySetAsSeries( RSI_array_buy,true);
double MA_low =iMAOnArray( RSI_array_buy,0, MA_period,1,MODE_SMA,0);
double RSI_0=iRSI(NULL, 0, RSI_period,MODE_SMA, 1);
double RSI_1=iRSI(NULL, 0, RSI_period,MODE_SMA, 2);   
//---------проверяем условие на покупку----------------------------
  if   (           ( RSI_1< MA_low)  &&
          ( RSI_0> MA_low)  )
   {
  ticket=OrderSend(Symbol(),0, Lot,Ask, Slippage,Bid- SL*Point,Ask+ TP*Point,NULL, MagicLong,0,CLR_NONE);
  if ( ticket<0) { Print("Ошибка открытия ордера BUY #", GetLastError()); return (0);   }          
   }
   }}
   //--------------------------------------------------------------
if ( Short)                   {     //если "выключатель" включен 
if (! ExpertOrder( MagicShort ))//если  нет открытых длинных позиций 
  {  
 // ---заполняем массив значениями рси  для коротких  позиций
double RSI_array_sell[50];
int    k=0;
while ( k<50)
 {
RSI_array_sell[ k]= iRSI(NULL, 0, RSI_period_SELL, MODE_SMA, k);
k++;
 }
ArraySetAsSeries( RSI_array_sell,true);
double MA_up =iMAOnArray( RSI_array_sell,0, MA_period_SELL ,1,MODE_SMA,0);
double RSI_0s=iRSI(NULL, 0, RSI_period_SELL,MODE_SMA, 1);
double RSI_1s=iRSI(NULL, 0, RSI_period_SELL,MODE_SMA,2);
    
//--------проверяем условие на продажу------------------------------
  if  (           ( RSI_1s > MA_up )  &&
          ( RSI_0s < MA_up )) 
   {       
  ticket=OrderSend(Symbol(),1, Lot,Bid, Slippage,Bid+ SL_*Point,Bid- TP_*Point,NULL, MagicShort,0,CLR_NONE);
  if ( ticket<0) { Print("Ошибка открытия ордера SELL #", GetLastError()); return (0);  }     
   } 
   }} 
 

Thank you!

 
Hello! Trying to ZZ in the form of a histogram with the display on the TF of the signal from both the low and high TF, but gave 5 errors" ExtMapBuffer2 "- variable not defined ", what's wrong? .....Help if you can not!!! Thanks
Files:
dinap_zzg.mq4  4 kb
 

Gentlemen (Comrades :)))

I'm trying to implement a MAMy indicator (it's in kodobase) in arrow form.

I'm trying to implement the MAMy indicator (it's in kodobase) in an arrow form.

The arrows are drawn on an unformed bar and if, by the time of its formation, the conditions have changed - the arrow is not removed, and can only be removed when restarting the indicator.

I would like the arrows to be drawn only on the formed bars. If you have time - give me a practical lesson - correct this messy code ...

(It's quite possible you'll find something superfluous - sorry (to write an indicator from scratch - my hands don't grow from there - although they're golden), I use other people's workpieces for now).

Thanks in advance.

 

Thank you very much !

That's exactly what the doctor ordered !

Because from the account history, on the chart.

it doesn't look very good.



 

Could you please tell me how mql can simulate a debugger (to watch the algorithm step by step with the current values of the variables), if there is no debugger, maybe there is a key press waiting and a dialog output function or something like that?

 

I found the Print function, but now I have another question: how does the indicator output work?

There are 512 bars on the chart. Theoretically the code should print start and bar number on 1-14 bars, then main and bar number on other bars, but for some reason it prints only start all the way down and from 295 bars. Can you tell me what's wrong?

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow

extern int Param=14;
extern double Razmah=0.9;

double VH[], VL[], Rang=0, z=0, z1=0, num=0, num1=0;
int init()
  {
   SetIndexBuffer(0, VH);
   SetIndexBuffer(1, VL);
   return(0);
  }
int start()
  {
   int i, counted_bars=IndicatorCounted();
   if ( counted_bars<= Param+1) 
   { 
      for( i=0; i<=Bars- counted_bars-1; i++)
      {
         VH[ i]=High[ i];
         VL[ i]=Low[ i];
         num++;
         Print("Start     ", num);
      }
      return(0);
   }
   
   i=-5;
   if( counted_bars> Param+1) i=Bars- counted_bars-1;
   while( i>=0)
     {
      num1++;
      Print("Main     ", num1 );
      VH[ i]=High[ i]*1.01;
      VL[ i]=Low[ i]*0.99;
      i--;
     }
   return(0);
  }
 
Andrej78 писал(а) >>

I found the Print function, but now I have another question: how does the indicator output work?

There are 512 bars on the chart. Theoretically the code should print start and bar number on 1-14 bars, then main and bar number on other bars, but for some reason only start is printed to the very end and from 295 bars. Please advise what is the problem.

Check your logs.

 
Vinin писал(а) >>

You need to look in the logs

>> how do you look at the logs?

 
Can you please help me loop it in, it's not working. Would a fresh look just be enough? Thank you in advance for your help. Description in the code.
Files:
proba9.mq4  3 kb
Reason: