/*[[ Name := 30mEUREUSD-Roger Author := Copyright © 2004, MetaQuotes Software Corp. Link := http://www.metaquotes.net/ Lots := 1.00 Stop Loss := 60 Take Profit := 160 Trailing Stop := 34 ]]*/ defines: MACDOpenLevel(1), MACDCloseLevel(38), MATrendPeriod(5), risk(10), mm(1); var: MacdCurrent(0), MacdPrevious(0), SignalCurrent(0), SignalPrevious(0), MaCurrent(0), MaPrevious(0), cnt(0), Ilo(0); /**********************************Money and Risk Management*************************************** Changing the Define: value of mm( ) will give you several money management options mm = 0 : Single 1 lot orders. mm = 1 : Fractional lots/ balance X the risk factor.(use for Mini accts) mm = 2 : Full lots/ balance X the risk factor up to 100 lot orders.(use for Regular accounts) *************************************************************************************************** RISK FACTOR: See Defines. Risk can be anything from 1 up. Factor of 5 adds a lot for every $20,000.00 added to the balance. adds .1 lot for every $2,000.00-Mini added. Factor of 10 adds a lot with every $10.000.00 ($1,000.00-Mini)added to the balance. adds .1 lot for every $1,000.00-Mini added The higher the risk, the easier it is to blow your margin.. ***************************************************************************************************/ If mm <> 0 then { Ilo = ceil(Balance*Risk/10000)/10; If Ilo > 100 then { Ilo = 100; } } Else { Ilo = lots; }; If mm >= 2 then { If Ilo > 1 then { Ilo = ceil(Ilo); } If Ilo < 1 then { Ilo = lots; } } If Bars<40 or TakeProfit<10 then Exit; MacdCurrent=iMACD(12,26,9,MODE_MAIN,0); MacdPrevious=iMACD(12,26,9,MODE_MAIN,1); SignalCurrent=iMACD(12,26,9,MODE_SIGNAL,0); SignalPrevious=iMACD(12,26,9,MODE_SIGNAL,1); MaCurrent=iMA(MATrendPeriod,MODE_EMA,0); MaPrevious=iMA(MATrendPeriod,MODE_EMA,1); If TotalTrades<1 then { If FreeMargin<100 then Exit; If MacdCurrent<0 and MacdCurrent>SignalCurrent and MacdPrevious (MACDOpenLevel*Point) and MaCurrent>MaPrevious then { SetOrder( OP_BUY, Ilo, Ask, 3,Ask-StopLoss*Point, Ask+TakeProfit*Point, RED); Exit; }; If MacdCurrent>0 and MacdCurrentSignalPrevious and MacdCurrent> (MACDOpenLevel*Point) and MaCurrent0 and MacdCurrentSignalPrevious and MacdCurrent> (MACDCloseLevel*Point) then { CloseOrder( OrderValue(cnt,VAL_TICKET), OrderValue(cnt,VAL_LOTS), Bid,3, Violet); Exit; }; If TrailingStop>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), Red); Exit; }; }; }; } else { If MacdCurrent<0 and MacdCurrent>SignalCurrent and MacdPrevious (MACDCloseLevel*Point) then { CloseOrder( OrderValue(cnt,VAL_TICKET), OrderValue(cnt,VAL_LOTS), Ask,3, Violet); Exit; }; 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), Red); Exit; }; }; }; }; }; };