/*[[ Name := X_O_I_A_H_Expert Lots := 1.00 Stop Loss := 30 Take Profit := 100 Trailing Stop := 30 ]]*/ /* Revision logs: */ define: Autotrade(0),Margincutoff(2000); var: cnt(0), Current(0),TradesInThisSymbol(0); var: OrderText(""); var: Autst(0); TradesInThisSymbol=0; for cnt=1 to TotalTrades begin If (Ord(cnt,VAL_TYPE)=OP_BUY or ord(cnt,VAL_TYPE)=OP_BUYSTOP) and OrderValue(cnt,VAL_SYMBOL)=Symbol then { TradesInThisSymbol += 1; If iCustom("X_O_I_A_H_Indicator",MODE_SECOND,0) < 0 and iCustom("X_O_I_A_H_Indicator",MODE_FIRST,0) == 0 and iWPR(14,0) < iWPR(14,1) and iCustom("X_I_Trend_Indicator",MODE_SECOND,0) < 0 then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,3,Violet); Exit; } if (hour == 23) then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,3,Violet); Exit; } If (Bid-Ord(cnt,VAL_OPENPRICE))>=(50*Point) and Ord(cnt,VAL_OPENPRICE) > Ord(cnt,VAL_STOPLOSS) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_OPENPRICE),Ord(cnt,VAL_TAKEPROFIT),Red); Exit; } If (Bid-Ord(cnt,VAL_OPENPRICE))>=(70*Point) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_OPENPRICE)+50*Point,Ord(cnt,VAL_TAKEPROFIT),Red); Exit; } } If (Ord(cnt,VAL_TYPE)=OP_SELL or ord(cnt,VAL_TYPE)=OP_SELLSTOP) and OrderValue(cnt,VAL_SYMBOL)=Symbol then { TradesInThisSymbol += 1; if iCustom("X_O_I_A_H_Indicator",MODE_FIRST,0) > 0 and iCustom("X_O_I_A_H_Indicator",MODE_SECOND,0) == 0 and iWPR(14,0) > iWPR(14,1) and iCustom("X_I_Trend_Indicator",MODE_FIRST,0) > 0 then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,3,Violet); Exit; } if (hour == 23) then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,3,Violet); Exit; } If (Ord(cnt,VAL_OPENPRICE)-Ask)>=(50*Point) and Ord(cnt,VAL_OPENPRICE) < Ord(cnt,VAL_STOPLOSS) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_OPENPRICE),Ord(cnt,VAL_TAKEPROFIT),Red); Exit; } If (Ord(cnt,VAL_OPENPRICE)-Ask)>=(50*Point) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_OPENPRICE)-50*Point,Ord(cnt,VAL_TAKEPROFIT),Red); Exit; } } end; if FreeMargin < Margincutoff then //no funds - exit Exit; if TradesInThisSymbol > 0 then Exit; OrderText = ""; //Must be blank before going into the main section if (hour == 23) then { if (Autotrade == 0) then { Autst = 1; } else { Autst = 0; } } if (iWPR(14,0) > iWPR(14,1) and iCustom("X_O_I_A_H_Indicator",MODE_FIRST,0) > 0) or (iWPR(14,0) > iWPR(14,1) and iCustom("X_I_Trend_Indicator",MODE_FIRST,0) > 0) then { OrderText = "BUY"; } // Is current bar a bear candle? if (iWPR(14,0) < iWPR(14,1) and iCustom("X_O_I_A_H_Indicator",MODE_SECOND,0) < 0) or(iWPR(14,0) < iWPR(14,1) and iCustom("X_I_Trend_Indicator",MODE_SECOND,0) < 0) then { OrderText = "SELL"; } If (OrderText <> "" and TotalTrades < 3 and TradesInThisSymbol==0 and hour > 0 and hour < 23 and Autst == 0) then { Switch OrderText Begin Case "SELL": SetArrow(time, bid, 216, red); SetOrder(OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,Red); Exit; Case "BUY": SetArrow(time, ask, 216, yellow); SetOrder(OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,Green); Exit; Default: Exit; //Alert("Unrecognised OrderText set (" + OrderText + "), signal cannot be generated. OrderText should be blank, BUY or SELL, check expert code."); //FileWrite("Unrecognised OrderText set (" + OrderText + "), signal cannot be generated. OrderText should be blank, BUY or SELL, check expert code."); End; };