/*[[ Name := OnlyProfit1.0 Author := Copyright © 2005, HomeTrade Co. Link := http://www.zzz.fromru.com Lots := 1.0 Stop Loss := 1000 Take Profit := 10 Trailing Stop := 1000 ]]*/ Define: Cor(5); Define: depth(12); Define: deviation(5); Define: backstep(3); Array: handle[4](0); Var: cnt(0),ttime(0),ZigZagOld(0),oldtrend(0),minc(1.22),i(0); Var: ZigZag(0),stopper(0),trend(0),j(0),k(0),m(0),maxc(1.22),n(0); if Symbol = "USDCHF" then i=1;if Symbol = "USDJPY" then i=2; if Symbol = "GBPUSD" then i=3;if Symbol = "EURUSD" then i=4; j=j+1; //------------------------------Close posicions--------------------------------- if Totaltrades>0 then Begin ttime=0; // не порали проверить открытые позиции if (OrderValue(cnt,VAL_TYPE)=OP_SELL and OrderValue(cnt,VAL_SYMBOL)=Symbol) then begin k=k+1; if (CurTime-LastTradeTime)>3600 and OrderValue(cnt,VAL_PROFIT)>=50 then begin stopper=0; CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,5,Gold);exit;end;end; if (OrderValue(cnt,VAL_TYPE)=OP_BUY and OrderValue(cnt,VAL_SYMBOL)=Symbol) then begin m=m+1; if (CurTime-LastTradeTime)>3600 and OrderValue(cnt,VAL_PROFIT)>=50 then begin stopper=0; CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,6,Red);exit;end; end;end; //--------------------------------Indicators Setting----------------------------- if j>=3 then begin handle[i]=FileOpen("zzold"+i,"!");FileSeek( handle[i],0,SEEK_SET ); ZigZagOld=FileReadNumber(handle[i]); FileClose(handle[i]);end; ZigZag=iCustom("ZigZag",depth,deviation,backstep,MODE_FIRST,0); if ZigZag<>0 and ZigZagOld<>0 and ZigZag<>ZigzagOld then begin if n<=Cor then begin n=n+1; if ZigZag=L and n>=Cor then begin trend=1;n=0;end; if ZigZag=H and n>=Cor then begin trend=-1;n=0;end;end;end; //if abs(ZigZag-ZigzagOld)*point<10 then trend=0;// if ZigZag=0 then n=0; Comment ("Stoppper=",stopper," ","Trend=",trend," ","ZZOld=",ZigZagOld," ","ZZ=",ZigZag, "\nISell=",k," ","IBuy=",m," ","Index=",j," ","AllPos=",Totaltrades," ","Corr=",Cor); //---------------------------------------------------------------------------------- If ZigZag=0 or time=ttime then exit; ttime=time; //------------------------------Open posicions---------------------------------- if Totaltrades<2 and Balance>4000 and FreeMargin>3000 then Begin for cnt=1 to TotalTrades begin if OrderValue(cnt,VAL_SYMBOL)=Symbol then exit;end; If CurTime > LastTradeTime + 15 Then Begin if (trend=-1 and stopper=0 and ZigZag<=H and ZigZag>C) then begin SetOrder(op_Sell,lots,PriceBid,5,Ask+stoploss*Point,Bid-TakeProfit*Point,Gold); SetArrow(Time[0],ZigZag,242,Gold);k=0;m=0;stopper=1;exit;end; if (trend=1 and stopper=0 and ZigZag>=L and ZigZag0 then begin j=0; handle[i] = FileOpen("zzold"+i,"!"); FileSeek(handle[i],0,SEEK_SET);FileWrite(handle[i],ZigZag);FileClose(handle[i]);end; //--------------------------------------------------------------------------------