/*[[ Name := Super_5_34_5 Author := Copyright © 2005, Barcode/Bob O'Brien Link := Notes := Lots := 1.00 Stop Loss := 0 Take Profit := 100 Trailing Stop := 60 ]]*/ ///////////////////////////////////////////////////// // Defines ///////////////////////////////////////////////////// Defines: Slippage(5); // Slippage Defines: StopYear(2005); Defines: MM(0),Leverage(1),AcctSize(10000); ///////////////////////////////////////////////////// // Variables ///////////////////////////////////////////////////// var: PriceOpen(0); // Price Open var: I(0); // Misc Counter Var: NewBar(0),First(True),LotMM(0),LotSize(10000),LotMax(50); Var: TradesThisSymbol(0); Var: SSUp1(0),SSUp2(0),SSUp3(0),SSDn1(0),SSDn2(0),SSDn3(0); var: FiveF1(0),FiveF2(0),FiveS1(0),FiveS2(0),SSBuy(False),SSSell(False); ///////////////////////////////////////////////// // Initialisation ///////////////////////////////////////////////// if year < stopyear then exit; If Curtime - LastTradeTime < 10 then Exit; If FreeMargin < 500 then Exit; TradesThisSymbol = 0; For I = 1 to TotalTrades { if ord(I, VAL_SYMBOL) == Symbol then TradesThisSymbol ++; // print ("totaltrades=",totaltrades," Order=",ord(I, VAL_SYMBOL)," ",symbol," ",tradesthissymbol); }; ///////////////////////////////////////////////// // Process the next bar details ///////////////////////////////////////////////// If NewBar != t[0] Then { NewBar = t[0]; If TradesThisSymbol < 1 Then { ///////////////////////////////////////////////// // Lot Management ///////////////////////////////////////////////// If MM < 0 then { LotMM = Round(Balance*Leverage/10000)/10; If LotMM > LotMax then LotMM = LotMax; }; If MM = 0 then LotMM = lots; if MM > 0 then { LotMM = Round(Balance*Leverage/10000)/10; If LotMM > 1 then LotMM = ceil(LotMM); if LotMM < 1 then LotMM = 1; If LotMM > LotMax then LotMM = LotMax; }; ///////////////////////////////////////////////// // New Orders Management ///////////////////////////////////////////////// SSDn1 = iCustom("supersignals",MODE_FIRST,1); SSUp1 = iCustom("supersignals",MODE_SECOND,1); SSDn2 = iCustom("supersignals",MODE_FIRST,2); SSUp2 = iCustom("supersignals",MODE_SECOND,2); SSDn3 = iCustom("supersignals",MODE_FIRST,3); SSUp3 = iCustom("supersignals",MODE_SECOND,3); FiveF1 = iCustom("5_34_5",MODE_FIRST,1); FiveS1 = iCustom("5_34_5",MODE_SECOND,1); FiveF2 = iCustom("5_34_5",MODE_FIRST,2); FiveS2 = iCustom("5_34_5",MODE_SECOND,2); SSBuy = False; SSSell = False; SSBuy = SSUp1 > 0 or SSUp2 > 0 or SSUp3 > 0; SSSell = SSDn1 > 0 or SSDn2 > 0 or SSDn3 > 0; print(day,"/",month," SSD1=",ssdn1," SSD2=",ssdn2," SSD3=",ssdn3," SSU1=",ssup1," SSU2=",ssup2," SSU3=",ssup3); print("FiveF1=",fivef1," FiveF2=",fivef2," FiveS1=",fives1," FiveS2=",fives2," SSBuy=",ssbuy," SSSell=",sssell); If FiveS1 > FiveS2 and FiveS1 > FiveF1 and SSBuy then { SetOrder(OP_BUYSTOP, LotMM, PriceOpen, Slippage, Low[1] - 1 * Point, PriceOpen + TakeProfit * Point, BLUE); Exit; }; If FiveS1 < FiveS2 and FiveS1 < FiveF1 and SSSell then { SetOrder(OP_SELLSTOP, LotMM, PriceOpen, Slippage, High[1] + 1 * Point, PriceOpen - TakeProfit * Point, RED); Exit; }; }; }; ///////////////////////////////////////////////// // Stop Loss Management ///////////////////////////////////////////////// If TradesThisSymbol > 0 Then { For i=1 to TotalTrades { If Ord(i,VAL_TYPE) = OP_BUY And OrderValue(i,VAL_SYMBOL) = Symbol Then { If (Ask-Ord(i,VAL_OPENPRICE)) > (TrailingStop * Point) Then { If Ord(i,VAL_STOPLOSS) < (Ask - TrailingStop * Point) Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), Ask - TrailingStop * Point, Ask + TakeProfit * Point, White); Exit; }; }; }; If Ord(i,VAL_TYPE) = OP_SELL And OrderValue(i,VAL_SYMBOL) = Symbol Then { If (Ord(i,VAL_OPENPRICE) - Bid) > (TrailingStop * Point) Then { If Ord(i,VAL_STOPLOSS) > (Bid + TrailingStop * Point) Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), Bid + TrailingStop * Point, Bid - TakeProfit * Point, Gold); Exit; }; }; }; }; };