/*[[ Name := Trend_Noise_Trader Author := Copyright © 2004, David W Honeywell Link := DavidHon@msn.com Lots := 1.00 Stop Loss := 100 Take Profit := 1000 Trailing Stop := 75 ]]*/ // 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); Define: Noise_Prds_Back(12);// This finds the high and low , set for how many periods you want to use // Default settings for Periods_Back is (18) on H1 , (36) on m30 , (72) on m15 , (216) on m5 , (1080) on m1 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 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 trades and Trade_Delay minimum time between trades If (TimeHour(T)=Hour_Begin) and (TimeHour(T)<(Hour_Begin+1) and (TimeMinute(T)<20) 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 trades and Trade_Delay minimum time between trades If (TimeHour(T)=Hour_Begin) and (TimeHour(T)<(Hour_Begin+1) and (TimeMinute(T)<20) 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 trades and Trade_Delay minimum time between trades If (TimeHour(T)=Hour_Begin) and (TimeHour(T)<(Hour_Begin+1) and (TimeMinute(T)<20) 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; }; }; }; }; };