Scrivo EA gratis

Ciao, civit.

Posta pure e vediamo che si riesce a fare.

Ciao il codice è questo, come anticipato il MM sembra fatto davvero male, soprattutto la gestione dello SL è tutta da rivedere imho:
Codice:
//---- input parameters
extern double    MiniLots=0.01;
extern double    MaxLot=10;
extern bool RiskControl = false;
extern int MaxTrades=30;
extern int SL=0;
extern int TP=0;
extern int BE=0;

double InitLots;
int ticket;

string symbol="EURUSD";
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
  return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
datetime Time0=0;

void start()
{

double PowerRisk;

symbol=Symbol();


 //Start 

    //Lot Size Check
if(MaxLot > MarketInfo(symbol,MODE_MAXLOT)) MaxLot=MarketInfo(symbol,MODE_MAXLOT);
      
if(InitLots < MarketInfo(symbol,MODE_MINLOT)) InitLots=MarketInfo(symbol,MODE_MINLOT);

   //cal Lot size
   if(RiskControl) {
      PowerRisk=AccountBalance()/10000;
      if(PowerRisk < 1) PowerRisk=1;
      
      InitLots = MiniLots *PowerRisk;
      if(InitLots > MaxLot) InitLots = MaxLot;
      Print("RiskControl PowerRisk=",PowerRisk," InitLots=",InitLots);
      }
   if(RiskControl==false) InitLots=MiniLots;
      
  // Make Order
double RSI,RSI1,RSIP,RSI15,RSI15P,S4H,SD,EMA1,EMA2,down,up;


   RSI=iRSI(0,0,11,PRICE_CLOSE,0);
   RSI1=iRSI(0,0,11,PRICE_CLOSE,1);
   RSIP=iRSI(0,0,11,PRICE_CLOSE,1);
   RSI15=iRSI(0,PERIOD_M15,11,PRICE_CLOSE,0);
   RSI15P=iRSI(0,PERIOD_M15,11,PRICE_CLOSE,1);
   S4H=iStochastic(symbol,PERIOD_H4,30,3,3,MODE_SMA,0,MODE_MAIN,0);
   SD=iStochastic(symbol,PERIOD_D1,30,3,3,MODE_SMA,0,MODE_MAIN,0);
   EMA1=iMA(symbol,PERIOD_H1,50,0,MODE_SMMA,PRICE_CLOSE,0);
   EMA2=iMA(symbol,PERIOD_H1,100,0,MODE_SMMA,PRICE_CLOSE,0);
   down=0;
   up=0;
 //  S1=iStochastic(0,0,30,3,3,MODE_SMA,0,MODE_MAIN,0);
  
//          TREND
 if((Time0!=Time[0]) && S4H<50.0 && EMA1<EMA2) down=1;
 if((Time0!=Time[0]) && S4H>50.0 && EMA1>EMA2) up=1;
 
 
 //         LAST BAR (DOWN or UP)
 double barclose, baropen, barup=0, bardown=0;
 barclose=iClose(NULL,0,1);
 baropen=iOpen(NULL,0,1);
 if(barclose>baropen) barup=1;
 if(barclose<baropen) bardown=1;


//          POSITIONS
if(up==1 && bardown==1 && RSI1<30.0 && RSI15<30.0)  {ticket=OrderSend(symbol,OP_BUY,InitLots*2,Ask,10,SL,TP,0,0,0,Black); Time0=Time[0];}
  else 
if(up==1 && bardown==1 && RSI1<30.0)  {ticket=OrderSend(symbol,OP_BUY,InitLots,Ask,10,SL,TP,0,0,0,Lime); Time0=Time[0];}
 
 
if(down==1 && barup==1 && RSI1>70.0 && RSI15>70.0)  {ticket=OrderSend(symbol,OP_SELL,InitLots*2,Bid,10,SL,TP,0,0,0,Black); Time0=Time[0];}
  else
if(down==1 && barup==1 && RSI1>70.0)  {ticket=OrderSend(symbol,OP_SELL,InitLots,Bid,10,SL,TP,0,0,0,Red); Time0=Time[0];}


  
  // closing LONG

int total=OrdersTotal();
for(int cnt=total-1;cnt>=0;cnt--)

     {
      OrderSelect(cnt, SELECT_BY_POS);
      if(   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // LONG position is opened
           {
            // should it be closed?
            if(RSI>70.0 || EMA1<EMA2 || (S4H<50.0 && RSI>50.0) )
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                  // exit
                }
            // check for trailing stop
            
           }
         else // go to SHORT position
           {
            // should it be closed?
            if(RSI<30.0 || EMA1>EMA2 || (S4H>50.0 && RSI<50.0) )
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
                // exit
              }
            // check for trailing stop
            
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+

Se serve altro chiedi pure!OK!
 
Ciao il codice è questo, come anticipato il MM sembra fatto davvero male, soprattutto la gestione dello SL è tutta da rivedere imho:
Codice:
...
Se serve altro chiedi pure!OK!

Ciao, civt.

Che dire, evidentemente per chi ha elaborato questo EA, il MM sottostante e la gestione degli SL sono fatti bene. A te non piace,ok, ma dimmi come vorresti che cambiassi la gestione degli SL e del MM e lo farò.

Ciao di nuovo
 
Ciao, civt.

Che dire, evidentemente per chi ha elaborato questo EA, il MM sottostante e la gestione degli SL sono fatti bene. A te non piace,ok, ma dimmi come vorresti che cambiassi la gestione degli SL e del MM e lo farò.

Ciao di nuovo

Riciao! Lascia perdere il precedente EA, lavoriamo con questo che è molto simile al precedente ma ha una base molto piu' solida e sembra essere piu' profittevole, qui cè da sistemare solamente il trailing stop (lo SL è ok e pure il TP), inoltre è presente un errore di funzione quando provo a compilarlo "Function "dailyprofit" is not referenced and will be removed from exp-file" prova a vedere che riesci a fare, poi eventualmente veniamo alla cose complicate!OK!

Codice:
//+-------------------------------------------------
//----   AS AT 17TH MAY 2011

extern bool Long_Short= true,Long_Only=false,Short_Only=false;
extern bool Auto_Disable_EA=true;
extern bool use_daily_target=false;
extern double TakeProfit = 130;
extern bool use_bb=true,use_rsi = true,use_sar=true;
extern int rsi_per=14;
extern int PRICE_TYPE=1;
extern double step=0.02,maximum=0.2;
extern double Lots = 0.01;
extern double InitialStop = 0;
extern double TrailingStop = 100;
extern int MaxTrades = 15;
extern int Pips = 100;
extern int SecureProfit = 10;
int AccountProtection = 1;
extern int OrderstoProtect = 6;
int ReverseCondition = 0;
extern double EURUSDPipValue = 10;
extern double GBPUSDPipValue = 10;
extern double USDCHFPipValue = 10;
extern double USDJPYPipValue = 9.715;
int magic = 222;
extern int       bb_period=20;
extern int       bb_deviation=2;
extern int       bb_shift=0;
extern int StartHour = 10;
extern int EndHour = 17;
int mm = 0;
int risk = 12;
int AccountisNormal = 0;
//----
int  OpenOrders = 0, cnt = 0;
int  slippage = 50;
double sl = 0, tp = 0;
double BuyPrice = 0, SellPrice = 0;
double lotsi = 0, mylotsi = 0;
int mode = 0, myOrderType = 0;
bool ContinueOpening = True;
double LastPrice = 0;
int  PreviousOpenOrders = 0;
double Profit = 0;
int LastTicket = 0, LastType = 0,res;
double LastClosePrice = 0, LastLots = 0;
double Pivot = 0;
double PipValue = 0;
string text = "", text2 = "";
int ActiveOrders=0;
double AllTP=0;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----  To assign a unique Magic number for each Pair.
 MathSrand(MathCeil(Ask*100));
 magic= MathRand();

   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//---- 
 
		         lotsi = Lots; 
//----
   if(lotsi > 100)
       lotsi = 100; 

   
   OpenOrders = 0;
//----
   for(cnt = 0; cnt < OrdersTotal(); cnt++)   
     {
       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	      //----
       if(OrderSymbol() == Symbol())
	  	       OpenOrders++;
     }       
//----
   if(OpenOrders < 1) 
     {
               ActiveOrders=0;              
              
	      if(TimeHour(TimeCurrent()) < StartHour) 
	          return(0);  
	      //----
       if(TimeHour(TimeCurrent())  > EndHour) 
	          return(0); 
	          
     }
//----
   if(Symbol() == "EURUSD") 
       PipValue = EURUSDPipValue; 
//----
   if(Symbol() == "GBPUSD") 
       PipValue = GBPUSDPipValue; 
//----
   if(Symbol() == "USDJPY") 
       PipValue = USDJPYPipValue; 
//----
   if(Symbol() == "USDCHF") 
       PipValue = USDCHFPipValue; 
//----
   if(PipValue == 0) 
     { 
       PipValue = 5; 
     }
//----
   if(PreviousOpenOrders > OpenOrders) 
	      for(cnt = OrdersTotal(); cnt >= 0; cnt--)
	        {
	          OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	  	       mode = OrderType();
		         //----
           if(OrderSymbol() == Symbol()) 
		           {
			            if(mode == OP_BUY) 
			                OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Green); 
			            //----
               if(mode == OP_SELL) 
			                OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Green); 
			            return(0);
		           }
	        }
   PreviousOpenOrders = OpenOrders;
