/*[[ Name := iTrend Expert v0.5 Author := Copyright © 2004, KillerKhan Link := http://www.iamatyourmuthazhouse.com/ Lots := 1.00 Stop Loss := 0 Take Profit := 0 Trailing Stop := 0 ]]*/ defines: TestYear(2004); defines: TestMonth(1); defines: LowestCapital(500); defines: slippage(5); defines: iBands_Mode_0_2(0); defines: iPower_Price_0_6(0); defines: iPrice_Type_0_3(0); defines: iBands_Period(20); defines: iBands_Deviation(2); defines: iPower_Period(14); defines: Go_Long(0); defines: Go_Short(0); defines: No_Trade(0); vars: value(0),value2(0),CurrentBar(0),Bands_Mode(0),Power_Price(0),CurrentPrice(0); vars: cnt(0),trd(0); /////////////////////////////// // Back Testing ////////////////////////////// If TimeYear(time[0]) < TestYear then Exit; If TimeMonth(time[0]) < TestMonth then Exit; /////////////////////////////// // Main Settings ////////////////////////////// If FreeMargin < LowestCapital then exit; If CurTime - LastTradeTime < 30 then exit; /////////////////////////////// // Delete Trades ////////////////////////////// if hour>=23 and hour<0 and minute>=45 and minute<55 then { for cnt=1 to TotalTrades { If (OrderValue(cnt,VAL_SYMBOL)= Symbol) then trd = trd+1; }; if trd=1 then { if OrderValue(cnt,VAL_TYPE) = OP_BUY and OrderValue(cnt,VAL_SYMBOL)= Symbol then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,slippage,Green); Exit; }; if OrderValue(cnt,VAL_TYPE) = OP_SELL and OrderValue(cnt,VAL_SYMBOL)= Symbol then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,slippage,Green); Exit; }; }; }; /////////////////////////////// // Set Trades /////////////////////////////// if hour>=0 and hour<1 and minute>=1 and minute<15 then { for cnt=1 to TotalTrades { If (OrderValue(cnt,VAL_SYMBOL)= Symbol) then trd = trd+1; }; if trd=1 then { if OrderValue(cnt,VAL_TYPE) = OP_BUY and OrderValue(cnt,VAL_SYMBOL)= Symbol then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,slippage,Green); Exit; }; if OrderValue(cnt,VAL_TYPE) = OP_SELL and OrderValue(cnt,VAL_SYMBOL)= Symbol then { CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,slippage,Green); Exit; }; }; if trd=0 then { /////////////////////////////// // iTrend Indicator ////////////////////////////// SetLoopCount(0); //if iBands_Mode_0_2=1 then Bands_Mode=MODE_LOW //else if iBands_Mode_0_2=2 then Bands_Mode=MODE_HIGH //else Bands_Mode=MODE_MAIN; Bands_Mode=MODE_MAIN; //if iPower_Price_0_6=1 then Power_Price=PRICE_OPEN //else if iPower_Price_0_6=2 then Power_Price=PRICE_HIGH //else if iPower_Price_0_6=3 then Power_Price=PRICE_LOW //else if iPower_Price_0_6=4 then Power_Price=PRICE_MEDIAN //else if iPower_Price_0_6=5 then Power_Price=PRICE_TYPICAL //else if iPower_Price_0_6=6 then Power_Price=PRICE_WEIGHTED //else Power_Price=PRICE_CLOSE; Power_Price=PRICE_CLOSE; For CurrentBar=Bars+1 DownTo 0 begin //if iPrice_Type_0_3=1 then CurrentPrice=open[CurrentBar] //else if iPrice_Type_0_3=2 then CurrentPrice=high[CurrentBar] //else if iPrice_Type_0_3=3 then CurrentPrice=low[CurrentBar] //else CurrentPrice=close[CurrentBar]; CurrentPrice=close[CurrentBar]; value=CurrentPrice-iBands(iBands_Period,iBands_Deviation,Bands_Mode,CurrentBar); if value < 0 then value = 0; if value > 0 then value = 1; setIndexValue(CurrentBar, value); value2=-(iBearsPower(iPower_Period,Power_Price,CurrentBar)+iBullsPower(iPower_Period,Power_Price,CurrentBar)); if value2 < 0 then value2 = 0; if value2 > 0 then value2 = -1; setIndexValue2(CurrentBar, value2); if value = 1 then Go_Long=1; if value2 = -1 then Go_Short=1; if value2 = -1 and value = 1 then No_Trade=1; //SetGlobalVariable("BUK",value); end; if Go_Long=1 then { SetOrder(OP_BUY,Lots,Ask,slippage,StopLoss,TakeProfit,BLUE); Comment("Buy Signal"); Go_Long=0; Exit; }; if Go_Short=1 then { SetOrder(OP_SELL,Lots,Bid,slippage,StopLoss,TakeProfit,RED); Comment("Sell Signal"); Go_Short=0; Exit; }; if No_Trade=1 then { Comment("No Signal"); No_Trade=0; Exit; }; }; };