/*[[ Name := TRUE_SCALPER Author := Copyright © 2005, Jacob Yego Link := http://www.PointForex.com/ Notes := Some improvements by Ron Thompson Notes := Original MT3 convertion by KillerKhan Notes := Codestructure reworked by Roger (Added optional RSI validation, optional Abandon method, MoneyManagement and ProfitLock System) Lots := 0.1 Stop Loss := 90 Take Profit := 44 Trailing Stop := 0 ]]*/ ////////////////////////////////////// // External Variables ////////////////////////////////////// Define: RSIMethodA(1); //Experimental setting. Need testing. Set this to "1" for activation, and set RSIMethodB to "0". Define: RSIMethodB(0); //The proven and tested method, set this to "1" and RSIMethodA to "0" if you want the it the "old' way. Define: RSIValue(50); //Probably best to leave this as it is. Define: AbandonMethodA(0); //Abandon position if inactivity, then force "hedge". Define: AbandonMethodB(1); //Abandon position if inactivity, but let indicators decide direction of new trade. Define: abandon(101); //Number of tics before abandon kicks in. Define: mm(1); //Only activate if you want automatic calculation of lot size based upon the below risk factor and your account balance. Define: Risk(3); //Only work if mm = "1". Set risk percentage for each trade. Default is set to 3% of account balance. Define: Slippage(3); //Leave at three. Define: UseProfitLock(1); //ProfitLock system. Set to "1" if you want to activate ProfitLock. Define: BreakEvenTrigger(25); //IF ProfitLock above is activated, this is the number of pips you want a trade to move into profitable territory before profitlock kicks in. Default is at 25 pip. Define: BreakEven(3); //Default set to 1 pip. Test different settings, example 3 pip. Define: LiveTrading(0); //If you trade LIVE (not demo, but REAL account) on InterbankFX, set this to "1", else leave at "0". Define: AccountIsMini(0); //If you trade a MINI account LIVE on InterbankFX, set this to "1", else leave at "0". Define: maxTradesPerPair(1); //Default is "1", as we want only ONE trade per pair at the same time. ////////////////////////////////////// // Internal Variables ////////////////////////////////////// Var: bartime(0); Var: bartick(0); Var: bullMA3(0); Var: bearMA7(0); Var: RSI(0); Var: RSI2(0); Var: vRSIPos(false); Var: vRSINeg(false); Var: p(0); Var: TP(0); Var: SL(0); Var: SetSell(false); Var: SetBuy(false); Var: BuySignal(false); Var: SellSignal(false); Var: cnt(0); Var: TradeBars(0); Var: MarginCutoff(0); Var: lotMM(0); Var: dStopLoss(0); Var: dTakeProfit(0); Var: CurrentTrades(0); dStopLoss = StopLoss * Point; dTakeProfit = TakeProfit * Point; ////////////////////////////////////// // Main Script ////////////////////////////////////// // Exit if time between Script execution is less than 10 Seconds if CurTime - LastTradeTime < 10 then Exit; // Evaluate what method is used for abandon. Only ONE of the methods can be activated (1) if AbandonMethodA == 1 and AbandonMethodB == 1 then { Alert("ERROR! AbandonMethodA and AbandonMethodB can NOT both be set to '1'. Default settings are AbandonMethodA = '1' and AbandonMethodB = '0'"); Exit; } // Evaluate what method is used for RSI. Only ONE of the methods can be activated (1) if RSIMethodA == 1 and RSIMethodB == 1 then { Alert("ERROR! RSIMethodA and RSIMethodB can NOT both be set to '1'. Default settings are RSIMethodA = '0' and RSIMethodB = '1'"); Exit; } if RSIMethodA == 0 and RSIMethodB == 0 then { Alert("ERROR! RSIMethodA and RSIMethodB can NOT both be set to '0'. Default settings are RSIMethodA = '0' and RSIMethodB = '1'"); Exit; } // ==================================================================================================== // PYRAMIDING - LINEAR // Money management risk exposure compounding - STRUCTURE BY ROBERT COCHRAN - http://autoforex.biz // ==================================================================================================== if AccountIsMini == 0 then MarginCutoff = 1000; if AccountIsMini == 1 then MarginCutoff = 100; if FreeMargin < MarginCutoff then Exit; 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 == 1 then { if AccountIsMini == 1 then lotMM = lotMM * 10; if AccountIsMini == 0 and lotMM < 1.0 then lotMM = 1.0; } if lotMM > 100 then lotMM = 100; } else { lotMM = Lots; // Change mm to 0 if you want the Lots parameter to be in effect }; // ==================================================================================================== // OPEN ORDER CHECK - // Each instance of a script is attached to one currency pair. // When this check executes, it sets CurrentTrades to 1 so that // only one trade for this symbol will be open, which is enforced // by "if CurrentTrades > maxTradesPerPair". // ==================================================================================================== CurrentTrades = 0; for cnt = 1 to TotalTrades { if OrderValue(cnt,VAL_SYMBOL) = Symbol then { CurrentTrades += 1; }; }; // Special Treatment for spesific pairs. if Symbol == "GBPUSD" then { dTakeProfit = 55 * Point; dStopLoss = 90 * Point; abandon = 69; }; // Set Variable Values p = Point; bullMA3 = iMA(3,MODE_EMA,1); bearMA7 = iMA(7,MODE_EMA,1); RSI = iRSI(2,2); RSI2 = iRSI(2,1); if RSIMethodA == 1 then { if RSI > RSIValue and RSI2 < RSIValue then { vRSIPos = True; vRSINeg = False; } else vRSIPos = False; if RSI < RSIValue and RSI2 > RSIValue then { vRSINeg = True; vRSIPos = False; } else vRSINeg = False; } if RSIMethodB == 1 then { if RSI > RSIValue then { vRSIPos = True; vRSINeg = False; } if RSI < RSIValue then { vRSINeg = True; vRSIPos = False; } } if ((bullMA3 > (bearMA7+p)) and vRSINeg) then { BuySignal = True; } else BuySignal = False; if ((bullMA3 < (bearMA7-p)) and vRSIPos) then { SellSignal = True; } else SellSignal = False; // ==================================================================================================== // PROFIT LOCK SYSTEM BY ROBERT COCHRAN - http://autoforex.biz // ==================================================================================================== for cnt = 1 to TotalTrades { if CurrentTrades <> 0 and OrderValue(cnt,VAL_SYMBOL) == Symbol then { if OrderValue(cnt,VAL_TYPE) == OP_BUY then { if UseProfitLock == 1 and Bid >= Ord(cnt,VAL_OPENPRICE) + BreakEvenTrigger*Point and Ord(cnt,VAL_OPENPRICE) > Ord(cnt,VAL_STOPLOSS) then { ModifyOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_OPENPRICE) + BreakEven*Point, Ord(cnt,VAL_TAKEPROFIT), BLUE); Exit; } }; // end OP_BUY check if OrderValue(cnt,VAL_TYPE) == OP_SELL then { if UseProfitLock == 1 and Ask <= Ord(cnt,VAL_OPENPRICE) - BreakEvenTrigger*Point and Ord(cnt,VAL_OPENPRICE) < Ord(cnt,VAL_STOPLOSS) then { ModifyOrder(Ord(cnt,VAL_TICKET), Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_OPENPRICE) - BreakEven*Point, Ord(cnt,VAL_TAKEPROFIT), BLUE); Exit; } }; // end OP_SELL check }; // end Symbol check }; // end for cnt=1 to TotalTrades // ==================================================================================================== // CALCULATE NUMBER OF BARS TRADE HAS BEEN OPEN // ==================================================================================================== if CurrentTrades > 0 then { if TradeBars == 0 and bartick == 0 then { for cnt = 1 to TotalTrades { if Ord(cnt,VAL_SYMBOL)=Symbol then { TradeBars = floor(((curtime - ord(cnt,VAL_OPENTIME))/60)/Period); bartime = Time[0]; bartick = TradeBars; } } }; if bartime != Time[0] then { bartime = Time[0]; bartick++; }; }; // ==================================================================================================== // ORDER CLOSURE (ABANDON METHODS) // Method A - Close Trades if they been running for longer than expected. // Force opening of new position in opposite direction ( Open 'Hedge" Position) // // Method B - Close Trades if they been running for longer than expected. // Let indicators decide new direction. // ==================================================================================================== if CurrentTrades > 0 then { for cnt = 1 to TotalTrades { if AbandonMethodA == 1 and bartick == abandon then { If Ord(cnt,VAL_TYPE)=OP_BUY and Ord(cnt,VAL_SYMBOL)=Symbol then { CloseOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_LOTS),Ord(cnt,VAL_CLOSEPRICE),0,BLUE); SetSell = true; Exit; }; // end OP_BUY check If Ord(cnt,VAL_TYPE)=OP_SELL and Ord(cnt,VAL_SYMBOL)=Symbol then { CloseOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_LOTS),Ord(cnt,VAL_CLOSEPRICE),0,BLUE); SetBuy = true; Exit; }; // end OP_SELL check }; if AbandonMethodB == 1 and bartick == abandon then { If Ord(cnt,VAL_TYPE)=OP_BUY and Ord(cnt,VAL_SYMBOL)=Symbol then { CloseOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_LOTS),Ord(cnt,VAL_CLOSEPRICE),0,WHITE); Exit; }; // end OP_BUY check If Ord(cnt,VAL_TYPE)=OP_SELL and Ord(cnt,VAL_SYMBOL)=Symbol then { CloseOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_LOTS),Ord(cnt,VAL_CLOSEPRICE),0,WHITE); Exit; }; // end OP_SELL check }; }; }; // ==================================================================================================== // TRADE ENTRY // ==================================================================================================== if CurrentTrades < maxTradesPerPair then { //LONG TRADES ENTRY CRITERIA if BuySignal or SetBuy then { SL = Ask - dStopLoss; TP = Ask + dTakeProfit; SetOrder(OP_BUY,lotMM,ask,Slippage,SL,TP,LIME); bartick=0; if SetBuy then SetBuy = false; Exit; } //SHORT TRADES ENTRY CRITERIA if SellSignal or SetSell then { SL = Bid + dStopLoss; TP = Bid - dTakeProfit; SetOrder(OP_SELL,lotMM,bid,Slippage,SL,TP,RED); bartick=0; if SetSell then SetSell = false; Exit; } };