[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 35

 
keep87:

double get_extrem(int n) {

   for(int i=1;;i++) {

      double ind=iCustom(Symbol(),0,"indicator_name",0,i);

      if(n>1)  

         if(ind!=0) n--;

         else

         if(ind!=0) return(ind);

      }

   }


If you need the bar number of the peak, change the function type to int and instead of return(ind); write return(i);

This is what I'm thinking about at the moment. All functions of double and int types always return concrete fixed values. For example, 1, 0, -1 and in this case the condition must be handled with this function in a different way than I did before, e.g:

if(FindOrders() > 1)

{

   Ordersend(...........); 

} 

In this case, we have to compare, for example, for 3 tribes:

if (get_extrem(3) == ind)
{
   // Делаем что-то при выполнении заданного условия
}

Is this the logical way to write it? Maybe it is more reasonable to set bool type to this function? Like: if we have found the third knee, then at the price (below or above ind) we buy or sell.

And in this case we compare the function with its n-threshold parameter with the price at this knee, and then what?

 
hoz:

I'm thinking about it at the moment. All my functions of double and int type always return specific fixed values. For example, 1, 0, -1, but in this case the condition should be performed with this function in a different way than I did before, like:

In this case, we have to compare, for example, for 3 tribes:

Is this the logical way to write it? Maybe it is more reasonable to set bool type to this function? Like: if we have found the third knee, we buy or sell at a price (lower or higher than ind).

In this case, we compare the function with its parameter n knee to the price at this knee, and then what?



double ind=iCustom(Symbol(),0,"indicator_name",0,i);

Double ind can return -2, -3 and so on and even Pi 3.14159......

And in this case, we are comparing the function with its n-knee parameters to the price at this knee, and then what? It is not quite clear....

 
hoz:

I'm thinking about it at the moment. All my functions of double and int type always return specific fixed values. For example, 1, 0, -1, but in this case the condition should be performed with this function in a different way than I did before, like:

In this case, we have to compare, for example, for 3 tribes:

Is this the logical way to write it? Maybe it is more reasonable to set bool type to this function? Like: if we have found the third knee, then at the price (below or above ind) we buy or sell.

And in this case we compare the function with its n-knee parameter with the price at this knee, and then what?



Well no, try experimenting...... it's all bullshit......
 
Sepulca:


Double ind can return -2, -3 and so on and even Pi 3.14159......

And in this case, we compare the function with its n-knee parameters with the price at this knee, and then what?


Why should we do that all of a sudden? Double ind will return a fractional number... and -2, -3 ... are integers. And as I understand it,Double ind is the price on the knee in theget_extrem(int n)parameter
 
Sepulca:



This site is not for trading... It's mainly devoted to MQL programming. If you paid attention in many codes they even warn "Not for real trading".

And where is the prof. who trades like a prof. And if the admins found out this way, I think they would not bother maintaining the site ...))

Like peas in a wall ).

What we need is an example of proper buying, at any randomly chosen period of time.

Yes they write not for the real trade... So what, and why?

Why not show an example for a real trade, without announcing the strategy.

Or there is no proper example in principle.

 

Good afternoon. Can you tell me how to get Heiken Ashi(HA) Hi-Lo (amplitude) parameter from the corresponding indicator . I've tried to handle global variables, but I'm having a hard time. In the HA code I have embedded getting in the following way

int start()

{

double haOpen, haHigh, haLow, haClose

...

GlobalVariableGet(pip);

...(this is standard code with HA calculation)

then we get the parameters of Hi-Lo candlesticks HA

result2=MathMin(ExtMapBuffer3[pos+1],ExtMapBuffer4[pos+1])

result22=MathMax(ExtMapBuffer3[pos+1],ExtMapBuffer4[pos+1]);

result3=MathMin(Low[pos+1],result2);

result33=MathMax(High[pos+1],result22);

result0=result33-result3; / calculation of HA amplitude

GlobalVariableSet(pip,result0);/assign amplitude value to globalVariableSet( pip,result0)

pos--;

}

//----

return(0);

}

Then I just insertGlobalVariableGet(pip) into formula in EA,but something is totally wrong, i.e. value of pip is not what it should be. Please tell me what's wrong. Or maybe how easy it is to get HA amplitude for EA operation.

 
Greetings all. I am new to programming myself, so please solve the problem.

