/*[[ Name := Golden Trader Author := Copyright © 2006, Link := Lots := 1.00 Stop Loss := 13 Take Profit := 7 Trailing Stop := 5 ]]*/ //Name := GoldenTrader (Spin of from Goldengoose and Goldeneagle) //Author := Original code author was Amir, modified by Autofx, Soma and Forex_Trader define: Autotrade(1),Margincutoff(100),mm(0),Risk(5),year_begin(2006),month_begin(1),day_begin(1); var: cnt(0), Current(0),TradesInThisSymbol(0); var: OrderText(""); var: Autst(0); var: NewDay(1); var: lotMM(0); var: ts(0); var: LiveTrading(False); var: AccountIsMini(False); // See comments near assignment statement below. ts = TrailingStop*Point; // ==================================================================================================== // DATE CHOKE - for testing // ==================================================================================================== If year >= year_begin and month >= month_begin and day >= day_begin then begin; // ==================================================================================================== // PYRAMIDING - LINEAR // Money management risk exposure compounding // ==================================================================================================== LiveTrading = True; AccountIsMini = False; // Change to False for real trading w/ 100k/regular account // or for all backtesting, since backtests allow // fractional lots. // Change to True for real trading w/ mini account if mm <> 0 then { lotMM = Ceil(Balance * risk / 10000) / 10; if lotMM < 0.1 then lotMM = Lots; if lotMM > 1.0 then lotMM = Ceil(lotMM); // Enforce lot size boundaries if LiveTrading then { if AccountIsMini then lotMM = lotMM * 10; if !AccountIsMini and lotMM < 1.0 then lotMM = 1.0; } if lotMM > 1000 then lotMM = 1000; } else { lotMM = Lots; // Change mm to 0 if you want the Lots parameter to be in effect }; // ==================================================================================================== // ORDER CLOSURES and MODIFICATIONS // ==================================================================================================== TradesInThisSymbol = 0; for cnt = 1 to TotalTrades begin if Ord(cnt,VAL_TYPE) = OP_BUY and OrderValue(cnt,VAL_SYMBOL) = Symbol then { TradesInThisSymbol += 1; if (iCustom("Heikin-Ashi MOD",0,300,MODE_FIRST,0) < iCustom("Heikin-Ashi MOD",0,300,MODE_SECOND,1)) //then//and //if iCustom("itrend",MODE_SECOND,0) < 0 then and iCustom("itrend",MODE_SECOND,0) < 0 then { CloseOrder(OrderValue(cnt,VAL_TICKET), OrderValue(cnt,VAL_LOTS),Bid,3,Violet); NewDay = 1; Exit; } if (hour == 23) then { CloseOrder(OrderValue(cnt,VAL_TICKET), OrderValue(cnt,VAL_LOTS),Ask,3,Violet); NewDay = 1; Exit; } if Bid - Ord(cnt,VAL_OPENPRICE) > ts and Ord(cnt,VAL_STOPLOSS) < Bid - ts then { ModifyOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_OPENPRICE), Bid - ts, Ord(cnt,VAL_TAKEPROFIT), Red); Exit; } } if Ord(cnt,VAL_TYPE) = OP_SELL and OrderValue(cnt,VAL_SYMBOL) = Symbol then { TradesInThisSymbol += 1; if (iCustom("Heikin-Ashi MOD",0,300,MODE_FIRST,0) > iCustom("Heikin-Ashi MOD",0,300,MODE_SECOND,1)) //then//and //if iCustom("itrend",MODE_FIRST,0) > 0 then and iCustom("itrend",MODE_FIRST,0) > 0 then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,0,Violet); NewDay = 1; Exit; } if (hour == 24) then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,0,Violet); NewDay = 1; Exit; } if Ord(cnt,VAL_OPENPRICE) - Ask > ts and Ord(cnt,VAL_STOPLOSS) > Ask + ts then { ModifyOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_OPENPRICE), Ask + ts, Ord(cnt,VAL_TAKEPROFIT), Red); Exit; } } end; // ==================================================================================================== // MARKET ORDERS // ==================================================================================================== if FreeMargin < Margincutoff then Exit; if TradesInThisSymbol > 0 then Exit; OrderText = ""; //Must be blank before going into the main section if (hour == 24) then { if (Autotrade == 0) then { Autst = 1; } else { Autst = 0; } NewDay = 1; } // Is current bar a bull candle? if (iCustom("Heikin-Ashi MOD",0,300,MODE_FIRST,0) > iCustom("Heikin-Ashi MOD",0,300,MODE_SECOND,1)) then { OrderText = "BUY"; } // Is current bar a bear candle? if (iCustom("Heikin-Ashi MOD",0,300,MODE_FIRST,0) < iCustom("Heikin-Ashi MOD",0,300,MODE_SECOND,1)) then { OrderText = "SELL"; } if (OrderText <> "" and TotalTrades < 3 and TradesInThisSymbol == 0 and NewDay == 1 and hour > 0 and hour < 23 and Autst == 0) then { Switch OrderText Begin Case "BUY": SetArrow(time, ask, 216, yellow); SetOrder(OP_BUY, lotMM, Ask, 3,Ask - StopLoss*Point, Ask + TakeProfit*Point, Green); NewDay = 0; Exit; Case "SELL": SetArrow(time, bid, 216, red); SetOrder(OP_SELL, lotMM, Bid, 3, Bid + StopLoss*Point, Bid - TakeProfit*Point, Red); NewDay = 0; Exit; Default: Exit; End; } End;