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

 
igrok2008 >> :

Hello.

There is an expert SimpleMA, I tweaked it a little for me, just a little ...:-))) and called MASimple_v2x.

then i tried to improve it BUT BUT

I got an error after the experiment.

WHAT DID I DO WRONG?????????????

>> thanks in advance.



Try it this way:

instead of - if MAF_0 - MAF_1= A
if MAS_0 - MAS_1= B

this - double A = MAF_0 - MAF_1;

double B = MAS_0 - MAS_1;

 

If I understand correctly, you are tracking a situation where both MAs are moving in the same direction. Many more interesting discoveries await you :))

//это выражение не имеет смысла, if здесь лишний
   if MAF_0 - MAF_1= A
   if MAS_0 - MAS_1= B
//если требовалось определить разницу значений МА на 1-ом и нулевом баре, то можно так
   double A = MAF_0 - MAF_1;
   double B = MAS_0 - MAS_1;
 
rushman >> :

Can you tell me if it is possible to increase the number of lots in a market order without opening new ones?

Not as far as I know! Only when you open a new lot. What is the sense to increase the lots after the deal? Or do you mean that you see how you opened in the right direction, and you want more and more money?

 
alsu 23.10.2009 10:22
>>

И что теперь с этим делать?

NormalizeDouble(Bid,4);   //:))))


Probably better (more versatile):

NormalizeDouble(Bid,Digits);
 

Help me find a bug in the code. no error when compiling but calculations and transactions don't go through( Thanks in advance to the pros who are here.

//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
extern int    EMA1 = 14;                                  // Период 1-й EМА
extern int    EMA2 = 48;                                  // Период 2-й EМА
extern int    EMA3 = 144;                                  // Период 3-й EМА                             
extern int period=12;
extern int porog =3;
extern int metod =1;
extern int metod2=1;
extern int prise =0;
extern double SL =  1000;                                  // СтопЛосс ордера
extern double TP =  500;                                  // ТэйкПрофит ордера
extern double Lots= 0.1;  
//--------------------------------------------------------------------------------------------
int
   New_Bar,                                              // 0/1 Факт образования нового бара
   Time_0,                                               // Время начала нового бара
   total;                                                // Крличество открытых ордеров
//--------------------------------------------------------------------------------------------
double 
   Lot,                                                  // Количество лотов
   Norm,                                                 // Предыдущее значение 1-й МА (розов)
   Fast,                                                  // Текущее    значение 1-й МА (розов)
   Slow,                                                // Текущее    значение 2-й МА(голубая)
   Signal[];
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
int init()  
   {
//============================================================================================
   SL = SL*Point;                                        // SL в пунктах
   TP = TP*Point;                                        // ТР в пунктах
   return;
//============================================================================================
   }  
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
int start()  
   {
//============================================================================================
   total=OrdersTotal();                                  // Общее количество ордеров
   if ( total==2)return;                                  // Уже открыты оба ордера

//----------------------------------------------------------------------------- Новый бар ----
   New_Bar=0;                                            // Для начала обнулимся
   if ( Time_0 != Time[0])                                // Если уже другое время начала бара
      {
      New_Bar= 1;                                        // А вот и новый бар
      Time_0 = Time[0];                                  // Запомним время начала нового бара
      } 
//--------------------------------------------------------------------------------------------
//---расчет тренда ввех или вниз (XMA)
   int limit;
   double tmp1, tmp2;
   int counted_bars=IndicatorCounted();
   int i;
   if( counted_bars<0) return(-1);
   if( counted_bars>0) counted_bars--;
   limit=Bars- counted_bars;
   for ( i = limit; i>=0; i--){
     tmp1=iMA(Symbol(),0, period,0, metod, prise, i);
     tmp2=iMA(Symbol(),0, period,1, metod2, prise, i); 
     if(MathAbs( tmp1- tmp2)>= porog*Point)
     {       Signal[ i]= tmp2;      }
     
//--------------------------------------------------------------------------------------------
   Fast  =iMA(NULL,0, EMA1, 0,MODE_EMA, PRICE_CLOSE, 0);// Текущее    значение 1-й EМА
   Norm =iMA(NULL,0, EMA2, 0,MODE_EMA, PRICE_CLOSE, 0);// Предыдущее значение 2-й EМА
   Slow=iMA(NULL,0, EMA3, 0,MODE_EMA, PRICE_CLOSE, 0);// Текущее    значение 3-й EМА
   
//--------------------------------------------------------------------------------------------
   if ( Fast> Norm && Norm> Slow && New_Bar==1 && Close[ i]> Signal[ i]) Open_Buy();      // Движение снизу вверх = откр. Buy
   if ( Fast< Norm && Norm< Slow && New_Bar==1 && Close[ i]< Signal[ i]) Open_Sell();     // Движение сверху вниз = откр. Sell
   
   }
      return;
//============================================================================================
   }  
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
int Open_Buy()  
   {
   if ( total==1)
      {
      OrderSelect(0, SELECT_BY_POS);                     // Выделим ордер
      if (OrderType()==0)return;                         // Если он buy, то не открываемся
      }
   OrderSend(Symbol(),0, Lots, Ask, 0, Ask- SL, Ask+ TP, "", 0, 0, Blue);// Открываемся
   return;
   }
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
int Open_Sell() 
   {
   if ( total==1)
      {
      OrderSelect(0, SELECT_BY_POS);                     // Выделим ордер
      if (OrderType()==1)return;                         // Если он sell, то не открываемся
      }
   OrderSend(Symbol(),1, Lots, Bid, 0, Bid+ SL, Bid- TP, "", 0, 0, Red);// Открываемся
   return;
   }
 

Hi all, a word of advice please!!! Got a few questions, can't do it myself:

1. How to make only one order open on one bar?

2. There are several buy and sell conditions, what function to use for this?

3. How to organize the transfer of an open position to Breakeven?

4. How to apply all three conditions in the EA code (if possible, with an example)?

I am looking forward to your answers. Thank you very much in advance.

 
Piboli >> :

Hello. I just happened to come across an article on a subject that interests me. Namely this: Choosing a window size. .... Optimal results are achieved

in the case of selecting a window size of the order of the fractal dimension of the data. In order to calculate it, we should "slice" the series with a sliding window of a sufficiently large size

(see Figure 5 ), and then calculate the fractal dimensionality of the resulting data using, for example, Box-count method....

Please advise (preferably simpler), how to calculate the size of this sliding window. Or at least where to look at it.


The author's contact details are on the website, I recommend consulting the original source.
 

HOORAY FOR THE WORK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thanks to maniac and granit77.

A recent anecdote. A literature class in a computer lab, led by a computer science teacher.

-Gerasim was, this.....thim......nu......a and he didn't have a sound card :-)))))))))))))))))

Well, as for the expert, I tried to shorten the trading condition. You know, for better perception.

That is, if there are mathematical calculations, it is better to call them via double.

 
Maniac >> :

Hi all, a word of advice please!!! Got a few questions, can't do it myself:

1. How to make only one order open on one bar?

....... ...

I am waiting for your answers. Thank you very much in advance.

https://www.mql5.com/ru/forum/102366

//-----------------

https://www.mql5.com/ru/forum/113983/page2

//-------------

https://www.mql5.com/ru/forum/110184

 
morok >> :

Help me find a bug in the code. no error when compiling but calculations and trades don't go through( Thanks in advance to the pros who are here.

The first thing that catches my eye in your code and that I am not sure of is the correctness of using the IndicatorCounted() function in the Expert Advisor. I haven't checked it but I believe its correctness is guaranteed only in custom indicators.

Reason: