Страницы: 1 2 След.
Ответить

Помогите кто с советником

 
Помогите мне с советником!! у меня есть советник но я не как не могу его заставить чтоб он в селл открывался не пойму в чем его загвозка. Напишите мне в аську 256908317
 
Если не боитесь, что Ваш грааль стащат, выкладывайте код прям здесь (если код имеется, ессно) :)
 
я боюсь что
тот грааль утащат и потое его будут все использовать! а если грааль все будут использовать то грааль не будет работать :gamer:
 
Цитата
liberwayа если грааль все будут использовать то грааль не будет работать


тогда это не Грааль :grin:
 
Так он же и так не работает :grin:
Вы его покупали?
 
нет не покупал!!! Нет вы серьезно поможите?
 
Цитата
liberwayнет не покупал!!! Нет вы серьезно поможите?

Грааль, надо полагать, написан на mql4?
Я немного шпрехаю, так что попробовать могу, но ничего не обещаю...
Вот здесь Вам подскажут быстрее: http://forum.mql4.com/ru/
 
#property copyright "Copyright © 2007, Liberway"

extern double TakeProfitB = 12;
extern double TakeProfitS = 12;
extern double StopLossB = 1080;
extern double StopLossS = 780;
extern double TakeProfitForLock = 0;
extern double StopLossForLock = 134;
extern double TrailingStop = 0;
extern double StepTrailingStop = 5;
extern double BuyStopLevel = 22;
extern double BuyLimitLevel = 17;
extern double SellStopLevel = 78;
extern double SellLimitLevel = 83;
extern int UseOneWayRealOrdersB = 1;
extern int UseOneWayRealOrdersS = 1;
extern double MinDistanceRealOrdersB = 390;
extern double MinDistanceRealOrdersS = 590;
extern int UseAveragingTakeProfitB = 0;
extern int UseAveragingTakeProfitS = 0;
extern int UseSpeedIndicator = 1;
extern int iSP_CountBars = 2;
extern int iSP_CountTimeFrames = 2;
extern int iSP_StartTimeFrame = 1;
extern int iSP_UseForOpenRealOrders = 0;
extern double iSP_MinValueForOpenRealOrders = 0.0005;
extern double iSP_UseMinTakeProfit = 10;
extern double iSP_StopLoss = 35;
extern int CountHighLowLimits = 2;
extern double iHL_LimitDistance1 = 150;
extern int iHL_Period1 = 4;
extern int iHL_CountBars1 = 24;
extern double iHL_LimitDistance2 = 700;
extern int iHL_Period2 = 6;
extern int iHL_CountBars2 = 15;
extern int UseFlatIndicator = 1;
extern double iFL_MinWidthCanal = 20;
extern double iFL_MaxWidthCanal = 40;
extern double iFL_MinExtremumsCount = 2;
extern int iFL_Period = 1;
extern int iFL_CountBars = 12;
extern double iFL_StopLoss = 25;
extern double iFL_LotSizeMultiply = 2;
extern int UseBuy = 1;
extern int UseSell = 1;
extern int OpenRealOrders = 1;
extern double Risk = 0.1;
extern double BuyDenyLevel = 177;
extern double SellDenyLevel = 162;
extern int MaxOrdersCount = 3;
extern double MinDistanceDeferFromPrice = 10;
extern double MaxDistanceDeferFromPrice = 50;
extern double MinDistanceBetweenDefer = 90;
extern double MinLot = 0.1;
extern double MaxLot = 5;
extern double LotStep = 0.1;
bool var_424 = false;
int var_428 = 0;
int OrdType0 = OP_BUY;
int OrdType1 = OP_SELL;
int OrdType2 = OP_BUYLIMIT;
int OrdType3 = OP_SELLLIMIT;
int OrdType4 = OP_BUYSTOP;
int OrdType5 = OP_SELLSTOP;
int TF = {PERIOD_M1,PERIOD_M5,PERIOD_M15,PERIOD_M30,PERIOD_H1,PERIOD_H4,PERIOD_D1,PERIOD_W1,PERIOD_MN1,0};
double var_460;
double StopLevel;
int arr_476;
double arr_480;
double arr_484;
double arr_488;
double var_492;
double var_500;
double arr_508;
double arr_512;
double var_516;
int var_524;
double var_528;
double var_536;
double var_544;

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

