int start()
{
if (TimeBar==Time[0]) return(0);
double FF10=iCustom(Symbol(),0,"new\\FEN 1",MA_1,MA_Mode_1,Price_Type_1,Band_MA_1,SD_1,1,1);
double FF11=iCustom(Symbol(),0,"new\\FEN 1",MA_1,MA_Mode_1,Price_Type_1,Band_MA_1,SD_1,1,2);
double FF20=iCustom(Symbol(),0,"new\\FEN 1",MA_1,MA_Mode_1,Price_Type_1,Band_MA_1,SD_1,2,1);
double FF21=iCustom(Symbol(),0,"new\\FEN 1",MA_1,MA_Mode_1,Price_Type_1,Band_MA_1,SD_1,2,2);
double SL,TP;
if (LastOpenPriceBay() >Ask&&FF20<FF21)
{
TimeBar=Time[0];
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP = 0;
if (stoploss!=0) SL = NormalizeDouble(Bid - stoploss*Point,Digits); else SL = 0;
bay =OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,Digits),slip,SL,TP,"o",123,3);
}
if (LastOpenPriceSell()<Bid && FF10<FF11)
{
TimeBar=Time[0];
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP = 0;
if (stoploss!=0) SL = NormalizeDouble(Ask + stoploss*Point,Digits); else SL = 0;
sell=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),slip,SL,TP,"o",321,3);
}
return(0);
}
double LastOpenPriceBay()
{
double LOPB =2;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)== true)
if(OrderSymbol()==Symbol()&& OrderMagicNumber()==123)
{
if(OrderType() == OP_BUY)
{
LOPB = OrderOpenPrice();
break;
}
}
}
return(LOPB);
}
double LastOpenPriceSell()
{
double LOPS =0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)== true)
if(OrderSymbol()==Symbol()&& OrderMagicNumber()==321)
{
if(OrderType() == OP_SELL)
{
LOPS = OrderOpenPrice();
break;
}
}
}
return(LOPS);
}