//+------------------------------------+ //| TRUE_SCALPER | //+------------------------------------+ // // This is the one used successfully by Jean-François // // Designed for M5 but I attached it to M15 and it worked fine. // long if EMA3>EMA7:::EMA3RSIPos) {RSIPOS=true; RSINEG=false;} if(RSI=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if( OrderSymbol()==Symbol() ) { OrdersPerSymbol++; } } // place new order based on direction // only if no other orders are open on this Symbol if(OrdersPerSymbol==0) { //ENTRY Ask(buy, long) if(bullMA3>(bearMA7+p) && RSINEG) { NRTRStopLoss(); SL=NRTRStopLoss();//Ask-(StopLoss*p); TP=Ask+(TakeProfit*p); OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,"BUY"+CurTime(),0,0,White); bartick=0; } //ENTRY Bid (sell, short) if(bullMA3<(bearMA7-p) && RSIPOS) { NRTRStopLoss(); SL=NRTRStopLoss();//Bid+(StopLoss*p); TP=Bid-(TakeProfit*p); OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,"SELL"+CurTime(),0,0,Red); bartick=0; } } //if // have we run out of ticks for average time-to-profit? if(OrdersPerSymbol==1 && bartick==abandon) { if(OrderType()==OP_BUY) { // close losing BUY order to avoid more loss OrderClose(OrderTicket(),Lots,Bid,Slippage,White); // setup and trade new order NRTRStopLoss(); SL=NRTRStopLoss();//Bid+(StopLoss*p); TP=Bid-(TakeProfit*p); OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,"SELL"+CurTime(),0,0,Red); // bump bartick to prevent multiple buys bartick++; } // if BUY if(OrderType()==OP_SELL) { // close losing SELL order to avoid more loss OrderClose(OrderTicket(),Lots,Ask,Slippage,Red); // setup and trade new order NRTRStopLoss(); SL=NRTRStopLoss();//Ask-(StopLoss*p); TP=Ask+(TakeProfit*p); OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,"BUY"+CurTime(),0,0,White); // bump bartick to prevent multiple buys bartick++; } //if SELL } //if OrdersPerSymbol for(cnt=0;cnt SergeyForceProfit*Point ) { OrderClose(OrderTicket(),Lots,Bid,0,White); return(0); } // if profit made } // if magic } // if Buy if(OrderType()==OP_SELL) { if (OrderMagicNumber()==0) { if( OrderOpenPrice()-Ask > (SergeyForceProfit*Point) ) { OrderClose(OrderTicket(),Lots,Ask,0,Red); return(0); } // if profit made } // if magic } //if Sell } // if Symbol } // for return(0); } // start() //Functions double NRTRStopLoss() { /*extern*/ int AveragePeriod=10; /*extern*/ int CountBars=300; double value1[],value2[]; { if (CountBars>iBars(Symbol(),PERIOD_H1)) CountBars=iBars(Symbol(),PERIOD_H1); SetIndexDrawBegin(0,iBars(Symbol(),PERIOD_H1)-CountBars+1); SetIndexDrawBegin(1,iBars(Symbol(),PERIOD_H1)-CountBars+1); int i,counted_bars=IndicatorCounted(); double value; double trend=0,dK,AvgRange,price; //---- if(iBars(Symbol(),PERIOD_H1)<=AveragePeriod) return(0); //---- initial zero if(counted_bars<1) { for(i=1;i<=AveragePeriod;i++) value1[iBars(Symbol(),PERIOD_H1)-i]=0.0; for(i=1;i<=AveragePeriod;i++) value2[iBars(Symbol(),PERIOD_H1)-i]=0.0; } AvgRange=0; for (i=1 ; i<=AveragePeriod ; i++) AvgRange+= MathAbs(iHigh(Symbol(),PERIOD_H1,i)-iLow(Symbol(),PERIOD_H1,i)); if (Symbol() == "USDJPY" || Symbol() == "GBPJPY" || Symbol() == "EURJPY") {dK = (AvgRange/AveragePeriod)/100;} else {dK = AvgRange/AveragePeriod;} if (iClose(Symbol(),PERIOD_H1,CountBars-1) > iOpen(Symbol(),PERIOD_H1,CountBars-1)) { value1[CountBars - 1] = iClose(Symbol(),PERIOD_H1,CountBars-1) * (1 - dK); trend = 1; value2[CountBars - 1] = 0.0; } if (iClose(Symbol(),PERIOD_H1,CountBars-1) < iOpen(Symbol(),PERIOD_H1,CountBars-1)) { value2[CountBars - 1] = iClose(Symbol(),PERIOD_H1,CountBars-1) * (1 + dK); trend = -1; value1[CountBars - 1] = 0.0; } //---- i=CountBars-1; while(i>=0) { value1[i]=0; value2[i]=0; if (trend >= 0) { if (iClose(Symbol(),PERIOD_H1,i) > price) price = iClose(Symbol(),PERIOD_H1,i); value = price * (1 - dK); if (iClose(Symbol(),PERIOD_H1,i) < value) { price = iClose(Symbol(),PERIOD_H1,i); value = price * (1 + dK); trend = -1; } } else { if (trend <= 0) { if (iClose(Symbol(),PERIOD_H1,i) < price) price = iClose(Symbol(),PERIOD_H1,i); value = price * (1 + dK); if (iClose(Symbol(),PERIOD_H1,i) > value) { price = iClose(Symbol(),PERIOD_H1,i); value = price * (1 - dK); trend = 1; } } } if (trend == 1) {value1[i]=value; value2[i]=0.0;} if (trend == -1) {value2[i]=value; value1[i]=0.0;} ObjectCreate("NRTR SL",2,0,CurTime(),value,CurTime(),value,0,0); i--; } return(value); } }//end NRTRStopLoss()