int glGetNormalOrderType(int iordtype)
{
switch (iordtype)
{
case OP_BUY: return(OrdType0);
case OP_SELL: return(OrdType1);
case OP_BUYLIMIT: return(OrdType2);
case OP_BUYSTOP: return(OrdType4);
case OP_SELLLIMIT: return(OrdType3);
case OP_SELLSTOP: return(OrdType5);
default: return(-1);
}
return(-1);
}

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

int init()
{
StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL);

if (TakeProfitB != 0.0) TakeProfitB = MathMax(StopLevel,TakeProfitB);
if (TakeProfitS != 0.0) TakeProfitS = MathMax(StopLevel,TakeProfitS);
if (StopLossB != 0.0) StopLossB = MathMax(StopLevel,StopLossB);
if (StopLossS != 0.0) StopLossS = MathMax(StopLevel,StopLossS);
if (iSP_StopLoss != 0.0) iSP_StopLoss = MathMax(StopLevel,iSP_StopLoss);
if (iFL_StopLoss != 0.0) iFL_StopLoss = MathMax(StopLevel,iFL_StopLoss);
if (TakeProfitForLock != 0.0) TakeProfitForLock = MathMax(StopLevel,TakeProfitForLock);
if (StopLossForLock != 0.0) StopLossForLock = MathMax(StopLevel,StopLossForLock);

if (UseSpeedIndicator == 1)
{
if (iSP_CountBars < 2) iSP_CountBars = 2;
if (iSP_CountBars > 10) iSP_CountBars = 10;
if (iSP_CountTimeFrames < 1) iSP_CountTimeFrames = 1;
if (iSP_CountTimeFrames > 5) iSP_CountTimeFrames = 5;
}

if (MaxOrdersCount < 0) MaxOrdersCount = 0;

MinLot = MathMax(MarketInfo(Symbol(),MODE_MINLOT),MinLot);
MaxLot = MathMin(MarketInfo(Symbol(),MODE_MAXLOT),MaxLot);
LotStep = MathMax(MarketInfo(Symbol(),MODE_LOTSTEP),LotStep);
}

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

int deinit()
{
return(0);
}

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

