// FUNGSI CLOSE ALL
if (ObjectGetInteger(0, "CLOSE ALL", OBJPROP_STATE) != 0)
{
bool ClsAll2,ClsAll3;
ObjectSetInteger(0, "CLOSE ALL", OBJPROP_STATE, 0);
for (int li_0 = OrdersTotal() - 1; li_0 >= 0; li_0--)
{
bool ClsAll=True;
ClsAll=OrderSelect(li_0, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol())
{
if (OrderSymbol() == Symbol())
{
if (OrderType() == OP_BUY)
/* bool*/ ClsAll2=True;
ClsAll2=OrderClose(OrderTicket(), OrderLots(), Bid, MagicID);
if (OrderType() == OP_SELL)
/* bool*/ ClsAll3=True;
ClsAll3=OrderClose(OrderTicket(), OrderLots(), Ask, MagicID);
}
Sleep(1000);
}
}
}
}
for ( i=0;i<OrdersTotal();i++){
for (int i=0;i<OrdersTotal();i++){
//+------------------------------------------------------------------+
//| ATRofMA.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Green
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_width1 2
//---- indicator parameters
extern int ATR_Period=7;
extern int MA_Period=7;
extern int MA_Shift=0;
input ENUM_MA_METHOD MA_Method=MODE_SMA; // Method
//---- indicator buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_ARROW,STYLE_DOT, 3);
SetIndexArrow(2,233);
SetIndexStyle(3,DRAW_ARROW,STYLE_DOT, 3);
SetIndexArrow(3,234);
SetIndexShift(0,MA_Shift);
SetIndexShift(1,MA_Shift);
SetIndexShift(2,MA_Shift);
SetIndexShift(3,MA_Shift);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
if(ATR_Period<2)
ATR_Period=14;
draw_begin=ATR_Period-1;
//---- indicator short name
IndicatorShortName("ATR=>MA,"+MA_Period+","+ATR_Period+";");
SetIndexDrawBegin(0,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
IndicatorDigits(5);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int limit;
if(Bars<=ATR_Period)
return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if(ExtCountedBars<0)
return(-1);
//---- last counted bar will be recounted
if(ExtCountedBars>0)
ExtCountedBars--;
//----
limit=Bars-ExtCountedBars;
for(int i=0; i<limit; i++)
ExtMapBuffer1[i]=iATR(Symbol(),0,ATR_Period,i);
for(i=0; i<limit; i++)
{
ExtMapBuffer2[i]=iMAOnArray(ExtMapBuffer1,0,MA_Period,0,MA_Method,i);
}
for(i=0; i<limit; i++)
{
if(ExtMapBuffer1[i]>ExtMapBuffer2[i] && ExtMapBuffer1[i+1]<ExtMapBuffer2[i+1])
{
ExtMapBuffer3[i]=iMAOnArray(ExtMapBuffer1,0,MA_Period,MA_Shift,MA_Method,i);
}
else
if(ExtMapBuffer1[i]<ExtMapBuffer2[i] && ExtMapBuffer1[i+1]<ExtMapBuffer2[i+1])
{
ExtMapBuffer3[i]=EMPTY_VALUE;
}
if(ExtMapBuffer1[i]<ExtMapBuffer2[i] && ExtMapBuffer1[i+1]>ExtMapBuffer2[i+1])
{
ExtMapBuffer4[i]=iMAOnArray(ExtMapBuffer1,0,MA_Period,MA_Shift,MA_Method,i);
}
else
if(ExtMapBuffer1[i]>ExtMapBuffer2[i] && ExtMapBuffer1[i+1]>ExtMapBuffer2[i+1])
{
ExtMapBuffer4[i]=EMPTY_VALUE;
}
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
alex30774