Tramloyr
Зарегистрирован: 12.02.2014 Сообщения: 6
|
Добавлено: Чт Мар 13, 2014 11:35 am Заголовок сообщения: ????????? ?????? ? ?????????? ? ??? ?????? |
|
|
??????? ???? ? ????????? ??? ????? ???
Код: | extern string T5_1 = "????????? ??? ????????";
extern bool WL = true; // ?????????, ?????????? ????????? ???????.
extern int WLstart = 30; // ?????? ????????? (?????? ???????)
extern int WLlevel = 1; // ???? ????????? (?????? ???????)
//---------------------------------------
extern string T5_2 = "Trailing ??? ????????";
extern bool Trailing = true; // ???. ?????????
extern int TrailingStop = 30; // ?????? ????? ? ???????
extern int TrailingStep = 30; // ??? ????? ? ???????
//==========================================================
//+------------------------------------------------------------------+
//| global variables |
//+------------------------------------------------------------------+
double dPiramidTP = 0.0;
double dWLstart = 0.0;
double dWLlevel = 0.0;
double dTrailingStop = 0.0;
double dTrailingStep = 0.0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
//---- ???????? ????????? ????????????? ??????
if(WLlevel < 0) WLlevel = 0.0;
if(WLstart < 0) WLstart = 0.0;
if(TrailingStop < 0) TrailingStop = 0.0;
if(TrailingStep < 0) TrailingStep = 0.0;
//---??????????? ??????
dWLstart = WLstart;
InfoChangeToDigit(_Symbol, dWLstart);
dWLlevel = WLlevel;
InfoChangeToDigit(_Symbol, dWLlevel);
dTrailingStop = TrailingStop;
InfoChangeToDigit(_Symbol, dTrailingStop);
dTrailingStep = TrailingStep;
InfoChangeToDigit(_Symbol, dTrailingStep);
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
// ???????? ???? ??????? ????????
void PiramidTrailing(){
if(Trailing && TrailingStop > 0.0){
for(int i=OrdersTotal()-1;i>=0;i--){
if(OrderSelect(i,SELECT_BY_POS)){
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicPiramid){
switch(OrderType()){
case OP_BUY:
double _price = OrderStopLoss();
if(_price == 0.0 || _price < OrderOpenPrice()) _price = OrderOpenPrice();
//
if(Bid >= NormalizeDouble(_price+dTrailingStop,Digits)){
double _new_sl = NormalizeDouble(Bid-dTrailingStep,Digits);
if(NormalizeDouble(OrderStopLoss()-_new_sl,Digits)!=0.0 && _new_sl > _price){
OrderModify(OrderTicket(),OrderOpenPrice(),_new_sl,OrderTakeProfit(),OrderExpiration());
}
}
break;
case OP_SELL:
_price = OrderStopLoss();
if(_price == 0.0 || _price > OrderOpenPrice()) _price = OrderOpenPrice();
//
if(Ask <= NormalizeDouble(_price-dTrailingStop,Digits)){
_new_sl = NormalizeDouble(Ask+dTrailingStep,Digits);
if(NormalizeDouble(OrderStopLoss()-_new_sl,Digits)!=0.0 && _new_sl < _price){
OrderModify(OrderTicket(),OrderOpenPrice(),_new_sl,OrderTakeProfit(),OrderExpiration());
}
}
break;
}
}
}
}
}
}
//+------------------------------------------------------------------+
// ????????? ????????? ??? ??????? ????????
void PiramidBE(){
if(WL && WLstart > 0){
for(int i=OrdersTotal()-1;i>=0;i--){
if(OrderSelect(i,SELECT_BY_POS)){
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicPiramid){
switch(OrderType()){
case OP_BUY:
if(OrderStopLoss()==0.0 || OrderStopLoss() < NormalizeDouble(OrderOpenPrice()+dWLlevel,Digits)){
if(Bid >= NormalizeDouble(OrderOpenPrice()+dWLstart,Digits)){
double _new_sl = NormalizeDouble(OrderOpenPrice()+dWLlevel,Digits);
if(NormalizeDouble(OrderStopLoss()-_new_sl,Digits)!=0.0){
OrderModify(OrderTicket(),OrderOpenPrice(),_new_sl,OrderTakeProfit(),OrderExpiration());
}
}
}
break;
case OP_SELL:
if(OrderStopLoss()==0.0 || OrderStopLoss() > NormalizeDouble(OrderOpenPrice()-dWLlevel,Digits)){
if(Ask <= NormalizeDouble(OrderOpenPrice()-dWLstart,Digits)){
_new_sl = NormalizeDouble(OrderOpenPrice()-dWLlevel,Digits);
if(NormalizeDouble(OrderStopLoss()-_new_sl,Digits)!=0.0){
OrderModify(OrderTicket(),OrderOpenPrice(),_new_sl,OrderTakeProfit(),OrderExpiration());
}
}
}
break;
}
}
}
}
}
}
|
??? ????? ???????? ? ???? ??? ?????? ??? ???? ????????
Код: | extern int BU_Start = 2; // ? ?????? ?????? ???????? ?????????? ??? ?????? |
? ??? ?? ? ???? ????????? ????? ??? ??????
Код: | extern int Trailing_Start= 2; // ? ?????? ?????? ???????? ??????? ???? ??? ??? ??????. |
???????? ???????? ??????
Код: | for(int i=OrdersTotal()-1;i>=0;i--){ |
??? ????? ???????
Код: | for(int i=OrdersTotal()-1;i>=BU_Start;i--){ |
??? ?? ? ? ?????, ?? ?????? ?????? ???????? ?? ???????? ? ??????????? ?? ???? ?? ????? ???
???? ??????? i>=2; ?? ??? ?????? ???????? ???????????? ?? ??????? ??????, ?? ???? ?????? 2 ???????? BU_Start ? ??????? ???????? ????????? ? ????????, ? ? ????? ?????? ???????????? ? ???? ????? ????? ??????????, ? ???????? ? ???? ?? ????? ?????? ??? ??? ??? ??????????? ? ?????? ??? ?????? ? ??????? ??????.
???? ????? ??????????? ???? ???????? ? ?????????? ? ???????????, ? ????? ?? ??? ???? ?????????? ??????????? ? ??? ????????? ???? ?? ??? ? ?????
???????. |
|