LIP/Arch/RU/LIP_v01.005/Include/LCL_Man_5_v1.005.mqh

457 lines
55 KiB
MQL5
Raw Permalink Normal View History

2025-05-30 15:03:51 +02:00
<EFBFBD><EFBFBD>//============================================================================================= MQL5 ===
// LibreCLOP Main_5 v1.005 MQL5
// >4C;L >1@01>B:8 A>1KB89
// LibreCoin (c)2014-2017
//======================================================================================================
#property strict
//============================================================================================= MQL5 ===
// INCLUDE - ?>4:;NG05<K5 <>4C;8
//------------------------------------------------------------------------------------------------------
//----- 1@0B=K5 AAK;:8 =0 >A=>2=>9 D09; ?@>5:B0
#include "LCL_Ref_5_v1.005.mqh"
//============================================================================================= MQL5 ===
// EVENT PROCESSING MODULE
//------------------------------------------------------------------------------------------------------
//
//============================================================================================= MQL5 ===
// On_Init() - 8=8F80;870F8O A>25B=8:0
//------------------------------------------------------------------------------------------------------
ENUM_INIT_RETCODE On_Init(){
//----- !G5BG8:8 8 =0AB@>9:8 AG5BG8:>2
gTick=0;
//gInTimer=false;
//----- ?@545;O5< =5>1E>48<>ABL 8A?>;L7>20=8O 3@0D8:8
GraphUse=( false //"CB =04> ?@>25@8BL :0:>9 @568< A :0:8< A>2<5AB8<
|| ((!MQLInfoInteger(MQL_TESTER))&&(!MQLInfoInteger(MQL_OPTIMIZATION))) //5 B5AB8@>20=85 8 =5 >?B8<870F8O
|| (MQLInfoInteger(MQL_VISUAL_MODE)) //8;8 287C0;L=K9 @568<
);
//----- ?@545;O5< 8<O ?@>3@0<<K
ProgramName=MQLInfoString(MQL_PROGRAM_NAME);
//----- ;>10;L=K5 ?0@0<5B@K
TheSymbol=Symbol();
//----- K1>@ 8=48:0B>@>2 4;O A83=0;>2 >B:@KB8O
int LastError=0;
//----- 0?CA: LibreInfoPDO
{if(GraphUse)
//{if((!GraphUse)&&((OpenMethod==Open_ADXW)||(CloseProfitMethod==CloseProfit_ADXW)||(CloseLossMethod==CloseLoss_ADXW)))
{
ResetLastError();
lip_handle=iCustom( TheSymbol,
PERIOD_CURRENT,
"Projects\\Indicatores\\LIP\\Main\\LIP_v01.005\\LibreInfoPDO v1.005.ex5",
//----- Input parameters
aInpPeriodADXW, //Period
aInpMethodADXW, //Method (MODE_SMA,MODE_EMA,MODE_SMMA,MODE_LWMA)
aSSCBaseMode, //>@@ (0..3)-(off/spread/close/midHLC)
aInpFastPeriodEMA, //Fast EMA period
aInpSlowPeriodEMA, //Slow EMA period
aDICalcMode, //DICalcMode(0..8)-(hi/low/mahl/mihl/suhl/isuhl/imahl/imihl)
//----- 0@0<5B@K A1@>A0 B5=45=F88
adDI, //;O +-DI 2 4>;OE >B (<0:A-AB0@B)
adActiv, //;O :B82=>AB8 ((+DI)+(-DI)) 2 4>;OE >B <0:A8<0;L=>9
adDelta, //;O 5;LBK ((+DI)-(-DI)) 2 4>;OE >B <0:A8<0;L=>9
//----- Levels
aL0, //L0 ADXOpenLvl
aL1, //L1 ADXOpenLvlMax
aL2, //L2 ADXCloseLvl
aL3, //L3 ADXReversLvl
aL4, //L4 ADXReversLvlMax
//----- Scale
aScaleMax //ScaleMax
);
LastError=GetLastError();
{if(LastError!=0)
{
Print("LCL: On_Init(): lip_handle = ",lip_handle," error = ",LastError);
}}//if(LastError!=0)
{if((GraphUse)&&(!ChartIndicatorAdd(0,(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL),lip_handle)))
////-----
// {if((!GraphUse)&&((OpenMethod==Open_ADXW)||(CloseProfitMethod==CloseProfit_ADXW)||(CloseLossMethod==CloseLoss_ADXW)))
// {
// ResetLastError();
// adxw_handle=iCustom( TheSymbol,
// PERIOD_CURRENT,
// "Projects\\Indicatores\\MQ5\\ADX\\adxw_zat_117.ex5",
// //----- Input parameters
// aInpPeriodADXW, //Period
// aInpMethodADXW, //Method (MODE_SMA,MODE_EMA,MODE_SMMA,MODE_LWMA)
// aSSCBaseMode, //>@@ (0..3)-(off/spread/close/midHLC)
// aInpFastPeriodEMA, //Fast EMA period
// aInpSlowPeriodEMA, //Slow EMA period
// aDICalcMode, //DICalcMode(0..8)-(hi/low/mahl/mihl/suhl/isuhl/imahl/imihl)
// //----- 0@0<5B@K A1@>A0 B5=45=F88
// adDI, //;O +-DI 2 4>;OE >B (<0:A-AB0@B)
// adActiv, //;O :B82=>AB8 ((+DI)+(-DI)) 2 4>;OE >B <0:A8<0;L=>9
// adDelta, //;O 5;LBK ((+DI)-(-DI)) 2 4>;OE >B <0:A8<0;L=>9
// //----- Levels
// aL0, //L0 ADXOpenLvl
// aL1, //L1 ADXOpenLvlMax
// aL2, //L2 ADXCloseLvl
// aL3, //L3 ADXReversLvl
// aL4, //L4 ADXReversLvlMax
// //----- Scale
// aScaleMax //ScaleMax
// );
// LastError=GetLastError();
// {if(LastError!=0)
// {
// Print("LIP: adxw_handle = ",adxw_handle," error = ",LastError);
// }}//if(LastError!=0)
{if((GraphUse)&&(!ChartIndicatorAdd(0,(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL),adxw_handle)))
{
Print("LCL: On_Init(): 5 4>102;5= adxw_zat");
//return(INIT_FAILED);
}}//if((GraphUse)&&(!ChartIndicatorAdd(0,(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL),adxw_handle)))
}else{
Print("LCL: On_Init(): 5 3@0D8G5A:89 @568<");
return(INIT_FAILED);
}}//if((!GraphUse)&&((OpenMethod==Open_ADXW)||(CloseProfitMethod==CloseProfit_ADXW)||(CloseLossMethod==CloseLoss_ADXW)))
//----- 1=C;5=85 3;>10;L=KE ?5@5<5==KE
datetime TimeSet=0;
{for(int i=1;i<=3;i++)//5@51>@ B8?>2 ><0=4
{
{for(int j=0;j<=1;j++)//5@51>@ B8?>2 >78F89
{
ReadyExp[(int)CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)]=0; //!1@0AK205< 2=CB@5==85 D;038 7025@H5=8O :><0=4K N: ReadyExp_N=0
RunCommand[(int)CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)]=false; //!1@0AK205< D;038 70?CA:0 :><0=4
GlobalSetUlong("LIP_"+TheSymbol+"_Command_"+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)),TimeSet,0); //!1@0AK205< :><0=4K Command_N=0
GlobalSetUlong("LIP_"+TheSymbol+"_Ready_"+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)),TimeSet,1); //#AB0=02;8205< D;038 7025@H5=8O Ready_N=1
}}//for(int j=0;i<=1;i++)
}}//for(int i=1;i<=2;i++)
//----- 0?><8=05< E5=4; ADXW 2 3;>10;L=>9 ?5@5<5==>9
//GlobalSetUlong("LIP_"+TheSymbol+"_ADXW",TimeSet,adxw_handle);
//----- 0?><8=05< ChartID 2 3;>10;L=>9 ?5@5<5==>9
//GlobalSetUlong("LIP_"+TheSymbol+"_ChartID",TimeSet,ChartID());
//----- >;CG05< :>@>B:>5 8<O 8=48:0B>@0 ADXW, =><5@ >:=0 8 =><5@ 8=48:0B>@0 2 >:=5
//Indicator_Search_Handle(adxw_handle,Chart_Ind_Name,Chart_Ind_Window,Chart_Ind_N);
//Print(ChartIndicatorName(0,Chart_Ind_Window,Chart_Ind_N));
//string Indicator_Name="";
//bool res=Indicator_Delete_Handle(adxw_handle,Indicator_Name);
//Print("adxw_handle=",adxw_handle," res=",res," Indicator_Name=",Indicator_Name);
//----- KE>4
return(INIT_SUCCEEDED);
}//On_Init()
//
//============================================================================================= MQL5 ===
// On_Tick() - A=>2=>9 >1@01>BG8: B8:>2
//------------------------------------------------------------------------------------------------------
void On_Tick(){
//-----
//{if(!gInTimer)
//{
gTick++;
// gInTimer=false;
//}}//if(!InTimer)
{if(gTick>4294967000)
{
gTick=100;
}}//if(gTick>4294967000)
//{if(Indicator_Search_Handle(adxw_handle,Chart_Ind_Name,Chart_Ind_Window,Chart_Ind_N))
//{
// Print("adxw_handle=",adxw_handle);
// Print("Chart_Ind_Window=",Chart_Ind_Window);
// Print("Chart_Ind_N=",Chart_Ind_N);
// Print("ChartIndicatorName=",ChartIndicatorName(0,Chart_Ind_Window,Chart_Ind_N));
//}else{
// Print("Error!!","adxw_handle=",adxw_handle);
//}}//if(Indicator_Search_Handle(adxw_handle,Chart_Ind_Name,Chart_Ind_Window,Chart_Ind_N))
//----- ;>: 4;O >1<5=0 A 8=48:0B>@><
//1. &8:; ?@>25@:8 7040=89 8 ?>AB0=>2:8 =0 2K?>;=5=85. 5@518@05< 2A5 :><0=4K >B 1 4> N. ;O :064>9:
// //1.0. A;8 :0=0; 70=OB BuseInd_N=1, - =5 8A?>;L7C5< 81> 8A?>;L7C5BAO 2 8=48:0B>@5, GB>1K =5 2K4020BL =>2CN :><0=4C 4> >:>=G0=8O >1@01>B:8 ?@54K4CI59.
// 1.1. A;8 >1=0@C65=0 :><0=40 N: Command_N=N, B> 2K?>;=O5<:
// 1.1.1. A;8 A=OB D;03 7025@H5=8O Ready_N=0, B> 2K?>;=O5<:
// 1.1.1.1. !1@0AK205< :><0=4C Command_N=0
// 1.1.1.2. !1@0AK205< 4;O A>25B=8:0 2=CB@5==89 D;03 7025@H5=8O :><0=4K N: ReadyExp_N=0; (87=0G0;L=> 2A5 MB8 D;038 A1@>H5=K, => =0 2AO:89)
// 1.1.1.3. 0?CA:05< :><0=4C =0 2K?>;=5=85 (?>A;5 2K?>;=5=8O :><0=4K 4>;65= 1KBL CAB0=>2;5= 2=CB@5==89 D;03 2K?>;=5=8O :><0=4K N: ReadyExp_N=1;
// // @57C;LB0B5 4>;6=> 1KBL: Ready_N=0 (A1@>H5=> 8=48:0B>@><), Command_N=0 (A1@>H5=> A>25B=8><), ReadyExp_N=0??? (A1@>H5=> A>25B=8:><)
// //!8BC0F8O Ready_N=0 + Command_N=0, 3>2>@8B > B><, GB> :><0=40 70?CI5=0 =0 2K?>;=5=85, => 5IQ =5 2K?>;=5=0.
datetime TimeSet=0;
ulong CommandGet=0;
ulong ReadyGet=0;
{for(int i=1;i<=3;i++)//5@51>@ B8?>2 ><0=4
{
{for(int j=0;j<=1;j++)//5@51>@ B8?>2 >78F89
{
{if(GlobalGetUlong("LIP_"+TheSymbol+"_Command_"+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)),CommandGet)
&&(CommandGet==CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j))) //A;8 >1=0@C65=0 :><0=40 N: Command_N=N
{
{if(GlobalGetUlong("LIP_"+TheSymbol+"_Ready_"+IntegerToString(CommandGet),ReadyGet)&&(ReadyGet==0)) //A;8 A=OB D;03 7025@H5=8O Ready_N=0
{
{if(GlobalSetUlong("LIP_"+TheSymbol+"_Command_"+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)),TimeSet,0))//!1@0AK205< :><0=4C Command_N=0
{
ReadyExp[(int)CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)]=0; //!1@0AK205< 4;O A>25B=8:0 2=CB@5==89 D;03 7025@H5=8O :><0=4K N: ReadyExp_N=0
RunCommand[(int)CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)]=true; //<8B0F8O 70?CA:0 :><0=4K
if(PrintDebug)Print("LCL: 70?CI5=0 :><0=40 "+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j))+" ");
}}//if(GlobalSetUlong("LIP_"+TheSymbol+"_Command_"+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)),TimeSet,0)
}}//if(GlobalGetUlong("LIP_"+TheSymbol+"_Ready_"+IntegerToString(CommandGet),ReadyGet)&&(ReadyGet==0))
}}//if(GlobalGetUlong("LIP_"+TheSymbol+"_Command_"+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)),CommandGet)
}}//for(int j=0;i<=1;i++)
}}//for(int i=1;i<=2;i++)
//2. &8:; ?@>25@:8 2K?>;=5=8O. 5@518@05< 2A5 :><0=4K >B 1 4> N. ;O :064>9:
// 2.1. A;8 CAB0=>2;5= 2=CB@5==89 D;03 7025@H5=8O :><0=4K N: ReadyExp_N=1, B> 2K?>;=O5<:
// 2.1.1. #AB0=02;8205BAO D;03 7025@H5=8O Ready_N=1 4;O ?5@5<5==>9 Ready_N (:><0=40 N 2K?>;=5=0)
// 2.1.2. !1@0AK205< 4;O A>25B=8:0 2=CB@5==89 D;03 7025@H5=8O :><0=4K N: ReadyExp_N=0;
// // @57C;LB0B5 4>;6=> 1KBL: Ready_N=1 (CAB0=>2;5=> A>25B=8:><), Command_N=0 (A1@>H5=> A>25B=8><), ReadyExp_N=0 (A1@>H5=> A>25B=8:><)
{for(int i=1;i<=3;i++)//5@51>@ B8?>2 ><0=4
{
{for(int j=0;j<=1;j++)//5@51>@ B8?>2 >78F89
{
{if(ReadyExp[(int)CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)]==1) //A;8 CAB0=>2;5= 2=CB@5==89 D;03 7025@H5=8O :><0=4K N: ReadyExp_N=1
{
{if(GlobalSetUlong("LIP_"+TheSymbol+"_Ready_"+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)),TimeSet,1))//#AB0=02;8205BAO D;03 7025@H5=8O Ready_N=1
{
ReadyExp[(int)CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)]=0; //!1@0AK205< 4;O A>25B=8:0 2=CB@5==89 D;03 7025@H5=8O :><0=4K N: ReadyExp_N=0
if(PrintDebug)Print("LCL: 7025@H5=0 :><0=40 "+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j))+" ");
}}//if(GlobalSetUlong("LIP_"+TheSymbol+"_Ready_"+IntegerToString(CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)),TimeSet,1)
}}//if(ReadyExp[(int)CommandCode((enCommandType)i,(ENUM_POSITION_TYPE)j)]==1)
}}//for(int j=0;i<=1;i++)
}}//for(int i=1;i<=2;i++)
//----- &8:; 2K?>;=5=8O.
ulong Deal;
uint Result;
bool ResultB;
{for(int i=1;i<=6;i++)//5@51>@ ><0=4
{
{if(RunCommand[i])
{
{switch(i)
{
case(1)://Open Buy
{
Result=PositionOrderSend( TheSymbol, //string symbol
ORDER_TYPE_BUY, //ENUM_ORDER_TYPE type
0.01, //double volume
SymbolInfoDouble(TheSymbol,SYMBOL_ASK), //double price
5, //ulong iSlip,
0.0, //double iSL,
0.0, //double iTP,
"", //string iComment,
0, //ulong iMagic,
0, //datetime iExpir,
Deal); //ulong &iDeal
if(PrintInfo)Print("LCL: 2K?>;=5=0 :><0=40 1>>"+" Open Buy"+" gTick="+IntegerToString(gTick));
break;
}
case(2)://Open Sell
{
Result=PositionOrderSend( TheSymbol, //string symbol
ORDER_TYPE_SELL, //ENUM_ORDER_TYPE type
0.01, //double volume
SymbolInfoDouble(TheSymbol,SYMBOL_BID), //double price
5, //ulong iSlip,
0.0, //double iSL,
0.0, //double iTP,
"", //string iComment,
0, //ulong iMagic,
0, //datetime iExpir,
Deal); //ulong &iDeal
if(PrintInfo)Print("LCL: 2K?>;=5=0 :><0=40 2>>"+" Open Sell"+" gTick="+IntegerToString(gTick));
break;
}
case(3)://Close Buy Profit
{
{if(PositionsTotal()>0)//A;8 5ABL >B:@KBK5 >@45@0
{
{for(int j=PositionsTotal()-1;j>=0;j--)//5@518@05< >B :>=F0 : =0G0;C
{
ulong Pos_Tick=PositionGetTicket(j);//K1>@ ?> =><5@C
{if(Pos_Tick<=0){continue;}}//5C40G=> - A;54CNI89
{if(!PositionSelectByTicket(Pos_Tick)){continue;}}//K1>@ ?> B8:5BC, =5C40G=> - A;54CNI89
{if(PositionGetString(POSITION_SYMBOL)!=TheSymbol){continue;}}//B1>@ ?> 8=AB@C<5=BC
//{if(PositionGetInteger(POSITION_MAGIC)!=iMagic){continue;}}//B1>@ ?> <038:C
double Pos_Profit=PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP);
ENUM_POSITION_TYPE Pos_Type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
{if((Pos_Type==POSITION_TYPE_BUY)&&(Pos_Profit>MinProfit))//0H;8 109 8 ?@>D8B > 1.0
{
ResultB=PositionCloseOne(Pos_Tick, //Ticket
5); //Slip
}}//if((Pos_Type==OP_BUY)&&((iType==OP_ALL)||(iType==OP_BUY)))
}}//for(i=PositionsTotal()-1;i>=0;i--)
}}//if(PositionsTotal()>0)
if(PrintInfo)Print("LCL: 2K?>;=5=0 :><0=40 3>>"+" Close Buy PROFIT"+" gTick="+IntegerToString(gTick));
break;
}
case(4)://Close Sell Profit
{
{if(PositionsTotal()>0)//A;8 5ABL >B:@KBK5 >@45@0
{
{for(int j=PositionsTotal()-1;j>=0;j--)//5@518@05< >B :>=F0 : =0G0;C
{
ulong Pos_Tick=PositionGetTicket(j);//K1>@ ?> =><5@C
{if(Pos_Tick<=0){continue;}}//5C40G=> - A;54CNI89
{if(!PositionSelectByTicket(Pos_Tick)){continue;}}//K1>@ ?> B8:5BC, =5C40G=> - A;54CNI89
{if(PositionGetString(POSITION_SYMBOL)!=TheSymbol){continue;}}//B1>@ ?> 8=AB@C<5=BC
//{if(PositionGetInteger(POSITION_MAGIC)!=iMagic){continue;}}//B1>@ ?> <038:C
double Pos_Profit=PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP);
ENUM_POSITION_TYPE Pos_Type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
{if((Pos_Type==POSITION_TYPE_SELL)&&(Pos_Profit>MinProfit))//0H;8 A5;;
{
ResultB=PositionCloseOne(Pos_Tick, //Ticket
5); //Slip
}}//if((Pos_Type==OP_SELL)&&((iType==OP_ALL)||(iType==OP_SELL)))
}}//for(i=PositionsTotal()-1;i>=0;i--)
}}//if(PositionsTotal()>0)
if(PrintInfo)Print("LCL: 2K?>;=5=0 :><0=40 4>>"+" Close Sell PROFIT"+" gTick="+IntegerToString(gTick));
break;
}
case(5)://Close Buy Loss - 8I5< >@45@ A <0:A8<0;L=K< C1KB:>< 8 70:@K205<
{
{if(PositionsTotal()>0)//A;8 5ABL >B:@KBK5 >@45@0
{
double MaxLoss=0.0;
ulong MaxLoss_Pos_Tick=0;
{for(int j=PositionsTotal()-1;j>=0;j--)//5@518@05< >B :>=F0 : =0G0;C
{
ulong Pos_Tick=PositionGetTicket(j);//K1>@ ?> =><5@C
{if(Pos_Tick<=0){continue;}}//5C40G=> - A;54CNI89
{if(!PositionSelectByTicket(Pos_Tick)){continue;}}//K1>@ ?> B8:5BC, =5C40G=> - A;54CNI89
{if(PositionGetString(POSITION_SYMBOL)!=TheSymbol){continue;}}//B1>@ ?> 8=AB@C<5=BC
//{if(PositionGetInteger(POSITION_MAGIC)!=iMagic){continue;}}//B1>@ ?> <038:C
double Pos_Profit=PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP);
ENUM_POSITION_TYPE Pos_Type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
{if((Pos_Type==POSITION_TYPE_BUY)&&(Pos_Profit<MaxLoss))//0H;8 109
{
MaxLoss=Pos_Profit;
MaxLoss_Pos_Tick=Pos_Tick;
}}//if((Pos_Type==POSITION_TYPE_BUY)&&(Pos_Profit<MaxLoss))
}}//for(i=PositionsTotal()-1;i>=0;i--)
{if((PositionSelectByTicket(MaxLoss_Pos_Tick))&&(MaxLoss<-MinLoss))
{
ResultB=PositionCloseOne(MaxLoss_Pos_Tick, //Ticket
5); //Slip
}}//K1>@ ?> B8:5BC
}}//if(PositionsTotal()>0)
if(PrintInfo)Print("LCL: 2K?>;=5=0 :><0=40 5>>"+" Close Buy LOSS"+" gTick="+IntegerToString(gTick));
break;
}
case(6)://Close Sell Loss - 8I5< >@45@ A <0:A8<0;L=K< C1KB:>< 8 70:@K205<
{
{if(PositionsTotal()>0)//A;8 5ABL >B:@KBK5 >@45@0
{
double MaxLoss=0.0;
ulong MaxLoss_Pos_Tick=0;
{for(int j=PositionsTotal()-1;j>=0;j--)//5@518@05< >B :>=F0 : =0G0;C
{
ulong Pos_Tick=PositionGetTicket(j);//K1>@ ?> =><5@C
{if(Pos_Tick<=0){continue;}}//5C40G=> - A;54CNI89
{if(!PositionSelectByTicket(Pos_Tick)){continue;}}//K1>@ ?> B8:5BC, =5C40G=> - A;54CNI89
{if(PositionGetString(POSITION_SYMBOL)!=TheSymbol){continue;}}//B1>@ ?> 8=AB@C<5=BC
//{if(PositionGetInteger(POSITION_MAGIC)!=iMagic){continue;}}//B1>@ ?> <038:C
double Pos_Profit=PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP);
ENUM_POSITION_TYPE Pos_Type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
{if((Pos_Type==POSITION_TYPE_SELL)&&(Pos_Profit<MaxLoss))//0H;8 109
{
MaxLoss=Pos_Profit;
MaxLoss_Pos_Tick=Pos_Tick;
}}//if((Pos_Type==POSITION_TYPE_BUY)&&(Pos_Profit<MaxLoss))
}}//for(i=PositionsTotal()-1;i>=0;i--)
{if((PositionSelectByTicket(MaxLoss_Pos_Tick))&&(MaxLoss<-MinLoss))
{
ResultB=PositionCloseOne(MaxLoss_Pos_Tick, //Ticket
5); //Slip
}}//K1>@ ?> B8:5BC
}}//if(PositionsTotal()>0)
if(PrintInfo)Print("LCL: 2K?>;=5=0 :><0=40 6>>"+" Close Sell LOSS"+" gTick="+IntegerToString(gTick));
break;
}
default:
{
break;
}
}}//
ReadyExp[i]=1; //#AB0=02;8205< 4;O A>25B=8:0 2=CB@5==89 D;03 7025@H5=8O :><0=4K N: ReadyExp_N=1
RunCommand[i]=false;
}}//if(RunCommand[i])
}}//for(int i=1;i<=6;i++)
//-----
//Print("gTick=",gTick);
//Comment("gTick=",gTick);
//-----
return;
}//On_Tick()
//
//============================================================================================= MQL5 ===
// On_Timer - 1@01>B:0 A>1KB89 ?> B09<5@C
//------------------------------------------------------------------------------------------------------
void On_Timer(){
//-----
//gnTimer++;
//{if(gnTimer>4294967000)
//{
// gnTimer=100;
//}}//if(gnTimer>4294967000)
//gInTimer=true;
On_Tick();
}//On_Timer()
//
//============================================================================================= MQL5 ===
// CommandCode - D>@<8@>20=85 :>40 :><0=4K 4;O 87 B8?0 :><0=4K 8 B8?0 ?>78F88
// E:
// iCommand : B8? :><0=4K (Command_None/Command_Open/Command_Close)
// iPosType : B8? ?>78F88 (Buy/Sell)
// KE:
// ulong : :>4 :><0=4K (0/1/2/3/4) - (=5B:><0=4K/?>:C?:0/?@>4060/70:@KB85?>:C?:8/70:@KB85?@>4068)
//------------------------------------------------------------------------------------------------------
ulong CommandCode(enCommandType iCommand, //B8? :><0=4K
ENUM_POSITION_TYPE iPosType){ //B8? ?>78F88
//----- Demo
{if(iCommand==Command_Open)
{
{if(iPosType==POSITION_TYPE_BUY)
{
return(1);//B:@KBL >:C?:C
}}//if(iPosType==POSITION_TYPE_BUY)
{if(iPosType==POSITION_TYPE_SELL)
{
return(2);//B:@KBL @>406C
}}//if(iPosType==POSITION_TYPE_SELL)
}}//if(iCommand==Commmand_Open)
{if(iCommand==Command_Close)
{
{if(iPosType==POSITION_TYPE_BUY)
{
return(3);//0:@KBL >:C?:C 2 ?@81K;L
}}//if(iPosType==POSITION_TYPE_BUY)
{if(iPosType==POSITION_TYPE_SELL)
{
return(4);//0:@KBL @>406C 2 ?@81K;L
}}//if(iPosType==POSITION_TYPE_SELL)
}}//if(iCommand==Commmand_Close)
{if(iCommand==Command_CloseLoss)
{
{if(iPosType==POSITION_TYPE_BUY)
{
return(5);//0:@KBL >:C?:C 2 C1KB>:
}}//if(iPosType==POSITION_TYPE_BUY)
{if(iPosType==POSITION_TYPE_SELL)
{
return(6);//0:@KBL @>406C 2 C1KB>:
}}//if(iPosType==POSITION_TYPE_SELL)
}}//if(iCommand==Command_CloseLoss)
return(0);//=5B :><0=4K
}//CheckCloseCondition()
//
//-----
////{if(GlobalSetDouble("tst_01",TimeSet,999.999))
////{
//// Print("TimeSet1=",TimeSet);
// {if(GlobalGetDouble("LIP_"+TheSymbol+"_Ask",DateSet))
// {
// //Print("LIP_"+TheSymbol+"_Ask=",DateSet);
// }}//if(GlobalGetDouble("tst_01",DateSet))
// {if(GlobalGetDouble("LIP_"+TheSymbol+"_Bid",DateSet))
// {
// //Print("LIP_"+TheSymbol+"_Bid=",DateSet);
// }}//if(GlobalGetDouble("tst_01",DateSet))
////}}//if(GlobalSetDouble("tst_01",999.999,TimeSet))
//-----
//string StringSet="";
////{if(GlobalSetString("tst_02",TimeSet,"EURUSD.z"))
////{
//// Print("TimeSet2=",TimeSet);
// {if(GlobalGetString("LIP_"+TheSymbol+"_Symbol",StringSet))
// {
// //Print("LIP_"+TheSymbol+"_Symbol=",StringSet);
// }}//if(GlobalGetString("tst_02",StringSet))
////}}//if(GlobalSetString("tst_02",TimeSet,"EURUSD.z"))