int start()
{
int ordtype;
int magic;
int var_start_8;
double var_start_12;
double lots;
double price;
double var_start_36;
double sl;
double tp;
double var_start_60;
double var_start_68;
double var_start_76;
double var_start_84;
double var_start_92;
double var_start_100;
double var_start_108;
int ticket;
int var_start_120;
int var_start_124;
int i;
int j;
int k;
int ordtotal;
bool var_start_144;
bool var_start_148;
string orddescr;
double arr_start_160;
int arr_start_164;
double var_start_168;
double var_start_176;
int var_start_184;
int var_start_188;

var_460 = 1.0 / MathPow(10,Digits);
var_500 = 0;
var_492 = 0;

if (UseSpeedIndicator == 1)
{
for (i = 0; i < iSP_CountTimeFrames; i++)
{
for (j = 0; j < iSP_CountBars; j++)
{
var_start_168 = (iHigh(NULL,TF,j + 2) + iLow(NULL,TF,j + 2) + iClose(NULL,TF,j + 2) * 2) / 4;
var_start_176 = (iHigh(NULL,TF,j + 1) + iLow(NULL,TF,j + 1) + iClose(NULL,TF,j + 1) * 2) / 4;
if (var_start_168 > 0.0)
arr_start_160 = (var_start_176 - var_start_168) / var_start_168;
else
arr_start_160 = 0;
}
if ((i == 0) && (iSP_StartTimeFrame == 0))
{
if (Bid > iOpen(NULL,TF,0)) arr_start_164 = 1; else
if (Bid < iOpen(NULL,TF,0)) arr_start_164 = -1; else
if (arr_start_160 > 0.0) arr_start_164 = 1; else
if (arr_start_160 < 0.0) arr_start_164 = -1; else
{
arr_start_164 = 0;
break;
}
}
else
{
if (iOpen(NULL,TF,0) > iClose(NULL,TF,1)) arr_start_164 = 1; else
if (iOpen(NULL,TF,0) < iClose(NULL,TF,1)) arr_start_164 = -1; else
if (arr_start_160 > 0.0) arr_start_164 = 1; else
if (arr_start_160 < 0.0) arr_start_164 = -1; else
{
arr_start_164 = 0;
break;
}
}
if (arr_start_160 * arr_start_164 <= 0.0)
{
arr_start_164 = 0;
break;
}
for (j = iSP_CountBars - 2; j >= 0; j--)
{
if ((arr_start_164 == 1) && (arr_start_160 <= arr_start_160))
{
arr_start_164 = 0;
break;
}
if ((arr_start_164 == -1) && (arr_start_160 >= arr_start_160))
{
arr_start_164 = 0;
break;
}
}
}
var_492 = arr_start_164;
for (i = 1; i < iSP_CountTimeFrames; i++)
{
if (arr_start_164 != var_492)
{
var_492 = 0;
break;
}
}
if (var_492 != 0.0)
{
var_start_168 = iOpen(NULL,TF,0);
var_start_176 = Bid;
if ((iSP_StartTimeFrame == 0) && (var_start_168 != var_start_176) && (var_start_168 > 0))
var_492 = (var_start_176 - var_start_168) / var_start_168;
else
var_492 = arr_start_160;
}
}

if (CountHighLowLimits > 0)
{
for (k = 0; k < CountHighLowLimits; k++)
{
arr_508 = 0;
arr_512 = 0;
switch (k)
{
case 0:
var_start_188 = iHL_Period1;
var_start_184 = iHL_CountBars1;
break;
case 1:
var_start_188 = iHL_Period2;
var_start_184 = iHL_CountBars2;
break;
default: continue;
}
for (i = 0; i < var_start_184; i++)
{
var_start_100 = iLow(NULL,TF,i);
var_start_108 = iHigh(NULL,TF,i);
if (var_start_100 > 0.0)
{
if ((arr_508 == 0) || (var_start_100 < arr_508)) arr_508 = var_start_100;
}
if (var_start_108 > 0.0)
{
if ((arr_512 == 0) || (var_start_108 > arr_512)) arr_512 = var_start_108;
}
}
}
}

if (UseFlatIndicator == 1)
{
var_524 = 0;
var_528 = 0;
var_536 = 0;
var_544 = 0;
for (i = 0; i < iFL_CountBars; i++)
{
var_start_100 = iLow(NULL,TF,i);
var_start_108 = iHigh(NULL,TF,i);
if (var_start_100 > 0.0)
{
if ((var_528 == 0) || (var_start_100 < var_528)) var_528 = var_start_100;
}
if (var_start_108 > 0.0)
{
if ((var_536 == 0) || (var_start_108 > var_536)) var_536 = var_start_108;
}
}
var_544 = var_536 - var_528;
if ((var_536 > 0) && (var_528 > 0) && (var_544 >= iFL_MinWidthCanal * var_460) && (var_544 <= iFL_MaxWidthCanal * var_460))
{
int var_start_196 = 0;
int lots0 = 0;
int lots4 = 0;
for (i = 0; i < iFL_CountBars; i++)
{
var_start_100 = iLow(NULL,TF,i);
var_start_108 = iHigh(NULL,TF,i);
if ((var_start_100 > 0) && (var_start_100 < var_528 + var_544 / 4) && (lots4 >= 0))
{
lots4 = -1;
var_start_196++;
}
if ((var_start_108 > 0) && (var_start_108 > var_536 - var_544 / 4) && (lots4 <= 0))
{
lots4 = 1;
lots0++;
}
}
if ((var_start_196 >= iFL_MinExtremumsCount) && (lots0 >= iFL_MinExtremumsCount)) var_524 = 1;
}
}

if (!glAnalizCurrentOrdersState()) return(0);

if ((arr_476 != 0) && (arr_476 != 0)) glDeleteAllDeferOrders(OrdType2);
if ((arr_476 != 0) && (arr_476 != 0)) glDeleteAllDeferOrders(OrdType3);
if ((arr_476 != 0) && (arr_476 != 0)) glDeleteAllDeferOrders(OrdType4,"",arr_480,0);
if ((arr_476 != 0) && (arr_476 != 0)) glDeleteAllDeferOrders(OrdType5,"",0,arr_484);

if ((arr_476 != 0) && (arr_476 != 0))
{
if (((TakeProfitForLock != 0) && ((TakeProfitForLock != TakeProfitB) || (TakeProfitForLock != TakeProfitS))) || ((StopLossForLock != 0) && ((StopLossForLock != StopLossB) || (StopLossForLock != StopLossS))))
{
var_start_60 = (Ask + Bid) / 2;
ordtotal = OrdersTotal();
for (i = 0; i < ordtotal; i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
Print("Ошибка получения текущего ордера OrderSelect(): ",GetLastError());
return(0);
}
ordtype = OrderType();
price = OrderOpenPrice();
tp = OrderTakeProfit();
sl = OrderStopLoss();
magic = OrderMagicNumber();
if (magic != 7770100)
{
if ((ordtype == OP_BUY) && (price == arr_480))
{
if (tp < price + TakeProfitForLock * var_460)
{
if ((MathAbs(Bid - sl) > StopLevel * var_460) && (MathAbs(Bid - (price + TakeProfitForLock * var_460)) > StopLevel * var_460))
{
if (OrderModify(OrderTicket(),price,sl,price + TakeProfitForLock * var_460,0))
{
tp = price + TakeProfitForLock * var_460;
}
}
}
if ((StopLossForLock != 0) && (price > arr_484) && (price - arr_484 > StopLossForLock * 2.2 * var_460) && (MathAbs(price - var_start_60) < MathAbs(arr_484 - var_start_60)) && (sl < price - StopLossForLock * var_460) && (Bid > price - StopLossForLock * var_460 * 2 / 3.0))
{
if ((MathAbs(Bid - (price - StopLossForLock * var_460)) > StopLevel * var_460) && (MathAbs(Bid - tp) > StopLevel * var_460))
{
if (OrderModify(OrderTicket(),price,price - StopLossForLock * var_460,tp,0))
{
sl = price - StopLossForLock * var_460;
}
}
}
}
else
{
if ((ordtype == OP_SELL) && (price == arr_484))
{
if (tp > price - TakeProfitForLock * var_460)
{
if ((MathAbs(Ask - sl) > StopLevel * var_460) && (MathAbs(Ask - (price - TakeProfitForLock * var_460)) > StopLevel * var_460))
{
if (OrderModify(OrderTicket(),price,sl,price - TakeProfitForLock * var_460,0))
{
tp = price - TakeProfitForLock * var_460;
}
}
}
if ((StopLossForLock != 0) && (price < arr_480) && (arr_480 - price > StopLossForLock * 2.2 * var_460) && (MathAbs(price - var_start_60) < MathAbs(arr_480 - var_start_60)) && (sl > price + StopLossForLock * var_460) && (Ask < price + StopLossForLock * var_460 * 2 / 3.0))
{
if ((MathAbs(Ask - (price + StopLossForLock * var_460)) > StopLevel * var_460) && (MathAbs(Ask - tp) > StopLevel * var_460))
{
if (OrderModify(OrderTicket(),price,price + StopLossForLock * var_460,tp,0))
{
sl = price + StopLossForLock * var_460;
}
}
}
}
}
}
}
}
}