//----
   if(OpenOrders >= MaxTrades) 
	      ContinueOpening = False;
   else 
	      ContinueOpening = True;
//----
   if(LastPrice == 0) 
	      for(cnt = 0; cnt < OrdersTotal(); cnt++)
	        {	
	          OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
		         mode = OrderType();	
		         //----
           if(OrderSymbol() == Symbol()) 
		           {
			            LastPrice = OrderOpenPrice();
			            //----
               if(mode == OP_BUY) 
			                myOrderType = 2; 
			            //----
               if(mode == OP_SELL) 
			                myOrderType = 1;	
		           }
	        }
//----
if(OpenOrders < 1) 
  {
      myOrderType = 3;
      //----
	
  double upBB=iBands(Symbol(),5,bb_period,bb_deviation,0,PRICE_OPEN,MODE_UPPER,bb_shift);
  double loBB=iBands(Symbol(),5,bb_period,bb_deviation,0,PRICE_OPEN,MODE_LOWER,bb_shift);
  
     int bar1=iBars(Symbol(),5);
     int bar2=iBars(Symbol(),15);
     int bar3=iBars(Symbol(),30);
     int bar4=iBars(Symbol(),60);
         
         datetime time=iTime(Symbol(),5,0);
         int shift1=iBarShift(Symbol(),5,time,true);
         int shift2=iBarShift(Symbol(),15,time,true);
         int shift3=iBarShift(Symbol(),30,time,true);
         int shift4=iBarShift(Symbol(),60,time,true);
     
   double   RSI1 =iRSI(Symbol(),5,rsi_per,PRICE_TYPE,shift1);
   double   RSI2 =iRSI(Symbol(),15,rsi_per,PRICE_TYPE,shift2);
   double   RSI3 =iRSI(Symbol(),30,rsi_per,PRICE_TYPE,shift3);
   double   RSI4 =iRSI(Symbol(),60,rsi_per,PRICE_TYPE,shift4);
   
   
    double  mabela = iSAR(Symbol(), 5,step,maximum,shift1); 
    double  mabelb = iSAR(Symbol(), 15,step,maximum,shift2); 
    double   mabelc = iSAR(Symbol(), 30,step,maximum,shift3); 
   
  //use all three signals 
  if(use_rsi && use_bb && use_sar)                 // use all three signals
  {
   if(RSI1>50 && RSI2>50 && RSI3>50 && RSI4>50 && High[bb_shift]>=upBB && mabela< Low[0] && mabelb < Low[0] && mabelc < Low[0] ) myOrderType = 2;
   if(RSI1<50 && RSI2<50 && RSI3<50 && RSI4<50 && Low[bb_shift]<=loBB  && mabela> High[0]&& mabelb > High[0]&& mabelc > High[0]) myOrderType = 1;
  }
  if(!use_rsi && use_bb && use_sar)                // use both bba and sar
  {
   if( High[bb_shift]>=upBB && mabela< Low[0] && mabelb < Low[0] && mabelc < Low[0] ) myOrderType = 2;
   if( Low[bb_shift]<=loBB  && mabela> High[0]&& mabelb > High[0]&& mabelc > High[0]) myOrderType = 1;
  }
  if(use_rsi && !use_bb && use_sar)                // use both rsi and sar
  {
   if(RSI1>50 && RSI2>50 && RSI3>50 && RSI4>50 && mabela< Low[0] && mabelb < Low[0] && mabelc < Low[0] ) myOrderType = 2;
   if(RSI1<50 && RSI2<50 && RSI3<50 && RSI4<50 && mabela> High[0]&& mabelb > High[0]&& mabelc > High[0]) myOrderType = 1;
  } 
  if(use_rsi && use_bb && !use_sar)                // use both rsi and bb
  {
   if(RSI1>50 && RSI2>50 && RSI3>50 && RSI4>50 && High[bb_shift]>=upBB  ) myOrderType = 2;
   if(RSI1<50 && RSI2<50 && RSI3<50 && RSI4<50 && Low[bb_shift]<=loBB   ) myOrderType = 1;
  } 	      
  else if(use_rsi && !use_bb && !use_sar)          // use only rsi
  {
   if(RSI1>50 && RSI2>50 && RSI3>50 && RSI4>50) myOrderType = 2;
   if(RSI1<50 && RSI2<50 && RSI3<50 && RSI4<50) myOrderType = 1;
  }
  else if(!use_rsi && use_bb &&  !use_sar)         // use only bb
  {
   if(High[bb_shift]>=upBB )myOrderType = 2; // return(buy);
   if(Low[bb_shift]<=loBB ) myOrderType = 1;// return(sell);
  }
  else if(!use_rsi && !use_bb && use_sar)          // use only sar
  {
  if( mabela< Low[0] && mabelb < Low[0] && mabelc < Low[0] ) myOrderType = 2;
  if( mabela> High[0]&& mabelb > High[0]&& mabelc > High[0]) myOrderType = 1;
  }
  
 } // end of if...
 
  
   Profit = 0;
   LastTicket = 0;
   LastType = 0;
	  LastClosePrice = 0;
	  LastLots = 0;	
