Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
MG_2H_v207a
//+------------------------------------------------------------------+
//| Martingeil.mq4 |
//| Steve |
//| |
//| Íàïèñàë Steve. |
//| Èçìåíåíèÿ SiLeM |
//| Âåøàòü íà êàæäûé ãðàôèê. |
//+------------------------------------------------------------------+
#property copyright "Steve, Silem v 2.07"
extern double startLots = 1;
extern bool StopTrade=false; //îñòàíîâèòü òîðãîâëþ
extern string Opis1 = "Ðàçìåð ïåðâîãî øàãà";
extern double Step = 20;
extern string Opis2 = "Êîëåíî ñ ëîêîì: îò 2 äî 9";
extern int Koleno = 6; //êîëè÷åñòâî êîëåí äî ëîêà
extern string Opis3 = "Ìíîæèòåëè äëÿ ñåòêè è íà÷ ëîòà";
extern double StMnSet2 = 1; //ñåòêà 2 êîëåíî
extern double StMnLot2 = 1; //ëîò íà 2 êîëåíå
extern double StMnSet3 = 1; //ñåòêà 3 êîëåíî
extern double StMnLot3 = 2; //ëîò íà 3 êîëåíå
extern double StMnSet4 = 1; //ñåòêà 4 êîëåíî
extern double StMnLot4 = 4; //ëîò íà 4 êîëåíå
extern double StMnSet5 = 1; //ñåòêà 5 êîëåíî
extern double StMnLot5 = 8; //ëîò íà 5 êîëåíå
extern double StMnSet6 = 1; //ñåòêà 6 êîëåíî
extern double StMnLot6 = 16; //ëîò íà 6 êîëåíå - ëîê
extern double StMnSet7 = 1; //ñåòêà 7 êîëåíî
extern double StMnLot7 = 32; //ëîò íà 7 êîëåíå - ëîê
extern double StMnSet8 = 1; //ñåòêà 8 êîëåíî
extern double StMnLot8 = 64; //ëîò íà 8 êîëåíå - ëîê
extern double StMnSet9 = 1; //ñåòêà 9 êîëåíî
extern double StMnLot9 = 128; //ëîò íà 9 êîëåíå - ëîê
extern int MNMin = 100; //Ìàäæèêíîìåð ìèíèìàëüíûé
extern double timeOut = 3000;
extern bool UseSound = True; // Èñïîëüçîâàòü çâóêîâîé ñèãíàë
extern bool UseExtSound = false; // Èñïîëüçîâàòü ãîëîñîâîé ñèãíàë
extern string NameFileSoundExp = "expert.wav"; // Íàèìåíîâàíèå çâóêîâîãî ôàéëà ïðè ñðàáîòêå îðäåðîâ - ÿ äîáàâèë
extern string NameFileSoundExpL = "Oooh_Male.wav"; // Íàèìåíîâàíèå çâóêîâîãî ôàéëà ïðè ñðàáîòêå îðäåðîâ âûñîêîãî êîëåíà - ÿ äîáàâèë
extern bool IsRabComm = false; //ïîêàçûâàòü ëè ðàáî÷èå êîììåíòàðèè
#include <stdlib.mqh>
/*
Àëãîðèòì îòêðûòèÿ ñäåëîê ïî ìàðòèíãåéëó
***************************************
ïîðÿäîê íóìåðàöèè îðäåðîâ ìàãè÷åñêèìè ÷èñëàìè
1. Îðäåðà áàé âñåãäà íóìåðóþòñÿ íå÷åòíûìè ÷èñëàìè
2. Îðäåðà ñåëë âñåãäà íóìåðóþòñÿ ÷åòíûìè ÷èñëàìè
MNB1 - ïåðâîíà÷àëüíûå îðåäðà íà áàé
MNS1 - ïåðâîíà÷àëüíûå îðäåðà íà ñåëë
*/
//************************************************************
// îïðåäåëèì ìàæèêíîìåðà äëÿ ðàçíûõ ðóê
int MNMax, MNB1, MNB2, MNB3, MNB4, MNB5, MNB6, MNB7, MNB8, MNB9, MNS1, MNS2, MNS3, MNS4, MNS5, MNS6, MNS7, MNS8, MNS9;
int MNB11, MNB21, MNB31, MNB41, MNB51, MNB61, MNB71, MNB81, MNB91, MNS11, MNS21, MNS31, MNS41, MNS51, MNS61, MNS71, MNS81, MNS91;
double tl;
//**************************
// ýòà ôóíêöèÿ ïðîâåðÿåò íàëè÷èå îðäåðà ñ äàííûì ìàãè÷åñêèì íîìåðîì
// èìÿ ôóíêöèè è ñïèñîê ïàðàìåòðîâ
//**************************
bool isMgNum(int num)
{
int t, cnt1;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber()==num && OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
return (True);// âîçâðàùàåìîå çíà÷åíèå
}
}
return (False);
}
//**************************************
//ôóíêöèÿ óäàëåíèÿ îðäåðà ïî ìàãè÷åñêîìó íîìåðó
bool
deleteOrderNum(int num) // èìÿ ôóíêöèè è ñïèñîê ïàðàìåòðîâ
{
int t, cnt1, tic, err;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){//òîëüêî äëÿ äàííîãî èíñòðóìåíòà
if (OrderMagicNumber()== num
&& (OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP)
)
{
tic=OrderDelete(OrderTicket());
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
return (True);// âîçâðàùàåìîå çíà÷åíèå
}
}
}
return (False);
}
//******************************
//ôóíêöèÿ, ïðîâåðÿþùàÿ àêòèâèðîâàí ëè äàííûé îðäåð â îòêðûòóþ ïîçèöèþ
bool
isOrderActive(int num) // èìÿ ôóíêöèè è ñïèñîê ïàðàìåòðîâ
{
int t, cnt1;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if (OrderMagicNumber()== num) {
if (OrderType()==OP_BUY || OrderType()==OP_SELL)
{
return (True);// âîçâðàùàåìîå çíà÷åíèå
}
}
}
}
return (False);
}
//******************************
///îïðåäåëåíèå ìàêñèìàëüíî îòêðûòûõ ëîòîâ ïî äàííîìó èíñòðóìåíòó
double
getTopLots () // èìÿ ôóíêöèè è ñïèñîê ïàðàìåòðîâ
{
int t, cnt1;
double topL;
t=OrdersTotal();
topL=0;
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if (OrderType()==OP_BUY || OrderType()==OP_SELL)
{
if (OrderLots()>topL)
{
topL=OrderLots();
}
}
}
}
return (topL);
}
//***************************************
//îïðåäåëåíèå ìàñèìàëüíîãî óðîâíÿ äëÿ äëèííûõ èëè êîðîòêèõ ïîçèöèé
int
getTopLevel (int mode) // èìÿ ôóíêöèè è ñïèñîê ïàðàìåòðîâ
{
int t, cnt1, tLev, cLev;
t=OrdersTotal();
cLev=0;
tLev=0;
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol()){
if (OrderType()==OP_BUY || OrderType()==OP_SELL){ //òîëüêî àêòèâèðîâàííûå ïîçèöèè
if (mode==1){ //ïðîâåðêà óðîâíÿ äëÿ ëîíãîâ
if (OrderMagicNumber()==MNB9) cLev=9;
if (OrderMagicNumber()==MNB8) cLev=8;
if (OrderMagicNumber()==MNB7) cLev=7;
if (OrderMagicNumber()==MNB6) cLev=6;
if (OrderMagicNumber()==MNB5) cLev=5;
if (OrderMagicNumber()==MNB4) cLev=4;
if (OrderMagicNumber()==MNB3) cLev=3;
if (OrderMagicNumber()==MNB2) cLev=2;
if (OrderMagicNumber()==MNB1) cLev=1;
if (OrderMagicNumber()==MNB91) cLev=91;
if (OrderMagicNumber()==MNB81) cLev=81;
if (OrderMagicNumber()==MNB71) cLev=71;
if (OrderMagicNumber()==MNB61) cLev=61;
if (OrderMagicNumber()==MNB51) cLev=51;
if (OrderMagicNumber()==MNB41) cLev=41;
if (OrderMagicNumber()==MNB31) cLev=31;
if (OrderMagicNumber()==MNB21) cLev=21;
if (OrderMagicNumber()==MNB11) cLev=11;
} else { //ïðîâåðêà óðîâíÿ äëÿ øîðòîâ
if (OrderMagicNumber()==MNS9) cLev=9;
if (OrderMagicNumber()==MNS8) cLev=8;
if (OrderMagicNumber()==MNS7) cLev=7;
if (OrderMagicNumber()==MNS6) cLev=6;
if (OrderMagicNumber()==MNS5) cLev=5;
if (OrderMagicNumber()==MNS4) cLev=4;
if (OrderMagicNumber()==MNS3) cLev=3;
if (OrderMagicNumber()==MNS2) cLev=2;
if (OrderMagicNumber()==MNS1) cLev=1;
if (OrderMagicNumber()==MNS91) cLev=91;
if (OrderMagicNumber()==MNS81) cLev=81;
if (OrderMagicNumber()==MNS71) cLev=71;
if (OrderMagicNumber()==MNS61) cLev=61;
if (OrderMagicNumber()==MNS51) cLev=51;
if (OrderMagicNumber()==MNS41) cLev=41;
if (OrderMagicNumber()==MNS31) cLev=31;
if (OrderMagicNumber()==MNS21) cLev=21;
if (OrderMagicNumber()==MNS11) cLev=11;
}
}
}
if (cLev>tLev) tLev=cLev;
}
return (tLev);
}
//***************************************
//îïðåäåëåíèå ìàñèìàëüíîãî óðîâíÿ äëÿ äëèííûõ èëè êîðîòêèõ ïîçèöèé ïî ïðèáûëüíîé ðóêå
int
getTopLevelP (int mode) // èìÿ ôóíêöèè è ñïèñîê ïàðàìåòðîâ
{
int t, cnt1, tLev, cLev;
t=OrdersTotal();
cLev=0;
tLev=0;
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol()){
if (OrderType()==OP_BUY || OrderType()==OP_SELL){ //òîëüêî àêòèâèðîâàííûå ïîçèöèè
if (mode==1){ //ïðîâåðêà óðîâíÿ äëÿ ëîíãîâ
if (OrderMagicNumber()==MNB9) cLev=9;
if (OrderMagicNumber()==MNB8) cLev=8;
if (OrderMagicNumber()==MNB7) cLev=7;
if (OrderMagicNumber()==MNB6) cLev=6;
if (OrderMagicNumber()==MNB5) cLev=5;
if (OrderMagicNumber()==MNB4) cLev=4;
if (OrderMagicNumber()==MNB3) cLev=3;
if (OrderMagicNumber()==MNB2) cLev=2;
if (OrderMagicNumber()==MNB1) cLev=1;
if (OrderMagicNumber()==MNB91) cLev=9;
if (OrderMagicNumber()==MNB81) cLev=8;
if (OrderMagicNumber()==MNB71) cLev=7;
if (OrderMagicNumber()==MNB61) cLev=6;
if (OrderMagicNumber()==MNB51) cLev=5;
if (OrderMagicNumber()==MNB41) cLev=4;
if (OrderMagicNumber()==MNB31) cLev=3;
if (OrderMagicNumber()==MNB21) cLev=2;
if (OrderMagicNumber()==MNB11) cLev=1;
} else { //ïðîâåðêà óðîâíÿ äëÿ øîðòîâ
if (OrderMagicNumber()==MNS9) cLev=9;
if (OrderMagicNumber()==MNS8) cLev=8;
if (OrderMagicNumber()==MNS7) cLev=7;
if (OrderMagicNumber()==MNS6) cLev=6;
if (OrderMagicNumber()==MNS5) cLev=5;
if (OrderMagicNumber()==MNS4) cLev=4;
if (OrderMagicNumber()==MNS3) cLev=3;
if (OrderMagicNumber()==MNS2) cLev=2;
if (OrderMagicNumber()==MNS1) cLev=1;
if (OrderMagicNumber()==MNS91) cLev=9;
if (OrderMagicNumber()==MNS81) cLev=8;
if (OrderMagicNumber()==MNS71) cLev=7;
if (OrderMagicNumber()==MNS61) cLev=6;
if (OrderMagicNumber()==MNS51) cLev=5;
if (OrderMagicNumber()==MNS41) cLev=4;
if (OrderMagicNumber()==MNS31) cLev=3;
if (OrderMagicNumber()==MNS21) cLev=2;
if (OrderMagicNumber()==MNS11) cLev=1;
}
}
}
if (cLev>tLev) tLev=cLev;
}
return (tLev);
}
//******************************************************
//îïðåäåëåíèå ñêîëüêî ëîòîâ îòêðûâàòü ïî çàäàííîìó íîìåðó óðîâíÿ
double
getLotByLevel (int level) // ôóíêöèÿ äëÿ âû÷èñëåíèÿ ëîòà ïî óðîâíþ
{
double lot1;
lot1=startLots;//çíà÷åíèå ïî óìîë÷àíèþ
if (level==1) lot1=startLots;
if (level==2) lot1=startLots*StMnLot2;
if (level==3) lot1=startLots*StMnLot3;
if (level==4) lot1=startLots*StMnLot4;
if (level==5) lot1=startLots*StMnLot5;
if (level==6) lot1=startLots*StMnLot6;
if (level==7) lot1=startLots*StMnLot7;
if (level==8) lot1=startLots*StMnLot8;
if (level==9) lot1=startLots*StMnLot9;
if (level==11) lot1=startLots;
if (level==21) lot1=startLots*StMnLot2;
if (level==31) lot1=startLots*StMnLot3;
if (level==41) lot1=startLots*StMnLot4;
if (level==51) lot1=startLots*StMnLot5;
if (level==61) lot1=startLots*StMnLot6;
if (level==71) lot1=startLots*StMnLot7;
if (level==81) lot1=startLots*StMnLot8;
if (level==91) lot1=startLots*StMnLot9;
return (lot1);
}
//*******************************************************
//ïîëó÷åíèå öåíû îòêðûòèÿ îðäåðà ïî åãî ìàãè÷åñêîìó íîìåðó
double
getOrderPriceByNum (int num) // ôóíêöèÿ äëÿ ïîëó÷åíèÿ öåíû îòêðûòèÿ îðäåðà ïî åãî íîìåðó
{
int t, cnt1;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if (OrderMagicNumber()== num) {
return (OrderOpenPrice());
}
}
}
return (0);
}
//*******************************************************
//ïîëó÷åíèå öåíû îòêðûòèÿ îðäåðà ïî ìàãè÷. íîìåðó (òîëüêî äëÿ îòêðûòûõ ïîçèöèé)
double
getOrderPriceByNum2 (int num) // ôóíêöèÿ äëÿ ïîëó÷åíèÿ öåíû îòêðûòèÿ îðäåðà ïî åãî íîìåðó
{
int t, cnt1;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if (OrderMagicNumber()== num && (OrderType()==OP_BUY || OrderType()==OP_SELL)) {
return (OrderOpenPrice());
}
}
}
return (0);
}
//*******************************************************
//ïîëó÷åíèå öåíû îòêðûòèÿ îðäåðà ïî ìàãè÷. íîìåðó (òîëüêî äëÿ îòêðûòûõ ïîçèöèé)
double
getOrderProfitByNum (int num) // ôóíêöèÿ äëÿ ïîëó÷åíèÿ öåíû îòêðûòèÿ îðäåðà ïî åãî íîìåðó
{
int t, cnt1;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if (OrderMagicNumber()== num && (OrderType()==OP_BUY || OrderType()==OP_SELL)) {
return (OrderTakeProfit());
}
}
}
return (0);
}
//**********************************************************************
//ôóíêöèÿ èçìåíÿåò òåêóùèé òýéêïðîôèò äëÿ âñåõ îòêðûòûõ ïîçèöèé
//íà öåíó ïðåäïîñëåäíåé ñäåëêè ñåðèè, íî íà 1 ïèïñ ëó÷øå
void
setNewTakeProfit2(int dir, double price)
{
int t, cnt1, tic, err;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if (OrderType()==OP_BUY && dir==1 && OrderMagicNumber()!=MNS6 && OrderMagicNumber()!=MNS61)//
{
if (NormalizeDouble(OrderTakeProfit(),Digits)!=NormalizeDouble(price,Digits)
&& NormalizeDouble(price,Digits)!=0
&& price>(100*Point))
{
tic=OrderModify(OrderTicket(),OrderOpenPrice(),0,price,0,DarkTurquoise);
Print ("setNewTakeProfit OP_BUY -", OrderTakeProfit(), "->", price, " lots= ", OrderLots(), " num= ", OrderTicket());
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
}
if (OrderType()==OP_SELL && dir==2 && OrderMagicNumber()!=MNB6 && OrderMagicNumber()!=MNB61) //
{
if (NormalizeDouble(OrderTakeProfit(),Digits)!=NormalizeDouble(price,Digits)
&& NormalizeDouble(price, Digits)!=0
&& price>(100*Point))
{
tic=OrderModify(OrderTicket(),OrderOpenPrice(),0,price,0,Gold);
Print ("setNewTakeProfit OP_SELL -", OrderTakeProfit(), "->", price, " lots= ", OrderLots(), " num= ", OrderTicket());
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
}
if (OrderType()==OP_BUY && OrderTakeProfit()==0 && OrderMagicNumber()!=MNS6 && OrderMagicNumber()!=MNS61) {
tic=OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderOpenPrice()+Step*Point,0,DarkTurquoise);
Print ("ìîäèöèêàöèÿ àêòèâíîãî îðäåðà, åñëè òýéêïðîôèò íóëåâîé èç setNewTakeProfit2");
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (OrderType()==OP_SELL && OrderTakeProfit()==0 && OrderMagicNumber()!=MNB6 && OrderMagicNumber()!=MNB61) {
tic=OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderOpenPrice()-Step*Point,0,Gold);
Print ("ìîäèöèêàöèÿ àêòèâíîãî îðäåðà, åñëè òýéêïðîôèò íóëåâîé èç setNewTakeProfit2");
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
}
}
}
//**********************************************************************
double //ñ÷èòàåò îòêðûòûå ëîòû äëÿ ëîíãîâ ïî äàííîìó èíñòðóìåíòó
getBuyLotsSum(int mode)
{
int t, cnt1;
double sm;
t=OrdersTotal();
sm=0;
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (mode!=1) {
if (OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax)
{
sm=sm+OrderLots();
}
} else { //à çäåñü ïî âñåì îòêðûòûì ïîçèöèÿì ñ÷åòà
if (OrderType()==OP_BUY)
{
sm=sm+OrderLots();
}
}
}
return(sm);
}
//**********************************************************************
double //ñ÷èòàåò îòêðûòûå ëîòû äëÿ øîðòîâ ïî äàííîìó èíñòðóìåíòó
getSellLotsSum(int mode)
{
int t, cnt1;
double sm;
t=OrdersTotal();
sm=0;
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (mode!=1) {
if (OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax)
{
sm=sm+OrderLots();
}
} else {//à çäåñü ïî âñåì îòêðûòûì ïîçèöèÿì ñ÷åòà
if (OrderType()==OP_SELL)
{
sm=sm+OrderLots();
}
}
}
return(sm);
}
//********************************************************************
//*********************************************
//Ôóíêöèè äëÿ ìîäèôèêàöèè îòëîæåííûõ îðäåðîâ ëîíãîâ
//çäåñü îïðåäåëÿåì ìàêñèìàëüíûé ìàãè÷åñêèé íîìåð îòêðûòîãî îðäåðà äëÿ ëîíãîâ
int getMaxLongNum(){
int t, cnt1;
int topL;
t=OrdersTotal();
topL=0;
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax && OrderMagicNumber()!=MNS6 && OrderMagicNumber()!=MNS61){
if (OrderType()==OP_BUY)
{
if (OrderMagicNumber()>topL) topL=OrderMagicNumber();
}
}
}
return (topL);
}
//******************
//çäåñü îïðåäåëÿåì ìàêñèìàëüíûé ìàãè÷åñêèé íîìåð îòêðûòîãî îðäåðà äëÿ øîðòîâ
int getMaxShortNum(){
int t, cnt1;
int topL;
t=OrdersTotal();
topL=0;
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax && OrderMagicNumber()<MNB6 && OrderMagicNumber()<MNB61){
if (OrderType()==OP_SELL)
{
if (OrderMagicNumber()>topL) topL=OrderMagicNumber();
}
}
}
return (topL);
}
//************************
//âû÷èñëåíèå öåíû îòêðûòèÿ îðäåðà, êîòîðûé åùå íå àêòèâèðîâàí (íóæåí äëÿ óñòàíîâêè
/// îòëîæåííîãî îðäåðà íîâîãî óðîâíÿ âåòêè èëè äëÿ ìîäèôèêàöèè öåíû óñòàíîâëåííîãî
// îòëîæåííîãî îðäåðà)
double getNextOrderPriceByNum(int n1, double p1){
//äëÿ ëîíãîâ öåíà ñëåäóþùåãî îðäåðà íèæå íà øàã
if (n1==MNB1) return (p1-Step*Point);
if (n1==MNB2) return (p1-Step*StMnSet3*Point);
if (n1==MNB3) return (p1-Step*StMnSet4*Point);
if (n1==MNB4) return (p1-Step*StMnSet5*Point);
if (n1==MNB5) return (p1-Step*StMnSet6*Point);
if (n1==MNB6) return (p1-Step*StMnSet7*Point);
if (n1==MNB7) return (p1-Step*StMnSet8*Point);
if (n1==MNB8) return (p1-Step*StMnSet9*Point);
if (n1==MNB11) return (p1-Step*1*Point);
if (n1==MNB21) return (p1-Step*StMnSet3*Point);
if (n1==MNB31) return (p1-Step*StMnSet4*Point);
if (n1==MNB41) return (p1-Step*StMnSet5*Point);
if (n1==MNB51) return (p1-Step*StMnSet6*Point);
if (n1==MNB61) return (p1-Step*StMnSet7*Point);
if (n1==MNB71) return (p1-Step*StMnSet8*Point);
if (n1==MNB81) return (p1-Step*StMnSet9*Point);
//äëÿ øîðòîâ öåíà ñëåäóþùåãî îðäåðà âûøå íà øàã
if (n1==MNS1) return (p1+Step*1*Point);
if (n1==MNS2) return (p1+Step*StMnSet3*Point);
if (n1==MNS3) return (p1+Step*StMnSet4*Point);
if (n1==MNS4) return (p1+Step*StMnSet5*Point);
if (n1==MNS5) return (p1+Step*StMnSet6*Point);
if (n1==MNS6) return (p1+Step*StMnSet7*Point);
if (n1==MNS7) return (p1+Step*StMnSet8*Point);
if (n1==MNS8) return (p1+Step*StMnSet9*Point);
if (n1==MNS11) return (p1+Step*1*Point);
if (n1==MNS21) return (p1+Step*StMnSet3*Point);
if (n1==MNS31) return (p1+Step*StMnSet4*Point);
if (n1==MNS41) return (p1+Step*StMnSet5*Point);
if (n1==MNS51) return (p1+Step*StMnSet6*Point);
if (n1==MNS61) return (p1+Step*StMnSet7*Point);
if (n1==MNS71) return (p1+Step*StMnSet8*Point);
if (n1==MNS81) return (p1+Step*StMnSet9*Point);
return (0);
}
//************************
//âû÷èñëåíèå öåíû îòêðûòèÿ îòëîæåííîãî îðäåðà ïî ïðèáûëüíîé ðóêå, êîòîðûé åùå íå àêòèâèðîâàí
// (íóæåí äëÿ óñòàíîâêè îòëîæåííîãî îðäåðà íîâîãî óðîâíÿ âåòêè èëè äëÿ ìîäèôèêàöèè öåíû
// óñòàíîâëåííîãî îòëîæåííîãî îðäåðà)
double getNextOrderPriceByNumP(int n1, double p1){
//äëÿ ëîíãîâ öåíà ñëåäóþùåãî îðäåðà âûøå íà øàã ñ ó÷åòîì ôàêòîðà
if (n1==MNB1) return (p1+Ask-Bid);
if (n1==MNB2) return (p1+Ask-Bid);
if (n1==MNB3) return (p1+Ask-Bid);
if (n1==MNB4) return (p1+Ask-Bid);
if (n1==MNB5) return (p1+Ask-Bid);
if (n1==MNB6) return (p1+Ask-Bid);
if (n1==MNB7) return (p1+Ask-Bid);
if (n1==MNB8) return (p1+Ask-Bid);
if (n1==MNB11) return (p1+Ask-Bid);
if (n1==MNB21) return (p1+Ask-Bid);
if (n1==MNB31) return (p1+Ask-Bid);
if (n1==MNB41) return (p1+Ask-Bid);
if (n1==MNB51) return (p1+Ask-Bid);
if (n1==MNB61) return (p1+Ask-Bid);
if (n1==MNB71) return (p1+Ask-Bid);
if (n1==MNB81) return (p1+Ask-Bid);
//äëÿ øîðòîâ öåíà ñëåäóþùåãî îðäåðà âûøå íà øàã ñ ó÷åòîì ôàêòîðà
if (n1==MNS1) return (p1-Ask+Bid);
if (n1==MNS2) return (p1-Ask+Bid);
if (n1==MNS3) return (p1-Ask+Bid);
if (n1==MNS4) return (p1-Ask+Bid);
if (n1==MNS5) return (p1-Ask+Bid);
if (n1==MNS6) return (p1-Ask+Bid);
if (n1==MNS7) return (p1-Ask+Bid);
if (n1==MNS8) return (p1-Ask+Bid);
if (n1==MNS11) return (p1-Ask+Bid);
if (n1==MNS21) return (p1-Ask+Bid);
if (n1==MNS31) return (p1-Ask+Bid);
if (n1==MNS41) return (p1-Ask+Bid);
if (n1==MNS51) return (p1-Ask+Bid);
if (n1==MNS61) return (p1-Ask+Bid);
if (n1==MNS71) return (p1-Ask+Bid);
if (n1==MNS81) return (p1-Ask+Bid);
return (0);
}
///************************************************************************
//îïðåäåëåíèå ñëåäóþùåãî ìàãè÷åñêîãî íîìåðà ïî äàííîìó
int getNextOrderNum(int n1){
if (n1==MNB1) return (MNB2);
if (n1==MNB2) return (MNB3);
if (n1==MNB3) return (MNB4);
if (n1==MNB4) return (MNB5);
if (n1==MNB5) return (MNB6);
if (n1==MNB6) return (MNB7);
if (n1==MNB7) return (MNB8);
if (n1==MNB8) return (MNB9);
if (n1==MNB11) return (MNB21);
if (n1==MNB21) return (MNB31);
if (n1==MNB31) return (MNB41);
if (n1==MNB41) return (MNB51);
if (n1==MNB51) return (MNB61);
if (n1==MNB61) return (MNB71);
if (n1==MNB71) return (MNB81);
if (n1==MNB81) return (MNB91);
if (n1==MNS1) return (MNS2);
if (n1==MNS2) return (MNS3);
if (n1==MNS3) return (MNS4);
if (n1==MNS4) return (MNS5);
if (n1==MNS5) return (MNS6);
if (n1==MNS6) return (MNS7);
if (n1==MNS7) return (MNS8);
if (n1==MNS8) return (MNS9);
if (n1==MNS11) return (MNS21);
if (n1==MNS21) return (MNS31);
if (n1==MNS31) return (MNS41);
if (n1==MNS41) return (MNS51);
if (n1==MNS51) return (MNS61);
if (n1==MNS61) return (MNS71);
if (n1==MNS71) return (MNS81);
if (n1==MNS81) return (MNS91);
return (0);
}
///************************************************************************
//îïðåäåëåíèå ñëåäóþùåãî ìàãè÷åñêîãî íîìåðà ïî äàííîìó äëÿ îðäåðîâ ïî ïðèáûëüíîé ðóêå
int getNextOrderNumP(int n1){
if (n1==MNB1) return (MNB11);
if (n1==MNB2) return (MNB11);
if (n1==MNB3) return (MNB11);
if (n1==MNB4) return (MNB11);
if (n1==MNB5) return (MNB11);
if (n1==MNB6) return (MNB11);
if (n1==MNB7) return (MNB11);
if (n1==MNB8) return (MNB11);
if (n1==MNB11) return (MNB1);
if (n1==MNB21) return (MNB1);
if (n1==MNB31) return (MNB1);
if (n1==MNB41) return (MNB1);
if (n1==MNB51) return (MNB1);
if (n1==MNB61) return (MNB1);
if (n1==MNB71) return (MNB1);
if (n1==MNB81) return (MNB1);
if (n1==MNS1) return (MNS11);
if (n1==MNS2) return (MNS11);
if (n1==MNS3) return (MNS11);
if (n1==MNS4) return (MNS11);
if (n1==MNS5) return (MNS11);
if (n1==MNS6) return (MNS11);
if (n1==MNS7) return (MNS11);
if (n1==MNS8) return (MNS11);
if (n1==MNS11) return (MNS1);
if (n1==MNS21) return (MNS1);
if (n1==MNS31) return (MNS1);
if (n1==MNS41) return (MNS1);
if (n1==MNS51) return (MNS1);
if (n1==MNS61) return (MNS1);
if (n1==MNS71) return (MNS1);
if (n1==MNS81) return (MNS1);
return (0);
}
//****ôóíêöèÿ ìîäèôèêàöèè îòëîæåííîãî îðäåðà
//çäåñü ïîëó÷àåì âû÷èñëåííûå öåíû îòêðûòèÿ è òýéêïðîôèòà äëÿ îòëîæåííûõ îðäåðîâ
//è åñëè îíè îòëè÷àþòñÿ îò öåí ìîäèôèöèðóåìîãî îðäåðà, èçìåíÿåì èõ
int modOrder(int num, double oprice, double prprice){
int t, cnt1, tic, err;
double p1, p2;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==num && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if ((OrderOpenPrice()!=oprice || OrderTakeProfit()!=prprice) && oprice!=0 && prprice!=0) {
if (OrderType()==OP_BUYLIMIT){
p1=oprice;
p2=prprice;
//NormalizeDouble(p2,Digits);
if (NormalizeDouble(OrderOpenPrice(),Digits)!=NormalizeDouble(p1,Digits)
|| NormalizeDouble(OrderTakeProfit(),Digits)!=NormalizeDouble(p2,Digits)) {
//if (OrderOpenPrice()!=p1 || OrderTakeProfit()!=p2) {
tic=OrderModify(OrderTicket(),p1,0,p2,0,Green);
Print ("ìîäèô BUYLIMIT ", OrderOpenPrice(), "->", p1, " t/p ", OrderTakeProfit(),"->", p2);
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
}
if (OrderType()==OP_SELLLIMIT){
p1=oprice;
p2=prprice;
if (NormalizeDouble(OrderOpenPrice(),Digits)!=NormalizeDouble(p1,Digits)
|| NormalizeDouble(OrderTakeProfit(),Digits)!=NormalizeDouble(p2,Digits)) {
tic=OrderModify(OrderTicket(),p1,0,p2,0,Green);
Print ("ìîäèô SELLLIMIT ", OrderOpenPrice(), "->", p1, " t/p ", OrderTakeProfit(),"->", p2);
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
}
}
if (OrderType()==OP_BUY && NormalizeDouble(OrderTakeProfit(),Digits)==0
&& NormalizeDouble(oprice,Digits)!=0) {
tic=OrderModify(OrderTicket(),oprice,0,oprice+Step*Point,0,Green);
Print ("ìîäèöèêàöèÿ àêòèâíîãî îðäåðà, åñëè òýéêïðîôèò ðàâåí íóëþ");
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (OrderType()==OP_SELL && NormalizeDouble(OrderTakeProfit(),Digits)==0
&& NormalizeDouble(oprice,Digits)!=0) {
tic=OrderModify(OrderTicket(),oprice,0,oprice-Step*Point,0,Green);
Print ("ìîäèöèêàöèÿ àêòèâíîãî îðäåðà, åñëè òýéêïðîôèò ðàâåí íóëþ");
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
}
}
return (1);
}
//****ôóíêöèÿ ìîäèôèêàöèè îòëîæåííîãî îðäåðà ïî ïðèáûëüíîé ðóêå
//çäåñü ïîëó÷àåì âû÷èñëåííûå öåíû îòêðûòèÿ è òýéêïðîôèòà äëÿ îòëîæåííûõ îðäåðîâ
//è åñëè îíè îòëè÷àþòñÿ îò öåí ìîäèôèöèðóåìîãî îðäåðà, èçìåíÿåì èõ
int modOrderP (int num, double oprice, double prprice){
int t, cnt1, tic, err;
double p1, p2;
t=OrdersTotal();
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==num && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if ((OrderOpenPrice()!=oprice || OrderTakeProfit()!=prprice) && oprice!=0 && prprice!=0) {
if (OrderType()==OP_BUYSTOP){
p1=oprice;
p2=prprice;
//NormalizeDouble(p2,Digits);
if (NormalizeDouble(OrderOpenPrice(),Digits)!=NormalizeDouble(p1,Digits)
|| NormalizeDouble(OrderTakeProfit(),Digits)!=NormalizeDouble(p2,Digits)) {
//if (OrderOpenPrice()!=p1 || OrderTakeProfit()!=p2) {
tic=OrderModify(OrderTicket(),p1,0,p2,0,Green);
Print ("ìîäèô BUYSTOP ", OrderOpenPrice(), "->", p1, " t/p ", OrderTakeProfit(),"->", p2);
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
}
if (OrderType()==OP_SELLSTOP){
p1=oprice;
p2=prprice;
if (NormalizeDouble(OrderOpenPrice(),Digits)!=NormalizeDouble(p1,Digits)
|| NormalizeDouble(OrderTakeProfit(),Digits)!=NormalizeDouble(p2,Digits)) {
tic=OrderModify(OrderTicket(),p1,0,p2,0,Green);
Print ("ìîäèô SELLSTOP ", OrderOpenPrice(), "->", p1, " t/p ", OrderTakeProfit(),"->", p2);
Print ("Ðåçóëüòàò = ",tic);
if (tic!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
}
}
}
}
return (1);
}
//***************************************
//ïîäñ÷åò ïðîôèòà ïî ïîçèöèÿì â çàâèñèìîñòè îò ðåæèìà
//ïðè mode=1 òîëüêî äëÿ òåêóùåãî èíñòðóìåíòà,
//ïðè ëþáîì äðóãîì äëÿ âñåõ ïîçèöèé ñ÷åòà
double getAllProfit(int mode){
int t, cnt1;
double pf;
t=OrdersTotal();
pf=0;
for(cnt1=0;cnt1<t;cnt1++){
OrderSelect(cnt1, SELECT_BY_POS, MODE_TRADES);
if (mode==1){
if (OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax && OrderSymbol()==Symbol() && (OrderType()==OP_BUY || OrderType()==OP_SELL)){
pf=pf+OrderProfit();
}
} else {
if (OrderType()==OP_BUY || OrderType()==OP_SELL){
pf=pf+OrderProfit();
}
}
}
return (pf);
}
//*********************************************************************
//ôóíêöèÿ äëÿ ðàñ÷åòà öåíû áåçóáûòî÷íîñòè ïëå÷à ïî äàííîìó èíñòðóìåíòó
//âû÷èñëåíèå öåíû, ãäå ñåðèÿ ñòàíîâèòñÿ áåçóáûòî÷íîé
double getAverPrice (int mode, int level, double p6, double p5, double p4, double p3, double p2, double p1, double p61, double p51, double p41, double p31, double p21, double p11){
int t, cnt1;
double price;
t=OrdersTotal();
price=0;
if (OrderSymbol()==Symbol() && OrderMagicNumber()>MNMin && OrderMagicNumber()<MNMax){
if (mode==1){ //ðàñ÷åò äëÿ ëîíãîâ
if (level==1) price=p1;
if (level==2) price=(StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots);
if (level==3) price=(StMnLot3*startLots*p3+StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots+StMnLot3*startLots);
if (level==4) price=(StMnLot4*startLots*p4+StMnLot3*startLots*p3+StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots);
if (level==5) price=(StMnLot5*startLots*p5+StMnLot4*startLots*p4+StMnLot3*startLots*p3+StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots+StMnLot5*startLots);
if (level==6) price=(StMnLot5*startLots*p5+StMnLot4*startLots*p4+StMnLot3*startLots*p3+StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots+StMnLot5*startLots);
if (level==11) price=p11;
if (level==21) price=(StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots);
if (level==31) price=(StMnLot3*startLots*p31+StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots+StMnLot3*startLots);
if (level==41) price=(StMnLot4*startLots*p41+StMnLot3*startLots*p31+StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots);
if (level==51) price=(StMnLot5*startLots*p51+StMnLot4*startLots*p41+StMnLot3*startLots*p31+StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots+StMnLot5*startLots);
if (level==61) price=(StMnLot5*startLots*p51+StMnLot4*startLots*p41+StMnLot3*startLots*p31+StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots+StMnLot5*startLots);
}
if (mode==2){ //ðàñ÷åò äëÿ øîðòîâ
if (level==1) price=p1;
if (level==2) price=(StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots);
if (level==3) price=(StMnLot3*startLots*p3+StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots+StMnLot3*startLots);
if (level==4) price=(StMnLot4*startLots*p4+StMnLot3*startLots*p3+StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots);
if (level==5) price=(StMnLot5*startLots*p5+StMnLot4*startLots*p4+StMnLot3*startLots*p3+StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots+StMnLot5*startLots);
if (level==6) price=(StMnLot5*startLots*p5+StMnLot4*startLots*p4+StMnLot3*startLots*p3+StMnLot2*startLots*p2+p1)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots+StMnLot5*startLots);
if (level==11) price=p11;
if (level==21) price=(StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots);
if (level==31) price=(StMnLot3*startLots*p31+StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots+StMnLot3*startLots);
if (level==41) price=(StMnLot4*startLots*p41+StMnLot3*startLots*p31+StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots);
if (level==51) price=(StMnLot5*startLots*p51+StMnLot4*startLots*p41+StMnLot3*startLots*p31+StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots+StMnLot5*startLots);
if (level==61) price=(StMnLot5*startLots*p51+StMnLot4*startLots*p41+StMnLot3*startLots*p31+StMnLot2*startLots*p21+p11)/(startLots+StMnLot2*startLots+StMnLot3*startLots+StMnLot4*startLots+StMnLot5*startLots);
}
}
return (price);
}
//*********************************************************************
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double sig=0, curPrice, topLot, devPrice, newPrice, newPriceSel, newPriceBuy, newPriceSelP, newPriceBuyP;
double lastOpenPrice, curProfitPriceBuy, curProfitPriceSell, nullPrice, nullPrice2;
int cnt, ticket, total, pr, openPos, topLev, direct, topLevBuy, topLevSell, topLevBuyP, topLevSellP;
bool isPosition, isStartLot, SeriesEmpty;
int n1, np2, n2, err;
double p1, pp1, pp2, p1p, p2, prof, tpBuy, tpSell, tpBuyP, tpSellP;
string isComm;
//*********************************************
//Ðàçëè÷íûå íà÷àëüíûå ïðîâåðêè íà ìèíèìàëüíûå çíà÷åíèÿ ñóììû íà ñ÷åòå
//ïðîâåðêà äîñòàòî÷íîãî êîëè÷åñòâà ìàðæè íà ñ÷åòå
//if(!IsConnected()) PlaySound(NameFileSound); //ÿ äîáàâèë
//if(!IsConnected()) Print("Ñâÿçü îòñóòñòâóåò!"); //ÿ äîáàâèë
if(AccountFreeMargin()<(50))
{
Print("Ìàëî äåíåã íà ñ÷åòå. Free Margin = ", AccountFreeMargin());
return(0);
}
//ïðîâåðêà óðîâíÿ òåêóùèõ ñðåäñòâ íà ñ÷åòå
if(AccountEquity()<(6))
{
Print("Ýêâèòè óïàëà ñëèøêîì íèçêî = ", AccountEquity());
return(0);
}
// ïðîâåðêà ïàðàìåòðà Koleno
if(Koleno<2 || Koleno>9)
{
Print("Íåâåðíîå çíà÷åíèå ïàðàìåòðà øàãîâ! Äîëæíî áûòü ìåæäó 2 è 9 âêëþ÷èòåëüíî.");
return(0);
}
//************************************************************
// îïðåäåëèì ìàæèêíîìåðà äëÿ ðàçíûõ ðóê
MNMax= MNMin+85; //Ìàäæèêíîìåð ìàêñèìàëüíûé
MNB1 = MNMin+1; //Ìàäæèêíîìåð äëÿ áàé1
MNB2 = MNMin+11; //Ìàäæèêíîìåð äëÿ áàé2
MNB3 = MNMin+21; //Ìàäæèêíîìåð äëÿ áàé3
MNB4 = MNMin+31; //Ìàäæèêíîìåð äëÿ áàé4
MNB5 = MNMin+41; //Ìàäæèêíîìåð äëÿ áàé5
MNB6 = MNMin+51; //Ìàäæèêíîìåð äëÿ áàé6
MNB7 = MNMin+61; //Ìàäæèêíîìåð äëÿ áàé7
MNB8 = MNMin+71; //Ìàäæèêíîìåð äëÿ áàé8
MNB9 = MNMin+81; //Ìàäæèêíîìåð äëÿ áàé9
MNB11= MNMin+3; //Ìàäæèêíîìåð äëÿ áàé1
MNB21 = MNMin+13; //Ìàäæèêíîìåð äëÿ áàé2
MNB31 = MNMin+23; //Ìàäæèêíîìåð äëÿ áàé3
MNB41 = MNMin+33; //Ìàäæèêíîìåð äëÿ áàé4
MNB51 = MNMin+43; //Ìàäæèêíîìåð äëÿ áàé5
MNB61 = MNMin+53; //Ìàäæèêíîìåð äëÿ áàé6
MNB71 = MNMin+63; //Ìàäæèêíîìåð äëÿ áàé7
MNB81 = MNMin+73; //Ìàäæèêíîìåð äëÿ áàé8
MNB91 = MNMin+83; //Ìàäæèêíîìåð äëÿ áàé9
MNS1 = MNMin+2; //Ìàäæèêíîìåð äëÿ ñåëë1
MNS2 = MNMin+12; //Ìàäæèêíîìåð äëÿ ñåëë2
MNS3 = MNMin+22; //Ìàäæèêíîìåð äëÿ ñåëë3
MNS4 = MNMin+32; //Ìàäæèêíîìåð äëÿ ñåëë4
MNS5 = MNMin+42; //Ìàäæèêíîìåð äëÿ ñåëë5
MNS6 = MNMin+52; //Ìàäæèêíîìåð äëÿ ñåëë6
MNS7 = MNMin+62; //Ìàäæèêíîìåð äëÿ ñåëë7
MNS8 = MNMin+72; //Ìàäæèêíîìåð äëÿ ñåëë8
MNS9 = MNMin+82; //Ìàäæèêíîìåð äëÿ ñåëë9
MNS11= MNMin+4; //Ìàäæèêíîìåð äëÿ ñåëë1
MNS21 = MNMin+14; //Ìàäæèêíîìåð äëÿ ñåëë2
MNS31 = MNMin+24; //Ìàäæèêíîìåð äëÿ ñåëë3
MNS41 = MNMin+34; //Ìàäæèêíîìåð äëÿ ñåëë4
MNS51 = MNMin+44; //Ìàäæèêíîìåð äëÿ ñåëë5
MNS61 = MNMin+54; //Ìàäæèêíîìåð äëÿ ñåëë6
MNS71 = MNMin+64; //Ìàäæèêíîìåð äëÿ ñåëë7
MNS81 = MNMin+74; //Ìàäæèêíîìåð äëÿ ñåëë8
MNS91 = MNMin+84; //Ìàäæèêíîìåð äëÿ ñåëë9
topLot=0;
total=OrdersTotal();
//****************************************************************************
//ïðîâåðÿåì íàëè÷èå ëîêèðîâàííûõ ïîçèöèé
if ((Koleno==2 && isMgNum(MNB2)==True) || (Koleno==2 && isMgNum(MNS2)==True) || (Koleno==2 && isMgNum(MNS21)==True) || (Koleno==2 && isMgNum(MNB21)==True) ||
(Koleno==3 && isMgNum(MNB3)==True) || (Koleno==3 && isMgNum(MNS3)==True) || (Koleno==3 && isMgNum(MNS31)==True) || (Koleno==3 && isMgNum(MNB31)==True) ||
(Koleno==4 && isMgNum(MNB4)==True) || (Koleno==4 && isMgNum(MNS4)==True) || (Koleno==4 && isMgNum(MNS41)==True) || (Koleno==4 && isMgNum(MNB41)==True) ||
(Koleno==5 && isMgNum(MNB5)==True) || (Koleno==5 && isMgNum(MNS5)==True) || (Koleno==5 && isMgNum(MNS51)==True) || (Koleno==5 && isMgNum(MNB51)==True) ||
(Koleno==6 && isMgNum(MNB6)==True) || (Koleno==6 && isMgNum(MNS6)==True) || (Koleno==6 && isMgNum(MNS61)==True) || (Koleno==6 && isMgNum(MNB61)==True) ||
(Koleno==7 && isMgNum(MNB7)==True) || (Koleno==7 && isMgNum(MNS7)==True) || (Koleno==7 && isMgNum(MNS71)==True) || (Koleno==7 && isMgNum(MNB71)==True) ||
(Koleno==8 && isMgNum(MNB8)==True) || (Koleno==8 && isMgNum(MNS8)==True) || (Koleno==8 && isMgNum(MNS81)==True) || (Koleno==8 && isMgNum(MNB81)==True) ||
(Koleno==9 && isMgNum(MNB9)==True) || (Koleno==9 && isMgNum(MNS9)==True) || (Koleno==9 && isMgNum(MNS91)==True) || (Koleno==9 && isMgNum(MNB91)==True))
{
StopTrade=true;
}
//âûñòàâëåíèå ïåðâûõ îðäåðîâ ñåðèè, åñëè òàêèõ åùå íåò
if (StopTrade==false && isMgNum(MNB1)==False && isMgNum(MNB11)==False) {
isComm="Martin Begin Up, "+MNB1;
ticket=OrderSend(Symbol(),OP_BUY,getLotByLevel(1),Ask,3,0,Ask+Step*Point,isComm,MNB1,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Martin Begin Up");
Print("Îòêðûòèå ïåðâîé ïîçèöèè ñåðèè ëîíãîâ ââåðõ ",MNB1," ",Symbol()," ñòàðò= ", Ask," t/p=",Ask+Step*Point," ticket=",ticket);
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (StopTrade==false && isMgNum(MNS1)==False && isMgNum(MNS11)==False) {
isComm="Martin Begin Down, "+MNS1;
ticket=OrderSend(Symbol(),OP_SELL,getLotByLevel(1),Bid,3,0,Bid-Step*Point,isComm,MNS1,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Martin Begin Down");
Print("Îòêðûòèå ïåðâîé ïîçèöèè ñåðèè øîðòîâ ââåðõ ",MNS1," ",Symbol()," ñòàðò= ", Bid," t/p=",Bid-Step*Point," ticket=",ticket);
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
newPriceBuy=0;
newPriceSel=0;
//îïðåäåëåíèå ìàêñèìàëüíîãî óðîâíÿ îòêðûòûõ îðäåðîâ äëÿ ëîíãîâ
topLevBuy=getTopLevel(1);
if (IsRabComm == true){Print("topLevBuy ",topLevBuy);}
//è äëÿ øîðòîâ
topLevSell=getTopLevel(2);
if (IsRabComm == true){Print("topLevSell ",topLevSell);}
//ìàêñèìàëüíûé óðîâåíü äëÿ ïðèáûëüíîé ðóêè
//äëÿ ëîíãîâ
topLevBuyP=getTopLevelP(1);
if (IsRabComm == true){Print("topLevBuyP ",topLevBuyP);}
//äëÿ øîðòîâ
topLevSellP=getTopLevelP(2);
if (IsRabComm == true){Print("topLevSellP ",topLevSellP);}
//âû÷èñëåíèå öåíû îòêðûòèÿ íîâîãî îòëîæåííîãî îðäåðà
//ïîòîì ìîæåò áûòü ìîäèôèöèðîâàí ôóíêöèåé ìîäèôèêàöèè
if (topLevBuy>0) {
n1=getMaxLongNum();
p1=getOrderPriceByNum(n1);
newPriceBuy=getNextOrderPriceByNum(n1, p1);
tpBuy=p1; //çàïîìíèòü çíà÷åíèå äëÿ óñòàíîâêè òýéêïðîôèòà îòëîæåííîãî - öåíà îòêðûòèÿ ïðåäûäóùåãî îðäåðà èëè ïîçèöèè
if (IsRabComm == true){Print("tpBuy ",tpBuy);}
}
if (topLevBuyP>0) {
n1=getMaxLongNum();
if (IsRabComm == true){Print("getMaxLongNum ",n1);}
p1=getOrderProfitByNum(n1);
if (IsRabComm == true){Print("getOrderPriceByNum ",p1);}
newPriceBuyP=getNextOrderPriceByNumP(n1, p1);
if (IsRabComm == true){Print("newPriceBuyP ",newPriceBuyP);}
tpBuyP=newPriceBuyP+Step*Point; //çàïîìíèòü çíà÷åíèå äëÿ óñòàíîâêè òýéêïðîôèòà îòëîæåííîãî - öåíà îòêðûòèÿ ïðåäûäóùåãî îðäåðà èëè ïîçèöèè
if (IsRabComm == true){Print("tpBuyP ",tpBuyP);}
}
//âû÷èñëåíèå öåíû îòêðûòèÿ íîâîãî îòëîæåííîãî îðäåðà äëÿ øîðòîâ
//ïîòîì ìîæåò áûòü ìîäèôèöèðîâàí ôóíêöèåé ìîäèôèêàöèè
if (topLevSell>0) {
n1=getMaxShortNum();
if (IsRabComm == true){Print("getMaxShortNum ",n1);}
p1=getOrderPriceByNum(n1);
if (IsRabComm == true){Print("getOrderPriceByNum ",p1);}
newPriceSel=getNextOrderPriceByNum(n1, p1);
if (IsRabComm == true){Print("newPriceSel ",newPriceSel);}
tpSell=p1;
if (IsRabComm == true){Print("tpSell ",tpSell);}
}
if (topLevSellP>0) {
n1=getMaxShortNum();
if (IsRabComm == true){Print("getMaxShortNum ",n1);}
p1=getOrderProfitByNum(n1);
if (IsRabComm == true){Print("getOrderPriceByNum ",p1);}
newPriceSelP=getNextOrderPriceByNumP(n1, p1);
if (IsRabComm == true){Print("newPriceSelP ",newPriceSelP);}
tpSellP=newPriceSelP-Step*Point;
if (IsRabComm == true){Print("tpSellP ",tpSellP);}
}
//òóò îáÿçàòåëüíî ïðîâåðèòü, äîïóñòèìà ëè òàêàÿ öåíà ïî ðûíêó?
//åñëè öåíà ðûíêà íèæå äëÿ áàéëèìèò îðäåðà, òî íóæíî âçÿòü öåíó íà íåñêîëüêî ïèïñîâ íèæå (íà ñïðýä)
//òåêóùåé
if (newPriceBuy>Bid) newPriceBuy=Bid-Step*Point;
if (newPriceBuyP<Bid) newPriceBuyP=Bid+Step*Point;
//ýòî äëÿ ñåëëëèìèò îðäåðîâ
if (newPriceSel<Ask) newPriceSel=Ask+Step*Point;
if (newPriceSelP>Ask) newPriceSelP=Ask-Step*Point;
// óñòàíîâêà îòëîæåííûõ îðäåðîâ ïî ïðèáûëüíîé ðóêå
if (StopTrade==false && isOrderActive(MNB1)==True && isMgNum(MNB11)==false) {
isComm="Îòëîæåííûé Ëîíã, "+MNB11;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(1),newPriceBuyP,3,0,tpBuyP,isComm,MNB11,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Pending Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (StopTrade==false && isOrderActive(MNB11)==True && isMgNum(MNB1)==false) {
isComm="Îòëîæåííûé Ëîíã, "+MNB1;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(1),newPriceBuyP,3,0,tpBuyP,isComm,MNB1,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Pending Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (StopTrade==false && isOrderActive(MNS1)==True && isMgNum(MNS11)==false) {
isComm="Îòëîæåííûé Øîðò, "+MNS11;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(1),newPriceSelP,3,0,tpSellP,isComm,MNS11,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Pending Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (StopTrade==false && isOrderActive(MNS11)==True && isMgNum(MNS1)==false) {
isComm="Îòëîæåííûé Øîðò, "+MNS1;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(1),newPriceSelP,3,0,tpSellP,isComm,MNS1,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Pending Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//óñòàíîâêà îðäåðîâ ñòóïåíåé ïî óáûòî÷íîé ðóêå
//ñòóïåíü 2
if (topLevBuy==1 && Koleno>2 && isOrderActive(MNB1)==True && isMgNum(MNB2)==False) {
isComm="Âòîðàÿ Ëîíã, "+MNB2;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(2),newPriceBuy,3,0,tpBuy,isComm,MNB2,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==11 && Koleno>2 && isOrderActive(MNB11)==True && isMgNum(MNB21)==False) {
isComm="Âòîðàÿ Ëîíã, "+MNB21;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(2),newPriceBuy,3,0,tpBuy,isComm,MNB21,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==1 && Koleno>2 && isOrderActive(MNS1)==True && isMgNum(MNS2)==False) {
isComm="Âòîðàÿ Øîðò, "+MNS2;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(2),newPriceSel,3,0,tpSell,isComm,MNS2,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==11 && Koleno>2 && isOrderActive(MNS11)==True && isMgNum(MNS21)==False) {
isComm="Âòîðàÿ Øîðò, "+MNS21;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(2),newPriceSel,3,0,tpSell,isComm,MNS21,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==1 && Koleno==2 && isOrderActive(MNB1)==True && isMgNum(MNB2)==False) {
isComm="Âòîðàÿ Ëîíã ËÎÊ, "+MNB2;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(2),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB2,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Second Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==11 && Koleno==2 && isOrderActive(MNB11)==True && isMgNum(MNB21)==False) {
isComm="Âòîðàÿ Ëîíã ËÎÊ, "+MNB21;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(2),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB21,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Second Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==1 && Koleno==2 && isOrderActive(MNS1)==True && isMgNum(MNS2)==False) {
isComm="Âòîðàÿ Øîðò ËÎÊ, "+MNS2;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(2),newPriceSel+Ask-Bid,3,0,0,isComm,MNS2,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Second Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==11 && Koleno==2 && isOrderActive(MNS11)==True && isMgNum(MNS21)==False) {
isComm="Âòîðàÿ Øîðò ËÎÊ, "+MNS21;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(2),newPriceSel+Ask-Bid,3,0,0,isComm,MNS21,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Second Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//ñòóïåíü 3
if (topLevBuy==2 && Koleno>3 && isOrderActive(MNB2)==True && isMgNum(MNB3)==False) {
isComm="Òðåòüÿ Ëîíã, "+MNB3;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(3),newPriceBuy,3,0,tpBuy,isComm,MNB3,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Third Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==21 && Koleno>3 && isOrderActive(MNB21)==True && isMgNum(MNB31)==False) {
isComm="Òðåòüÿ Ëîíã, "+MNB31;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(3),newPriceBuy,3,0,tpBuy,isComm,MNB31,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Third Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==2 && Koleno>3 && isOrderActive(MNS2)==True && isMgNum(MNS3)==False) {
isComm="Òðåòüÿ Øîðò, "+MNS3;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(3),newPriceSel,3,0,tpSell,isComm,MNS3,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==21 && Koleno>3 && isOrderActive(MNS21)==True && isMgNum(MNS31)==False) {
isComm="Òðåòüÿ Øîðò, "+MNS31;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(3),newPriceSel,3,0,tpSell,isComm,MNS31,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Third Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==2 && Koleno==3 && isOrderActive(MNB2)==True && isMgNum(MNB3)==False) {
isComm="Òðåòüÿ Ëîíã ËÎÊ, "+MNB3;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(3),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB3,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Third Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==21 && Koleno==3 && isOrderActive(MNB21)==True && isMgNum(MNB31)==False) {
isComm="Òðåòüÿ Ëîíã ËÎÊ, "+MNB31;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(3),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB31,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Third Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==2 && Koleno==3 && isOrderActive(MNS2)==True && isMgNum(MNS3)==False) {
isComm="Òðåòüÿ Øîðò ËÎÊ, "+MNS3;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(3),newPriceSel+Ask-Bid,3,0,0,isComm,MNS3,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Third Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==21 && Koleno==3 && isOrderActive(MNS21)==True && isMgNum(MNS31)==False) {
isComm="Òðåòüÿ Øîðò ËÎÊ, "+MNS31;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(3),newPriceSel+Ask-Bid,3,0,0,isComm,MNS31,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Third Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//ñòóïåíü 4
if (topLevBuy==3 && Koleno>4 && isOrderActive(MNB3)==True && isMgNum(MNB4)==False) {
isComm="×åòâåðòàÿ Ëîíã, "+MNB4;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(4),newPriceBuy,3,0,tpBuy,isComm,MNB4,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Fourth Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==31 && Koleno>4 && isOrderActive(MNB31)==True && isMgNum(MNB41)==False) {
isComm="×åòâåðòàÿ Ëîíã, "+MNB41;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(4),newPriceBuy,3,0,tpBuy,isComm,MNB41,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Fourth Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==3 && Koleno>4 && isOrderActive(MNS3)==True && isMgNum(MNS4)==False) {
isComm="×åòâåðòàÿ Øîðò, "+MNS4;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(4),newPriceSel,3,0,tpSell,isComm,MNS4,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==31 && Koleno>4 && isOrderActive(MNS31)==True && isMgNum(MNS41)==False) {
isComm="×åòâåðòàÿ Øîðò, "+MNS41;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(4),newPriceSel,3,0,tpSell,isComm,MNS41,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Fourth Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==3 && Koleno==4 && isOrderActive(MNB3)==True && isMgNum(MNB4)==False) {
isComm="×åòâåðòàÿ Ëîíã ËÎÊ, "+MNB4;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(4),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB4,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Fourth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==31 && Koleno==4 && isOrderActive(MNB31)==True && isMgNum(MNB41)==False) {
isComm="×åòâåðòàÿ Ëîíã ËÎÊ, "+MNB41;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(4),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB41,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Fourth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==3 && Koleno==4 && isOrderActive(MNS3)==True && isMgNum(MNS4)==False) {
isComm="×åòâåðòàÿ Øîðò ËÎÊ, "+MNS4;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(4),newPriceSel+Ask-Bid,3,0,0,isComm,MNS4,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Fourth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==31 && Koleno==4 && isOrderActive(MNS31)==True && isMgNum(MNS41)==False) {
isComm="×åòâåðòàÿ Øîðò ËÎÊ, "+MNS41;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(4),newPriceSel+Ask-Bid,3,0,0,isComm,MNS41,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Fourth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//ñòóïåíü 5
if (topLevBuy==4 && Koleno>5 && isOrderActive(MNB4)==True && isMgNum(MNB5)==False) {
isComm="Ïÿòàÿ Ëîíã, "+MNB5;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(5),newPriceBuy,3,0,tpBuy,isComm,MNB5,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Fifth Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==41 && Koleno>5 && isOrderActive(MNB41)==True && isMgNum(MNB51)==False) {
isComm="Ïÿòàÿ Ëîíã, "+MNB51;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(5),newPriceBuy,3,0,tpBuy,isComm,MNB51,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Fifth Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==4 && Koleno>5 && isOrderActive(MNS4)==True && isMgNum(MNS5)==False) {
isComm="Ïÿòàÿ Øîðò, "+MNS5;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(5),newPriceSel,3,0,tpSell,isComm,MNS5,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==41 && Koleno>5 && isOrderActive(MNS41)==True && isMgNum(MNS51)==False) {
isComm="Ïÿòàÿ Øîðò, "+MNS51;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(5),newPriceSel,3,0,tpSell,isComm,MNS51,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Fifth Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==4 && Koleno==5 && isOrderActive(MNB4)==True && isMgNum(MNB5)==False) {
isComm="Ïÿòàÿ Ëîíã ËÎÊ, "+MNB5;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(5),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB5,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Fifth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==41 && Koleno==5 && isOrderActive(MNB41)==True && isMgNum(MNB51)==False) {
isComm="Ïÿòàÿ Ëîíã ËÎÊ, "+MNB51;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(5),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB51,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Fifth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==4 && Koleno==5 && isOrderActive(MNS4)==True && isMgNum(MNS5)==False) {
isComm="Ïÿòàÿ Øîðò ËÎÊ, "+MNS5;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(5),newPriceSel+Ask-Bid,3,0,0,isComm,MNS5,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Fifth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==41 && Koleno==5 && isOrderActive(MNS41)==True && isMgNum(MNS51)==False) {
isComm="Ïÿòàÿ Øîðò ËÎÊ, "+MNS51;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(5),newPriceSel+Ask-Bid,3,0,0,isComm,MNS51,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Fifth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//ñòóïåíü 6
if (topLevBuy==5 && Koleno>6 && isOrderActive(MNB5)==True && isMgNum(MNB6)==False) {
isComm="Øåñòàÿ Ëîíã, "+MNB6;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(6),newPriceBuy,3,0,tpBuy,isComm,MNB6,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Sixth Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==51 && Koleno>6 && isOrderActive(MNB51)==True && isMgNum(MNB61)==False) {
isComm="Øåñòàÿ Ëîíã, "+MNB61;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(6),newPriceBuy,3,0,tpBuy,isComm,MNB61,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Sixth Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==5 && Koleno>6 && isOrderActive(MNS5)==True && isMgNum(MNS6)==False) {
isComm="Øåñòàÿ Øîðò, "+MNS6;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(6),newPriceSel,3,0,tpSell,isComm,MNS6,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==51 && Koleno>6 && isOrderActive(MNS51)==True && isMgNum(MNS61)==False) {
isComm="Øåñòàÿ Øîðò, "+MNS61;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(6),newPriceSel,3,0,tpSell,isComm,MNS61,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Sixth Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==5 && Koleno==6 && isOrderActive(MNB5)==True && isMgNum(MNB6)==False) {
isComm="Øåñòàÿ Ëîíã ËÎÊ, "+MNB6;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(6),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB6,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Sixth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==51 && Koleno==6 && isOrderActive(MNB51)==True && isMgNum(MNB61)==False) {
isComm="Øåñòàÿ Ëîíã ËÎÊ, "+MNB61;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(6),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB61,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Sixth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==5 && Koleno==6 && isOrderActive(MNS5)==True && isMgNum(MNS6)==False) {
isComm="Øåñòàÿ Øîðò ËÎÊ, "+MNS6;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(6),newPriceSel+Ask-Bid,3,0,0,isComm,MNS6,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Sixth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==51 && Koleno==6 && isOrderActive(MNS51)==True && isMgNum(MNS61)==False) {
isComm="Øåñòàÿ Øîðò ËÎÊ, "+MNS61;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(6),newPriceSel+Ask-Bid,3,0,0,isComm,MNS61,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Sixth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//ñòóïåíü 7
if (topLevBuy==6 && Koleno>7 && isOrderActive(MNB6)==True && isMgNum(MNB7)==False) {
isComm="Ñåäüìàÿ Ëîíã, "+MNB7;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(7),newPriceBuy,3,0,tpBuy,isComm,MNB7,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Seventh Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==61 && Koleno>7 && isOrderActive(MNB61)==True && isMgNum(MNB71)==False) {
isComm="Ñåäüìàÿ Ëîíã, "+MNB71;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(7),newPriceBuy,3,0,tpBuy,isComm,MNB71,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Seventh Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==6 && Koleno>7 && isOrderActive(MNS6)==True && isMgNum(MNS7)==False) {
isComm="Ñåäüìàÿ Øîðò, "+MNS7;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(7),newPriceSel,3,0,tpSell,isComm,MNS7,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==61 && Koleno>7 && isOrderActive(MNS61)==True && isMgNum(MNS71)==False) {
isComm="Ñåäüìàÿ Øîðò, "+MNS71;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(7),newPriceSel,3,0,tpSell,isComm,MNS71,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Seventh Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==6 && Koleno==7 && isOrderActive(MNB6)==True && isMgNum(MNB7)==False) {
isComm="Ñåäüìàÿ Ëîíã ËÎÊ, "+MNB7;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(7),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB7,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Seventh Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==61 && Koleno==7 && isOrderActive(MNB61)==True && isMgNum(MNB71)==False) {
isComm="Ñåäüìàÿ Ëîíã ËÎÊ, "+MNB71;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(7),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB71,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Seventh Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==6 && Koleno==7 && isOrderActive(MNS6)==True && isMgNum(MNS7)==False) {
isComm="Ñåäüìàÿ Øîðò ËÎÊ, "+MNS7;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(7),newPriceSel+Ask-Bid,3,0,0,isComm,MNS7,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Seventh Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==61 && Koleno==7 && isOrderActive(MNS61)==True && isMgNum(MNS71)==False) {
isComm="Ñåäüìàÿ Øîðò ËÎÊ, "+MNS71;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(7),newPriceSel+Ask-Bid,3,0,0,isComm,MNS71,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Seventh Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//ñòóïåíü 8
if (topLevBuy==7 && Koleno>8 && isOrderActive(MNB7)==True && isMgNum(MNB8)==False) {
isComm="Âîñüìàÿ Ëîíã, "+MNB8;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(8),newPriceBuy,3,0,tpBuy,isComm,MNB8,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Eighth Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==71 && Koleno>8 && isOrderActive(MNB71)==True && isMgNum(MNB81)==False) {
isComm="Âîñüìàÿ Ëîíã, "+MNB81;
ticket=OrderSend(Symbol(),OP_BUYLIMIT,getLotByLevel(8),newPriceBuy,3,0,tpBuy,isComm,MNB81,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Eighth Long");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==7 && Koleno>8 && isOrderActive(MNS7)==True && isMgNum(MNS8)==False) {
isComm="Âîñüìàÿ Øîðò, "+MNS8;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(8),newPriceSel,3,0,tpSell,isComm,MNS8,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Second Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==71 && Koleno>8 && isOrderActive(MNS71)==True && isMgNum(MNS81)==False) {
isComm="Âîñüìàÿ Øîðò, "+MNS81;
ticket=OrderSend(Symbol(),OP_SELLLIMIT,getLotByLevel(8),newPriceSel,3,0,tpSell,isComm,MNS81,0,Gold);
if (UseSound) PlaySound(NameFileSoundExp);
// if (UseExtSound) SpeechText("Eighth Short");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==7 && Koleno==8 && isOrderActive(MNB7)==True && isMgNum(MNB8)==False) {
isComm="Âîñüìàÿ Ëîíã ËÎÊ, "+MNB8;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(8),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB8,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Eighth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==71 && Koleno==8 && isOrderActive(MNB71)==True && isMgNum(MNB81)==False) {
isComm="Âîñüìàÿ Ëîíã ËÎÊ, "+MNB81;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(8),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB81,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Eighth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==7 && Koleno==8 && isOrderActive(MNS7)==True && isMgNum(MNS8)==False) {
isComm="Âîñüìàÿ Øîðò ËÎÊ, "+MNS8;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(8),newPriceSel+Ask-Bid,3,0,0,isComm,MNS8,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Eighth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==71 && Koleno==8 && isOrderActive(MNS71)==True && isMgNum(MNS81)==False) {
isComm="Âîñüìàÿ Øîðò ËÎÊ, "+MNS81;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(8),newPriceSel+Ask-Bid,3,0,0,isComm,MNS81,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Eighth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//ñòóïåíü 9
if (topLevBuy==8 && Koleno==9 && isOrderActive(MNB8)==True && isMgNum(MNB9)==False) {
isComm="Äåâÿòàÿ Ëîíã ËÎÊ, "+MNB9;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(9),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB9,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Nineth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevBuy==81 && Koleno==9 && isOrderActive(MNB81)==True && isMgNum(MNB91)==False) {
isComm="Äåâÿòàÿ Ëîíã ËÎÊ, "+MNB91;
ticket=OrderSend(Symbol(),OP_SELLSTOP,getLotByLevel(9),newPriceBuy-Ask+Bid,3,0,0,isComm,MNB91,0,DarkTurquoise);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Nineth Long Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==8 && Koleno==9 && isOrderActive(MNS8)==True && isMgNum(MNS9)==False) {
isComm="Äåâÿòàÿ Øîðò ËÎÊ, "+MNS9;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(9),newPriceSel+Ask-Bid,3,0,0,isComm,MNS9,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Nineth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
if (topLevSell==81 && Koleno==9 && isOrderActive(MNS81)==True && isMgNum(MNS91)==False) {
isComm="Äåâÿòàÿ Øîðò ËÎÊ, "+MNS91;
ticket=OrderSend(Symbol(),OP_BUYSTOP,getLotByLevel(9),newPriceSel+Ask-Bid,3,0,0,isComm,MNS91,0,Gold);
if (UseSound) PlaySound(NameFileSoundExpL);
// if (UseExtSound) SpeechText("Nineth Short Lock");
if (ticket!=1) {err=GetLastError();
Print ("Îøèáêà = ", ErrorDescription(err));}
Sleep(timeOut);
}
//òåïåðü ìîæíî îïðåäåëèòü öåíó, íà êîòîðîé íóæíî çàêðûòü
//âñå ñäåëêè íà ïåðâîì æå îòêàòå è êîòîðàÿ ÿâëÿåòñÿ ÷óòü ëó÷øåé
//öåíîé îòêðûòèÿ ïðåäïîñëåäíåãî ïëå÷à
curProfitPriceBuy=0;
curProfitPriceSell=0;
//âû÷èñëåíèå íîâûõ öåí ïðîôèòîâ îòêðûòûõ îðäåðîâ äëÿ ëîíãîâ
if (Koleno==9)
{
if (isOrderActive(MNB9)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB9)==False && isOrderActive(MNB8)==True) curProfitPriceBuy=getOrderPriceByNum(MNB7);
if (isOrderActive(MNB9)==False && isOrderActive(MNB8)==False && isOrderActive(MNB7)==True) curProfitPriceBuy=getOrderPriceByNum(MNB6);
if (isOrderActive(MNB9)==False && isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==True) curProfitPriceBuy=getOrderPriceByNum(MNB5);
if (isOrderActive(MNB9)==False && isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==True) curProfitPriceBuy=getOrderPriceByNum(MNB4);
if (isOrderActive(MNB9)==False && isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==True) curProfitPriceBuy=getOrderPriceByNum(MNB3);
if (isOrderActive(MNB9)==False && isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==True) curProfitPriceBuy=getOrderPriceByNum(MNB2);
if (isOrderActive(MNB9)==False && isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==False && isOrderActive(MNB2)==True)
{
if (isOrderActive(MNB1)==True) curProfitPriceBuy=getOrderPriceByNum(MNB1);
}
if (isOrderActive(MNB91)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB91)==False && isOrderActive(MNB81)==True) curProfitPriceBuy=getOrderPriceByNum(MNB71);
if (isOrderActive(MNB91)==False && isOrderActive(MNB81)==False && isOrderActive(MNB71)==True) curProfitPriceBuy=getOrderPriceByNum(MNB61);
if (isOrderActive(MNB91)==False && isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==True) curProfitPriceBuy=getOrderPriceByNum(MNB51);
if (isOrderActive(MNB91)==False && isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==True) curProfitPriceBuy=getOrderPriceByNum(MNB41);
if (isOrderActive(MNB91)==False && isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==True) curProfitPriceBuy=getOrderPriceByNum(MNB31);
if (isOrderActive(MNB91)==False && isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==True) curProfitPriceBuy=getOrderPriceByNum(MNB21);
if (isOrderActive(MNB91)==False && isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==False && isOrderActive(MNB21)==True)
{
if (isOrderActive(MNB11)==True) curProfitPriceBuy=getOrderPriceByNum(MNB11);
}
}
if (Koleno==8)
{
if (isOrderActive(MNB8)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB8)==False && isOrderActive(MNB7)==True) curProfitPriceBuy=getOrderPriceByNum(MNB6);
if (isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==True) curProfitPriceBuy=getOrderPriceByNum(MNB5);
if (isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==True) curProfitPriceBuy=getOrderPriceByNum(MNB4);
if (isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==True) curProfitPriceBuy=getOrderPriceByNum(MNB3);
if (isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==True) curProfitPriceBuy=getOrderPriceByNum(MNB2);
if (isOrderActive(MNB8)==False && isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==False && isOrderActive(MNB2)==True)
{
if (isOrderActive(MNB1)==True) curProfitPriceBuy=getOrderPriceByNum(MNB1);
}
if (isOrderActive(MNB81)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB81)==False && isOrderActive(MNB71)==True) curProfitPriceBuy=getOrderPriceByNum(MNB61);
if (isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==True) curProfitPriceBuy=getOrderPriceByNum(MNB51);
if (isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==True) curProfitPriceBuy=getOrderPriceByNum(MNB41);
if (isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==True) curProfitPriceBuy=getOrderPriceByNum(MNB31);
if (isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==True) curProfitPriceBuy=getOrderPriceByNum(MNB21);
if (isOrderActive(MNB81)==False && isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==False && isOrderActive(MNB21)==True)
{
if (isOrderActive(MNB11)==True) curProfitPriceBuy=getOrderPriceByNum(MNB11);
}
}
if (Koleno==7)
{
if (isOrderActive(MNB7)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB7)==False && isOrderActive(MNB6)==True) curProfitPriceBuy=getOrderPriceByNum(MNB5);
if (isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==True) curProfitPriceBuy=getOrderPriceByNum(MNB4);
if (isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==True) curProfitPriceBuy=getOrderPriceByNum(MNB3);
if (isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==True) curProfitPriceBuy=getOrderPriceByNum(MNB2);
if (isOrderActive(MNB7)==False && isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==False && isOrderActive(MNB2)==True)
{
if (isOrderActive(MNB1)==True) curProfitPriceBuy=getOrderPriceByNum(MNB1);
}
if (isOrderActive(MNB71)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB71)==False && isOrderActive(MNB61)==True) curProfitPriceBuy=getOrderPriceByNum(MNB51);
if (isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==True) curProfitPriceBuy=getOrderPriceByNum(MNB41);
if (isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==True) curProfitPriceBuy=getOrderPriceByNum(MNB31);
if (isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==True) curProfitPriceBuy=getOrderPriceByNum(MNB21);
if (isOrderActive(MNB71)==False && isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==False && isOrderActive(MNB21)==True)
{
if (isOrderActive(MNB11)==True) curProfitPriceBuy=getOrderPriceByNum(MNB11);
}
}
if (Koleno==6)
{
if (isOrderActive(MNB6)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB6)==False && isOrderActive(MNB5)==True) curProfitPriceBuy=getOrderPriceByNum(MNB4);
if (isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==True) curProfitPriceBuy=getOrderPriceByNum(MNB3);
if (isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==True) curProfitPriceBuy=getOrderPriceByNum(MNB2);
if (isOrderActive(MNB6)==False && isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==False && isOrderActive(MNB2)==True)
{
if (isOrderActive(MNB1)==True) curProfitPriceBuy=getOrderPriceByNum(MNB1);
}
if (isOrderActive(MNB61)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB61)==False && isOrderActive(MNB51)==True) curProfitPriceBuy=getOrderPriceByNum(MNB41);
if (isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==True) curProfitPriceBuy=getOrderPriceByNum(MNB31);
if (isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==True) curProfitPriceBuy=getOrderPriceByNum(MNB21);
if (isOrderActive(MNB61)==False && isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==False && isOrderActive(MNB21)==True)
{
if (isOrderActive(MNB11)==True) curProfitPriceBuy=getOrderPriceByNum(MNB11);
}
}
if (Koleno==5)
{
if (isOrderActive(MNB5)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB5)==False && isOrderActive(MNB4)==True) curProfitPriceBuy=getOrderPriceByNum(MNB3);
if (isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==True) curProfitPriceBuy=getOrderPriceByNum(MNB2);
if (isOrderActive(MNB5)==False && isOrderActive(MNB4)==False && isOrderActive(MNB3)==False && isOrderActive(MNB2)==True)
{
if (isOrderActive(MNB1)==True) curProfitPriceBuy=getOrderPriceByNum(MNB1);
}
if (isOrderActive(MNB51)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB51)==False && isOrderActive(MNB41)==True) curProfitPriceBuy=getOrderPriceByNum(MNB31);
if (isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==True) curProfitPriceBuy=getOrderPriceByNum(MNB21);
if (isOrderActive(MNB51)==False && isOrderActive(MNB41)==False && isOrderActive(MNB31)==False && isOrderActive(MNB21)==True)
{
if (isOrderActive(MNB11)==True) curProfitPriceBuy=getOrderPriceByNum(MNB11);
}
}
if (Koleno==4)
{
if (isOrderActive(MNB4)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB4)==False && isOrderActive(MNB3)==True) curProfitPriceBuy=getOrderPriceByNum(MNB2);
if (isOrderActive(MNB4)==False && isOrderActive(MNB3)==False && isOrderActive(MNB2)==True)
{
if (isOrderActive(MNB1)==True) curProfitPriceBuy=getOrderPriceByNum(MNB1);
}
if (isOrderActive(MNB41)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB41)==False && isOrderActive(MNB31)==True) curProfitPriceBuy=getOrderPriceByNum(MNB21);
if (isOrderActive(MNB41)==False && isOrderActive(MNB31)==False && isOrderActive(MNB21)==True)
{
if (isOrderActive(MNB11)==True) curProfitPriceBuy=getOrderPriceByNum(MNB11);
}
}
if (Koleno==3)
{
if (isOrderActive(MNB3)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB3)==False && isOrderActive(MNB2)==True)
{
if (isOrderActive(MNB1)==True) curProfitPriceBuy=getOrderPriceByNum(MNB1);
}
if (isOrderActive(MNB31)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB31)==False && isOrderActive(MNB21)==True)
{
if (isOrderActive(MNB11)==True) curProfitPriceBuy=getOrderPriceByNum(MNB11);
}
}
if (Koleno==2)
{
if (isOrderActive(MNB2)==True) curProfitPriceBuy=Ask+1000*Point;
if (isOrderActive(MNB21)==True) curProfitPriceBuy=Ask+1000*Point;
}
//âû÷èñëåíèå öåí ïðîôèòîâ îòêðûòûõ îðäåðîâ äëÿ øîðòîâ
if (Koleno==9)
{
if (isOrderActive(MNS9)==True) curProfitPriceSell=Bid-500*Point;
if (isOrderActive(MNS9)==False && isOrderActive(MNS8)==True) curProfitPriceSell=getOrderPriceByNum(MNS7);
if (isOrderActive(MNS9)==False && isOrderActive(MNS8)==False && isOrderActive(MNS7)==True) curProfitPriceSell=getOrderPriceByNum(MNS6);
if (isOrderActive(MNS9)==False && isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==True) curProfitPriceSell=getOrderPriceByNum(MNS5);
if (isOrderActive(MNS9)==False && isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==True) curProfitPriceSell=getOrderPriceByNum(MNS4);
if (isOrderActive(MNS9)==False && isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==True) curProfitPriceSell=getOrderPriceByNum(MNS3);
if (isOrderActive(MNS9)==False && isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==True) curProfitPriceSell=getOrderPriceByNum(MNS2);
if (isOrderActive(MNS9)==False && isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==False && isOrderActive(MNS2)==True)
{
if (isOrderActive(MNS1)==True) curProfitPriceSell=getOrderPriceByNum(MNS1);
}
if (isOrderActive(MNS91)==True) curProfitPriceSell=Bid-500*Point;
if (isOrderActive(MNS91)==False && isOrderActive(MNS81)==True) curProfitPriceSell=getOrderPriceByNum(MNS71);
if (isOrderActive(MNS91)==False && isOrderActive(MNS81)==False && isOrderActive(MNS71)==True) curProfitPriceSell=getOrderPriceByNum(MNS61);
if (isOrderActive(MNS91)==False && isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==True) curProfitPriceSell=getOrderPriceByNum(MNS51);
if (isOrderActive(MNS91)==False && isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==True) curProfitPriceSell=getOrderPriceByNum(MNS41);
if (isOrderActive(MNS91)==False && isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==True) curProfitPriceSell=getOrderPriceByNum(MNS31);
if (isOrderActive(MNS91)==False && isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==True) curProfitPriceSell=getOrderPriceByNum(MNS21);
if (isOrderActive(MNS91)==False && isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==False && isOrderActive(MNS21)==True)
{
if (isOrderActive(MNS11)==True) curProfitPriceSell=getOrderPriceByNum(MNS11);
}
}
if (Koleno==8)
{
if (isOrderActive(MNS8)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS8)==False && isOrderActive(MNS7)==True) curProfitPriceSell=getOrderPriceByNum(MNS6);
if (isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==True) curProfitPriceSell=getOrderPriceByNum(MNS5);
if (isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==True) curProfitPriceSell=getOrderPriceByNum(MNS4);
if (isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==True) curProfitPriceSell=getOrderPriceByNum(MNS3);
if (isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==True) curProfitPriceSell=getOrderPriceByNum(MNS2);
if (isOrderActive(MNS8)==False && isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==False && isOrderActive(MNS2)==True)
{
if (isOrderActive(MNS1)==True) curProfitPriceSell=getOrderPriceByNum(MNS1);
}
if (isOrderActive(MNS81)==True) curProfitPriceSell=Bid+1000*Point;
if (isOrderActive(MNS81)==False && isOrderActive(MNS71)==True) curProfitPriceSell=getOrderPriceByNum(MNS61);
if (isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==True) curProfitPriceSell=getOrderPriceByNum(MNS51);
if (isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==True) curProfitPriceSell=getOrderPriceByNum(MNS41);
if (isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==True) curProfitPriceSell=getOrderPriceByNum(MNS31);
if (isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==True) curProfitPriceSell=getOrderPriceByNum(MNS21);
if (isOrderActive(MNS81)==False && isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==False && isOrderActive(MNS21)==True)
{
if (isOrderActive(MNS11)==True) curProfitPriceSell=getOrderPriceByNum(MNS11);
}
}
if (Koleno==7)
{
if (isOrderActive(MNS7)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS7)==False && isOrderActive(MNS6)==True) curProfitPriceSell=getOrderPriceByNum(MNS5);
if (isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==True) curProfitPriceSell=getOrderPriceByNum(MNS4);
if (isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==True) curProfitPriceSell=getOrderPriceByNum(MNS3);
if (isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==True) curProfitPriceSell=getOrderPriceByNum(MNS2);
if (isOrderActive(MNS7)==False && isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==False && isOrderActive(MNS2)==True)
{
if (isOrderActive(MNS1)==True) curProfitPriceSell=getOrderPriceByNum(MNS1);
}
if (isOrderActive(MNS71)==True) curProfitPriceSell=Bid+1000*Point;
if (isOrderActive(MNS71)==False && isOrderActive(MNS61)==True) curProfitPriceSell=getOrderPriceByNum(MNS51);
if (isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==True) curProfitPriceSell=getOrderPriceByNum(MNS41);
if (isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==True) curProfitPriceSell=getOrderPriceByNum(MNS31);
if (isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==True) curProfitPriceSell=getOrderPriceByNum(MNS21);
if (isOrderActive(MNS71)==False && isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==False && isOrderActive(MNS21)==True)
{
if (isOrderActive(MNS11)==True) curProfitPriceSell=getOrderPriceByNum(MNS11);
}
}
if (Koleno==6)
{
if (isOrderActive(MNS6)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS6)==False && isOrderActive(MNS5)==True) curProfitPriceSell=getOrderPriceByNum(MNS4);
if (isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==True) curProfitPriceSell=getOrderPriceByNum(MNS3);
if (isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==True) curProfitPriceSell=getOrderPriceByNum(MNS2);
if (isOrderActive(MNS6)==False && isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==False && isOrderActive(MNS2)==True)
{
if (isOrderActive(MNS1)==True) curProfitPriceSell=getOrderPriceByNum(MNS1);
}
if (isOrderActive(MNS61)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS61)==False && isOrderActive(MNS51)==True) curProfitPriceSell=getOrderPriceByNum(MNS41);
if (isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==True) curProfitPriceSell=getOrderPriceByNum(MNS31);
if (isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==True) curProfitPriceSell=getOrderPriceByNum(MNS21);
if (isOrderActive(MNS61)==False && isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==False && isOrderActive(MNS21)==True)
{
if (isOrderActive(MNS11)==True) curProfitPriceSell=getOrderPriceByNum(MNS11);
}
}
if (Koleno==5)
{
if (isOrderActive(MNS5)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS5)==False && isOrderActive(MNS4)==True) curProfitPriceSell=getOrderPriceByNum(MNS3);
if (isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==True) curProfitPriceSell=getOrderPriceByNum(MNS2);
if (isOrderActive(MNS5)==False && isOrderActive(MNS4)==False && isOrderActive(MNS3)==False && isOrderActive(MNS2)==True)
{
if (isOrderActive(MNS1)==True) curProfitPriceSell=getOrderPriceByNum(MNS1);
}
if (isOrderActive(MNS51)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS51)==False && isOrderActive(MNS41)==True) curProfitPriceSell=getOrderPriceByNum(MNS31);
if (isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==True) curProfitPriceSell=getOrderPriceByNum(MNS21);
if (isOrderActive(MNS51)==False && isOrderActive(MNS41)==False && isOrderActive(MNS31)==False && isOrderActive(MNS21)==True)
{
if (isOrderActive(MNS11)==True) curProfitPriceSell=getOrderPriceByNum(MNS11);
}
}
if (Koleno==4)
{
if (isOrderActive(MNS4)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS4)==False && isOrderActive(MNS3)==True) curProfitPriceSell=getOrderPriceByNum(MNS2);
if (isOrderActive(MNS4)==False && isOrderActive(MNS3)==False && isOrderActive(MNS2)==True)
{
if (isOrderActive(MNS1)==True) curProfitPriceSell=getOrderPriceByNum(MNS1);
}
if (isOrderActive(MNS41)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS41)==False && isOrderActive(MNS31)==True) curProfitPriceSell=getOrderPriceByNum(MNS21);
if (isOrderActive(MNS41)==False && isOrderActive(MNS31)==False && isOrderActive(MNS21)==True)
{
if (isOrderActive(MNS11)==True) curProfitPriceSell=getOrderPriceByNum(MNS11);
}
}
if (Koleno==3)
{
if (isOrderActive(MNS3)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS3)==False && isOrderActive(MNS2)==True)
{
if (isOrderActive(MNS1)==True) curProfitPriceSell=getOrderPriceByNum(MNS1);
}
if (isOrderActive(MNS31)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS31)==False && isOrderActive(MNS21)==True)
{
if (isOrderActive(MNS11)==True) curProfitPriceSell=getOrderPriceByNum(MNS11);
}
}
if (Koleno==2)
{
if (isOrderActive(MNS2)==True) curProfitPriceSell=Bid-1000*Point;
if (isOrderActive(MNS21)==True) curProfitPriceSell=Bid-1000*Point;
}
//ïåðåóñòàíîâêà ïðîôèòîâ äëÿ ëîíãîâ
//ïåðåäâèãàíèå íà öåíó ïðåäïîñëåäíåé ñòóïåíè +1 ïèïñ
if (Koleno==9)
{
if (isOrderActive(MNB9)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB9)==true) setNewTakeProfit2(1, 0);
if (isOrderActive(MNB91)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB91)==true) setNewTakeProfit2(1, 0);
}
if (Koleno==8)
{
if (isOrderActive(MNB8)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB8)==true) setNewTakeProfit2(1, 0);
if (isOrderActive(MNB81)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB81)==true) setNewTakeProfit2(1, 0);
}
if (Koleno==7)
{
if (isOrderActive(MNB7)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB7)==true) setNewTakeProfit2(1, 0);
if (isOrderActive(MNB71)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB71)==true) setNewTakeProfit2(1, 0);
}
if (Koleno==6)
{
if (isOrderActive(MNB6)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB6)==true) setNewTakeProfit2(1, 0);
if (isOrderActive(MNB61)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB61)==true) setNewTakeProfit2(1, 0);
}
if (Koleno==5)
{
if (isOrderActive(MNB5)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB5)==true) setNewTakeProfit2(1, 0);
if (isOrderActive(MNB51)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB51)==true) setNewTakeProfit2(1, 0);
}
if (Koleno==4)
{
if (isOrderActive(MNB4)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB4)==true) setNewTakeProfit2(1, 0);
if (isOrderActive(MNB41)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB41)==true) setNewTakeProfit2(1, 0);
}
if (Koleno==3)
{
if (isOrderActive(MNB3)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB3)==true) setNewTakeProfit2(1, 0);
if (isOrderActive(MNB31)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB31)==true) setNewTakeProfit2(1, 0);
}
if (Koleno==2)
{
if (isOrderActive(MNB2)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB2)==true) setNewTakeProfit2(1, 0);
if (isOrderActive(MNB21)==false) setNewTakeProfit2(1, curProfitPriceBuy);
if (isOrderActive(MNB21)==true) setNewTakeProfit2(1, 0);
}
//ïåðåóñòàíîâêà ïðîôèòîâ äëÿ øîðòîâ
//ïåðåäâèãàíèå íà öåíó ïðåäïîñëåäíåé ñòóïåíè -1 ïèïñ
if (Koleno==9)
{
if (isOrderActive(MNS9)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS9)==true) setNewTakeProfit2(2, 0);
if (isOrderActive(MNS91)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS91)==true) setNewTakeProfit2(2, 0);
}
if (Koleno==8)
{
if (isOrderActive(MNS8)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS8)==true) setNewTakeProfit2(2, 0);
if (isOrderActive(MNS81)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS81)==true) setNewTakeProfit2(2, 0);
}
if (Koleno==7)
{
if (isOrderActive(MNS7)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS7)==true) setNewTakeProfit2(2, 0);
if (isOrderActive(MNS71)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS71)==true) setNewTakeProfit2(2, 0);
}
if (Koleno==6)
{
if (isOrderActive(MNS6)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS6)==true) setNewTakeProfit2(2, 0);
if (isOrderActive(MNS61)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS61)==true) setNewTakeProfit2(2, 0);
}
if (Koleno==5)
{
if (isOrderActive(MNS5)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS5)==true) setNewTakeProfit2(2, 0);
if (isOrderActive(MNS51)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS51)==true) setNewTakeProfit2(2, 0);
}
if (Koleno==4)
{
if (isOrderActive(MNS4)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS4)==true) setNewTakeProfit2(2, 0);
if (isOrderActive(MNS41)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS41)==true) setNewTakeProfit2(2, 0);
}
if (Koleno==3)
{
if (isOrderActive(MNS3)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS3)==true) setNewTakeProfit2(2, 0);
if (isOrderActive(MNS31)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS31)==true) setNewTakeProfit2(2, 0);
}
if (Koleno==2)
{
if (isOrderActive(MNS2)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS2)==true) setNewTakeProfit2(2, 0);
if (isOrderActive(MNS21)==false) setNewTakeProfit2(2, curProfitPriceSell);
if (isOrderActive(MNS21)==true) setNewTakeProfit2(2, 0);
}
//**************************************
//****************************
//óäàëåíèå âñåõ ëèøíèõ îðäåðîâ â ñëó÷àå, åñëè ñåðèÿ
//çàêðûëàñü ïðîôèòîì, ò.å. åñëè íåò îòêðûòûõ îðäåðîâ ïåðâîé ñòóïåíè
//óäàëåíèå ëèøíèõ ëîíãîâ, åñëè íåò îðäåðà ïåðâîé ñòóïåíè
if (isOrderActive(MNB1)==false)
{
deleteOrderNum(MNB11);
deleteOrderNum(MNB2);
deleteOrderNum(MNB3);
deleteOrderNum(MNB4);
deleteOrderNum(MNB5);
deleteOrderNum(MNB6);
deleteOrderNum(MNB7);
deleteOrderNum(MNB8);
deleteOrderNum(MNB9);
}
if (isOrderActive(MNB11)==false)
{
deleteOrderNum(MNB1);
deleteOrderNum(MNB21);
deleteOrderNum(MNB31);
deleteOrderNum(MNB41);
deleteOrderNum(MNB51);
deleteOrderNum(MNB61);
deleteOrderNum(MNB71);
deleteOrderNum(MNB81);
deleteOrderNum(MNB91);
}
//äëÿ øîðòîâ
if (isOrderActive(MNS1)==false)
{
deleteOrderNum(MNS11);
deleteOrderNum(MNS2);
deleteOrderNum(MNS3);
deleteOrderNum(MNS4);
deleteOrderNum(MNS5);
deleteOrderNum(MNS6);
deleteOrderNum(MNS7);
deleteOrderNum(MNS8);
deleteOrderNum(MNS9);
}
if (isOrderActive(MNS11)==false)
{
deleteOrderNum(MNS1);
deleteOrderNum(MNS21);
deleteOrderNum(MNS31);
deleteOrderNum(MNS41);
deleteOrderNum(MNS51);
deleteOrderNum(MNS61);
deleteOrderNum(MNS71);
deleteOrderNum(MNS81);
deleteOrderNum(MNS91);
}
//****Ýòî áëîê ïðîâåðêè ïðàâèëüíîñòè öåí îòëîæåííûõ îðäåðîâ è èõ êîððåêöèÿ,
// åñëè ýòî íåîáõîäèìî
//Ñíà÷àëà ïðîâåðÿåì âåòêó äëÿ ëîíãîâ
//íóæíî âûÿñíèòü, êàêàÿ àêòèâíàÿ ïîçèöèÿ (îòêðûòàÿ) ìàêñèìàëüíà
n1=getMaxLongNum();
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ ââåðõ getMaxLongNum ",n1);}
//òåïåðü ïîëó÷èòü öåíó îòêðûòèÿ ýòîé ïîçèöèè
p1=getOrderPriceByNum(n1);
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ ââåðõ getOrderPriceByNum(n1) ",p1);}
p1p=getOrderProfitByNum(n1);
//òåïåðü íàäî ðàñ÷èòàòü öåíó îòêðûòèÿ îòëîæåííîãî îðäåðà, ïîñêîëüêó ïðàâèëà
//ìîãóò áûòü ðàçíûìè
p2=getNextOrderPriceByNum(n1, p1);
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ ââåðõ getNextOrderPriceByNum(n1, p1)= p2 ",p2);}
pp2=getNextOrderPriceByNumP(n1, p1p); // ýòî äëÿ ïðèáûëüíîé ðóêè
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ ââåðõ getNextOrderPriceByNumP(n1, p1) (äëÿ ïðèá ðóêè) ",pp2);}
//óçíàòü, êàêîé áóäåò ñëåäóþùèé íîìåð îðäåðà
n2=getNextOrderNum(n1);
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ ââåðõ getNextOrderNum(n1) n2 ",n2);}
np2=getNextOrderNumP(n1); // ýòî äëÿ ïðèáûëüíîé ðóêè
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ ââåðõ getNextOrderNumP(n1) np2 ",np2);}
// p1 - ýòî áóäåò öåíà ïðîôèòà äëÿ ñëåäóþùåé ïîçèöèè
//if () p1=Bid-3*(Ask-Bid);
//íàêîíåö ìîäèôèöèðóåì îðäåð
p1=p1;
p2=p2;
pp2=pp2;
pp1=pp2+Step*Point;
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ ââåðõ ÒÏ pp2 ",pp2);}
//èäåì íà ôóíêöèþ ìîäèôèêàöèè öåí îòëîæåííûõ îðäåðîâ
if (isMgNum(n2)==True && p2<(Bid-(Ask-Bid)-3*Point)) {
modOrder(n2, p2, p1);
}
if (isMgNum(np2)==True && pp2>(Bid-(Ask-Bid)-3*Point)) {
modOrderP(np2, pp2, pp1);
}
//**** Çäåñü óäàëèì ëèøíèå îòëîæåííûå îðäåðà äëÿ ëîíãîâ
// äëÿ ýòîãî íàì äîñòàòî÷íî çíàòü íîìåð ìàêñèìàëüíîé îòêðûòîé ïîçû
// ïðîïóñòèòü ñëåäóþùèé ïî óðîâíþ ëèìèòíûé îðäåð è óäàëèòü âñå îñòàëüíûå
if (n1==MNB1){
deleteOrderNum(MNB3);
deleteOrderNum(MNB4);
deleteOrderNum(MNB5);
deleteOrderNum(MNB6);
deleteOrderNum(MNB7);
deleteOrderNum(MNB8);
deleteOrderNum(MNB9);
}
if (n1==MNB2){
deleteOrderNum(MNB4);
deleteOrderNum(MNB5);
deleteOrderNum(MNB6);
deleteOrderNum(MNB7);
deleteOrderNum(MNB8);
deleteOrderNum(MNB9);
}
if (n1==MNB3){
deleteOrderNum(MNB5);
deleteOrderNum(MNB6);
deleteOrderNum(MNB7);
deleteOrderNum(MNB8);
deleteOrderNum(MNB9);
}
if (n1==MNB4){
deleteOrderNum(MNB6);
deleteOrderNum(MNB7);
deleteOrderNum(MNB8);
deleteOrderNum(MNB9);
}
if (n1==MNB5){
deleteOrderNum(MNB7);
deleteOrderNum(MNB8);
deleteOrderNum(MNB9);
}
if (n1==MNB6){
deleteOrderNum(MNB8);
deleteOrderNum(MNB9);
}
if (n1==MNB7){
deleteOrderNum(MNB9);
}
if (n1==MNB11){
deleteOrderNum(MNB31);
deleteOrderNum(MNB41);
deleteOrderNum(MNB51);
deleteOrderNum(MNB61);
deleteOrderNum(MNB71);
deleteOrderNum(MNB81);
deleteOrderNum(MNB91);
}
if (n1==MNB21){
deleteOrderNum(MNB41);
deleteOrderNum(MNB51);
deleteOrderNum(MNB61);
deleteOrderNum(MNB71);
deleteOrderNum(MNB81);
deleteOrderNum(MNB91);
}
if (n1==MNB31){
deleteOrderNum(MNB51);
deleteOrderNum(MNB61);
deleteOrderNum(MNB71);
deleteOrderNum(MNB81);
deleteOrderNum(MNB91);
}
if (n1==MNB41){
deleteOrderNum(MNB61);
deleteOrderNum(MNB71);
deleteOrderNum(MNB81);
deleteOrderNum(MNB91);
}
if (n1==MNB51){
deleteOrderNum(MNB71);
deleteOrderNum(MNB81);
deleteOrderNum(MNB91);
}
if (n1==MNB61){
deleteOrderNum(MNB81);
deleteOrderNum(MNB91);
}
if (n1==MNB71){
deleteOrderNum(MNB91);
}
//***âñå òî æå ñàìîå äåëàåì äëÿ øîðòîâ
n1=getMaxShortNum();
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ getMaxShortNum ",n1);}
p1=getOrderPriceByNum(n1);
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ âíèç getOrderPriceByNum(n1) ",p1);}
p1p=getOrderPriceByNum(n1);
p2=getNextOrderPriceByNum(n1, p1);
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ âíèç getNextOrderPriceByNum(n1, p1)= p2 ",p2);}
pp2=getNextOrderPriceByNumP(n1, p1p);
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ âíèç getNextOrderPriceByNumP(n1, p1) (äëÿ ïðèá ðóêè) ",pp2);}
n2=getNextOrderNum(n1);
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ âíèç getNextOrderNum(n1) n2 ",n2);}
np2=getNextOrderNumP(n1);
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ âíèç getNextOrderNumP(n1) np2 ",np2);}
p1=p1;
p2=p2;
pp2=pp2;
pp1=pp2+Step*Point;
if (IsRabComm == true){Print("Ïðîâåðêà îòë îðäåðîâ âíèç ÒÏ pp2 ",pp2);}
if (isMgNum(n2)==True && p2>(Ask+(Ask-Bid)+3*Point)) {
modOrder(n2, p2, p1);
}
if (isMgNum(np2)==True && np2<(Ask+(Ask-Bid)+3*Point)) {
modOrder(np2, pp2, pp1);
}
//***äëÿ øîðòîâ óäàëåíèå ëèøíèõ
if (n1==MNS1) //åñëè ìàêñèìàëüíûé îòêðûòûé ïåðâîé ñòóïåíè, òî óäàëÿåì
{ //âñå îðäåðà âûøå âòîðîé
deleteOrderNum(MNS3);
deleteOrderNum(MNS4);
deleteOrderNum(MNS5);
deleteOrderNum(MNS6);
deleteOrderNum(MNS7);
deleteOrderNum(MNS8);
deleteOrderNum(MNS9);
}
if (n1==MNS2) //óäàëÿåì âñå âûøå òðåòüåé
{
deleteOrderNum(MNS4);
deleteOrderNum(MNS5);
deleteOrderNum(MNS6);
deleteOrderNum(MNS7);
deleteOrderNum(MNS8);
deleteOrderNum(MNS9);
}
if (n1==MNS3) //óäàëÿåì âñå âûøå ÷åòâåðòîé
{
deleteOrderNum(MNS5);
deleteOrderNum(MNS6);
deleteOrderNum(MNS7);
deleteOrderNum(MNS8);
deleteOrderNum(MNS9);
}
if (n1==MNS4) //óäàëÿåì âñå âûøå ïÿòîé
{
deleteOrderNum(MNS6);
deleteOrderNum(MNS7);
deleteOrderNum(MNS8);
deleteOrderNum(MNS9);
}
if (n1==MNS5) //óäàëÿåì âñå âûøå ïÿòîé
{
deleteOrderNum(MNS7);
deleteOrderNum(MNS8);
deleteOrderNum(MNS9);
}
if (n1==MNS6) //óäàëÿåì âñå âûøå ïÿòîé
{
deleteOrderNum(MNS8);
deleteOrderNum(MNS9);
}
if (n1==MNS7) //óäàëÿåì âñå âûøå ïÿòîé
{
deleteOrderNum(MNS9);
}
if (n1==MNS11) //åñëè ìàêñèìàëüíûé îòêðûòûé ïåðâîé ñòóïåíè, òî óäàëÿåì
{ //âñå îðäåðà âûøå âòîðîé
deleteOrderNum(MNS31);
deleteOrderNum(MNS41);
deleteOrderNum(MNS51);
deleteOrderNum(MNS61);
deleteOrderNum(MNS71);
deleteOrderNum(MNS81);
deleteOrderNum(MNS91);
}
if (n1==MNS21) //óäàëÿåì âñå âûøå òðåòüåé
{
deleteOrderNum(MNS41);
deleteOrderNum(MNS51);
deleteOrderNum(MNS61);
deleteOrderNum(MNS71);
deleteOrderNum(MNS81);
deleteOrderNum(MNS91);
}
if (n1==MNS31) //óäàëÿåì âñå âûøå ÷åòâåðòîé
{
deleteOrderNum(MNS51);
deleteOrderNum(MNS61);
deleteOrderNum(MNS71);
deleteOrderNum(MNS81);
deleteOrderNum(MNS91);
}
if (n1==MNS41) //óäàëÿåì âñå âûøå ïÿòîé
{
deleteOrderNum(MNS61);
deleteOrderNum(MNS71);
deleteOrderNum(MNS81);
deleteOrderNum(MNS91);
}
if (n1==MNS51) //óäàëÿåì âñå âûøå ïÿòîé
{
deleteOrderNum(MNS71);
deleteOrderNum(MNS81);
deleteOrderNum(MNS91);
}
if (n1==MNS61) //óäàëÿåì âñå âûøå ïÿòîé
{
deleteOrderNum(MNS81);
deleteOrderNum(MNS91);
}
if (n1==MNS71) //óäàëÿåì âñå âûøå ïÿòîé
{
deleteOrderNum(MNS91);
}
//*************** Ðàñïå÷àñòêà ðàçëè÷íîé èíôîðìàöèè íà ýêðàíå
tl=getTopLots(); //íàøëè ìàêñèìàëüíûé ëîò ñðåäè îòêðûòûõ
Comment("Version 2.7a", "\n",
"Ïðîôèò ïî ïàðå (áåç ñâîïîâ) = ", getAllProfit(1), " - ", MathFloor(getAllProfit(1)/getAllProfit(0)*100)," %", "\n",
"Îáùèé ïðîôèò (áåç ñâîïîâ) = ", getAllProfit(0), "\n",
" Ìàêñèìàëüíûé ëîò =", tl, "\n",
" Óðîâåíü ëîíãîâ = ",topLevBuy, "\n", //ìàêñèìàëüíûé óðîâåíü ëîíãîâ
" Óðîâåíü øîðòîâ = ", topLevSell, "\n", //ìàêñèìàëüíûé óðîâåíü øîðòîâ
" ×èñëî ëîòîâ: øîðò = ", getSellLotsSum(1), " ëîíã = ", getBuyLotsSum(1));
return(0);
}
//*******************************************
// the end.
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---