if ((UseSpeedIndicator == 1) && (var_492 != 0))
{
if ((var_492 > 0) && (arr_476 > 0) && (arr_480 < Bid + var_460 * 20.0))
{
glDeleteAllDeferOrders(OrdType3);
}
if ((var_492 < 0) && (arr_476 > 0) && (arr_484 > Ask - var_460 * 20.0))
{
glDeleteAllDeferOrders(OrdType2);
}
}

if (CountHighLowLimits > 0)
{
for (k = 0; k < CountHighLowLimits; k++)
{
switch (k)
{
case 0: var_516 = iHL_LimitDistance1; break;
case 1: var_516 = iHL_LimitDistance2; break;
default: continue;
}
if ((arr_476 != 0) && (arr_508 > 0) && (arr_484 >= arr_508 + var_516 * var_460))
{
glDeleteAllDeferOrders(OrdType4,"",arr_508 + var_516 * var_460,0);
}
if ((arr_476 != 0) && (arr_512 > 0) && (arr_480 <= arr_512 - var_516 * var_460))
{
glDeleteAllDeferOrders(OrdType5,"",0,arr_512 - var_516 * var_460);
}
}
}

ordtotal = OrdersTotal();

if (TrailingStop > 0.0)
{
for (i = 0; i < ordtotal; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol() == Symbol())
{
if (OrderType() == OP_BUY)
{
if (Bid > OrderOpenPrice() + var_460 * TrailingStop)
{
if ((OrderStopLoss() == 0) || (OrderStopLoss() < Bid - var_460 * (TrailingStop + StepTrailingStop)))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid - var_460 * TrailingStop,OrderTakeProfit(),0);
}
}
}
else
{
if (OrderType() == OP_SELL)
{
if (Ask < OrderOpenPrice() - var_460 * TrailingStop)
{
if ((OrderStopLoss() == 0) || (OrderStopLoss() > Ask + var_460 * (TrailingStop + StepTrailingStop)))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask + var_460 * TrailingStop,OrderTakeProfit(),0);
}
}
}
}
}
}
}

if (!glAnalizCurrentOrdersState()) return(0);

if (Risk > 0.0)
var_start_12 = glDoubleRound(AccountFreeMargin() / 1000.0 * Risk,LotStep);
else
var_start_12 = MinLot;