It is necessary that multiple EAs on the same account, open a limited number of orders.

For example: 10 EAs but can only open 5 orders, but no more than one per currency pair.

This is implemented as follows, but it does not work that way.

extern int МаксКолОрдеров   = 5;

//+------------------------------------------------------------------+

int ПодсчетОткрОрдеров() {
  int k=OrdersTotal();
   if (Символ=="0") Символ=Symbol();
    for (int i=МаксКолОрдеров; i<k; i++) {
     if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Символ || Символ=="") {
       if (МагикНомер<0 || OrderMagicNumber()==МагикНомер) {
      if (OrderMagicNumber()<1) return(True);
     }
    }
   }
  }
 return;

}

//+------------------------------------------------------------------+
int start()
  {
   if(ПодсчетОткрОрдеров()==0)ПровТоргУсловий();
   }

 
evgenGX:

1. I was prompted above about global variables, thanks. I'm reading the documentation. In your version, how is it done ?

2. I want the Expert Advisor to not enter the market again after reaching a profit, until the manual confirmation of the trading authorisation.


1. the profit level on each bar is monitored. If it exceeds the specified percentage of the deposit, all deals are closed.

2. See and edit this Expert Advisor, add filter on magik and everything you need...


 

Help me to complete the code. I tried to write a code that says:

-if MA50 crosses MA200 from bottom to top and then

-if price goes down to МА50

-two lines are drawn on the chart, support and resistance (drawn for the last 15 bars);

It's like everything works, but I can not ensure that these lines have appeared the first time, then remained in place, it needs to the trading algorithm(and they continue to be drawn).

Can I bind them to time or bar?

Here is the code. What do I need to add?

#property copyright "Copyright © 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"


bool  Fact_1 = false;                    // Глобальная перемен для бай.   
bool  Fact_2 = false;                    // Глобальная перемен для бай
bool  Fact_3 = false;                    // Глобальная перемен для бай

double support;
double resist;

 int timeFrame = 5;
 int numBars = 15;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----

  ObjectsDeleteAll(); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----


   //---------------------------------------------------------------------------
if (Fact_3==true)                            //Если событие уже..
         
                                              //..было, то выходим
     return(0);
 
//----

  //---- БЛОК ОТКРЫТИЯ  BUY--------------------------------------------------------------
 
 if (iMA(NULL,PERIOD_M5,50,0,MODE_EMA,PRICE_CLOSE,2)<iMA(NULL,PERIOD_M5,200,0,MODE_EMA,PRICE_CLOSE,0)&&
iMA(NULL,PERIOD_M5,50,0,MODE_EMA,PRICE_CLOSE,1)>=iMA(NULL,PERIOD_M5,200,0,MODE_EMA,PRICE_CLOSE,0))//если МА50 пересекает МА200 снизу вверх по M5
Fact_1 = true;       // Произошло событие 1 
//-
if (Fact_1 == true &&  Low[0]<= iMA(NULL,PERIOD_M5,50,0,MODE_EMA,PRICE_CLOSE,0))//если цена опустилась до МА50
 Fact_2 = true; // Произошло событие 2 
 if (Fact_2 == true)

{
// Определяем линии поддержки\сопротивления
  support = 10000;
  resist = 0;
 
  for(int u = 1;u<=numBars;u++)
  {
   if(support>iLow(Symbol(),timeFrame,u))
     support = iLow(Symbol(),timeFrame,u);
   if(resist<iHigh(Symbol(),timeFrame,u))
     resist = iHigh(Symbol(),timeFrame,u);
  }  
   ObjectSet("lineSupport",OBJPROP_PRICE1,support);
  ObjectSet("lineResist",OBJPROP_PRICE1,resist);
 
 }


 //----
  {
    ObjectCreate("lineSupport",OBJ_HLINE,0,0,0);
    ObjectSet("lineSupport",OBJPROP_COLOR,Blue);
   
    ObjectCreate("lineResist",OBJ_HLINE,0,0,0);
    ObjectSet("lineResist",OBJPROP_COLOR,Red);
    }
//----

//что сюда добавить что бы линии появившись, оставались на месте?




//----
   return(0);
  }

 

What will happen, what can happen if

buy, sell without specifying a margin for slippage.Usually +- 2 points are put in.

The response is a requote.

And if no slippage value is set, is it guaranteed to buy?