double GetPipRange() { if (StringFind(Symbol(), "JPY", 0) > 0) return (0.01); else return (0.0001); } double GetPipValue(string symbol) { double tickSize = 0.0001; if (StringFind(symbol, "JPY", 0) != -1) tickSize = 0.01; //Case 1 - USD is in the second part of the pair if (StringFind(symbol, "USD", 0) == 3) { return (0.0001); } //Case 2 - USD is in the first half of the name if (StringFind(symbol, "USD", 0) == 0) { return ( tickSize / MarketInfo(symbol, MODE_BID) ); } //Case 3 - USD doesnt appear in the name of the pair if (StringFind(symbol, "USD", 0) == -1) { string matchingUSDpair = GetMatchingUSDPair(symbol); //3.1 - the matching pair contains USD in the first position if ( StringFind(matchingUSDpair, "USD", 0) == 0 ) { return ( tickSize / MarketInfo(matchingUSDpair, MODE_BID) ); } else //3.2 - the matching pair containd USD in the second half of the name { return ( tickSize * MarketInfo(matchingUSDpair, MODE_BID)/ MarketInfo(symbol, MODE_BID) ); } } } string GetMatchingUSDPair(string symbol) { string matchingPair; string usdPairs[13] = { "EURUSD", "GBPUSD", "USDJPY", "USDCHF", "USDCAD", "AUDUSD", "NZDUSD", "USDSGD", "USDNOK", "USDDKK", "USDSEK", "USDHKD", "USDMXN" }; //Get last 3 characters of symbol entered as parameter string baseCurrency = StringSubstr(symbol, 3, 3); bool found = false; int i = 0; while ((found == false) && (i < 13) ) { if (usdPairs[i] == baseCurrency + "USD" || usdPairs[i] == "USD" + baseCurrency ) { matchingPair = usdPairs[i]; found = true; } i++; } return (matchingPair); } void AnalyzeExitSituation() { //Close trades that are two bars old int totalOrders = OrdersTotal(); int i = 0; while (i < totalOrders) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES ) == true) // If there is the next one { if (OrderSymbol() == Symbol() && OrderMagicNumber() == magicNumber) { if (Time[barsToExit] >= OrderOpenTime() ) { if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 3); if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, 3); } } } i++; } } bool BullishMomentum(int bars) { double yesterdayClose = Close[1]; int i = 2; bool isHighest = true; while (i <= bars && isHighest == true) { if (yesterdayClose < Close[i]) isHighest = false; i++; } return (isHighest); } bool BearishMomentum(int bars) { double yesterdayClose = Close[1]; int i = 2; bool isLowest = true; while (i <= bars && isLowest == true) { if (yesterdayClose > Close[i]) isLowest = false; i++; } return (isLowest); }