//----
	  for(cnt = 0; cnt < OrdersTotal(); cnt++)
	    {
	      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	      //----
       if(OrderSymbol() == Symbol()) 
	        {			
	  	       LastTicket = OrderTicket();
			        //----
           if(OrderType() == OP_BUY) 
			            LastType = OP_BUY; 
			        //----
           if(OrderType() == OP_SELL) 
			            LastType = OP_SELL; 
			        LastClosePrice = OrderClosePrice();
			        LastLots = OrderLots();
			        //----
           if(LastType == OP_BUY) 
			          {			
				           if(OrderClosePrice() < OrderOpenPrice()) 
					              Profit = Profit - (OrderOpenPrice() - OrderClosePrice())*OrderLots() / 
					                       Point; 
				           //----
               if(OrderClosePrice() > OrderOpenPrice()) 
					              Profit = Profit + (OrderClosePrice() - OrderOpenPrice())*OrderLots() / 
					                       Point; 
			          }
			        //----
           if(LastType==OP_SELL) 
			          {
				           if(OrderClosePrice() > OrderOpenPrice()) 
					              Profit = Profit - (OrderClosePrice() - OrderOpenPrice())*OrderLots() / 
					                       Point; 
				           //----
               if(OrderClosePrice() < OrderOpenPrice()) 
					              Profit = Profit + (OrderOpenPrice() - OrderClosePrice())*OrderLots() / 
					                       Point;
			          }
	        }
     }
	  Profit = Profit*PipValue;
	  text2 = "Profit: $" + DoubleToStr(Profit,2) + " +/-";
//----
 //  if(OpenOrders >= (MaxTrades - OrderstoProtect) && AccountProtection == 1) 
	      if(Profit >= SecureProfit) 
	        {
	          OrderClose(LastTicket, LastLots, LastClosePrice, slippage, Yellow);		 
	          ContinueOpening = False;
	          return(0);
	        }

//----
   if(myOrderType == 1 && ContinueOpening && (Long_Short|| Short_Only)) 
     {	
       if((Bid - LastPrice) >= Pips*Point || OpenOrders < 1) 
         {		
           SellPrice = Bid;				
           LastPrice = 0;
           //----
           if(TakeProfit == 0) 
               tp = 0; 
           else 
               tp = SellPrice - TakeProfit*Point; 
           //----
           if(InitialStop == 0) 
               sl = 0; 
           else 
               sl = SellPrice + InitialStop*Point;  
           //----
           if(OpenOrders >=2) 
             {
               mylotsi = 2*mylotsi;			
               //----
		       } 
		         else 
		             mylotsi=lotsi; 
		         //----
        
		       res=OrderSend(Symbol(), OP_SELL, mylotsi, SellPrice, slippage, sl, tp,"MTF EA Sell",magic, 0, Red);
		     if (res < 0)
         mylotsi=mylotsi/2;	    		    // i.e if opening of order failed.
          else 
           {
               ActiveOrders++;              // increament open orders.
              if(ActiveOrders==1) AllTP=tp;
            else
               ModifyTP(tp);
           
           }
		         return(0);
	        }
     }     
   if(myOrderType == 2 && ContinueOpening&& (Long_Short|| Long_Only)) 
     {
       if((LastPrice-Ask) >= Pips*Point || OpenOrders < 1) 
         {		
           BuyPrice = Ask;
           LastPrice = 0;
           //----
           if(TakeProfit == 0) 
               tp = 0; 
           else 
               tp = BuyPrice + TakeProfit*Point; 
           //----
           if(InitialStop==0)  
               sl = 0; 
           else 
               sl = BuyPrice - InitialStop*Point; 
           //----
           if(OpenOrders >=2) 
             {
               mylotsi = 2*mylotsi;
             } 
           else 
               mylotsi = lotsi; 
           //----
         //  if(mylotsi > 100) 
         //      mylotsi = 100; 
         res=OrderSend(Symbol(), OP_BUY, mylotsi, BuyPrice, slippage, sl, tp, "MTF EA Buy", magic, 0,Blue);
         if (res < 0)
         mylotsi=mylotsi/2;	    		    // i.e if opening of order failed.
          else 
           {
               ActiveOrders++;              // increament open orders.
              if(ActiveOrders==1) AllTP=tp;
              else ModifyTP(tp);
         
           }
                  
            return(0);
         }
     }                                
//----                                                                
   return(0);                                                                                 
  }
  
 void ModifyTP(double tp) 
  {
   int cnt;
    // if we have opened positions we take care of them
   for(cnt =0;cnt <=OrdersTotal() ;  cnt++)
     {
       OrderSelect(cnt, SELECT_BY_POS,MODE_TRADES);
	      //----
       if(OrderSymbol() == Symbol() && OrderMagicNumber()==magic) 
	         {	
	  	       if(OrderType() == OP_SELL) 
	  	  	      if( OrderModify(OrderTicket(),OrderOpenPrice(), OrderStopLoss(),tp, 1000, Purple)) Comment("\n\n\n\n MODIFYING ORDER........");
	  					                //   return(0);	  					
	  		   }
	  	       if(OrderType() == OP_BUY)
	  	      {
	  		      if( OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), tp, 1000, Purple))Comment("\n\n\n\n MODIFYING ORDER........");
                                //   return(0);
				}
   	     
     } 
  }// 
 
  
double dailyprofit()
{
  int day=Day(); double res1=0,res2=0;
  
  for(int i=0; i<OrdersHistoryTotal(); i++)
  {   
      OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(OrderMagicNumber()!=magic) continue;
      if(TimeDay(OrderOpenTime())==day) res1+=OrderProfit();
  }
  
 for(i=0; i<OrdersTotal(); i++)
  {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);   
      if(OrderMagicNumber()!=magic) continue;
      if(TimeDay(OrderOpenTime())==day) res2+=OrderProfit();
  }
  
  return(res1+res2);
}
//+------------------------------------------------------------------+

Ti ringrazio in anticipo per il tuo prezioso tempo!:bow:
 
Riciao! Lascia perdere il precedente EA, lavoriamo con questo che è molto simile al precedente ma ha una base molto piu' solida e sembra essere piu' profittevole, qui cè da sistemare solamente il trailing stop (lo SL è ok e pure il TP), inoltre è presente un errore di funzione quando provo a compilarlo "Function "dailyprofit" is not referenced and will be removed from exp-file" prova a vedere che riesci a fare, poi eventualmente veniamo alla cose complicate!OK!

Codice:
//+-------------------------------------------------
//----   AS AT 17TH MAY 2011

extern bool Long_Short= true,Long_Only=false,Short_Only=false;
extern bool Auto_Disable_EA=true;
extern bool use_daily_target=false;
extern double TakeProfit = 130;
extern bool use_bb=true,use_rsi = true,use_sar=true;
extern int rsi_per=14;
extern int PRICE_TYPE=1;
extern double step=0.02,maximum=0.2;
extern double Lots = 0.01;
extern double InitialStop = 0;
extern double TrailingStop = 100;
extern int MaxTrades = 15;
extern int Pips = 100;
extern int SecureProfit = 10;
int AccountProtection = 1;
extern int OrderstoProtect = 6;
int ReverseCondition = 0;
extern double EURUSDPipValue = 10;
extern double GBPUSDPipValue = 10;
extern double USDCHFPipValue = 10;
extern double USDJPYPipValue = 9.715;
int magic = 222;
extern int       bb_period=20;
extern int       bb_deviation=2;
extern int       bb_shift=0;
extern int StartHour = 10;
extern int EndHour = 17;
int mm = 0;
int risk = 12;
int AccountisNormal = 0;
//----
int  OpenOrders = 0, cnt = 0;
int  slippage = 50;
double sl = 0, tp = 0;
double BuyPrice = 0, SellPrice = 0;
double lotsi = 0, mylotsi = 0;
int mode = 0, myOrderType = 0;
bool ContinueOpening = True;
double LastPrice = 0;
int  PreviousOpenOrders = 0;
double Profit = 0;
int LastTicket = 0, LastType = 0,res;
double LastClosePrice = 0, LastLots = 0;
double Pivot = 0;
double PipValue = 0;
string text = "", text2 = "";
int ActiveOrders=0;
double AllTP=0;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----  To assign a unique Magic number for each Pair.
 MathSrand(MathCeil(Ask*100));
 magic= MathRand();

   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//---- 
 
		         lotsi = Lots; 
//----
   if(lotsi > 100)
       lotsi = 100; 

   
   OpenOrders = 0;
//----
   for(cnt = 0; cnt < OrdersTotal(); cnt++)   
     {
       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	      //----
       if(OrderSymbol() == Symbol())
	  	       OpenOrders++;
     }       
//----
   if(OpenOrders < 1) 
     {
               ActiveOrders=0;              
              
	      if(TimeHour(TimeCurrent()) < StartHour) 
	          return(0);  
	      //----
       if(TimeHour(TimeCurrent())  > EndHour) 
	          return(0); 
	          
     }
//----
   if(Symbol() == "EURUSD") 
       PipValue = EURUSDPipValue; 
//----
   if(Symbol() == "GBPUSD") 
       PipValue = GBPUSDPipValue; 
//----
   if(Symbol() == "USDJPY") 
       PipValue = USDJPYPipValue; 
//----
   if(Symbol() == "USDCHF") 
       PipValue = USDCHFPipValue; 
//----
   if(PipValue == 0) 
     { 
       PipValue = 5; 
     }
//----
   if(PreviousOpenOrders > OpenOrders) 
	      for(cnt = OrdersTotal(); cnt >= 0; cnt--)
	        {
	          OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	  	       mode = OrderType();
		         //----
           if(OrderSymbol() == Symbol()) 
		           {
			            if(mode == OP_BUY) 
			                OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Green); 
			            //----
               if(mode == OP_SELL) 
			                OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Green); 
			            return(0);
		           }
	        }
   PreviousOpenOrders = OpenOrders;
//----
   if(OpenOrders >= MaxTrades) 
	      ContinueOpening = False;
   else 
	      ContinueOpening = True;
//----
   if(LastPrice == 0) 
	      for(cnt = 0; cnt < OrdersTotal(); cnt++)
	        {	
	          OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
		         mode = OrderType();	
		         //----
           if(OrderSymbol() == Symbol()) 
		           {
			            LastPrice = OrderOpenPrice();
			            //----
               if(mode == OP_BUY) 
			                myOrderType = 2; 
			            //----
               if(mode == OP_SELL) 
			                myOrderType = 1;	
		           }
	        }
//----
if(OpenOrders < 1) 
  {
      myOrderType = 3;
      //----
	
  double upBB=iBands(Symbol(),5,bb_period,bb_deviation,0,PRICE_OPEN,MODE_UPPER,bb_shift);
  double loBB=iBands(Symbol(),5,bb_period,bb_deviation,0,PRICE_OPEN,MODE_LOWER,bb_shift);
  
     int bar1=iBars(Symbol(),5);
     int bar2=iBars(Symbol(),15);
     int bar3=iBars(Symbol(),30);
     int bar4=iBars(Symbol(),60);
         
         datetime time=iTime(Symbol(),5,0);
         int shift1=iBarShift(Symbol(),5,time,true);
         int shift2=iBarShift(Symbol(),15,time,true);
         int shift3=iBarShift(Symbol(),30,time,true);
         int shift4=iBarShift(Symbol(),60,time,true);
     
   double   RSI1 =iRSI(Symbol(),5,rsi_per,PRICE_TYPE,shift1);
   double   RSI2 =iRSI(Symbol(),15,rsi_per,PRICE_TYPE,shift2);
   double   RSI3 =iRSI(Symbol(),30,rsi_per,PRICE_TYPE,shift3);
   double   RSI4 =iRSI(Symbol(),60,rsi_per,PRICE_TYPE,shift4);
   
   
    double  mabela = iSAR(Symbol(), 5,step,maximum,shift1); 
    double  mabelb = iSAR(Symbol(), 15,step,maximum,shift2); 
    double   mabelc = iSAR(Symbol(), 30,step,maximum,shift3); 
   
  //use all three signals 
  if(use_rsi && use_bb && use_sar)                 // use all three signals
  {
   if(RSI1>50 && RSI2>50 && RSI3>50 && RSI4>50 && High[bb_shift]>=upBB && mabela< Low[0] && mabelb < Low[0] && mabelc < Low[0] ) myOrderType = 2;
   if(RSI1<50 && RSI2<50 && RSI3<50 && RSI4<50 && Low[bb_shift]<=loBB  && mabela> High[0]&& mabelb > High[0]&& mabelc > High[0]) myOrderType = 1;
  }
  if(!use_rsi && use_bb && use_sar)                // use both bba and sar
  {
   if( High[bb_shift]>=upBB && mabela< Low[0] && mabelb < Low[0] && mabelc < Low[0] ) myOrderType = 2;
   if( Low[bb_shift]<=loBB  && mabela> High[0]&& mabelb > High[0]&& mabelc > High[0]) myOrderType = 1;
  }
  if(use_rsi && !use_bb && use_sar)                // use both rsi and sar
  {
   if(RSI1>50 && RSI2>50 && RSI3>50 && RSI4>50 && mabela< Low[0] && mabelb < Low[0] && mabelc < Low[0] ) myOrderType = 2;
   if(RSI1<50 && RSI2<50 && RSI3<50 && RSI4<50 && mabela> High[0]&& mabelb > High[0]&& mabelc > High[0]) myOrderType = 1;
  } 
  if(use_rsi && use_bb && !use_sar)                // use both rsi and bb
  {
   if(RSI1>50 && RSI2>50 && RSI3>50 && RSI4>50 && High[bb_shift]>=upBB  ) myOrderType = 2;
   if(RSI1<50 && RSI2<50 && RSI3<50 && RSI4<50 && Low[bb_shift]<=loBB   ) myOrderType = 1;
  } 	      
  else if(use_rsi && !use_bb && !use_sar)          // use only rsi
  {
   if(RSI1>50 && RSI2>50 && RSI3>50 && RSI4>50) myOrderType = 2;
   if(RSI1<50 && RSI2<50 && RSI3<50 && RSI4<50) myOrderType = 1;
  }
  else if(!use_rsi && use_bb &&  !use_sar)         // use only bb
  {
   if(High[bb_shift]>=upBB )myOrderType = 2; // return(buy);
   if(Low[bb_shift]<=loBB ) myOrderType = 1;// return(sell);
  }
  else if(!use_rsi && !use_bb && use_sar)          // use only sar
  {
  if( mabela< Low[0] && mabelb < Low[0] && mabelc < Low[0] ) myOrderType = 2;
  if( mabela> High[0]&& mabelb > High[0]&& mabelc > High[0]) myOrderType = 1;
  }
  
 } // end of if...
 
  
   Profit = 0;
   LastTicket = 0;
   LastType = 0;
	  LastClosePrice = 0;
	  LastLots = 0;	
//----
	  for(cnt = 0; cnt < OrdersTotal(); cnt++)
	    {
	      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	      //----
       if(OrderSymbol() == Symbol()) 
	        {			
	  	       LastTicket = OrderTicket();
			        //----
           if(OrderType() == OP_BUY) 
			            LastType = OP_BUY; 
			        //----
           if(OrderType() == OP_SELL) 
			            LastType = OP_SELL; 
			        LastClosePrice = OrderClosePrice();
			        LastLots = OrderLots();
			        //----
           if(LastType == OP_BUY) 
			          {			
				           if(OrderClosePrice() < OrderOpenPrice()) 
					              Profit = Profit - (OrderOpenPrice() - OrderClosePrice())*OrderLots() / 
					                       Point; 
				           //----
               if(OrderClosePrice() > OrderOpenPrice()) 
					              Profit = Profit + (OrderClosePrice() - OrderOpenPrice())*OrderLots() / 
					                       Point; 
			          }
			        //----
           if(LastType==OP_SELL) 
			          {
				           if(OrderClosePrice() > OrderOpenPrice()) 
					              Profit = Profit - (OrderClosePrice() - OrderOpenPrice())*OrderLots() / 
					                       Point; 
				           //----
               if(OrderClosePrice() < OrderOpenPrice()) 
					              Profit = Profit + (OrderOpenPrice() - OrderClosePrice())*OrderLots() / 
					                       Point;
			          }
	        }
     }
	  Profit = Profit*PipValue;
	  text2 = "Profit: $" + DoubleToStr(Profit,2) + " +/-";
//----
 //  if(OpenOrders >= (MaxTrades - OrderstoProtect) && AccountProtection == 1) 
	      if(Profit >= SecureProfit) 
	        {
	          OrderClose(LastTicket, LastLots, LastClosePrice, slippage, Yellow);		 
	          ContinueOpening = False;
	          return(0);
	        }

//----
   if(myOrderType == 1 && ContinueOpening && (Long_Short|| Short_Only)) 
     {	
       if((Bid - LastPrice) >= Pips*Point || OpenOrders < 1) 
         {		
           SellPrice = Bid;				
           LastPrice = 0;
           //----
           if(TakeProfit == 0) 
               tp = 0; 
           else 
               tp = SellPrice - TakeProfit*Point; 
           //----
           if(InitialStop == 0) 
               sl = 0; 
           else 
               sl = SellPrice + InitialStop*Point;  
           //----
           if(OpenOrders >=2) 
             {
               mylotsi = 2*mylotsi;			
               //----
		       } 
		         else 
		             mylotsi=lotsi; 
		         //----
        
		       res=OrderSend(Symbol(), OP_SELL, mylotsi, SellPrice, slippage, sl, tp,"MTF EA Sell",magic, 0, Red);
		     if (res < 0)
         mylotsi=mylotsi/2;	    		    // i.e if opening of order failed.
          else 
           {
               ActiveOrders++;              // increament open orders.
              if(ActiveOrders==1) AllTP=tp;
            else
               ModifyTP(tp);
           
           }
		         return(0);
	        }
     }     
   if(myOrderType == 2 && ContinueOpening&& (Long_Short|| Long_Only)) 
     {
       if((LastPrice-Ask) >= Pips*Point || OpenOrders < 1) 
         {		
           BuyPrice = Ask;
           LastPrice = 0;
           //----
           if(TakeProfit == 0) 
               tp = 0; 
           else 
               tp = BuyPrice + TakeProfit*Point; 
           //----
           if(InitialStop==0)  
               sl = 0; 
           else 
               sl = BuyPrice - InitialStop*Point; 
           //----
           if(OpenOrders >=2) 
             {
               mylotsi = 2*mylotsi;
             } 
           else 
               mylotsi = lotsi; 
           //----
         //  if(mylotsi > 100) 
         //      mylotsi = 100; 
         res=OrderSend(Symbol(), OP_BUY, mylotsi, BuyPrice, slippage, sl, tp, "MTF EA Buy", magic, 0,Blue);
         if (res < 0)
         mylotsi=mylotsi/2;	    		    // i.e if opening of order failed.
          else 
           {
               ActiveOrders++;              // increament open orders.
              if(ActiveOrders==1) AllTP=tp;
              else ModifyTP(tp);
         
           }
                  
            return(0);
         }
     }                                
//----                                                                
   return(0);                                                                                 
  }
  
 void ModifyTP(double tp) 
  {
   int cnt;
    // if we have opened positions we take care of them
   for(cnt =0;cnt <=OrdersTotal() ;  cnt++)
     {
       OrderSelect(cnt, SELECT_BY_POS,MODE_TRADES);
	      //----
       if(OrderSymbol() == Symbol() && OrderMagicNumber()==magic) 
	         {	
	  	       if(OrderType() == OP_SELL) 
	  	  	      if( OrderModify(OrderTicket(),OrderOpenPrice(), OrderStopLoss(),tp, 1000, Purple)) Comment("\n\n\n\n MODIFYING ORDER........");
	  					                //   return(0);	  					
	  		   }
	  	       if(OrderType() == OP_BUY)
	  	      {
	  		      if( OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), tp, 1000, Purple))Comment("\n\n\n\n MODIFYING ORDER........");
                                //   return(0);
				}
   	     
     } 
  }// 
 
  
double dailyprofit()
{
  int day=Day(); double res1=0,res2=0;
  
  for(int i=0; i<OrdersHistoryTotal(); i++)
  {   
      OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(OrderMagicNumber()!=magic) continue;
      if(TimeDay(OrderOpenTime())==day) res1+=OrderProfit();
  }
  
 for(i=0; i<OrdersTotal(); i++)
  {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);   
      if(OrderMagicNumber()!=magic) continue;
      if(TimeDay(OrderOpenTime())==day) res2+=OrderProfit();
  }
  
  return(res1+res2);
}
//+------------------------------------------------------------------+

Ti ringrazio in anticipo per il tuo prezioso tempo!:bow:

Ciao Syson, qui sotto allego una gestione del trailing stop a mio avviso molto interessante ed originale che lavora in modo proporzionale, se riesci ad integrarla nel precedente EA diventi il mio idolo!!!:bow:

Codice:
// trade assistant - to watch after SL's for your trades
// some ideas and code fragments: "S.Projects" - "cortex.snowcron.com"
 
 
extern int logging=1;
//logging=1  - if you want logs in Experts\Files directory
extern int nTrailingStop=35;
//nTrailingStop [pips] - initial trailing stop. It will be used until your trade will reach profit = nPropSLThreshold
extern int nPropSLThreshold=12;
//nPropSLThreshold [pips] - after reaching this profit proportional trailing stop will be used
extern double dPropSLRatio=0.35;
//dPropSLRatio [decimal] - multiplying factor ( PropSL = Profit * dPropSLRatio  - Spred )
extern int nUseEscape=0;
//nUseEscape [ 1 or 0 ] - escape misplaced trades as soon as they reach some minimal profit
extern int nEscapeLevel=0;
//nEscapeLevel [pips] - lose size after which we want our trade to terminate 
//as soon as it will reach next high
extern int nEscapeTP=35;
//nEscapeTP [pips] - take profit level in pips (you can set to negative value 
//- then it will be a lose that you would be happy to get, 
//in the case your trade reached some impressive negative pips value)
 
double dEscapeLevel;
double dStopLoss;
double dTrailingStop;
double dEscapeTP;
double dPropSLThreshold;
double dTakeProfit;
double dTakeProfitMin;
double dTakeProfitMax;
double dTakeProfitT;
int nBars, nSpread, nDigits, nBarsSameTrend, nCloseErr, nOpenErr, i;
 
double dDeltaPrice, dnBid, dnAsk, dSpread, dStopLevel, dMax, dMin, dMacdDelta, dMacd1, dMacd2;
 
// double dOldBalance, dNewBalance;
 
int nTakeProfitMax=100;
extern int nSlip = 2;
int nBarsSinceTrade=0;
 
string strExpert = "tp-1.0.0";
 
// ------
 
int init ()
{
   nBars = Bars;
   nSpread = MarketInfo(Symbol(), MODE_SPREAD);
   dSpread = NormalizeDouble(nSpread * Point,4);
   nDigits = MarketInfo(Symbol(), MODE_DIGITS);
   dEscapeTP = NormalizeDouble(nEscapeTP * Point,4);  
 
   dEscapeLevel = nEscapeLevel * Point;
 
   return(0);
}
 
// ------
int deinit()
{
   return(0);
}
 
// ------
 
int start()
{ 
 
   // ------
   // to let MT rest a bit after new bar:
   // Sleep(2500);
   // RefreshRates();
   
   
   dnBid=NormalizeDouble(Bid,nDigits);
   dnAsk=NormalizeDouble(Ask,nDigits); 
 
   ModifyOrders();
 
   // ------
 
   return(0);
}
 
 
// ------
 
void ModifyOrders()
{ 
   double dSl;
   double arrSL[4];
   double arrTP[4];
 
   dTrailingStop = NormalizeDouble(nTrailingStop * Point,4);
   dEscapeTP = NormalizeDouble(nEscapeTP * Point,4);
   dPropSLThreshold = nPropSLThreshold * Point;
   dSpread = MarketInfo(Symbol(),MODE_SPREAD) * Point;
   dStopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL) * Point;
  
   for(int nCnt = 0; nCnt < OrdersTotal(); nCnt++)
   {
      OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
      if(true) //(OrderMagicNumber() == nMagic)
      {
         if(OrderType() == OP_BUY)
         { 
            dSl=OrderStopLoss();
            if( dSl == 0 )
            dSl = dnBid - dTrailingStop;
   
            arrSL[0]=dSl; 
            arrSL[1]=dSl; 
            arrSL[2]=dSl;
            arrSL[3]=dSl;
 
            LogSL("OP_BUY-check",dSl,arrSL[0],arrSL[1],arrSL[2],arrSL[3]);
   
            // if( Bid > OrderOpenPrice() + dMaSLDelta )
            // arrSL[3]=OrderOpenPrice() + dMaSLDelta;
 
 
            if( dPropSLRatio > 0 ) 
            {
               if( Bid > (OrderOpenPrice() + dPropSLThreshold) )
               {
                  dSl = NormalizeDouble( OrderOpenPrice() + dPropSLRatio*(Bid - OrderOpenPrice()) - dSpread,4 ); 
                  if(OrderStopLoss() < dSl)
                  arrSL[1]=dSl;
               } 
            }
 
            if(Bid < OrderOpenPrice() + 4*dSpread )
            {
               arrSL[2]=dnBid - dTrailingStop;
            }
 
            dSl=arrSL[ArrayMaximum(arrSL)];
 
            LogSL("OP_BUY - max",dSl,arrSL[0],arrSL[1],arrSL[2],arrSL[3]);
 
            if( dSl > OrderStopLoss() || OrderStopLoss() == 0 )
               {
                  OrderModify(OrderTicket(), OrderOpenPrice(), 
                     dSl, OrderTakeProfit(), 0, Yellow);
                  Log("Buy - modify", 8888, 8888, 0, nBarsSameTrend, OrderOpenPrice(), dSl);
               }
 
            // Escape buy
            //if( dEscape != 0 && dnBid < OrderOpenPrice() - dEscape - 5 * Point ) 
            if( nUseEscape == 1 && dnBid < OrderOpenPrice() - dEscapeLevel - 5 * Point ) 
            {
               OrderModify(OrderTicket(), OrderOpenPrice(), 
               OrderStopLoss(), OrderOpenPrice() + dEscapeTP, 0, Aqua);
               Log("Buy - EscapeLevel", 8888, 8888, 0, nBarsSameTrend, OrderOpenPrice(), dSl);
            }
 
         } // end OP_BUY
 
////////////////////////////////////////////////////////////////////////////////////////////////// 
 
         if(OrderType() == OP_SELL)
         {
            dSl=OrderStopLoss();
            if( dSl == 0 )
            dSl = dnAsk + dTrailingStop;
            arrSL[0]=dSl; 
            arrSL[1]=dSl; 
            arrSL[2]=dSl;
            arrSL[3]=dSl;
 
            nBarsSinceTrade=GlobalVariableGet("tp-100-BarsSinceTrade") + 1;
            GlobalVariableSet("tp-100-BarsSinceTrade",nBarsSinceTrade);
 
 
            //if( nBarsSinceTrade >= 1 && nBarsSinceTrade < 3 )
            // if( Ask < OrderOpenPrice() - dMaSLDelta )
            // arrSL[3]=OrderOpenPrice() - dMaSLDelta;
 
            if( dPropSLRatio > 0 ) 
            {
               if( Ask < (OrderOpenPrice() - dPropSLThreshold) )
               {
                  dSl = NormalizeDouble( OrderOpenPrice() - dPropSLRatio*(OrderOpenPrice() - Ask) + dSpread,4 ); 
                  if( dSl < OrderStopLoss() )
                  arrSL[1]=dSl;
               } 
            }
 
            if( Ask > OrderOpenPrice() - 4*dSpread )
               arrSL[2]=dnAsk + dTrailingStop + dSpread;
 
            dSl=arrSL[ArrayMinimum(arrSL)];
            //if( dSl == 0 )
           // dSl = arrSL[0];
 
            LogSL("OP_SELL - min",dSl,arrSL[0],arrSL[1],arrSL[2],arrSL[3]);
 
            if( dSl < OrderStopLoss() || OrderStopLoss() == 0 )
            {
               OrderModify(OrderTicket(), OrderOpenPrice(), 
                  dSl, OrderTakeProfit(), 0, Yellow);
               Log("Sell - modify", 8888, 8888, 0, nBarsSameTrend, OrderOpenPrice(), dSl);
            }
 
            // Escape sell
            //if( dEscape != 0 && dnAsk > OrderOpenPrice() + dEscape + 5 * Point ) 
            if( nUseEscape == 1 && dnAsk > OrderOpenPrice() + dEscapeLevel + 5 * Point ) 
            {
               OrderModify(OrderTicket(), OrderOpenPrice(), 
               OrderStopLoss(), OrderOpenPrice() - dEscapeTP, 0, Aqua);
               
               Log("Buy - EscapeLevel", 8888, 8888, 0, nBarsSameTrend, OrderOpenPrice(), dSl);
            }
 
         } // End OP_SELL
      } //end if(OrderMagicNumber() == nMagic)
 
   } //end for(int nCnt = 0; nCnt < OrdersTotal(); nCnt++)
} // end ModifyOrders()
 
 
////////////////////////////////////////////////////////////////////////////////////////////////// 
 
 
void Log(string msg, double val1, double val2, double val3, double val4, double val5, double val6)
{
   if(logging > 0 )
   { 
      int handle;
      handle=FileOpen("tp-100-log.txt",FILE_CSV|FILE_READ|FILE_WRITE,';');
      if(handle<1)
      {
         Print("File tp-100-log.txt not found, the last error is ", GetLastError());
         return(false);
      }
 
      FileSeek(handle, 0, SEEK_END);
      //---- add data to the end of file
      //FileWrite(handle, Year(), Month(), Day(), Hour(), Minute(), "Bid, Ask ", msg, Bid, Ask, "___", val1, val2, val3, val4, val5, val6);
      FileWrite(handle, Year(), Month(), Day(), Hour(), Minute(), msg, Bid, Ask, 8888, "___", val1, val2, "___", val3, val4, "___", val5, val6);
      FileClose(handle);
   }
}
 
 
void LogSL(string msg, double val1, double val2, double val3, double val4, double val5)
{
   if(logging > 0 )
   { 
      int handle;
      handle=FileOpen("tp-100-log-sl.txt",FILE_CSV|FILE_READ|FILE_WRITE,';');
      if(handle<1)
      {
         Print("File tp-100-log-sl.txt not found, the last error is ", GetLastError());
         return(false);
      }
      FileSeek(handle, 0, SEEK_END);
      //---- add data to the end of file
      FileWrite(handle, Year(), Month(), Day(), Hour(), Minute(), msg, Bid, Ask, val1, val2, val3, val4, val5);
      FileClose(handle);
   }
}
 
ciao,

l'ultimo ea postato e' completo?

per farlo girare su meta trader 4 come devo fare?


ps. io avrei un trading system molto facile da fare..ma guardando le statistiche di uno simile potrebbe rendere con un capitale di 10k sui 500 euro al mese.


lo descrivo:

Eur/Usd se scende di 200 apre sell 0.05 con take profit +200 -200
apro 1.44400 tp 14600 sl 14200

se sale l'opposto.


se l'operazione 0.05 prende lo stop loss apro 0.10 con stop loss e take profit e take profit sempre 300 e - 300

se l'operazione 0.10 prende lo stop loss si apriranno a loro volta 0.20 0.40 0.80...

questi raddoppi vorrei pero' che puntassero (gestendo i tp) al pareggio dell'intera operazione non al guadagno. (cosi' da avere piu' chance di chiudere il ciclo (non di guadagnare), quindi tp piu' corti dello sl) o cmq vedi tu...

quando il sistema apre la posizione 0.20 vorrei ripartisse un secondo sistema normalmente da 0.05.

il sistema, preso lo sl o il tp a 0.80 deve fermarsi e incassare la perdita

pps. vorrei che fosse presente la possibilita' che il venerdi' non appena si chiudono le operazioni il sistema non parta piu' fino a domenica notte all'una.


GRAZIEEEEEEEEEE

ps. prometto che se lo fai posto mensilmente i report.
e' semplice e ******. ma stoppando le perdite secondo me puo' essere interessante.


Ho pensato di puntare al pareggio perche' un'altro trading system che partiva cosi' chiudeva circa 107 operazioni al primo lotto 0.05 e altre 107 andavano poi raddoppiate etc etc...


Non voglio guadagnare con i raddoppi, diventa troppo rischioso e voglio poter contabilizzare una perdita sicura non illimitata.

la statistica su 3 mesi era circa questa: (al mese) 107 operazioni chiuse in guadagno alla prima posizione aperta

38 alla seconda 37 alla terza.

poi 10, 8 7 6 e via dicendo...arrivando ad aprire settimanalmente lotti da 1.80 o addirittura 3.60 che poi andavano gestiti manualmente.


quindi..chiudendo le prime due in profitto dovrebbe fare

107 + 38 positive. 145.

214 (numero operazioni mensili)

quindi 214 - 145. rimangono 69 operazioni. che il sistema dovrebbe cercare di chiudere in pareggio con i lotti 0.20 0.40 0.80.

il motivo di chiuderle in pareggio e' proprio per avere piu' chance (mettendo tp piu' stretti) che il sistema si chiuda...

il profitto dovrebbe essere cosi'

107 * 7 (op 0.05) 749 + (circa 14 - 7) operazioni chiuse a 0.10 * 38= 266

266 + 749= 1015

a cui vanno tolte le operazioni (ahime mazzete) chiuse a 0.80 in perdita.


Visto che lo farei girare su 10.000 euro un profitto di anche 250 euro al mese sarebbe ottimo. e sopratutto potrebbe davvero essere un sistema da non guardare ne controllare mai.

Grazie mille ragazzi
 
Ultima modifica:
ciao,

l'ultimo ea postato e' completo?

per farlo girare su meta trader 4 come devo fare?


ps. io avrei un trading system molto facile da fare..ma guardando le statistiche di uno simile potrebbe rendere con un capitale di 10k sui 500 euro al mese.


lo descrivo:

Eur/Usd se scende di 200 apre sell 0.05 con take profit +200 -200
apro 1.44400 tp 14600 sl 14200

se sale l'opposto.


se l'operazione 0.05 prende lo stop loss apro 0.10 con stop loss e take profit e take profit sempre 300 e - 300

se l'operazione 0.10 prende lo stop loss si apriranno a loro volta 0.20 0.40 0.80...

questi raddoppi vorrei pero' che puntassero (gestendo i tp) al pareggio dell'intera operazione non al guadagno. (cosi' da avere piu' chance di chiudere il ciclo (non di guadagnare), quindi tp piu' corti dello sl) o cmq vedi tu...

quando il sistema apre la posizione 0.20 vorrei ripartisse un secondo sistema normalmente da 0.05.

il sistema, preso lo sl o il tp a 0.80 deve fermarsi e incassare la perdita

pps. vorrei che fosse presente la possibilita' che il venerdi' non appena si chiudono le operazioni il sistema non parta piu' fino a domenica notte all'una.


GRAZIEEEEEEEEEE

ps. prometto che se lo fai posto mensilmente i report.
e' semplice e ******. ma stoppando le perdite secondo me puo' essere interessante.


Ho pensato di puntare al pareggio perche' un'altro trading system che partiva cosi' chiudeva circa 107 operazioni al primo lotto 0.05 e altre 107 andavano poi raddoppiate etc etc...


Non voglio guadagnare con i raddoppi, diventa troppo rischioso e voglio poter contabilizzare una perdita sicura non illimitata.

la statistica su 3 mesi era circa questa: (al mese) 107 operazioni chiuse in guadagno alla prima posizione aperta

38 alla seconda 37 alla terza.

poi 10, 8 7 6 e via dicendo...arrivando ad aprire settimanalmente lotti da 1.80 o addirittura 3.60 che poi andavano gestiti manualmente.


quindi..chiudendo le prime due in profitto dovrebbe fare

107 + 38 positive. 145.

214 (numero operazioni mensili)

quindi 214 - 145. rimangono 69 operazioni. che il sistema dovrebbe cercare di chiudere in pareggio con i lotti 0.20 0.40 0.80.

il motivo di chiuderle in pareggio e' proprio per avere piu' chance (mettendo tp piu' stretti) che il sistema si chiuda...

il profitto dovrebbe essere cosi'

107 * 7 (op 0.05) 749 + (circa 14 - 7) operazioni chiuse a 0.10 * 38= 266

266 + 749= 1015

a cui vanno tolte le operazioni (ahime mazzete) chiuse a 0.80 in perdita.


Visto che lo farei girare su 10.000 euro un profitto di anche 250 euro al mese sarebbe ottimo. e sopratutto potrebbe davvero essere un sistema da non guardare ne controllare mai.

Grazie mille ragazzi

Con i dovuti settaggi quello che hai in mente si può fare con l'ea che ho appena postato (andrebbe però perfezionato il MM con il trailing stop come richiesto s Syson), prova ad utilizzare un massimo di due ordini con stop loss e take profit stretti e vedrai che diventerà profittevole, allego l'eseguibile OK!
 

Allegati

  • MTF rsi_sar.mq4
    14 KB · Visite: 171
Ultima modifica:
spetta....l'allegato che hai postato e' del sistema prima o del mio?
 
spetta....l'allegato che hai postato e' del sistema prima o del mio?

MTF rsi_sar.mq4‎ è l'eseguibile dell'ultimo EA che ho copiato a Syson per chiedere l'aggiunta del trailing stop, lavora con RSI/SAR/BB può effettuare martingale, stop loss, take profit e può essere settato un ritracciamento minimo ad ogni nuovo ingresso.
 
ma io per aprirlo che software devo usare?

scusa ma proprio non so nulla di come 'scrivere e/o modificare un ts'..


sorry..se mi dai qualche breve indicazione mi faresti un favorone
 
allora ho copiato il file mq4 nella cartella experts...poi ho aperto dall'interno della metatrader4 il compilatore, mi da il seguente errore:

'MTF rsi_sar.mq4' in fase di compilazione...
Function "dailyprofit" is not referenced and will be removed from exp-file
0 errore(i), 1 avvertimento(i)


e' per questo che non mi trova poi alcun indicatore?
 
allora ho copiato il file mq4 nella cartella experts...poi ho aperto dall'interno della metatrader4 il compilatore, mi da il seguente errore:

'MTF rsi_sar.mq4' in fase di compilazione...
Function "dailyprofit" is not referenced and will be removed from exp-file
0 errore(i), 1 avvertimento(i)


e' per questo che non mi trova poi alcun indicatore?

Come già anticipato a Syson nei miei precedenti post quello è un errore che non compromette la bontà del sistema, l'unica necessità è quella di far lavorare il trailing profit poi sarà "completo"

Guarda questo video se non sai come installare e testare gli EA Come eseguire un Test di strategia sulla MetaTrader4 - YouTube

Syson se ci sei batti un colpo!:D
 
Ragazzi, scusate, sto provando diversi EA in un account demo. Ne ho provati più di uno, in diversi grafici. C'è un modo per vedere quale EA mi ha aperto e chiuso le posizioni? Ho fatto l'errore di metterne troppi, ne avevo 4, che operavano su eur/usd, ma in timeframe differenti. Ora devo vedere chi ha fatto cappelle e chi no.
Grazie
 
..??????????????????????????..

Scusa blond.......


Ma il magic number non lo usi????


(stai testando in mt4 giusto??)
 
Ciao, sì, sto trandando con mt4. Ma siccome l'account demo lo seguo poco, gli ho buttato sopra 3 EA diversi. E scusa l'ignoranza, ma il magic number sarebbe?
 
Ciao, sì, sto trandando con mt4. Ma siccome l'account demo lo seguo poco, gli ho buttato sopra 3 EA diversi. E scusa l'ignoranza, ma il magic number sarebbe?

Il Magic Number è un numero che puoi assegnare ad ogni ordine aperto da un determinato ea. Così puoi, ad esempio, dire all'ea di chiudere solo gli ordini aperti da lui in precedenza.

per Syson: mi piace moltissimo il modo in cui gestisci gl iinvii degli ordini usando un ciclo while; suggerisco di utilizzare anche IsTradeContextBusy
Fare qualcosa del tipo:
if(!IsTradeContextBusy)
{
//invia l'ordine etc. etc..
}



Ciao
 
Il Magic Number è un numero che puoi assegnare ad ogni ordine aperto da un determinato ea. Così puoi, ad esempio, dire all'ea di chiudere solo gli ordini aperti da lui in precedenza.


Ciao

Ho controllato, e tutti gli EA hanno i magic numbers. Ora, come posso distinguere gli ordini dei diversi EA? Ho guardato nello storico, ma non ho visto riferimenti agli EA.
Ancora grazie.
 
Ho controllato, e tutti gli EA hanno i magic numbers. Ora, come posso distinguere gli ordini dei diversi EA? Ho guardato nello storico, ma non ho visto riferimenti agli EA.
Ancora grazie.

Allora, se conosci il magic number che ogni ea assegna agliordini che apre, puoi crearti un piccolo script che te li elenca, ad esempio

string desc_ea;
for(int i = 0; i < OrdersHistoryTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS) == true)
{
if(OrderMagicNumber() == 1)
{
desc_ea = "pincopallo";
Alert("ordine nr " +
OrderTicket() +
" aperto il: " +
OrderOpenPrice() +
" dallo ea: " +
desc_ea);
}
else if(OrderMagicNumber() == 2)
{
desc_ea = "vattelapesca";
Alert("ordine nr " +
OrderTicket() +
" aperto il: " +
OrderOpenPrice() +
" dallo ea: " +
desc_ea);
}
}
}


Ciao
 
Salve.

Ho appena appurato che non posso propormi come money manager.
Avrei fatto tutto gestendo i conti tramite un EA, ma visto che in Italia tale pratica è considerata illegale, non avendo soldi miei da gestire, né soldi di terzi da poter gestire, cercherò almeno di rendermi utile in quest'altra maniera, scrivendo cioè codice mql4 per chi non ne fosse in grado.
Ogni riga di codice eventualmente scritta sarà resa pubblica, perciò invito chiunque non volesse rendere note le proprie strategie a non proporle qua, né a contattarmi in privato.

Dite pure.

Ciao Syson, sono nuovo qui (non del forex), saluti a tutti!
dunque: Ho vari metodi di trading sul forex che vorre automatizzare in maniera che siano sempre attivi anche a pc spento! naturalmente non capisco un acc. di MQL ne di Java. Puoi, Vuoi aiutarmi? L'appello è rivolto eventualmente anche ad altre persone capaci di scrivere queste diavolerie personalizzate. Grazie + grazie...
 
MTF rsi_sar.mq4‎ è l'eseguibile dell'ultimo EA che ho copiato a Syson per chiedere l'aggiunta del trailing stop, lavora con RSI/SAR/BB può effettuare martingale, stop loss, take profit e può essere settato un ritracciamento minimo ad ogni nuovo ingresso.


Scusami per il disturbo.... non sarebbe possibile avere la versione per VT di questo ts?
grazie
 
ciao, apprezzo molto la disponibilità! mi servirebbe un'aggiunta a questo expert che ho fatto io scopiazzando qua e là, attualmente se i trades son in positivo di almeno un numero predefinito di pips sposta lo stop in pari. vorrei che chiudesse tutte le posizioni qualora il guadagno (parliamo di floating non di beginning equity+x )raggiunga x euro, puoi aiutarmi?

extern double e_BreakEvenStop = 15;
double g_Point = 0.0001;
int init() {
if (Point == 0.00001) g_Point = 0.0001;
else {
if (Point == 0.001) g_Point = 0.01;
else g_Point = Point;
}
return (0);
}
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
string curr = Symbol();
int ot = OrdersTotal();
int ords[200], ordType[200], ordTicket[200]; double ordLots[200];
string ordComments[200];
int ix=0;
for (int i=0; i<ot; i++)
{
int o = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol())
if ((OrderType() == OP_BUY) || (OrderType() == OP_SELL))
{
double sl = 0;
if ((OrderType() == OP_BUY) && (Bid - OrderOpenPrice()) > (e_BreakEvenStop * g_Point))
sl = OrderOpenPrice() ;
if ((OrderType() == OP_SELL) && (OrderOpenPrice() - Ask) > (e_BreakEvenStop * g_Point))
sl = OrderOpenPrice() ;

if (sl != 0)
OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
 
Ultima modifica:
Indietro