/*[[ Name := Multi_Lot_Scapler-P-DAY Author := Copyright © 2005 Alejandro Galindo - FAB4X Link := Copyright © 2005 Alejandro Galindo - FAB4X INTL Notes := Lots := 0.10 Stop Loss := 0 Take Profit := 10 Trailing Stop := 5 ]]*/ Define: MaxTrades(5); Define: Pips(2); Define: SecureProfit(10); Define: AccountProtection(1); Define: OrderstoProtect(3); Define: ReverseCondition(0); Define: EURUSDPipValue(10); Define: GBPUSDPipValue(10); Define: USDCHFPipValue(7.94); Define: USDJPYPipValue(9.03); Define: mm(0); Define: risk(12); Define: AccountisNormal(0); Define: TimeZoneofData(0); Var: OpenOrders(0); Var: cnt(0); Var: slippage(5); Var: sl(0); Var: tp(0); Var: BuyPrice(0); Var: SellPrice(0); Var: lotsi(0); Var: mylotsi(0); Var: mode(0); Var: OrderType(0); Var: ContinueOpening(True); Var: LastPrice(0); Var: PreviousOpenOrders(0); Var: Profit(0); Var: LastTicket(0); Var: LastType(0); Var: LastClosePrice(0); Var: LastLots(0); Var: Pivot(0); Var: PipValue(0); Var: Reversed(False); Var: text(""); Var: text2(""); Var: myl(0); Var: myh(0); Var: myC(0); Var: myO(0); Var: mypivot(0); Var: Today(0); Var: RefDate(0); Var: LastBarOfDay(0); Var: FirstBarOfDay(0); Var: Loop(0); Var: myyh(0); Var: myyl(0); Var: myyc(0); Var: p(0); Var: flp(0); Var: feh(0); Var: fel(0); Var: ph(0); Var: pl(0); Var: gap(0); //if CurTime > then // { //Alert("This Trail version has expired. To continue to use, please send paypal payment: $99/M : fab4x@yahoo.com"); //Exit; // } if AccountisNormal == 1 then { if mm != 0 then lotsi = Ceil(Balance * risk / 10000) else lotsi = Lots; } else { if mm != 0 then lotsi = Ceil(Balance * risk / 10000) / 10 else lotsi = Lots; } if lotsi > 100 then lotsi = 100; OpenOrders = 0; for cnt = 1 to TotalTrades { if Ord(cnt,VAL_SYMBOL) == Symbol then OpenOrders++; } myh = High[0]; myl = Low[0]; myC = Close[0]; myO = Open[0]; myyh = High[1]; myyl = Low[1]; myyc = Close[1]; p = (myyh + myyl + myyc + myO) / 4; ph = (myyh + myh + myyc + myO) / 4; pl = (myyl + myl + myyc + myO) / 4; flp = (myh + myl + myC) / 3; gap = Abs(p - flp) * 10000; MoveObject("P",OBJ_HLINE,Time[0],p,Time[0],p,Gold,1,STYLE_SOLID); SetObjectText("P_txt","Pivot Zone","Arial",7,White); MoveObject("P_txt",OBJ_TEXT,Time[0],p,Time[0],p,White); if Ask > p and Ask > flp then { MoveObject("FLP",OBJ_HLINE,Time[0],flp,Time[0],flp,LimeGreen,1,STYLE_SOLID); SetObjectText("FLP_txt","Floating Trend Direction - LONG","Arial",7,White); MoveObject("FLP_txt",OBJ_TEXT,Time[0],flp,Time[0],flp,White); Comment("Account: ",AccNum," - ",AccName,"\nLastPrice=",LastPrice," Previous open orders=",PreviousOpenOrders,"\nContinue opening=",ContinueOpening," OrderType=",OrderType,"\n",text2," Balance: ",NumberToStr(Balance,2),"\nLots=",lotsi,"\n",text,"Trend Bias -- LONG"); } if Bid < p and Bid < flp then { MoveObject("FLP",OBJ_HLINE,Time[0],flp,Time[0],flp,Red,1,STYLE_SOLID); SetObjectText("FLP_txt","Floating Trend Direction - SHORT","Arial",7,White); MoveObject("FLP_txt",OBJ_TEXT,Time[0],flp,Time[0],flp,White); Comment("Account: ",AccNum," - ",AccName,"\nLastPrice=",LastPrice," Previous open orders=",PreviousOpenOrders,"\nContinue opening=",ContinueOpening," OrderType=",OrderType,"\n",text2," Balance: ",NumberToStr(Balance,2),"\nLots=",lotsi,"\n",text,"Trend Bias -- SHORT"); } switch Symbol begin case "EURUSD": PipValue = EURUSDPipValue; case "GBPUSD": PipValue = GBPUSDPipValue; case "USDJPY": PipValue = USDJPYPipValue; case "USDCHF": PipValue = USDCHFPipValue; default: PipValue = 5; end; if PreviousOpenOrders > OpenOrders then { for cnt = TotalTrades downto 1 { mode = Ord(cnt,VAL_TYPE); if Ord(cnt,VAL_SYMBOL) == Symbol then { if mode == OP_BUY then CloseOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_LOTS),Ord(cnt,VAL_CLOSEPRICE),slippage,Blue); if mode == OP_SELL then CloseOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_LOTS),Ord(cnt,VAL_CLOSEPRICE),slippage,Red); Exit; } } } PreviousOpenOrders = OpenOrders; if OpenOrders >= MaxTrades then ContinueOpening = False else ContinueOpening = True; if LastPrice == 0 then { for cnt = 1 to TotalTrades { mode = Ord(cnt,VAL_TYPE); if Ord(cnt,VAL_SYMBOL) == Symbol then { LastPrice = Ord(cnt,VAL_OPENPRICE); if mode == OP_BUY then OrderType = 2; if mode == OP_SELL then OrderType = 1; } } } if OpenOrders < 1 then OrderType = 0; if OpenOrders < 1 and Bid < p and Bid < flp and gap >= 7 then { LastPrice = 0; OrderType = 1; } if OpenOrders < 1 and Ask > p and Ask > flp and gap >= 7 then { LastPrice = 0; OrderType = 2; } for cnt = TotalTrades downto 1 { if OrderValue(cnt,VAL_SYMBOL) == Symbol and Reversed == False then { if OrderValue(cnt,VAL_TYPE) == OP_SELL then { if TrailingStop > 0 then { if OrderValue(cnt,VAL_OPENPRICE) - Ask >= TrailingStop * Point + Pips * Point then { if OrderValue(cnt,VAL_STOPLOSS) > Ask + Point * TrailingStop or OrderValue(cnt,VAL_STOPLOSS) == 0 then { ModifyOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_OPENPRICE),Ask + Point * TrailingStop,OrderValue(cnt,VAL_CLOSEPRICE) - TakeProfit * Point - TrailingStop * Point,Purple); Exit; } } } } if OrderValue(cnt,VAL_TYPE) == OP_BUY then { if TrailingStop > 0 then { if Bid - OrderValue(cnt,VAL_OPENPRICE) >= TrailingStop * Point + Pips * Point 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_CLOSEPRICE) + TakeProfit * Point + TrailingStop * Point,Yellow); Exit; } } } } } } Profit = 0; LastTicket = 0; LastType = 0; LastClosePrice = 0; LastLots = 0; for cnt = 1 to TotalTrades { if Ord(cnt,VAL_SYMBOL) == Symbol then { LastTicket = Ord(cnt,VAL_TICKET); if Ord(cnt,VAL_TYPE) == OP_BUY then LastType = 0; if Ord(cnt,VAL_TYPE) == OP_SELL then LastType = 1; LastClosePrice = Ord(cnt,VAL_CLOSEPRICE); LastLots = Ord(cnt,VAL_LOTS); if LastType == 0 then { if Ord(cnt,VAL_CLOSEPRICE) < Ord(cnt,VAL_OPENPRICE) then { Profit = Profit - (Ord(cnt,VAL_OPENPRICE) - Ord(cnt,VAL_CLOSEPRICE)) * Ord(cnt,VAL_LOTS) / Point; } if Ord(cnt,VAL_CLOSEPRICE) > Ord(cnt,VAL_OPENPRICE) then { Profit = Profit + (Ord(cnt,VAL_CLOSEPRICE) - Ord(cnt,VAL_OPENPRICE)) * Ord(cnt,VAL_LOTS) / Point; } } if LastType == 1 then { if Ord(cnt,VAL_CLOSEPRICE) > Ord(cnt,VAL_OPENPRICE) then { Profit = Profit - (Ord(cnt,VAL_CLOSEPRICE) - Ord(cnt,VAL_OPENPRICE)) * Ord(cnt,VAL_LOTS) / Point; } if Ord(cnt,VAL_CLOSEPRICE) < Ord(cnt,VAL_OPENPRICE) then { Profit = Profit + (Ord(cnt,VAL_OPENPRICE) - Ord(cnt,VAL_CLOSEPRICE)) * Ord(cnt,VAL_LOTS) / Point; } } } } Profit = Profit * PipValue; text2 = "Profit: $" + NumberToStr(Profit,2) + " +/- "; if OpenOrders >= MaxTrades - OrderstoProtect and AccountProtection == 1 then { if OrderType == 2 and Bid == tp then { CloseOrder(LastTicket,LastLots,LastClosePrice,slippage,Yellow); ContinueOpening = False; Exit; } if OrderType == 1 and Ask == tp then { CloseOrder(LastTicket,LastLots,LastClosePrice,slippage,Yellow); ContinueOpening = False; Exit; } } if OrderType == 1 and ContinueOpening then { if Bid - LastPrice >= Pips * Point or OpenOrders < 1 then { SellPrice = Bid; LastPrice = 0; if TakeProfit == 0 then tp = 0 else tp = SellPrice - TakeProfit * Point; if StopLoss == 0 then sl = 0 else sl = SellPrice + StopLoss * Point; if OpenOrders != 0 then { mylotsi = lotsi; for cnt = 1 to OpenOrders { if MaxTrades > 12 then mylotsi = Normalize(mylotsi * 1.5,1) else mylotsi = Normalize(mylotsi * 2,1); } } else { mylotsi = lotsi; } if mylotsi > 100 then mylotsi = 100; SetOrder(OP_SELL,mylotsi,SellPrice,slippage,sl,tp,Red); Exit; } } if OrderType == 2 and ContinueOpening then { if LastPrice - Ask >= Pips * Point or OpenOrders < 1 then { BuyPrice = Ask; LastPrice = 0; if TakeProfit == 0 then tp = 0 else tp = BuyPrice + TakeProfit * Point; if StopLoss == 0 then sl = 0 else sl = BuyPrice - StopLoss * Point; if OpenOrders != 0 then { mylotsi = lotsi; for cnt = 1 to OpenOrders { if MaxTrades > 12 then mylotsi = Normalize(mylotsi * 1.5,1) else mylotsi = Normalize(mylotsi * 2,1); } } else { mylotsi = lotsi; } if mylotsi > 100 then mylotsi = 100; SetOrder(OP_BUY,mylotsi,BuyPrice,slippage,sl,tp,Blue); Exit; } }