if (var_start_12 < MinLot) var_start_12 = MinLot;
if (var_start_12 > MaxLot) var_start_12 = MaxLot;

if (AccountFreeMargin() < var_start_12 * 1000.0)
{
if (arr_476 + arr_476 == 0) return(0);
}

for (i = 0; i < 2; i++)
{
if (MaxOrdersCount != 0)
{
if (arr_476 + arr_476 >= MaxOrdersCount) break;
}
if (i == 0)
{
if (UseBuy == 0) continue;
var_start_120 = OrdType0;
orddescr = "BUY";
var_start_60 = Ask;
}
else
{
if (UseSell == 0) continue;
var_start_120 = OrdType1;
orddescr = "SELL";
var_start_60 = Bid;
}
var_start_68 = MathFloor(var_start_60 / var_460 / 100.0) * 100.0 * var_460;
if (OpenRealOrders == 1)
{
var_start_148 = false;
if ((UseFlatIndicator == 1) && var_524)
{
if ((var_start_120 == OrdType0) && (var_start_60 > var_528) && (var_start_60 <= var_528 + var_544 / 4))
{
if ((iOpen(NULL,TF,0) >= iClose(NULL,TF,1)) && (iClose(NULL,TF,1) > iClose(NULL,TF,2)) && (iClose(NULL,TF,2) > iClose(NULL,TF,3)))
{
var_start_148 = true;
ordtype = OP_BUY;
price = var_start_60;
tp = price + NormalizeDouble(var_544 / 2,Digits);
if (TakeProfitB > 0.0)
{
if (tp > price + TakeProfitB * var_460) tp = price + TakeProfitB * var_460;
}
if (iFL_StopLoss > 0.0) sl = price - iFL_StopLoss * var_460; else
if (StopLossB > 0.0) sl = price - StopLossB * var_460; else sl = 0;
}
}
if ((var_start_120 == OrdType1) && (var_start_60 < var_536) && (var_start_60 >= var_536 - var_544 / 4))
{
if ((iOpen(NULL,TF,0) <= iClose(NULL,TF,1)) && (iClose(NULL,TF,1) < iClose(NULL,TF,2)) && (iClose(NULL,TF,2) < iClose(NULL,TF,3)))
{
var_start_148 = true;
ordtype = OP_SELL;
price = var_start_60;
tp = price - NormalizeDouble(var_544 / 2,Digits);
if (TakeProfitS > 0.0)
{
if (tp < price - TakeProfitS * var_460) tp = price - TakeProfitS * var_460;
}
if (iFL_StopLoss > 0.0) sl = price + iFL_StopLoss * var_460; else
if (StopLossS > 0.0) sl = price + StopLossS * var_460; else sl = 0;
}
}
if (var_start_148) magic = 7770200;
}
if (!var_start_148 && (UseSpeedIndicator == 1) && (iSP_UseForOpenRealOrders == 1) && (MathAbs(var_492) > iSP_MinValueForOpenRealOrders))
{
if ((var_start_120 == OrdType0) && (var_492 > 0))
{
var_start_148 = true;
ordtype = OP_BUY;
price = var_start_60;
if (iSP_UseMinTakeProfit == 1.0)
tp = price + MarketInfo(Symbol(),MODE_STOPLEVEL) * var_460;
else
tp = price + TakeProfitB * var_460;
if (iSP_StopLoss > 0.0) sl = price - iSP_StopLoss * var_460; else
if (StopLossB > 0.0) sl = price - StopLossB * var_460; else
sl = 0;
}
if ((var_start_120 == OrdType1) && (var_492 < 0))
{
var_start_148 = true;
ordtype = OP_SELL;
price = var_start_60;
if (iSP_UseMinTakeProfit == 1.0)
tp = price - MarketInfo(Symbol(),MODE_STOPLEVEL) * var_460;
else
tp = price - TakeProfitS * var_460;
if (iSP_StopLoss > 0.0) sl = price + iSP_StopLoss * var_460; else
if (StopLossS > 0.0) sl = price + StopLossS * var_460; else
sl = 0;
}
if (var_start_148) magic = 7770300;
}
if (var_start_148)
{
if (!glCheckOrderBeforeAdding(price,var_start_120,ordtype,var_start_60)) var_start_148 = false;
}
if (var_start_148)
{
if (!glCheckDistanceFromOneWayReal(price,var_start_120,orddescr,var_start_76)) var_start_148 = false;
}
if (var_start_148)
{
if (!glCheckHighLowLimit(price,var_start_120,orddescr)) var_start_148 = false;
}
if (var_start_148)
{
if (!glCheckOpenOrdersBeforeAdding(price,ordtype,var_start_60)) var_start_148 = false;
}
if (var_start_148)
{
lots = var_start_12;
if (magic == 7770200)
{
if ((iFL_LotSizeMultiply > 0) && (iFL_LotSizeMultiply != 1))
{
lots = glDoubleRound(var_start_12 * iFL_LotSizeMultiply,LotStep);
if (lots > MaxLot) lots = MaxLot;
}
}
ticket = OrderSend(Symbol(),ordtype,lots,price,0,sl,tp,"Liberway.com",magic,0,Green);
if (ticket > 0)
{
if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
if (!glAnalizCurrentOrdersState()) return(0);
continue;
}
}
else
{
Print("Ошибка открытия ",orddescr," ордера (Lots = ",var_start_12,"): ",GetLastError());
}
}
}
for (j = 0; j < 2; j++)
{
magic = 7770000;
if (j == 0)
{
if (var_start_120 == OrdType0)
{
if (BuyStopLevel < 0.0) continue;
ordtype = OP_BUYSTOP;
var_start_124 = OrdType4;
orddescr = "BUY STOP";
if (var_start_60 < var_start_68 + BuyStopLevel * var_460)
price = var_start_68 + BuyStopLevel * var_460;
else
price = var_start_68 + (BuyStopLevel + 30.0) * var_460;
}
else
{
if (SellStopLevel < 0.0) continue;
ordtype = OP_SELLSTOP;
var_start_124 = OrdType5;
orddescr = "SELL STOP";
if (var_start_60 < var_start_68 + SellStopLevel * var_460)
price = var_start_68 - (30.0 - SellStopLevel) * var_460;
else
price = var_start_68 + SellStopLevel * var_460;
}
}
else
{
if (var_start_120 == OrdType0)
{
if (BuyLimitLevel < 0.0) continue;
ordtype = OP_BUYLIMIT;
var_start_124 = OrdType2;
orddescr = "BUY LIMIT";
if (var_start_60 < var_start_68 + BuyLimitLevel * var_460)
price = var_start_68 - (30.0 - BuyLimitLevel) * var_460;
else
price = var_start_68 + BuyLimitLevel * var_460;
}
else
{
if (SellLimitLevel < 0.0) continue;
ordtype = OP_SELLLIMIT;
var_start_124 = OrdType3;
orddescr = "SELL LIMIT";
if (var_start_60 < var_start_68 + SellLimitLevel * var_460)
price = var_start_68 + SellLimitLevel * var_460;
else
price = var_start_68 + (SellLimitLevel + 30.0) * var_460;
}
}
if (var_start_120 == OrdType0)
{
tp = price + TakeProfitB * var_460;
if (StopLossB > 0.0)
sl = price - StopLossB * var_460;
else
sl = 0;
}
else
{
tp = price - TakeProfitS * var_460;
if (StopLossS > 0.0)
sl = price + StopLossS * var_460;
else
sl = 0;
}
var_start_144 = true;
if (var_start_144)
{
if (!glCheckOrderBeforeAdding(price,var_start_120,ordtype,var_start_60)) var_start_144 = false;
}
if (var_start_144)
{
if (MinDistanceDeferFromPrice != 0.0)
{
if (MathAbs(price - var_start_60) < MinDistanceDeferFromPrice * var_460) var_start_144 = false;
}
if (MaxDistanceDeferFromPrice != 0.0)
{
if (MathAbs(price - var_start_60) > MaxDistanceDeferFromPrice * var_460) var_start_144 = false;
}
}
if (var_start_144)
{
if ((arr_476 > 0) && (j == 1)) var_start_144 = false;
}
if (var_start_144)
{
if (arr_476 > 0)
{
if ((var_start_124 == OrdType4) || (var_start_124 == OrdType3))
var_start_84 = arr_480;
else
var_start_84 = arr_484;
var_start_92 = MinDistanceBetweenDefer * var_460;
if ((var_start_124 == OrdType4) || (var_start_124 == OrdType3))
{
if (price > var_start_84 - var_start_92) var_start_144 = false;
}
else
{
if (price < var_start_84 + var_start_92) var_start_144 = false;
}
}
}
if (var_start_144 && (arr_476 > 0))
{
if (glCheckDistanceFromOneWayReal(price,var_start_120,orddescr,var_start_76))
{
if (((var_start_120 == OrdType0) && (UseAveragingTakeProfitB == 1)) || ((var_start_120 == OrdType1) && (UseAveragingTakeProfitS == 1)))
{
tp = (price + var_start_76) / 2;
magic = 7770100;
}
}
else
{
var_start_144 = false;
}
}
if (var_start_144 && (UseSpeedIndicator == 1))
{
if (j == 1)
{
if ((var_start_120 == OrdType0) && (var_492 < 0)) var_start_144 = false;
if ((var_start_120 == OrdType1) && (var_492 > 0)) var_start_144 = false;
}
}
if (var_start_144 && (CountHighLowLimits > 0))
{
if (!glCheckHighLowLimit(price,var_start_120,orddescr)) var_start_144 = false;
}
if (var_start_144)
{
if (!glCheckOpenOrdersBeforeAdding(price,ordtype,var_start_60)) var_start_144 = false;
}
if (var_start_144)
{
lots = var_start_12;
ticket = OrderSend(Symbol(),ordtype,lots,price,0,sl,tp,"Liberway.com",magic,0,Green);
if (ticket > 0)
{
if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
if (!glAnalizCurrentOrdersState()) return(0);
}
}
else
{
Print("Ошибка открытия ",orddescr," ордера (Lots = ",var_start_12,"): ",GetLastError());
}
}
}
}
}

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

bool glCheckOrderBeforeAdding(double price, int iordtype1, int iordtype2, double inp_coba_16)
{
double var_coba_24 = SellDenyLevel;

if (Symbol() == "EURJPY")
{
if ((iordtype1 == OrdType0) && (Time > D'2007.07.06 05:28') && (Time < D'2007.08.17 03:17')) return(false);
if (Time < D'2007.08.14 05:28') var_coba_24 = 155;
if (Time < D'2007.01.05 07:18') var_coba_24 = 0;
}

if (iordtype1 == OrdType0)
{
if (UseBuy == 0) return(false);
if ((iordtype2 == OP_BUY) && (OpenRealOrders == 0)) return(false);
if ((BuyDenyLevel > 0) && (price >= BuyDenyLevel)) return(false);
}

if (iordtype1 == OrdType1)
{
if (UseSell == 0) return(false);
if ((iordtype2 == OP_SELL) && (OpenRealOrders == 0)) return(false);
if ((var_coba_24 > 0) && (price <= var_coba_24)) return(false);
}
return(true);
}

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

bool glCheckOpenOrdersBeforeAdding(double price, int iordtype, double maxprice)
{
int i;
int var_cooba_24;
int var_cooba_28;
int ordtotal;
int ordtype;
int ticket;
double delta;
double maxdelta;

if ((iordtype == OP_BUY) || (iordtype == OP_BUYLIMIT))
{
if (!glDeleteAllDeferOrders(OP_BUYLIMIT)) return(false);
}

if ((iordtype == OP_SELL) || (iordtype == OP_SELLLIMIT))
{
if (!glDeleteAllDeferOrders(OP_SELLLIMIT)) return(false);
}

if (MaxOrdersCount != 0)
{
ordtotal = OrdersTotal();
while (ordtotal >= MaxOrdersCount)
{
maxdelta = 0;
for (i = 0; i < ordtotal; i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
Print("Ошибка получения текущего ордера OrderSelect(): ",GetLastError());
continue;
}
ordtype = OrderType();
if ((ordtype == OP_BUYLIMIT) || (ordtype == OP_BUYSTOP))
{
delta = MathAbs(Ask - OrderOpenPrice());
}
else
{
if ((ordtype == OP_SELLLIMIT) || (ordtype == OP_SELLSTOP))
{
delta = MathAbs(Bid - OrderOpenPrice());
}
else
{
continue;
}
}
if (delta > maxdelta)
{
maxdelta = delta;
ticket = OrderTicket();
}
}
if (maxdelta > MathAbs(price - maxprice))
{
if (OrderDelete(ticket)) ordtotal = OrdersTotal(); else return(false);
}
else
{
return(false);
}
}
}
return(true);
}

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

