// License Agreement // Forex-Experts hereby grants you a non-exclusive license to use its accompanying software product provided that, // 1) Licensee does not utilize the software in a manner which is disparaging to Forex-Experts. // 2) Rent, lease, transfer or otherwise transfer rights to the Software; or remove any proprietary notices or labels on the Software. // This license does not grant you any right to any enhancement or update with distribution purpose. // Title, ownership rights, and intellectual property rights in and to the Software shall remain in Forex-Experts. // The Software is protected by the international copyright laws. Title, ownership rights, and intellectual property rights in and to the content // accessed through the Software is the property of the applicable content owner and may be protected by applicable copyright or other law. // This License gives you no rights to such content. // This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, // INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. // FOREX-EXPERTS AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE // OR ITS DERIVATIVES. IN NO EVENT WILL FOREX-EXPERTS OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL // CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY // TO USE SOFTWARE, EVEN IF FOREX-EXPERTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. // This software is not designed or intended for use in on-line control of aircraft, air traffic, aircraft navigation or aircraft communications; // or in the design, construction, operation or maintenance of any nuclear facility. Licensee represents and warrants that it will not use or // redistribute the Software for such purposes. /*[[ Name := NewsTrader ver. 2.3 Author := Ver.2.3 Copyright © 2005, Forex-Experts. Link := http://www.forex-experts.com/ Notes := Set stops orders before news Lots := 0.10 Stop Loss := 15 Take Profit := 30 Trailing Stop := 15 ]]*/ Var: Ver(""),Owner(""); Ver="2.3 "; Owner="Mr. Robert Ross Todd"; Var: ValL(""); ValL="NewsTrader ver. "+Ver+" "+Owner+"\nFor support go at http://www.forex-experts.com"; Comment(ValL); Defines: SHour1(14),SMinute1(29); //Time to set Far orders Defines: SHour2(14),SMinute2(20); //Time to set Low orders Defines: Sday(0); //Day of month to set orders, if =0 then set orders every day. Defines: Setmin(1); // How long sets orders Defines: Dist(1); Defines: TotalOrd(1); //How many orders to sets Defines: OrdLife1(2); //Delete stops orders after this time, in Minute Defines: OrdLife2(30); //Delete stops orders after this time, in Minute Defines: Range1(15), Range2(50); Defines: Stop1(15), Stop2(30); Defines: Profit1(120), Profit2(100); Defines: ProfitZero(15); Defines: Lots1(0.8),Lots2(0.4); Defines: AutoTS(0); Defines: SetOrders(1); //If 1 - set orders, 0 - delete orders Defines: Patr(9),kts(4); // Calculate stops Defines: Slippage(5); Var: TimeSet1(0),TimeSet2(0); Variable: cnt(0),OpenPos(0),mode(0),ATR(0),VStop2(0),ModBuy(0),ModSell(0),DaySet(0); ATR=(Ceil(iATR(Patr,1)*10000))/10000; If Sday=0 Then { DaySet=Day; } Else { DaySet=Sday; }; TimeSet1=StrToTime(Year+"."+Month+"."+DaySet+" "+SHour1+":"+SMinute1); TimeSet2=StrToTime(Year+"."+Month+"."+DaySet+" "+SHour2+":"+SMinute2); //Condition to set orders OpenPos=0; for cnt=1 to TotalTrades { If Ord(cnt,VAL_SYMBOL)=Symbol) AND (Ord(cnt,VAL_TYPE)=OP_SELLSTOP OR Ord(cnt,VAL_TYPE)=OP_BUYSTOP) Then { OpenPos=OpenPos+1; } } If TotalOrd=1 And (CurTime-TimeSet1>=0 And CurTime-TimeSet1<=Setmin*60) And SetOrders=1 Then { //Two orders If (TotalOrd=1 Or TotalOrd=2) And OpenPos=0 Then { SetOrder(OP_SEllSTOP,Lots1,bid-Range1*point,Slippage,Bid-Range1*point+(Stop1*Point),bid-Range1*point-Profit1*Point,RED); Exit; } If (TotalOrd=1 Or TotalOrd=2) And OpenPos=1 Then { SetOrder(OP_BUYSTOP,Lots1,ask+Range1*point,Slippage,Ask+Range1*point-(Stop1*Point),ask+Range1*point+Profit1*Point,Blue); Exit; } } //Two orders If TotalOrd=2 Then { If ((CurTime-TimeSet2>=0) And (CurTime-TimeSet1<0)) And SetOrders=1 Then { If (TotalOrd=1 Or TotalOrd=2) And OpenPos=0 Then { SetOrder(OP_SEllSTOP,Lots2,bid-Range2*point,Slippage,Bid-Range2*point+(Stop2*Point),bid-Range2*point-Profit2*Point,RED); Exit; } If (TotalOrd=1 Or TotalOrd=2) And OpenPos=1 Then { SetOrder(OP_BUYSTOP,Lots2,ask+Range2*point,Slippage,Ask+Range2*point-(Stop2*Point),ask+Range2*point+Profit2*Point,Blue); Exit; } //If CurTime - LastTradeTime < 10 Then Exit; If TotalOrd=2 And OpenPos=2 Then { If Ord(1,VAL_SYMBOL)=Symbol) AND (Ord(1,VAL_TYPE)=OP_SELLSTOP AND Abs(bid-Range2*point-Ord(1,VAL_OPENPRICE))>Dist*point And ModSell=0 Then { //Modify Sellstop ModSell=1; ModBuy=0; ModifyOrder(Ord(1,VAL_TICKET),bid-Range2*point,Bid-Range2*point+(Stop2*Point),bid-Range2*point-Profit2*Point,Aqua); Exit; } If Ord(1,VAL_SYMBOL)=Symbol) AND (Ord(1,VAL_TYPE)=OP_BUYSTOP AND Abs(ask+Range2*point-Ord(1,VAL_OPENPRICE))>Dist*point And ModBuy=0 Then { //Modify BuyStop ModSell=0; ModBuy=1; ModifyOrder(Ord(1,VAL_TICKET),ask+Range2*point,Ask+Range2*point-(Stop2*Point),ask+Range2*point+Profit2*Point,Aqua); Exit; } If Ord(2,VAL_SYMBOL)=Symbol) AND (Ord(2,VAL_TYPE)=OP_SELLSTOP AND Abs(bid-Range2*point-Ord(2,VAL_OPENPRICE))>Dist*point And ModSell=0 Then { //Modify Sellstop ModSell=1; ModBuy=0; ModifyOrder(Ord(2,VAL_TICKET),bid-Range2*point,Bid-Range2*point+(Stop2*Point),bid-Range2*point-Profit2*Point,Aqua); Exit; } If Ord(2,VAL_SYMBOL)=Symbol) AND (Ord(2,VAL_TYPE)=OP_BUYSTOP AND Abs(ask+Range2*point-Ord(2,VAL_OPENPRICE))>Dist*point And ModBuy=0 Then { //Modify BuyStop ModSell=0; ModBuy=1; ModifyOrder(Ord(2,VAL_TICKET),ask+Range2*point,Ask+Range2*point-(Stop2*Point),ask+Range2*point+Profit2*Point,Aqua); Exit; } } } If (CurTime-TimeSet1>=0 And CurTime-TimeSet1<=Setmin*60) And SetOrders=1 Then { //Print("Set Small orders"); If TotalOrd=2 And OpenPos=2 Then { SetOrder(OP_SEllSTOP,Lots1,bid-Range1*point,Slippage,Bid-Range1*point+(Stop1*Point),bid-Range1*point-Profit1*Point,RED); Exit; } If TotalOrd=2 And OpenPos=3 Then { SetOrder(OP_BUYSTOP,Lots1,ask+Range1*point,Slippage,Ask+Range1*point-(Stop1*Point),ask+Range1*point+Profit1*Point,Blue); Exit; } } } If (CurTime-TimeSet1>=0 And CurTime-TimeSet1<=Setmin*60) And SetOrders=0 Then { for cnt=1 to TotalTrades { If (OrderValue(cnt,VAL_TYPE)=OP_SELLSTOP Or OrderValue(cnt,VAL_TYPE)=OP_BUYSTOP) And Ord(cnt,VAL_SYMBOL)=Symbol Then { Deleteorder(ord(cnt,VAL_TICKET),DarkRed); Exit; } } } for cnt=1 to TotalTrades { If TotalOrd=1 Then { If (OrderValue(cnt,VAL_TYPE)=OP_SELLSTOP Or OrderValue(cnt,VAL_TYPE)=OP_BUYSTOP) And TotalOrd=1 And Ord(cnt,VAL_SYMBOL)=Symbol And CurTime-Ord(cnt,VAL_OPENTIME) > OrdLife1*60 And OrdLife1<>0 Then { Deleteorder(ord(cnt,VAL_TICKET),DarkRed); Exit; } } If TotalOrd=2 Then { If (OrderValue(cnt,VAL_TYPE)=OP_SELLSTOP Or OrderValue(cnt,VAL_TYPE)=OP_BUYSTOP) And cnt=3 And Ord(cnt,VAL_SYMBOL)=Symbol And CurTime-Ord(cnt,VAL_OPENTIME) > OrdLife1*60 And OrdLife1<>0 Then { Deleteorder(ord(cnt,VAL_TICKET),DarkRed); Exit; } If (OrderValue(cnt,VAL_TYPE)=OP_SELLSTOP Or OrderValue(cnt,VAL_TYPE)=OP_BUYSTOP) And TotalTrades<=2 And Ord(cnt,VAL_SYMBOL)=Symbol And CurTime-Ord(cnt,VAL_OPENTIME) > OrdLife2*60 And OrdLife2<>0 Then { Deleteorder(ord(cnt,VAL_TICKET),DarkRed); Exit; } } mode=OrderValue(cnt,VAL_TYPE); If (mode=OP_BUY AND Ord(cnt,VAL_SYMBOL)=Symbol) then // if the already opened position were BUY { //Modify stoploss to zero profit If ProfitZero Then { If (Bid-Ord(cnt,VAL_OPENPRICE))>ProfitZero*Point Then { If (Ord(cnt,VAL_STOPLOSS)-Ord(cnt,VAL_OPENPRICE))<0 Then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),Ord(cnt,VAL_OPENPRICE)+Point,Ord(cnt,VAL_TAKEPROFIT),Aqua); }; }; }; // Auto Trailing stop If AutoTS=1 Then Begin If H-Ord(cnt,VAL_OPENPRICE)>ATR*kts and (Ord(cnt,VAL_STOPLOSS)0 then { If (Bid-OrderValue(cnt,VAL_OPENPRICE))>(Point*TrailingStop) then { If OrderValue(cnt,VAL_STOPLOSS)<(Bid-Point*TrailingStop) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), Bid-Point*TrailingStop,OrderValue(cnt,VAL_TAKEPROFIT),Magenta); Exit; }; }; }; //*** End; }; If (mode=OP_SELL AND Ord(cnt,VAL_SYMBOL)=Symbol) then // if the already opened position were SELL { //Modify stoploss to zero profit If ProfitZero Then { If (Ord(cnt,VAL_OPENPRICE)-Ask)>ProfitZero*Point Then { If (Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_STOPLOSS))<0 Then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),Ord(cnt,VAL_OPENPRICE)-Point,Ord(cnt,VAL_TAKEPROFIT),Aqua); Exit; }; }; }; // Auto Trailing stop If AutoTS=1 Then Begin If Ord(cnt,VAL_OPENPRICE)-L>ATR*kts and (Ord(cnt,VAL_STOPLOSS)>L+ATR*kts or Ord(cnt,VAL_STOPLOSS) = 0 ) then Begin ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),L+ATR*kts,Ord(cnt,VAL_TAKEPROFIT),Magenta); Exit; End; End Else Begin If TrailingStop>0 then { If (OrderValue(cnt,VAL_OPENPRICE)-Ask)>(Point*TrailingStop) then { If OrderValue(cnt,VAL_STOPLOSS)=0 or OrderValue(cnt,VAL_STOPLOSS)>(Ask+Point*TrailingStop) then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE), Ask+Point*TrailingStop,OrderValue(cnt,VAL_TAKEPROFIT),Magenta); Exit; }; }; }; //*** End; }; }; // the end