//+------------------------------------------------------------------+ //| iFxOverEasy.mq4 | //| Copyright © 2005, Shahin Monsef | //| shahinmonsef@hotmail.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, Shahin Monsef/Shimodax" #property link "shahinonsef@hotmail.com" /* History: Version 1.0 - intial expert coded by Shahin Monsef Version 1.1 / Aug 27, 2005: mods by Shimodax - option for min channel width - now checks laguerre for level crossing - option to use or ignore asctrend from decision - added trail stop trigger (profit from which trailstop gets activated) Version 1.2 / Aug 28, 2005: mods by Shimodax - handle laguerre signal correctly (stays valid for x (Input) minutes) - don't reenter trades on the same bar */ #define LONGCOLOR DodgerBlue #define SHORTCOLOR OrangeRed extern bool UseAscTrend= 0; extern int StopLoss=15, TrailingStopTrigger= 15, TrailingStop= 10, MinChannelWidth= 40, TakeProfit= 150, PauseToReEntryMinutes= 15, LaguerreValidityMinutes= 45; extern bool DebugTrace= 1; int LastSignalTime, LaguerreSignal, LaguerreSignaltime; int init(){return(0);} int deinit(){return(0);} int start() { double UL,DL; int res= 0; if(Bars<20) return(0); int currenttrades=0; for( int x=0;x<OrdersTotal();x++){ OrderSelect(x, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol()==Symbol()){ currenttrades++; } } if (currenttrades == 0) { if(AccountFreeMargin()<1000) return; iCustom(NULL,0,"SHI_Channel",0,0); double MIDL2=ObjectGet("MIDL",OBJPROP_PRICE2); double MIDL1=ObjectGet("MIDL",OBJPROP_PRICE1); double TL1 =ObjectGet("TL1" ,OBJPROP_PRICE2); double TL2 =ObjectGet("TL2" ,OBJPROP_PRICE2); if( TL1>TL2){ UL=TL1; DL=TL2; }else{ UL=TL2; DL=TL1; } double i_Trend1 =iCustom(NULL,0,"i_Trend" ,0,0); double i_Trend2 =iCustom(NULL,0,"i_Trend" ,1,0); double Juice1 =iCustom(NULL,0,"Juice" ,0,0); double PAsctrnd1= 0, PAsctrnd2= 0; if (UseAscTrend) { PAsctrnd1= iCustom(NULL,0,"PerkyAsctrend1",0,0); PAsctrnd2= iCustom(NULL,0,"PerkyAsctrend1",1,0); } else { PAsctrnd1= 1; // not taken into account (make it irrelevant, i.e. set always true) PAsctrnd2= 1; } // must be checked after AscTrend(!) double Laguerre1= iCustom(NULL,0,"Laguerre",0,0); double Laguerre2= iCustom(NULL,0,"Laguerre",0,1); if (Laguerre2<0.15 && Laguerre1>=0.15) { LaguerreSignal= 1; // LONG LaguerreSignaltime= Time[0]; } else if (Laguerre2>0.75 && Laguerre1<=0.75) { LaguerreSignal= -1; // SHORT LaguerreSignaltime= Time[0]; } if (LaguerreSignal!=0 && (Time[0]-LaguerreSignaltime)>LaguerreValidityMinutes*60) { LaguerreSignal= 0; // expire laguerre crossing signal after n mintues } res= 0; if(Juice1>0.0 && UL-DL>MinChannelWidth*Point && (Time[0]-LastSignalTime)>PauseToReEntryMinutes*60) { if(MIDL2>MIDL1 && Ask<UL && Ask>DL && i_Trend1>i_Trend2 && LaguerreSignal==1 && PAsctrnd1>0.0){ res= OrderSend(Symbol(),OP_BUY ,1,Ask,5, Ask-StopLoss*Point, Ask+TakeProfit*Point, "",0,0,LONGCOLOR); } if(MIDL2<MIDL1 && Bid<UL && Bid>DL && i_Trend1<i_Trend2 && LaguerreSignal==-1 && PAsctrnd2>0.0){ res= OrderSend(Symbol(),OP_SELL,1,Bid,5,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",0,0,SHORTCOLOR); } if (res!=0) { LastSignalTime= Time[0]; Print("**** TRADE ****"); } } if (res!=0 || DebugTrace) { Print(Symbol()," ", Bid, "/", Ask, " -- Laguerre2/1/sig= ",Laguerre2, "/",Laguerre1, "/", LaguerreSignal, ", Juice= ",Juice1); Print(" SHI= ", MIDL2-MIDL1, ", ITrend= ", i_Trend1,"/",i_Trend2, ", AscTrend= ", PAsctrnd1, "/", PAsctrnd2); } } else{ for( int i=0; i<OrdersTotal();i++){ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if (OrderSymbol()!=Symbol()) continue; double trailstop= TrailingStop*Point, trailstoptrigger= TrailingStopTrigger*Point, unrealisedprofit; switch (OrderType()){ case OP_BUY: unrealisedprofit= Bid-OrderOpenPrice(); if (TrailingStop && unrealisedprofit>trailstoptrigger && (!OrderStopLoss() || OrderStopLoss()<Bid-trailstop)) OrderModify(OrderTicket(),0,Bid-trailstop,OrderTakeProfit(),0,LONGCOLOR); break; case OP_SELL: unrealisedprofit= OrderOpenPrice()-Ask; if (TrailingStop && unrealisedprofit>trailstoptrigger && (!OrderStopLoss() || OrderStopLoss()>Ask+trailstop)) OrderModify(OrderTicket(),0,Ask+trailstop,OrderTakeProfit(),0,SHORTCOLOR); break; } } } }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Juice
Laguerre
i_Trend
SHI_Channel
PerkyAsctrend1
Order Management characteristics:
Checks for the total of open orders
It automatically opens orders when conditions are reached
It can change open orders parameters, due to possible stepping strategy
Other Features: