1 - Al backtesting make very few positions open, why is this happening?Code:extern double TakeProfit = 100,StopLoss = 50; extern double Lots = 0.2; extern double TrailingStop = 50; extern double MATrendPeriod=50; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { double MacdCurrent, MacdPrevious, SignalCurrent ; double SignalPrevious, MaCurrent, MaPrevious , PRECIOACTUAL = Bid; int cnt, ticket, total, C, Totalbarras; double MinimoPrecio=Bid, Maximum=Bid; double pips2points, // slippage 3 pips 3=points 30=points pips2dbl, StopLossPips, Slippage.Pips; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); // check TakeProfit } // to simplify the coding and speed up access // data are put into internal variables MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_LWMA,PRICE_HIGH,0); MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_LWMA,PRICE_LOW,1); int counted_bars=IndicatorCounted(); C=Bars-counted_bars; total=OrdersTotal(); // if(total<1) // { // no opened orders identified if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } // check for long position (BUY) possibility // numero de barras Alert("PRECIO ACTUAL= ",PRECIOACTUAL," DIGITOS= ",PRECIOACTUAL ," 1MEDIA= ",MaCurrent," 2MEDIA= ",MaPrevious," bars Min= ",MinimoPrecio," Max= ",Maximum); if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // check for short position (SELL) possibility if(PRECIOACTUAL == MaCurrent ) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",TimeCurrent(),0,Green); { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); } if(MaPrevious== PRECIOACTUAL ) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid+TakeProfit*Point,"macd sample",TimeCurrent(),0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); } // } return(0); }



Reply With Quote
