+------------------------------------------------------------------+ //| FX185mq4 | //| Copyright @2006, Hua Ai (aha) | //| | //+------------------------------------------------------------------+ #property copyright "Copyright @2006, Hua Ai (aha)" #property link "" //Adjustable parameters extern int FasterEMA = 5; extern int SlowerEMA = 12; extern int RSIPeriod = 21; extern double TotalLots = 3.0; extern int TPLevel1 = 55; extern double TPLevel1Lots = 1.0; extern int TPLevel2 = 89; extern double TPLevel2Lots = 1.0; extern int TPLevel3 = 144; //Parameters optimized for different pairs int TrailingStop = 30; int CrossEffectiveTime = 2; int TunnelBandWidth = 0; int TunnelSafeZone = 120; int HardStopLoss = 30; int StopLossToFibo = 20; bool LondonOpen = true; bool NewYorkOpen = true; bool TokyoOpen = true; // Indicator buffers to mark the signal double CrossUp[]; double CrossDown[]; // State registers store cross up/down information bool EMACrossedUp; bool EMACrossedDown; bool RSICrossedUp; bool RSICrossedDown; bool TunnelCrossedUp; bool TunnelCrossedDown; // Cross up/down info should expire in a couple of bars. // Timer registers to control the expiration. int EMACrossedUpTimer; int RSICrossedUpTimer; int EMACrossedDownTimer; int RSICrossedDownTimer; //bool startup; //int SignalLabeled; // 0: initial state; 1: up; 2: down. //bool upalert,downalert; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { if (Symbol() == "EURUSD") { TrailingStop = 25; CrossEffectiveTime = 2; TunnelBandWidth = 5; TunnelSafeZone = 120; HardStopLoss = 30; StopLossToFibo = 50; LondonOpen = true; // ok NewYorkOpen = true; // the best TokyoOpen = false;// disaster } else if (Symbol() == "GBPUSD") { TrailingStop = 50; CrossEffectiveTime = 2; TunnelBandWidth = 8; TunnelSafeZone = 160; HardStopLoss = 30; StopLossToFibo = 15; LondonOpen = true; // ok NewYorkOpen = false;// so so TokyoOpen = true; // the best } else if (Symbol() == "USDCHF") { TrailingStop = 70; CrossEffectiveTime = 2; TunnelBandWidth = 9; TunnelSafeZone = 160; HardStopLoss = 30; StopLossToFibo = 30; LondonOpen = true; // Great NewYorkOpen = true; // Ok TokyoOpen = true; // so so } else if (Symbol() == "AUDUSD") { TrailingStop = 60; CrossEffectiveTime = 2; TunnelBandWidth = 6; TunnelSafeZone = 70; HardStopLoss = 30; StopLossToFibo = 30; LondonOpen = true; // Great NewYorkOpen = true; // Ok TokyoOpen = true; // so so } // No cross EMACrossedUp = false; RSICrossedUp = false; TunnelCrossedUp = false; EMACrossedDown = false; RSICrossedDown = false; TunnelCrossedDown = false; // Reset timers EMACrossedUpTimer = 0; RSICrossedUpTimer = 0; EMACrossedDownTimer = 0; RSICrossedDownTimer = 0; //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- EMACrossedUp = false; RSICrossedUp = false; TunnelCrossedUp = false; EMACrossedDown = false; RSICrossedDown = false; TunnelCrossedDown = false; EMACrossedUpTimer = 0; RSICrossedUpTimer = 0; EMACrossedDownTimer = 0; RSICrossedDownTimer = 0; //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int i, cnt, total, ticket, orders; double fasterEMAnow, slowerEMAnow; double fasterEMAprevious, slowerEMAprevious; double RSInow, RSIprevious; double VegasTunnelFast, VegasTunnelSlow; double VegasPriceCrossedL, VegasPriceCrossedS; if (Minute()=CrossEffectiveTime) RSICrossedUp = false; // Reset state register when crossed 3 bars ago // Check if there is a RSI cross down if ((RSInow < 50) && (RSIprevious > 50) && (RSICrossedDown == false)) { RSICrossedUp = false; RSICrossedDown = true; } if (RSICrossedDown == true) RSICrossedDownTimer++; // Record the number of bars the cross has happened else RSICrossedDownTimer=0; // Reset the timer once the cross is reversed if (RSICrossedDownTimer>=CrossEffectiveTime) RSICrossedDown = false; // Reset register when crossed 3 bars ago // Check if there is a EMA cross up if ( (fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (EMACrossedUp == false) ) { EMACrossedUp = true; EMACrossedDown = false; } if (EMACrossedUp == true) EMACrossedUpTimer++; // Record the number of bars the cross has happened else EMACrossedUpTimer=0; // Reset the timer once the cross is reversed if (EMACrossedUpTimer>=CrossEffectiveTime) EMACrossedUp = false; // Reset register when crossed 3 bars ago // Check if there is a EMA cross down if ( (fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (EMACrossedDown == false) ) { EMACrossedUp = false; EMACrossedDown = true; } if (EMACrossedDown == true) EMACrossedDownTimer++; // Record the number of bars the cross has happened else EMACrossedDownTimer=0; // Reset the timer once the cross is reversed if (EMACrossedDownTimer>=CrossEffectiveTime) EMACrossedDown = false; // Reset register when crossed 3 bars ago if ((Close[1]>VegasTunnelFast && Close[1]>VegasTunnelSlow) && (Close[2]VegasPriceCrossedS+(TunnelBandWidth+StopLossToFibo)*Point) OrderModify(OrderTicket(),Bid,VegasPriceCrossedS+(TunnelBandWidth+StopLossToFibo)*Point,OrderTakeProfit(),0); continue; } else { if(AskVegasPriceCrossedS+(TPLevel1+StopLossToFibo)*Point) OrderModify(OrderTicket(),Bid,VegasPriceCrossedS+(TPLevel1+StopLossToFibo)*Point,OrderTakeProfit(),0); continue; } // Reach 2nd TP level, close the 2nd lot, move up remainder stop to TPLevel2-StopLossToFibo // Or start trailing stop else if(AskVegasPriceCrossedS+(TPLevel2+StopLossToFibo)*Point) OrderModify(OrderTicket(),Bid,VegasPriceCrossedS+(TPLevel2+StopLossToFibo)*Point,OrderTakeProfit(),0); continue; } // Reach 1nd TP level, close the 1st lot, move up remainder stop to TPLevel1-StopLossToFibo else if(AskVegasPriceCrossedS+(TPLevel3+StopLossToFibo)*Point) OrderModify(OrderTicket(),Bid,VegasPriceCrossedS+(TPLevel3+StopLossToFibo)*Point,OrderTakeProfit(),0); continue; } } } } } // ********************************************************************* // based on states, determine entry situations. // ********************************************************************* //Check the trading time if ( !((LondonOpen==true && Hour()>=7 && Hour()=12 && Hour()=0 && Hour()=23 && Hour() |
新系统
回复:0 浏览:386
- 楼主admin 圈主
- 2019-05-05 13:36