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

 
001 писал(а) >>
If you could do it in code, I've been racking my brains :)
int Order_Count[6];
//===============================================================================
// Функция возвращаюшая количество ордеров определенного типа исхода из заданных ограничений
//===============================================================================
int Order_Count_Calculate(string _Symbol, int _Magic, int _OP=-1){
   ArrayInitialize( Order_Count,0);
   for (int i = OrdersTotal() - 1;  i >= 0;  i--) {
      if (!OrderSelect( i, SELECT_BY_POS, MODE_TRADES))   continue;
      if (OrderSymbol() != _Symbol)                     continue;
      if (OrderMagicNumber() != _Magic)                   continue;
      Order_Count[OrderType()]++;
   }
   if (_OP>=0) return( Order_Count[_OP]);
   return(0);
}
This will do
 

What could be the problem? The indicator showed several pieces during the test and the EA looped in what could be the problem with the indicator?



Files:
trix_pv_4.mq4  10 kb
 

In which variable is the value of OsMA stored?



//+------------------------------------------------------------------+
//| OsMA.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp.
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
#property indicator_width1 2
//---- indicator parameters
extern int FastEMA=12;
extern inttern SlowEMA=26;
extern inttern SignalSMA=9;
//---- indicator buffers
double OsmaBuffer[];
double MacdBuffer[];;
double SignalBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialisation function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexDrawBegin(0,SignalSMA);
IndicatorDigits(Digits+2);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,OsmaBuffer);
SetIndexBuffer(1,MacdBuffer);
SetIndexBuffer(2,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("OsMA("+FastEMA+", "+SlowEMA+", "+SignalSMA+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Average of Oscillator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1st additional buffer
for(int i=0; i<limit; i++)
MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2nd additional buffer
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
//---- main loop
for(i=0; i<limit; i++)
OsmaBuffer[i]=MacdBuffer[i]-SignalBuffer[i];
//---- done

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

 
Vinin писал(а) >>
This variant will do

Thank you very much! Although I haven't dealt with functions, now I need to figure out how to call it, pass the variable values to it, and get the values back. If I understand the mechanism correctly.

 
vlandex >> :

In which variable is the value of OsMA stored?

isn't it in the buffer ?

 
Infinity >> :

>> but isn't it in the buffer?

>> What buffer?

 
vlandex писал(а) >>

Which one?

OsmaBuffer[]

 
vlandex >> :

>> which one?

дабавте перед

Alert("Значения MacdBuffer[i]="MacdBuffer[i]);

Alert("Значения SignalBuffer[i]="SignalBuffer[i]);

Alert("Значения OSMA ="OsmaBuffer[i]);

return(0);
}


just have to normalise the values

 

Hello.

Why isn't the stop transferring for buy positions? for sell positions everything works.

if(OrdersTotal()>0)
{
if(Bid==buy||Bid==busell)
{
OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES);
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(), 0, Blue);
}
return(0);
}

 
1Rakso >> :

What could be the problem? The indicator showed several pieces during the test, and the EA looped in what could be the problem of the indicator?

Incorrectly set parameters (by number or type) in the EA.

Alternatively, remove all string parameters from the indicator.

Reason: