/*[[ Name := Trend_Noise_Trader_v2 Author := Copyright © 2004, David W Honeywell Link := DavidHon@msn.com Lots := 1.00 Stop Loss := 100 Take Profit := 1000 Trailing Stop := 50 ]]*/ // Time Chokes for back-testing If TimeYear(T) < 2004 Then Exit; If TimeMonth(T) < 1 Then Exit; If TimeDay(T) < 1 Then Exit; // User Defined Variables Define: Hour_Begin(0);// This is the hour on the chart that you want this to set trades Define: Trend_Prds_Back(36);// This finds high and low of the Trend(X) periods Define: Noise_Prds_Back(12);// This finds high and low of the Noise(X) periods Define: Range_Plus_Minus(15);// This is the range minus of the high and plus of the low ( Periods_Back ) Define: slippage(3); // Variable used as a position number of the open trades Var: cnt(0); // Variables that change according to price action Var: Trend_High(0); Var: Trend_Low(0); Var: Noise_High(0); Var: Noise_Low(0); Var: Prev_Bar_Close(0); // Number of open trades Variable Var: Open_Trades(0); // Time Delay Variable Var: vTime(0); // Price Action Variables Definitions Trend_High = High[Highest(MODE_HIGH,Trend_Prds_Back,Trend_Prds_Back)]; Trend_Low = Low[Lowest(MODE_LOW,Trend_Prds_Back,Trend_Prds_Back)]; Noise_High = High[Highest(MODE_HIGH,Noise_Prds_Back,Noise_Prds_Back)]; Noise_Low = Low[Lowest(MODE_LOW,Noise_Prds_Back,Noise_Prds_Back)]; Prev_Bar_Close = Close[1]; // Number of Open Trades Variable Definition Open_Trades = 0; // Time between Processes Choke , must be 10 seconds or more between expert processing If (CurTime-LastTradeTime)<10 Then Exit; //------------------------------------------------------------------------------------------- // Anti-Trend trading section // This tells us if the Noise H/L is greater than half of the Trend H/L If (Noise_High-Noise_Low)>((Trend_High-Trend_Low)/2) Then { // If No Open trades Begin If Symbol==Symbol and Open_Trades<=0 Then { // Margin Choke inside Open trades so the Trailing Stop can still operate If FreeMargin<1000 Then Exit; // Set Order Trade Time Allowance , Begin_Hour // Minutes allowed to look for a trade // Must be a new vTime period , only 1 trade per period If (TimeHour(T)=Hour_Begin) and (TimeHour(T)<(Hour_Begin+1) and (TimeMinute(T)<5) and vTime != Time[0]) Then { // Set Order according to our price conditions If ((Noise_High-Prev_Bar_Close)0 Then { // Margin Choke inside Open trades so the Trailing Stop can still operate If FreeMargin<1000 Then Exit; // Set Order Trade Time Allowance , Begin_Hour // Minutes allowed to look for a trade // Must be a new vTime period , only 1 trade per period If (TimeHour(T)=Hour_Begin) and (TimeHour(T)<(Hour_Begin+1) and (TimeMinute(T)<5) and vTime != Time[0])) Then { // Set Order according to our price conditions If ((Noise_High-Prev_Bar_Close)0 Then { // Margin Choke inside Open trades so the Trailing Stop can still operate If FreeMargin<1000 Then Exit; // Set Order Trade Time Allowance , Begin_Hour // Minutes allowed to look for a trade // Must be a new vTime period , only 1 trade per period If (TimeHour(T)=Hour_Begin) and (TimeHour(T)<(Hour_Begin+1) and (TimeMinute(T)<5) and vTime != Time[0])) Then { // Set Order according to our price conditions If ((Noise_High-Prev_Bar_Close)(TrailingStop*Point) then { If Ord(cnt,VAL_STOPLOSS)<(Ord(cnt,VAL_CLOSEPRICE)-TrailingStop*Point) then { ModifyOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_CLOSEPRICE)-TrailingStop*Point, Ord(cnt,VAL_OPENPRICE)+TakeProfit*Point,Cyan); Exit; }; }; }; If Ord(cnt,Val_Symbol)==Symbol and Ord(cnt,VAL_TYPE)==OP_SELL then { If (Ord(cnt,VAL_OPENPRICE)-Ord(cnt,VAL_CLOSEPRICE))>(TrailingStop*Point) then { If Ord(cnt,VAL_STOPLOSS)>(Ord(cnt,VAL_CLOSEPRICE)+TrailingStop*Point) or Ord(cnt,VAL_STOPLOSS)=0 then { ModifyOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_CLOSEPRICE)+TrailingStop*Point, Ord(cnt,VAL_OPENPRICE)-TakeProfit*Point,Fuchsia); Exit; }; }; }; }; };