bool glCheckDistanceFromOneWayReal(double price, int inp_cdfowr_8, string orddescr, double& inp_cdfowr_20)
{
double var_cdfowr_28;

if (arr_476 == 0) return(true);

if ((inp_cdfowr_8 == OrdType0) && (UseOneWayRealOrdersB == 0)) return(false);
if ((inp_cdfowr_8 == OrdType1) && (UseOneWayRealOrdersS == 0)) return(false);

if (inp_cdfowr_8 == OrdType0)
{
inp_cdfowr_20 = arr_480;
var_cdfowr_28 = arr_476 * MinDistanceRealOrdersB * var_460;
}
else
{
inp_cdfowr_20 = arr_484;
var_cdfowr_28 = arr_476 * MinDistanceRealOrdersS * var_460;
}

if (inp_cdfowr_8 == OrdType0)
{
if (price > inp_cdfowr_20 - var_cdfowr_28) return(false);
}
else
{
if (price < inp_cdfowr_20 + var_cdfowr_28) return(false);
}
return(true);
}

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

bool glCheckHighLowLimit(double price, int inp_chll_8, string orddescr)
{
int var_chll_20;
int var_chll_24;
int i;
int var_chll_32;

for (i = 0; i < CountHighLowLimits; i++)
{
switch (i)
{
case 0: var_516 = iHL_LimitDistance1; break;
case 1: var_516 = iHL_LimitDistance2; break;
default:continue;
}
if ((inp_chll_8 == OrdType0) && (arr_508 > 0) && (price >= arr_508 + var_516 * var_460)) return(false);
if ((inp_chll_8 == OrdType1) && (arr_512 > 0) && (price <= arr_512 - var_516 * var_460)) return(false);
}
return(true);
}

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

