Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 483

 
culler:

Help me solve a problem to determine the moment of intersection of two MA lines.

I can't figure out how to describe it.

There are MAfast and MAslow

double MAfast=iMA(NULL,0,9,0,MODE_EMA,PRICE_CLOSE,1);

double MAslow=iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE,1);

if(MAfast>MAslow) it works only if MAfast is on the bottom, when it crosses it, it catches the moment of crossing, but then MAfast is on top and the order goes BUY ))))

I have it in my code how to determine the moment of crossing and compare its direction from down to up or vice versa.

In my code it is simply more or less. Hence the errors.

There's a lot to see and dohere.
 
artmedia70:
if ((x1 - y1)*(x2 - y2) < 0)
{
// we have intersection
}


TarasBY:
There's a lot of interesting stuff waiting for you here.

Thank you. Thank you.
 
culler:

Help me solve a problem to determine the moment of intersection of two MA lines.

I can't figure out how to describe it.

There are MAfast and MAslow

double MAfast=iMA(NULL,0,9,0,MODE_EMA,PRICE_CLOSE,1);

double MAslow=iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE,1);

if(MAfast>MAslow) it works only if MAfast is on the bottom, when it crosses it, it catches the moment of crossing, but then MAfast is on top and the order goes BUY ))))

I have it in my code how to determine the moment of crossing and compare its direction from down to up or vice versa.

In my code it is simply more or less. Hence the errors.


A very useful thread, and on your question!
 
The documentation says:

bool WindowIsVisible( int index)
Returns TRUE if the chart subwindow is visible, otherwise returns FALSE. The chart subwindow can be hidden because of the visibility properties of the indicator placed in it.
Parameters:
index - Index of the chart subwindow.
Example:
 int maywin=WindowFind("MyMACD"); if(maywin>-1 && WindowIsVisible(maywin)==true) Print("MyMACD window visible"); else Print("MyMACD window not found or not visible")
;
Please explain what it means: "A chart subwindow may be hidden due to visibility properties of the indicator placed in it"? What is this indicator property????
 

Doesn't stopplay return an int?

The compiler gives a warning "possible loss of data due to type conversion" to this code:

   int slevel = MarketInfo(Symbol(), MODE_STOPLEVEL);
да и на 
   int digits = MarketInfo( Symbol(), MODE_DIGITS);
тоже
 

Help is needed, part of the position is not closing when testing the EA

void Zacritie_poz_sell ()
{
 
 int    i, k=OrdersTotal();
 string sy=Symbol();
 
for (i=0; i<k; i++) 
{
 if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
 {
  if ( OrderSymbol() == sy)
   {
    if (OrderType()==OP_SELL)
     {
       if ( OrderMagicNumber()==Magic)
       {
        double TP = OrderTakeProfit();
        double Prise = OrderOpenPrice();
        double Close_poz = NormalizeDouble( Prise-(Prise-TP)/2,Digits);
        double Lots1 = NormalizeDouble (Lots/4,Digits);
        double TP1 = OrderTakeProfit()+1*Point;
        double SL = OrderOpenPrice()-20*Point;
         if ( Bid == Close_poz && OrderStopLoss() != SL && TP == TP1 && Lots != Lots1)
         {
          
           OrderClose(OrderTicket(),Lots1, Bid, 40*Point, Yellow);

           break;
           Sleep (1000*5);
           RefreshRates();
         
          
         }
         
       }
     }
  
    }
   }
 }
}
 
miha91:

Help is needed, part of the position is not closing when testing the EA


for (i=k-1; i>=0; i--)
 
evillive:

Doesn't stopplay return an int?

The compiler generates the "possible loss of data due to type conversion " warning on code like this:

Explicit type conversion:

int slevel = (int)MarketInfo(Symbol(), MODE_STOPLEVEL);
See... The function is of type double, but the request identifier can define the return type int. That's why it's swearing.
 

I'm optimising an EA, there's a lot of overshoot, about 10^17 degrees, there are more parameters, but they can't be optimised any more. Why are there such restrictions?

Plus a question on genetic algorithm. It seems to stop working properly on such big data, the final profit jumps quite dramatically, often downwards. That is, now it has found profitable settings, but not any other time. Are the developers going to fix it?

 
366366:

I'm optimising an EA, there's a lot of overshoot, about 10^17 degrees, and there are more parameters, but they can't be optimised anymore. Why are there such restrictions?

Plus a question on genetic algorithm. It seems to stop working properly on such big data, the final profit jumps quite dramatically, often downwards. That is, now it has found profitable settings, but not any other time. Are the developers going to fix it?


I gave up on this "genetic algorithm" a long time ago. Mathematics requires precision, and with this genetic algorithm we risk "spilling the baby"! It's better to optimize on the opening of bars on M1! You'll get better results and save time! There is no point in chasing on ticks, they lie immensely!