رجعت لطلب مساعدتكم ما النا غنى ما عرفت ساعد نفسي كتبت تعريف للمسافة بين الصفقات لكن ما عرفت بأي امر دخلو و كمان ما عرفت اتحكم بالمضاعفة او شوف الامر الخاص فيها
input int MaxTrades = 0;
input bool EnableTimeFilter = false;
input string Start_Hour ="00:00";
input string End_Hour = "23:00";
input bool CloseInReverse=false;
input string info1="Trendsignal Settings";
input int RISK=0;
input int SSP=0;
input string info2="Money Management";
input double Lots= 0.03;
input bool MoneyManagement = true;
input double Risk=5;
input int TakeProfit=10;
input int StopLoss=0;
input int TrailingStop=4;
input int BreakEven=0;
input int BreakEvenPips=1;
input int Step=10;
input int MagicNumber=55555;
datetime Timee;
double point;
int P;
int Lot_Digits;
int OnInit(void)
{
if(MarketInfo(Symbol(),MODE_MINLOT)<0.1)Lot_Digits =2;
else Lot_Digits=1;
if(_Digits==5||_Digits==3)P=10;
else P=1;
if(_Digits<4)
{
point=0.01;
}
else
{
point=0.0001;
}
return(0);
}
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS deinitialization function |
//+------------------------------------------------------------------+
int TotalOrders(int type)
{
int cnt=0;
for(int i =0;i<OrdersTotal();i++){
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
if(OrderSymbol()==Symbol() && MagicNumber==OrderMagicNumber()&&OrderType()==type ){
cnt++;
}
}
}
return(cnt);
}
//+------------------------------------------------------------------+
//| FUNCTION DEFINITIONS Start function |
//+------------------------------------------------------------------+
bool TimeFilter(string StartH,string EndH)
{
datetime Start= StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + StartH);
datetime End= StrToTime(TimeToStr(TimeCurrent(), TIME_DATE) + " " + EndH);
if(!(Time[0]>=Start && Time[0]<=End))
{
return(false);
}
return(true);
}
double TrendSignal(int index,int shift)
{
double TS=iCustom(Symbol(),0,"Trendsignal version 2",RISK,SSP,index,shift);
return(TS);
}
void OnTick(void)
{
Comment("Programmed By MR.dollar");
if(TrailingStop>0)MoveTrailingStop();
if(BreakEven>0)MoveBreakEven();
if(EnableTimeFilter&&TimeFilter(Start_Hour,End_Hou r)==false)return;
double NewLots;
if(MoneyManagement) NewLots = LotManage();
else NewLots=Lots;
double SL,TP;
if (TrendSignal(0,1)!=0&&Timee!=Time[0]){
if(CloseInReverse)
CloseOrders(OP_SELL);
if(TotalOrders(OP_BUY)<MaxTrades||MaxTrades==0)
{
if(StopLoss==0){SL=0;}else{SL=Ask-StopLoss*point;}
if(TakeProfit==0){TP=0;}else{TP=Ask+TakeProfit*poi nt;}
int ticket= OrderSend(Symbol(),OP_BUY,NewLots,NormalizeDouble( Ask,_Digits),3*P,SL,TP,"EA",MagicNumber,0,Blue);
PlaySound("Alert.wav");
Timee=Time[0];
}
}
if (TrendSignal(1,1)!=0&&Timee!=Time[0]){
if(CloseInReverse)
CloseOrders(OP_BUY);
if(TotalOrders(OP_SELL)<MaxTrades||MaxTrades==0)
{
if(StopLoss==0){SL=0;}else{SL=Bid+StopLoss*point;}
if(TakeProfit==0){TP=0;}else{TP=Bid-TakeProfit*point;}
ticket= OrderSend(Symbol(),OP_SELL,NewLots,NormalizeDouble (Bid,_Digits),3*P,SL,TP,"EA",MagicNumber,0,Red);
PlaySound("Alert.wav");
Timee=Time[0];
}
}
}
//+------------------------------------------------------------------+
void CloseOrders(int type)
{
for (int cnt = 0 ; cnt < OrdersTotal() ; cnt++)
{
bool select=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == MagicNumber && OrderSymbol()==Symbol()&&OrderType()==type)
{
if (OrderType()==OP_BUY)
{
bool close=OrderClose(OrderTicket(),OrderLots()