bool glAnalizCurrentOrdersState()
{
int i;
int var_acos_4;
int var_acos_8;
int ordtotal = OrdersTotal();
int ordtype;
int normordtype;
double price;
double lots;

for (i = 0; i < 6; i++)
{
arr_480 = -1;
arr_484 = -1;
arr_488 = 0;
arr_476 = 0;
}

for (i = 0; i < ordtotal; i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
Print("Ошибка получения текущего ордера OrderSelect(): ",GetLastError());
return(false);
}
ordtype = OrderType();
price = OrderOpenPrice();
lots = OrderLots();
normordtype = glGetNormalOrderType(ordtype);
if (normordtype == -1)
{
Print("Ошибка определения типа текущего ордера: OrderType() = ",ordtype);
return(false);
}
arr_476 = arr_476 + 1;
if ((arr_480 == -1) || (price < arr_480))
{
arr_480 = price;
}
if ((arr_484 == -1) || (price > arr_484))
{
arr_484 = price;
}
arr_488 = arr_488 + lots;
}
return(true);
}

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

int glDeleteAllDeferOrders(int iordtype = -1, string symbol = "", double minprice = 0, double maxprice = 0)
{
int i;
double var_dado_32;
int ordtotal;
int ordtype;
double openprice;
int result = 1;

ordtotal = OrdersTotal();
for (i = ordtotal - 1; i >= 0; i--)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
ordtype = OrderType();
openprice = OrderOpenPrice();
if (((iordtype == -1) || (ordtype == iordtype)) && ((symbol == "") || (OrderSymbol() == symbol)))
{
if (iordtype == -1)
{
if ((ordtype == OP_BUY) || (ordtype == OP_SELL)) continue;
}
if ((minprice != 0) && (openprice < minprice)) continue;
if ((maxprice != 0) && (openprice > maxprice)) continue;
if (!OrderDelete(OrderTicket())) result = 0;
}
}
else
{
result = 0;
}
}
return(result);
}

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

double glDoubleRound(double ilots, double step)
{
int var_dr_16;
int var_dr_20 = 1;
double var_dr_24;
double var_dr_32;

if (step == 0.0) return(ilots);

while (step * var_dr_20 < 1.0)
{
var_dr_20 = var_dr_20 * 10;
}

var_dr_16 = step * var_dr_20;
var_dr_24 = MathFloor(ilots * var_dr_20);
if (MathAbs(ilots * var_dr_20 - var_dr_24) > 0.5) var_dr_24++;
var_dr_32 = var_dr_24 / var_dr_16;

if (var_dr_32 != MathRound(var_dr_32))
{
if (MathAbs(var_dr_32 - MathFloor(var_dr_32)) > 0.5)
var_dr_32 = MathFloor(var_dr_32) + 1.0;
else
var_dr_32 = MathFloor(var_dr_32);
var_dr_24 = var_dr_32 * var_dr_16;
}
return(var_dr_24 / var_dr_20);
}


Помогите плиз :wall:
 
Надеюсь на вас!
 
Цитата
liberwayНадеюсь на вас!

Ок, гляну, но особых надежд на меня не возлагайте, я же говорю, шо трохы шпрехаю :oops:
И было бы не плохо на описание советника глянуть :)
Страницы: 1 2 След.
Ответить
Читают тему (гостей: 1)

Вход