├── AcceleratorOscillator.mq5 ├── AccumulationDistributionEA.mq5 ├── AdaptiveMovingAverage.mq5 ├── AdnancedMomentumEA_Version-1.mq5 ├── AdvancedAdaptiveMovingAverage.mq5 ├── AdvancedBbreakEvenStop.mq5 ├── AdvancedCommodityChannelIndex.mq5 ├── AdvancedIVIDyA.mq5 ├── AdvancedMomentumEA.mq5 ├── AdvancedMomentumEAforBTCAUD20.mq5 ├── AdvancedMomentumEAforBTCUSD20.mq5 ├── AdvancedRelativeVigorIndex.mq5 ├── AdvancedSARExpertAdvisor.mq5 ├── AdvancedTradingRange.mq5 ├── AdvancedTrailingStop.mq5 ├── AdvancedWPR.mq5 ├── AdvanncedSMA.mq5 ├── AdvfanceEMAcrossOver.mq5 ├── AverageDirectionalMovingIndex.mq5 ├── AverageTrueRange.mq5 ├── AwesomeOscillatorEA.mq5 ├── BollingerBandsStandaloneEA.mq5 ├── BullsPowerOscillator.mq5 ├── BullsPowerOscillatorStandalone.mq5 ├── BuyLimit.mq5 ├── BuyStop.mq5 ├── ChartEventMouseDown.mq5 ├── ChartObject.mq5 ├── Chartevent_Click.mq5 ├── CheckEntryBollingerBands.mq5 ├── CheckEntry_MacD.mq5 ├── CheckFilter_Volumes.mq5 ├── CheckSignal_BollingerBands.mq5 ├── CommodityChannelIndex.mq5 ├── DeMarker.mq5 ├── DoubleExponentialMovingAverage.mq5 ├── DynnamicPositionSize.mq5 ├── EA_MA_Cross_Over.mq5 ├── Envelopes.mq5 ├── FirstProgram.mq5 ├── ForceIndex.mq5 ├── FractalAdaptiveMovingAverage.mq5 ├── GetSignal_All.mq5 ├── HighestCandle.mq5 ├── IchimokuH1GBPUSD.mq5 ├── MacD.mq5 ├── MacDStandaloneEA.mq5 ├── MainModule.mq5 ├── Momentum_TripleMA_WPR.mq5 ├── MonneyFlowIndex.mq5 ├── MyExampleOne.mq5 ├── MyFramework1.mq5 ├── MyStrategyTester.mq5 ├── ObjectLabel.mq5 ├── ObjectOrientedLine.mq5 ├── OnBalanceVolumeEA.mq5 ├── ParabolicSAAR.mq5 ├── PositionMultiplier.mq5 ├── README.md ├── RVIStandaloneEA.mq5 ├── RandomEntry.mq5 ├── RelativeStrengthIndex_RSI.mq5 ├── RelativeVigorIndex.mq5 ├── SellLimit.mq5 ├── ShiftedMovingAverage.mq5 ├── SignalStcking.mq5 ├── SiimpleEMACrossover.mq5 ├── SimpleArrowEA.mq5 ├── SimpleBWMFI.mq5 ├── SimpleBearsPowerIndicator.mq5 ├── SimpleBollingerBands.mq5 ├── SimpleBuy.mq5 ├── SimpleCancelOrder.mq5 ├── SimpleChaikinEA.mq5 ├── SimpleCustomDateTime.mq5 ├── SimpleDoji.mq5 ├── SimpleEnvelopes.mq5 ├── SimpleExternalSignal.mq5 ├── SimpleHighestLowesAndAverageCandle.mq5 ├── SimpleIchimoku.mq5 ├── SimpleMomentum.mq5 ├── SimpleMouseClickEvent.mq5 ├── SimpleMovingAverage.mq5 ├── SimpleNewCandle.mq5 ├── SimpleOrderHistoryProfit.mq5 ├── SimplePositionCount.mq5 ├── SimplePriceInfo.mq5 ├── SimpleRSI.mq5 ├── SimpleRSIBollingerBandEntry.mq5 ├── SimpleRSIBollingerEntry.mq5 ├── SimpleRectangle.mq5 ├── SimpleStandardDeviation.mq5 ├── SimpleSwapInfo.mq5 ├── SimpleSymbolInfo.mq5 ├── SimpleTimeBasedEntry.mq5 ├── SimpleTripleExponentialMovinngAverage.mq5 ├── SimpleVolumesFilter.mq5 ├── StochasticOscillator.mq5 ├── TrendBasedSellStop.mq5 ├── TrendFilter.mq5 └── TripleMovingAverage.mq5 /AcceleratorOscillator.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(GetValue_AccceleratorOscillator() > 0.0001 && GetPositions_Sell() < 100) 10 | trade.Sell(0.01, NULL, Bid, 0, Bid - (300 * _Point), NULL); 11 | if(GetValue_AccceleratorOscillator() < -0.0001 && GetPositions_Buy() < 100) 12 | trade.Buy(0.01, NULL, Ask, 0, Ask + (300 * _Point), NULL); 13 | 14 | /* 15 | if(CheckEntry_AccceleratorOscillator() == "Long" && GetPositions_Sell() < 100) 16 | trade.Sell(0.01, NULL, Bid, 0, Bid - (300 * _Point), NULL); 17 | 18 | if(CheckEntry_AccceleratorOscillator() == "Short" && GetPositions_Buy() < 100) 19 | trade.Buy(0.01, NULL, Ask, 0, Ask + (300 * _Point), NULL); 20 | */ 21 | 22 | Comment("Buy Positions: ", GetPositions_Buy(), "\nSell Positions: ", GetPositions_Sell(), "\nValue: ", GetValue_AccceleratorOscillator()); 23 | 24 | } 25 | 26 | double GetValue_AccceleratorOscillator() 27 | { 28 | double Value = 0.00; 29 | 30 | double AcceleratorOscillatorArray[]; 31 | ArraySetAsSeries(AcceleratorOscillatorArray, true); 32 | int AcceleratorOscillatorHandler = iAC(_Symbol, _Period); 33 | CopyBuffer(AcceleratorOscillatorHandler, 0, 0, 3, AcceleratorOscillatorArray); 34 | Value = AcceleratorOscillatorArray[0]; 35 | return Value; 36 | } 37 | 38 | string CheckEntry_AccceleratorOscillator() 39 | { 40 | string Signal = ""; 41 | 42 | double AcceleratorOscillatorArray[]; 43 | ArraySetAsSeries(AcceleratorOscillatorArray, true); 44 | int AcceleratorOscillatorHandler = iAC(_Symbol, _Period); 45 | CopyBuffer(AcceleratorOscillatorHandler, 0, 0, 3, AcceleratorOscillatorArray); 46 | double Current_AcceleratorOscillator_Value = AcceleratorOscillatorArray[0]; 47 | double Previous_AcceleratorOscillator_Value = AcceleratorOscillatorArray[1]; 48 | 49 | if(Current_AcceleratorOscillator_Value > 0 && Previous_AcceleratorOscillator_Value > Current_AcceleratorOscillator_Value) 50 | Signal = "Long"; 51 | if(Current_AcceleratorOscillator_Value < 0 && Previous_AcceleratorOscillator_Value < Current_AcceleratorOscillator_Value) 52 | Signal = "Short"; 53 | 54 | return Signal; 55 | } 56 | 57 | int GetPositions_Sell() 58 | { 59 | int numberOfSellPositions = 0; 60 | 61 | for(int i = PositionsTotal() -1; i >= 0; i--) 62 | { 63 | string CurrencyPair = PositionGetSymbol(i); 64 | 65 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 66 | 67 | if(Symbol() == CurrencyPair) 68 | { 69 | if(PositionDirection == POSITION_TYPE_SELL) 70 | { 71 | numberOfSellPositions = numberOfSellPositions + 1; 72 | } 73 | } 74 | } 75 | 76 | return numberOfSellPositions; 77 | } 78 | 79 | int GetPositions_Buy() 80 | { 81 | int numberOfBuyPositions = 0; 82 | 83 | for(int i = PositionsTotal() -1; i >= 0; i--) 84 | { 85 | string CurrencyPair = PositionGetSymbol(i); 86 | 87 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 88 | 89 | if(Symbol() == CurrencyPair) 90 | { 91 | if(PositionDirection == POSITION_TYPE_BUY) 92 | { 93 | numberOfBuyPositions = numberOfBuyPositions + 1; 94 | } 95 | } 96 | } 97 | 98 | return numberOfBuyPositions; 99 | } -------------------------------------------------------------------------------- /AccumulationDistributionEA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | TradeNowOnAccumulationDistribution(); 7 | Comment( 8 | "\nTotal Buy Positions : ", GetPositions_Buy(), 9 | "\nTotal Sell Positions : ", GetPositions_Sell(), 10 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 11 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 12 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 13 | "\nTotal Positions : ", PositionsTotal() 14 | ); 15 | } 16 | 17 | string Check_Momentum_Entry() 18 | { 19 | string Signal = ""; 20 | 21 | double priceInformation[]; 22 | 23 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 24 | 25 | ArraySetAsSeries(priceInformation, true); 26 | 27 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 28 | 29 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 30 | 31 | if(MomentumValue > 100.00)//Over Bought 32 | { 33 | Signal = "Sell"; 34 | } 35 | 36 | if(MomentumValue < 100.00)//Over Sold 37 | { 38 | Signal = "Buy"; 39 | } 40 | 41 | return Signal; 42 | } 43 | 44 | void TradeNowOnAccumulationDistribution() 45 | { 46 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 47 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 48 | 49 | if(Check_Momentum_Entry() == "Buy" && GetPositions_Buy() < 100 && GetAccumulationDistributionSignal() == "Buy") 50 | { 51 | //For H1 52 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 53 | //For M1 54 | trade.Buy(0.01, NULL, Ask, 0, Ask + 300 * _Point, NULL); 55 | } 56 | 57 | if(Check_Momentum_Entry() == "Sell" && GetPositions_Sell() < 100 && GetAccumulationDistributionSignal() == "Sell") 58 | { 59 | //For H1 60 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 61 | //For M1 62 | trade.Sell(0.01, NULL, Bid, 0, Bid - 300 * _Point, NULL); 63 | } 64 | } 65 | 66 | void CloseAllPositions() 67 | { 68 | for(int i = PositionsTotal() -1; i >= 0; i--) 69 | { 70 | int ticket = PositionGetTicket(i); 71 | trade.PositionClose(ticket); 72 | } 73 | } 74 | 75 | int GetPositions_Sell() 76 | { 77 | int numberOfSellPositions = 0; 78 | 79 | for(int i = PositionsTotal() -1; i >= 0; i--) 80 | { 81 | string CurrencyPair = PositionGetSymbol(i); 82 | 83 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 84 | 85 | if(Symbol() == CurrencyPair) 86 | { 87 | if(PositionDirection == POSITION_TYPE_SELL) 88 | { 89 | numberOfSellPositions = numberOfSellPositions + 1; 90 | } 91 | } 92 | } 93 | 94 | return numberOfSellPositions; 95 | } 96 | 97 | int GetPositions_Buy() 98 | { 99 | int numberOfBuyPositions = 0; 100 | 101 | for(int i = PositionsTotal() -1; i >= 0; i--) 102 | { 103 | string CurrencyPair = PositionGetSymbol(i); 104 | 105 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 106 | 107 | if(Symbol() == CurrencyPair) 108 | { 109 | if(PositionDirection == POSITION_TYPE_BUY) 110 | { 111 | numberOfBuyPositions = numberOfBuyPositions + 1; 112 | } 113 | } 114 | } 115 | 116 | return numberOfBuyPositions; 117 | } 118 | 119 | string GetAccumulationDistributionSignal() 120 | { 121 | double AccumulationDistributionArray[]; 122 | int AccumulationDistributionHandler = iAD(_Symbol, _Period, VOLUME_TICK); 123 | ArraySetAsSeries(AccumulationDistributionArray, true); 124 | CopyBuffer(AccumulationDistributionHandler, 0, 0, 3, AccumulationDistributionArray); 125 | 126 | string Signal = ""; 127 | 128 | if(AccumulationDistributionArray[0] > 0) 129 | Signal = "Sell"; 130 | 131 | if(AccumulationDistributionArray[0] < 0) 132 | Signal = "Buy"; 133 | 134 | return Signal; 135 | } -------------------------------------------------------------------------------- /AdaptiveMovingAverage.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create ann array of several prices 4 | double AdaptiveMovingAverageArray[]; 5 | 6 | //Define the properties of adaptive moving average 7 | int AdaptiveMovingAverageDefinition = iAMA(_Symbol, _Period, 9, 2, 30, 0, PRICE_CLOSE); 8 | 9 | //Sort the price array from current candle downwards 10 | ArraySetAsSeries(AdaptiveMovingAverageArray, true); 11 | 12 | //Define EA, one line, current candle, 3 candles, store result 13 | CopyBuffer(AdaptiveMovingAverageDefinition, 0, 0, 3, AdaptiveMovingAverageArray); 14 | 15 | //Get the value 16 | double AdaptiveMovingAverageValue = AdaptiveMovingAverageArray[0]; 17 | 18 | Comment("Adaptive Moving Average Value : ", AdaptiveMovingAverageValue); 19 | 20 | } -------------------------------------------------------------------------------- /AdnancedMomentumEA_Version-1.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | CPositionInfo m_position; 4 | 5 | void OnTick() 6 | { 7 | TradeNowOnMomentum(); 8 | Comment( 9 | "Profit: ", DetermineVolume() 10 | 11 | ); 12 | } 13 | 14 | string Check_Momentum_Entry() 15 | { 16 | string Signal = ""; 17 | 18 | double priceInformation[]; 19 | 20 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 21 | 22 | ArraySetAsSeries(priceInformation, true); 23 | 24 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 25 | 26 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 27 | 28 | if(MomentumValue > 100.00)//Over Bought 29 | { 30 | Signal = "Sell"; 31 | } 32 | 33 | if(MomentumValue < 100.00)//Over Sold 34 | { 35 | Signal = "Buy"; 36 | } 37 | 38 | return Signal; 39 | } 40 | 41 | void TradeNowOnMomentum() 42 | { 43 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 44 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 45 | 46 | if(Check_Momentum_Entry() == "Buy" && GetPositions_Buy() < 10 && GetTripleMovingAverageSignal() == "Buy Now!") 47 | { 48 | //For H1 49 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 50 | //For M1 51 | trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 52 | } 53 | 54 | if(Check_Momentum_Entry() == "Sell" && GetPositions_Sell() < 10 && GetTripleMovingAverageSignal() == "Sell Now!") 55 | { 56 | //For H1 57 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 58 | //For M1 59 | trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 60 | } 61 | } 62 | 63 | void CloseAllPositions() 64 | { 65 | for(int i = PositionsTotal() -1; i >= 0; i--) 66 | { 67 | int ticket = PositionGetTicket(i); 68 | trade.PositionClose(ticket); 69 | } 70 | } 71 | 72 | int GetPositions_Sell() 73 | { 74 | int numberOfSellPositions = 0; 75 | 76 | for(int i = PositionsTotal() -1; i >= 0; i--) 77 | { 78 | string CurrencyPair = PositionGetSymbol(i); 79 | 80 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 81 | 82 | if(Symbol() == CurrencyPair) 83 | { 84 | if(PositionDirection == POSITION_TYPE_SELL) 85 | { 86 | numberOfSellPositions = numberOfSellPositions + 1; 87 | } 88 | } 89 | } 90 | 91 | return numberOfSellPositions; 92 | } 93 | 94 | int GetPositions_Buy() 95 | { 96 | int numberOfBuyPositions = 0; 97 | 98 | for(int i = PositionsTotal() -1; i >= 0; i--) 99 | { 100 | string CurrencyPair = PositionGetSymbol(i); 101 | 102 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 103 | 104 | if(Symbol() == CurrencyPair) 105 | { 106 | if(PositionDirection == POSITION_TYPE_BUY) 107 | { 108 | numberOfBuyPositions = numberOfBuyPositions + 1; 109 | } 110 | } 111 | } 112 | 113 | return numberOfBuyPositions; 114 | } 115 | 116 | string GetTripleMovingAverageSignal() 117 | { 118 | double movingAverage100Array[]; 119 | double movingAverage50Array[]; 120 | double movingAverage10Array[]; 121 | 122 | int movingAverage100Definition = iMA(_Symbol, _Period, 100, 0, MODE_SMA, PRICE_CLOSE); 123 | int movingAverage50Definition = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); 124 | int movingAverage10Definition = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); 125 | 126 | ArraySetAsSeries(movingAverage100Array, true); 127 | ArraySetAsSeries(movingAverage50Array, true); 128 | ArraySetAsSeries(movingAverage10Array, true); 129 | 130 | CopyBuffer(movingAverage100Definition, 0, 0, 10, movingAverage100Array); 131 | CopyBuffer(movingAverage50Definition, 0, 0, 10, movingAverage50Array); 132 | CopyBuffer(movingAverage10Definition, 0, 0, 10, movingAverage10Array); 133 | 134 | string Signal = ""; 135 | 136 | if(movingAverage100Array[0] > movingAverage50Array[0]) 137 | if(movingAverage50Array[0] > movingAverage10Array[0]) 138 | Signal = "Buy Now!"; 139 | 140 | if(movingAverage100Array[0] < movingAverage50Array[0]) 141 | if(movingAverage50Array[0] < movingAverage10Array[0]) 142 | Signal = "Sell Now!"; 143 | 144 | return Signal; 145 | } 146 | 147 | double DetermineVolume() 148 | { 149 | double profit = 0; 150 | for(int i = PositionsTotal() - 1; i >= 0; i--) 151 | { 152 | string symbol = PositionGetString(POSITION_SYMBOL); 153 | if(_Symbol == symbol) 154 | { 155 | m_position.SelectByIndex(i); 156 | profit += (m_position.Profit() + m_position.Swap() + m_position.Commission()); 157 | } 158 | } 159 | 160 | return profit; 161 | } -------------------------------------------------------------------------------- /AdvancedAdaptiveMovingAverage.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | TradeNowOnAdaptiveMovingAverage(); 7 | Comment( 8 | "\nTotal Buy Positions : ", GetPositions_Buy(), 9 | "\nTotal Sell Positions : ", GetPositions_Sell(), 10 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 11 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 12 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 13 | "\nTotal Positions : ", PositionsTotal() 14 | ); 15 | } 16 | 17 | 18 | void TradeNowOnAdaptiveMovingAverage() 19 | { 20 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 21 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 22 | 23 | if(GetAdaptiveMovingAverageSignal() == "Buy" && GetPositions_Buy() < 100) 24 | { 25 | //For H1 26 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 27 | //For M1 28 | trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 29 | } 30 | 31 | if(GetAdaptiveMovingAverageSignal() == "Sell" && GetPositions_Sell() < 100) 32 | { 33 | //For H1 34 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 35 | //For M1 36 | trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 37 | } 38 | } 39 | 40 | void CloseAllPositions() 41 | { 42 | for(int i = PositionsTotal() -1; i >= 0; i--) 43 | { 44 | int ticket = PositionGetTicket(i); 45 | trade.PositionClose(ticket); 46 | } 47 | } 48 | 49 | int GetPositions_Sell() 50 | { 51 | int numberOfSellPositions = 0; 52 | 53 | for(int i = PositionsTotal() -1; i >= 0; i--) 54 | { 55 | string CurrencyPair = PositionGetSymbol(i); 56 | 57 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 58 | 59 | if(Symbol() == CurrencyPair) 60 | { 61 | if(PositionDirection == POSITION_TYPE_SELL) 62 | { 63 | numberOfSellPositions = numberOfSellPositions + 1; 64 | } 65 | } 66 | } 67 | 68 | return numberOfSellPositions; 69 | } 70 | 71 | int GetPositions_Buy() 72 | { 73 | int numberOfBuyPositions = 0; 74 | 75 | for(int i = PositionsTotal() -1; i >= 0; i--) 76 | { 77 | string CurrencyPair = PositionGetSymbol(i); 78 | 79 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 80 | 81 | if(Symbol() == CurrencyPair) 82 | { 83 | if(PositionDirection == POSITION_TYPE_BUY) 84 | { 85 | numberOfBuyPositions = numberOfBuyPositions + 1; 86 | } 87 | } 88 | } 89 | 90 | return numberOfBuyPositions; 91 | } 92 | 93 | string GetAdaptiveMovingAverageSignal() 94 | { 95 | MqlRates priceInformation[]; 96 | ArraySetAsSeries(priceInformation, true); 97 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), priceInformation); 98 | 99 | double AdaptiveMovingAverageArray[]; 100 | int AdaptiveMovingAverageHandler = iAMA(_Symbol, _Period, 9, 2, 30, 0, PRICE_CLOSE); 101 | ArraySetAsSeries(AdaptiveMovingAverageArray, true); 102 | CopyBuffer(AdaptiveMovingAverageHandler, 0, 0, 3, AdaptiveMovingAverageArray); 103 | 104 | double AdaptiveMovingAverageValue = NormalizeDouble(AdaptiveMovingAverageArray[0], 6); 105 | 106 | string Signal = ""; 107 | 108 | if(AdaptiveMovingAverageValue > priceInformation[0].close) 109 | Signal = "Sell"; 110 | if(AdaptiveMovingAverageValue < priceInformation[0].close) 111 | Signal = "Buy"; 112 | 113 | return Signal; 114 | } -------------------------------------------------------------------------------- /AdvancedBbreakEvenStop.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | 8 | if(PositionsTotal() < 12) 9 | trade.Buy(0.10, NULL, Ask, Ask - 300 * _Point, Ask + 300 * _Point, NULL); 10 | 11 | CheckBreakEventStop(Ask); 12 | } 13 | 14 | void CheckBreakEventStop(double Ask) 15 | { 16 | for(int i=PositionsTotal(); i>0; i--) 17 | { 18 | string Symbol = PositionGetSymbol(i); 19 | 20 | if(_Symbol == Symbol) 21 | { 22 | //Get the ticket number 23 | ulong PositionTicket = PositionGetInteger(POSITION_TICKET); 24 | //Get the position buy price 25 | double PositionBuyPrice = PositionGetDouble(POSITION_PRICE_OPEN);; 26 | 27 | if(Ask > PositionBuyPrice + 100 * _Point) 28 | { 29 | //Modify the stop loss 30 | trade.PositionModify(PositionTicket, PositionBuyPrice, 0); 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /AdvancedCommodityChannelIndex.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double balance = AccountInfoDouble(ACCOUNT_BALANCE); 7 | double equity = AccountInfoDouble(ACCOUNT_EQUITY); 8 | double profit = AccountInfoDouble(ACCOUNT_PROFIT); 9 | string method = ""; 10 | 11 | if(profit < -1000) 12 | { 13 | TradeNowOnMomentum(); 14 | method = "Momentum Trading..."; 15 | } 16 | else 17 | { 18 | TradeOnCommodityChannelIndex(); 19 | method = "CCI Trading..."; 20 | } 21 | 22 | Comment( 23 | "\nTotal Buy Positions : ", GetPositions_Buy(), 24 | "\nTotal Sell Positions : ", GetPositions_Sell(), 25 | "\nAccount Balance : ", balance, 26 | "\nAccount Equity : ", equity, 27 | "\nAccount Profit : ", profit, 28 | "\nTotal Positions : ", PositionsTotal(), 29 | "\nAction : ", method 30 | 31 | ); 32 | } 33 | 34 | void TradeOnCommodityChannelIndex() 35 | { 36 | 37 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 38 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 39 | 40 | if(Get_CommodityChannelIndex_Signal() == "Buy" && GetPositions_Buy() < 50) 41 | { 42 | trade.Buy(0.01, NULL, Ask, 0, Ask + (500 * _Point), NULL); 43 | } 44 | 45 | if(Get_CommodityChannelIndex_Signal() == "Sell" && GetPositions_Sell() < 50) 46 | { 47 | trade.Sell(0.01, NULL, Bid, 0, Bid - (500 * _Point), NULL); 48 | } 49 | } 50 | 51 | string Get_CommodityChannelIndex_Signal() 52 | { 53 | string Signal = ""; 54 | 55 | double CommodityChannelIndexArray[]; 56 | int CommodityChannelIndexHandler = iCCI(_Symbol, _Period, 32, PRICE_TYPICAL); 57 | ArraySetAsSeries(CommodityChannelIndexArray, true); 58 | CopyBuffer(CommodityChannelIndexHandler, 0, 0, 3, CommodityChannelIndexArray); 59 | float CommodityChannelIndexValue = CommodityChannelIndexArray[0]; 60 | 61 | if(CommodityChannelIndexValue > 200) 62 | Signal = "Sell"; 63 | if(CommodityChannelIndexValue < -200) 64 | Signal = "Buy"; 65 | 66 | return Signal; 67 | } 68 | 69 | void CloseAllPositions() 70 | { 71 | for(int i = PositionsTotal() -1; i >= 0; i--) 72 | { 73 | int ticket = PositionGetTicket(i); 74 | trade.PositionClose(ticket); 75 | } 76 | } 77 | 78 | int GetPositions_Sell() 79 | { 80 | int numberOfSellPositions = 0; 81 | 82 | for(int i = PositionsTotal() -1; i >= 0; i--) 83 | { 84 | string CurrencyPair = PositionGetSymbol(i); 85 | 86 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 87 | 88 | if(Symbol() == CurrencyPair) 89 | { 90 | if(PositionDirection == POSITION_TYPE_SELL) 91 | { 92 | numberOfSellPositions = numberOfSellPositions + 1; 93 | } 94 | } 95 | } 96 | 97 | return numberOfSellPositions; 98 | } 99 | 100 | int GetPositions_Buy() 101 | { 102 | int numberOfBuyPositions = 0; 103 | 104 | for(int i = PositionsTotal() -1; i >= 0; i--) 105 | { 106 | string CurrencyPair = PositionGetSymbol(i); 107 | 108 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 109 | 110 | if(Symbol() == CurrencyPair) 111 | { 112 | if(PositionDirection == POSITION_TYPE_BUY) 113 | { 114 | numberOfBuyPositions = numberOfBuyPositions + 1; 115 | } 116 | } 117 | } 118 | 119 | return numberOfBuyPositions; 120 | } 121 | 122 | string Check_Momentum_Entry() 123 | { 124 | string Signal = ""; 125 | 126 | double priceInformation[]; 127 | 128 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 129 | 130 | ArraySetAsSeries(priceInformation, true); 131 | 132 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 133 | 134 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 135 | 136 | if(MomentumValue > 100.00)//Over Bought 137 | { 138 | Signal = "Sell"; 139 | } 140 | 141 | if(MomentumValue < 100.00)//Over Sold 142 | { 143 | Signal = "Buy"; 144 | } 145 | 146 | return Signal; 147 | } 148 | 149 | void TradeNowOnMomentum() 150 | { 151 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 152 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 153 | 154 | if(Check_Momentum_Entry() == "Buy" && GetPositions_Buy() < 100 && GetTripleMovingAverageSignal() == "Buy Now!") 155 | { 156 | trade.Buy(0.01, NULL, Ask, 0, Ask + 300 * _Point, NULL); 157 | } 158 | 159 | if(Check_Momentum_Entry() == "Sell" && GetPositions_Sell() < 100 && GetTripleMovingAverageSignal() == "Sell Now!") 160 | { 161 | trade.Sell(0.01, NULL, Bid, 0, Bid - 300 * _Point, NULL); 162 | } 163 | } 164 | 165 | string GetTripleMovingAverageSignal() 166 | { 167 | double movingAverage100Array[]; 168 | double movingAverage50Array[]; 169 | double movingAverage10Array[]; 170 | 171 | int movingAverage100Definition = iMA(_Symbol, _Period, 100, 0, MODE_SMA, PRICE_CLOSE); 172 | int movingAverage50Definition = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); 173 | int movingAverage10Definition = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); 174 | 175 | ArraySetAsSeries(movingAverage100Array, true); 176 | ArraySetAsSeries(movingAverage50Array, true); 177 | ArraySetAsSeries(movingAverage10Array, true); 178 | 179 | CopyBuffer(movingAverage100Definition, 0, 0, 10, movingAverage100Array); 180 | CopyBuffer(movingAverage50Definition, 0, 0, 10, movingAverage50Array); 181 | CopyBuffer(movingAverage10Definition, 0, 0, 10, movingAverage10Array); 182 | 183 | string Signal = ""; 184 | 185 | if(movingAverage100Array[0] > movingAverage50Array[0]) 186 | if(movingAverage50Array[0] > movingAverage10Array[0]) 187 | Signal = "Buy Now!"; 188 | 189 | if(movingAverage100Array[0] < movingAverage50Array[0]) 190 | if(movingAverage50Array[0] < movingAverage10Array[0]) 191 | Signal = "Sell Now!"; 192 | 193 | return Signal; 194 | } -------------------------------------------------------------------------------- /AdvancedIVIDyA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(checkEntry_VariableIndexDynamicAverage() == "Buy" && GetPositions_Buy() < 100 && Check_Momentum_Entry() == "Buy") 10 | trade.Buy(0.01, NULL, Ask, 0, Ask + (100 * _Point), NULL); 11 | if(checkEntry_VariableIndexDynamicAverage() == "Sell" && GetPositions_Sell() < 100 && Check_Momentum_Entry() == "Sell") 12 | trade.Sell(0.01, NULL, Bid, 0, Bid - (100 * _Point), NULL); 13 | 14 | Comment( 15 | "\nTotal Buy Positions : ", GetPositions_Buy(), 16 | "\nTotal Sell Positions : ", GetPositions_Sell(), 17 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 18 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 19 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 20 | "\nTotal Positions : ", PositionsTotal() 21 | ); 22 | } 23 | 24 | string checkEntry_VariableIndexDynamicAverage() 25 | { 26 | string Signal = ""; 27 | MqlRates priceInfo[]; 28 | ArraySetAsSeries(priceInfo, true); 29 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInfo); 30 | 31 | double VariableIndexDynamicAverageArray[]; 32 | int VariableIndexDynamicAverageHandler = iVIDyA(_Symbol, _Period, 9, 12, 0, PRICE_CLOSE); 33 | ArraySetAsSeries(VariableIndexDynamicAverageArray, true); 34 | CopyBuffer(VariableIndexDynamicAverageHandler, 0, 0, 3, VariableIndexDynamicAverageArray); 35 | float VariableIndexDynamicAverageValue = VariableIndexDynamicAverageArray[0]; 36 | 37 | if(VariableIndexDynamicAverageValue > priceInfo[1].close && VariableIndexDynamicAverageValue < priceInfo[2].close) 38 | Signal = "Sell"; 39 | if(VariableIndexDynamicAverageValue < priceInfo[1].close && VariableIndexDynamicAverageValue > priceInfo[2].close) 40 | Signal = "Buy"; 41 | 42 | return Signal; 43 | } 44 | 45 | string Check_Momentum_Entry() 46 | { 47 | string Signal = ""; 48 | 49 | double priceInformation[]; 50 | 51 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 52 | 53 | ArraySetAsSeries(priceInformation, true); 54 | 55 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 56 | 57 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 58 | 59 | if(MomentumValue > 100.00)//Over Bought 60 | { 61 | Signal = "Sell"; 62 | } 63 | 64 | if(MomentumValue < 100.00)//Over Sold 65 | { 66 | Signal = "Buy"; 67 | } 68 | 69 | return Signal; 70 | } 71 | 72 | int GetPositions_Buy() 73 | { 74 | int numberOfPositionsBuy = 0; 75 | 76 | for(int i = PositionsTotal() - 1; i >= 0; i--) 77 | { 78 | string currenyPair = PositionGetSymbol(i); 79 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 80 | if(currenyPair == _Symbol) 81 | if(PositionDirection == POSITION_TYPE_BUY) 82 | numberOfPositionsBuy++; 83 | } 84 | return numberOfPositionsBuy; 85 | } 86 | 87 | int GetPositions_Sell() 88 | { 89 | int numberOfPositionsSell = 0; 90 | 91 | for(int i = PositionsTotal() - 1; i >= 0; i--) 92 | { 93 | string currencyPair = PositionGetSymbol(i); 94 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 95 | 96 | if(currencyPair == _Symbol) 97 | if(PositionDirection == POSITION_TYPE_SELL) 98 | numberOfPositionsSell++; 99 | } 100 | return numberOfPositionsSell; 101 | } -------------------------------------------------------------------------------- /AdvancedMomentumEA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | TradeNowOnMomentum(); 7 | Comment( 8 | "\nTotal Buy Positions : ", GetPositions_Buy(), 9 | "\nTotal Sell Positions : ", GetPositions_Sell(), 10 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 11 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 12 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 13 | "\nTotal Positions : ", PositionsTotal(), 14 | "\nMomentum : ", Check_Momentum_Entry(), 15 | "\nTriple MA: ", GetTripleMovingAverageSignal() 16 | 17 | ); 18 | } 19 | 20 | string Check_Momentum_Entry() 21 | { 22 | string Signal = ""; 23 | 24 | double priceInformation[]; 25 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 26 | ArraySetAsSeries(priceInformation, true); 27 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 28 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 29 | if(MomentumValue > 100.00)//Over Bought 30 | { 31 | Signal = "Sell"; 32 | } 33 | 34 | if(MomentumValue < 100.00)//Over Sold 35 | { 36 | Signal = "Buy"; 37 | } 38 | 39 | return Signal; 40 | } 41 | 42 | void TradeNowOnMomentum() 43 | { 44 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 45 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 46 | 47 | if(Check_Momentum_Entry() == "Buy" && GetPositions_Buy() < 10 && GetTripleMovingAverageSignal() == "Buy Now!") 48 | { 49 | //For H1 50 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 51 | //For M1 52 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 53 | //For Bitcoin only 54 | trade.Buy(0.01, NULL, Ask, 0, Ask + 50000 * _Point, NULL); 55 | } 56 | 57 | if(Check_Momentum_Entry() == "Sell" && GetPositions_Sell() < 10 && GetTripleMovingAverageSignal() == "Sell Now!") 58 | { 59 | //For H1 60 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 61 | //For M1 62 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 63 | //For Bitcoin only 64 | trade.Sell(0.01, NULL, Bid, 0, Bid - 50000 * _Point, NULL); 65 | } 66 | } 67 | 68 | void CloseAllPositions() 69 | { 70 | for(int i = PositionsTotal() -1; i >= 0; i--) 71 | { 72 | int ticket = PositionGetTicket(i); 73 | trade.PositionClose(ticket); 74 | } 75 | } 76 | 77 | int GetPositions_Sell() 78 | { 79 | int numberOfSellPositions = 0; 80 | 81 | for(int i = PositionsTotal() -1; i >= 0; i--) 82 | { 83 | string CurrencyPair = PositionGetSymbol(i); 84 | 85 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 86 | 87 | if(Symbol() == CurrencyPair) 88 | { 89 | if(PositionDirection == POSITION_TYPE_SELL) 90 | { 91 | numberOfSellPositions = numberOfSellPositions + 1; 92 | } 93 | } 94 | } 95 | 96 | return numberOfSellPositions; 97 | } 98 | 99 | int GetPositions_Buy() 100 | { 101 | int numberOfBuyPositions = 0; 102 | 103 | for(int i = PositionsTotal() -1; i >= 0; i--) 104 | { 105 | string CurrencyPair = PositionGetSymbol(i); 106 | 107 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 108 | 109 | if(Symbol() == CurrencyPair) 110 | { 111 | if(PositionDirection == POSITION_TYPE_BUY) 112 | { 113 | numberOfBuyPositions = numberOfBuyPositions + 1; 114 | } 115 | } 116 | } 117 | 118 | return numberOfBuyPositions; 119 | } 120 | 121 | string GetTripleMovingAverageSignal() 122 | { 123 | double movingAverage100Array[]; 124 | double movingAverage50Array[]; 125 | double movingAverage10Array[]; 126 | 127 | int movingAverage100Definition = iMA(_Symbol, _Period, 100, 0, MODE_SMA, PRICE_CLOSE); 128 | int movingAverage50Definition = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); 129 | int movingAverage10Definition = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); 130 | 131 | ArraySetAsSeries(movingAverage100Array, true); 132 | ArraySetAsSeries(movingAverage50Array, true); 133 | ArraySetAsSeries(movingAverage10Array, true); 134 | 135 | CopyBuffer(movingAverage100Definition, 0, 0, 10, movingAverage100Array); 136 | CopyBuffer(movingAverage50Definition, 0, 0, 10, movingAverage50Array); 137 | CopyBuffer(movingAverage10Definition, 0, 0, 10, movingAverage10Array); 138 | 139 | string Signal = ""; 140 | 141 | if(movingAverage100Array[0] > movingAverage50Array[0]) 142 | if(movingAverage50Array[0] > movingAverage10Array[0]) 143 | Signal = "Buy Now!"; 144 | 145 | if(movingAverage100Array[0] < movingAverage50Array[0]) 146 | if(movingAverage50Array[0] < movingAverage10Array[0]) 147 | Signal = "Sell Now!"; 148 | 149 | return Signal; 150 | } -------------------------------------------------------------------------------- /AdvancedMomentumEAforBTCAUD20.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | TradeNowOnMomentum(); 7 | Comment( 8 | "\nTotal Buy Positions : ", GetPositions_Buy(), 9 | "\nTotal Sell Positions : ", GetPositions_Sell(), 10 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 11 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 12 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 13 | "\nTotal Positions : ", PositionsTotal(), 14 | "\nMomentum : ", Check_Momentum_Entry(), 15 | "\nTriple MA: ", GetTripleMovingAverageSignal() 16 | 17 | ); 18 | } 19 | 20 | string Check_Momentum_Entry() 21 | { 22 | string Signal = ""; 23 | 24 | double priceInformation[]; 25 | 26 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 27 | 28 | ArraySetAsSeries(priceInformation, true); 29 | 30 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 31 | 32 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 33 | 34 | if(MomentumValue > 100.00)//Over Bought 35 | { 36 | Signal = "Sell"; 37 | } 38 | 39 | if(MomentumValue < 100.00)//Over Sold 40 | { 41 | Signal = "Buy"; 42 | } 43 | 44 | return Signal; 45 | } 46 | 47 | void TradeNowOnMomentum() 48 | { 49 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 50 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 51 | 52 | while(Check_Momentum_Entry() == "Buy" && GetPositions_Buy() < 1 && GetTripleMovingAverageSignal() == "Buy Now!") 53 | { 54 | //For H1 55 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 56 | //For M1 57 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 58 | //For Bitcoin only 59 | trade.Buy(0.50, NULL, Ask, 0, Ask + 300 * _Point, NULL); 60 | } 61 | 62 | while(Check_Momentum_Entry() == "Sell" && GetPositions_Sell() < 1 && GetTripleMovingAverageSignal() == "Sell Now!") 63 | { 64 | //For H1 65 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 66 | //For M1 67 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 68 | //For Bitcoin only 69 | trade.Sell(0.50, NULL, Bid, 0, Bid - 300 * _Point, NULL); 70 | } 71 | } 72 | 73 | void CloseAllPositions() 74 | { 75 | for(int i = PositionsTotal() -1; i >= 0; i--) 76 | { 77 | int ticket = PositionGetTicket(i); 78 | trade.PositionClose(ticket); 79 | } 80 | } 81 | 82 | int GetPositions_Sell() 83 | { 84 | int numberOfSellPositions = 0; 85 | 86 | for(int i = PositionsTotal() -1; i >= 0; i--) 87 | { 88 | string CurrencyPair = PositionGetSymbol(i); 89 | 90 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 91 | 92 | if(Symbol() == CurrencyPair) 93 | { 94 | if(PositionDirection == POSITION_TYPE_SELL) 95 | { 96 | numberOfSellPositions = numberOfSellPositions + 1; 97 | } 98 | } 99 | } 100 | 101 | return numberOfSellPositions; 102 | } 103 | 104 | int GetPositions_Buy() 105 | { 106 | int numberOfBuyPositions = 0; 107 | 108 | for(int i = PositionsTotal() -1; i >= 0; i--) 109 | { 110 | string CurrencyPair = PositionGetSymbol(i); 111 | 112 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 113 | 114 | if(Symbol() == CurrencyPair) 115 | { 116 | if(PositionDirection == POSITION_TYPE_BUY) 117 | { 118 | numberOfBuyPositions = numberOfBuyPositions + 1; 119 | } 120 | } 121 | } 122 | 123 | return numberOfBuyPositions; 124 | } 125 | 126 | string GetTripleMovingAverageSignal() 127 | { 128 | double movingAverage100Array[]; 129 | double movingAverage50Array[]; 130 | double movingAverage10Array[]; 131 | 132 | int movingAverage100Definition = iMA(_Symbol, _Period, 100, 0, MODE_SMA, PRICE_CLOSE); 133 | int movingAverage50Definition = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); 134 | int movingAverage10Definition = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); 135 | 136 | ArraySetAsSeries(movingAverage100Array, true); 137 | ArraySetAsSeries(movingAverage50Array, true); 138 | ArraySetAsSeries(movingAverage10Array, true); 139 | 140 | CopyBuffer(movingAverage100Definition, 0, 0, 10, movingAverage100Array); 141 | CopyBuffer(movingAverage50Definition, 0, 0, 10, movingAverage50Array); 142 | CopyBuffer(movingAverage10Definition, 0, 0, 10, movingAverage10Array); 143 | 144 | string Signal = ""; 145 | 146 | if(movingAverage100Array[0] > movingAverage50Array[0]) 147 | if(movingAverage50Array[0] > movingAverage10Array[0]) 148 | Signal = "Buy Now!"; 149 | 150 | if(movingAverage100Array[0] < movingAverage50Array[0]) 151 | if(movingAverage50Array[0] < movingAverage10Array[0]) 152 | Signal = "Sell Now!"; 153 | 154 | return Signal; 155 | } -------------------------------------------------------------------------------- /AdvancedMomentumEAforBTCUSD20.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | TradeNowOnMomentum(); 7 | Comment( 8 | "\nTotal Buy Positions : ", GetPositions_Buy(), 9 | "\nTotal Sell Positions : ", GetPositions_Sell(), 10 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 11 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 12 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 13 | "\nTotal Positions : ", PositionsTotal(), 14 | "\nMomentum : ", Check_Momentum_Entry(), 15 | "\nTriple MA: ", GetTripleMovingAverageSignal() 16 | 17 | ); 18 | } 19 | 20 | string Check_Momentum_Entry() 21 | { 22 | string Signal = ""; 23 | 24 | double priceInformation[]; 25 | 26 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 27 | 28 | ArraySetAsSeries(priceInformation, true); 29 | 30 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 31 | 32 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 33 | 34 | if(MomentumValue > 100.00)//Over Bought 35 | { 36 | Signal = "Sell"; 37 | } 38 | 39 | if(MomentumValue < 100.00)//Over Sold 40 | { 41 | Signal = "Buy"; 42 | } 43 | 44 | return Signal; 45 | } 46 | 47 | void TradeNowOnMomentum() 48 | { 49 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 50 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 51 | 52 | while(Check_Momentum_Entry() == "Buy" && GetPositions_Buy() < 2 && GetTripleMovingAverageSignal() == "Buy Now!") 53 | { 54 | //For H1 55 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 56 | //For M1 57 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 58 | //For Bitcoin only 59 | trade.Buy(0.01, NULL, Ask, 0, Ask + 10000 * _Point, NULL); 60 | } 61 | 62 | while(Check_Momentum_Entry() == "Sell" && GetPositions_Sell() < 2 && GetTripleMovingAverageSignal() == "Sell Now!") 63 | { 64 | //For H1 65 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 66 | //For M1 67 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 68 | //For Bitcoin only 69 | trade.Sell(0.01, NULL, Bid, 0, Bid - 10000 * _Point, NULL); 70 | } 71 | } 72 | 73 | void CloseAllPositions() 74 | { 75 | for(int i = PositionsTotal() -1; i >= 0; i--) 76 | { 77 | int ticket = PositionGetTicket(i); 78 | trade.PositionClose(ticket); 79 | } 80 | } 81 | 82 | int GetPositions_Sell() 83 | { 84 | int numberOfSellPositions = 0; 85 | 86 | for(int i = PositionsTotal() -1; i >= 0; i--) 87 | { 88 | string CurrencyPair = PositionGetSymbol(i); 89 | 90 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 91 | 92 | if(Symbol() == CurrencyPair) 93 | { 94 | if(PositionDirection == POSITION_TYPE_SELL) 95 | { 96 | numberOfSellPositions = numberOfSellPositions + 1; 97 | } 98 | } 99 | } 100 | 101 | return numberOfSellPositions; 102 | } 103 | 104 | int GetPositions_Buy() 105 | { 106 | int numberOfBuyPositions = 0; 107 | 108 | for(int i = PositionsTotal() -1; i >= 0; i--) 109 | { 110 | string CurrencyPair = PositionGetSymbol(i); 111 | 112 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 113 | 114 | if(Symbol() == CurrencyPair) 115 | { 116 | if(PositionDirection == POSITION_TYPE_BUY) 117 | { 118 | numberOfBuyPositions = numberOfBuyPositions + 1; 119 | } 120 | } 121 | } 122 | 123 | return numberOfBuyPositions; 124 | } 125 | 126 | string GetTripleMovingAverageSignal() 127 | { 128 | double movingAverage100Array[]; 129 | double movingAverage50Array[]; 130 | double movingAverage10Array[]; 131 | 132 | int movingAverage100Definition = iMA(_Symbol, _Period, 100, 0, MODE_SMA, PRICE_CLOSE); 133 | int movingAverage50Definition = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); 134 | int movingAverage10Definition = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); 135 | 136 | ArraySetAsSeries(movingAverage100Array, true); 137 | ArraySetAsSeries(movingAverage50Array, true); 138 | ArraySetAsSeries(movingAverage10Array, true); 139 | 140 | CopyBuffer(movingAverage100Definition, 0, 0, 10, movingAverage100Array); 141 | CopyBuffer(movingAverage50Definition, 0, 0, 10, movingAverage50Array); 142 | CopyBuffer(movingAverage10Definition, 0, 0, 10, movingAverage10Array); 143 | 144 | string Signal = ""; 145 | 146 | if(movingAverage100Array[0] > movingAverage50Array[0]) 147 | if(movingAverage50Array[0] > movingAverage10Array[0]) 148 | Signal = "Buy Now!"; 149 | 150 | if(movingAverage100Array[0] < movingAverage50Array[0]) 151 | if(movingAverage50Array[0] < movingAverage10Array[0]) 152 | Signal = "Sell Now!"; 153 | 154 | return Signal; 155 | } -------------------------------------------------------------------------------- /AdvancedRelativeVigorIndex.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(checkEntry_RelativeVigorIndex() == "Buy" && GetPositions_Buy() < 100) 10 | trade.Buy(0.01, NULL, Ask, 0, Ask + (100 * _Point), NULL); 11 | if(checkEntry_RelativeVigorIndex() == "Sell" && GetPositions_Sell() < 100) 12 | trade.Sell(0.01, NULL, Bid, 0, Bid - (100 * _Point), NULL); 13 | 14 | Comment( 15 | "\nTotal Buy Positions : ", GetPositions_Buy(), 16 | "\nTotal Sell Positions : ", GetPositions_Sell(), 17 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 18 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 19 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 20 | "\nTotal Positions : ", PositionsTotal() 21 | ); 22 | } 23 | 24 | string checkEntry_RelativeVigorIndex() 25 | { 26 | string Signal = ""; 27 | 28 | double RelativeVigorIndexArray1[]; 29 | double RelativeVigorIndexArray2[]; 30 | 31 | int RelativeVigorIndexHandler = iRVI(_Symbol, _Period, 10); 32 | 33 | ArraySetAsSeries(RelativeVigorIndexArray1, true); 34 | ArraySetAsSeries(RelativeVigorIndexArray2, true); 35 | 36 | CopyBuffer(RelativeVigorIndexHandler, 0, 0, 3, RelativeVigorIndexArray1); 37 | CopyBuffer(RelativeVigorIndexHandler, 1, 0, 3, RelativeVigorIndexArray2); 38 | 39 | double RelativeVigorIndexValue1 = NormalizeDouble(RelativeVigorIndexArray1[0], 3); 40 | double RelativeVigorIndexValue2 = NormalizeDouble(RelativeVigorIndexArray2[0], 3); 41 | 42 | if(RelativeVigorIndexValue1 < RelativeVigorIndexValue2 && RelativeVigorIndexValue1 < 0 && RelativeVigorIndexValue2 < 0) 43 | Signal = "Buy"; 44 | if(RelativeVigorIndexValue1 > RelativeVigorIndexValue2 && RelativeVigorIndexValue1 > 0 && RelativeVigorIndexValue2 > 0) 45 | Signal = "Sell"; 46 | 47 | return Signal; 48 | } 49 | 50 | string Check_Momentum_Entry() 51 | { 52 | string Signal = ""; 53 | 54 | double priceInformation[]; 55 | 56 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 57 | 58 | ArraySetAsSeries(priceInformation, true); 59 | 60 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 61 | 62 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 63 | 64 | if(MomentumValue > 100.00)//Over Bought 65 | { 66 | Signal = "Sell"; 67 | } 68 | 69 | if(MomentumValue < 100.00)//Over Sold 70 | { 71 | Signal = "Buy"; 72 | } 73 | 74 | return Signal; 75 | } 76 | 77 | int GetPositions_Buy() 78 | { 79 | int numberOfPositionsBuy = 0; 80 | 81 | for(int i = PositionsTotal() - 1; i >= 0; i--) 82 | { 83 | string currenyPair = PositionGetSymbol(i); 84 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 85 | if(currenyPair == _Symbol) 86 | if(PositionDirection == POSITION_TYPE_BUY) 87 | numberOfPositionsBuy++; 88 | } 89 | return numberOfPositionsBuy; 90 | } 91 | 92 | int GetPositions_Sell() 93 | { 94 | int numberOfPositionsSell = 0; 95 | 96 | for(int i = PositionsTotal() - 1; i >= 0; i--) 97 | { 98 | string currencyPair = PositionGetSymbol(i); 99 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 100 | 101 | if(currencyPair == _Symbol) 102 | if(PositionDirection == POSITION_TYPE_SELL) 103 | numberOfPositionsSell++; 104 | } 105 | return numberOfPositionsSell; 106 | } -------------------------------------------------------------------------------- /AdvancedSARExpertAdvisor.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | MqlRates priceInformation[]; 7 | ArraySetAsSeries(priceInformation, true); 8 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 9 | 10 | double SARArray[]; 11 | int SARDefinition = iSAR(_Symbol, _Period, 0.02, 0.2); 12 | ArraySetAsSeries(SARArray, true); 13 | CopyBuffer(SARDefinition, 0, 0, 3, SARArray); 14 | 15 | double lastSARValue = NormalizeDouble(SARArray[1], 5); 16 | double nextToLastSARValue = NormalizeDouble(SARArray[2], 5); 17 | 18 | string Signal = ""; 19 | 20 | if(lastSARValue > priceInformation[1].high) 21 | if(nextToLastSARValue < priceInformation[2].low) 22 | Signal = "Sell"; 23 | 24 | if(lastSARValue < priceInformation[1].low) 25 | if(nextToLastSARValue > priceInformation[2].high) 26 | Signal = "Buy"; 27 | 28 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 29 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 30 | 31 | if(Signal == "Buy") 32 | trade.Buy(0.10, NULL, Ask, 0, Ask + 100 * _Point, NULL); 33 | 34 | if(Signal == "Sell") 35 | trade.Sell(0.10, NULL, Bid, 0, Bid - 100 * _Point, NULL); 36 | 37 | } -------------------------------------------------------------------------------- /AdvancedTradingRange.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //variable for a trading range 4 | double TradingRange = 0; 5 | 6 | //Create variable for highest and lowest candle 7 | int HighestCandle, LowestCandle; 8 | 9 | //Create arrays for highest and lowest candle 10 | double High[], Low[]; 11 | 12 | //Sort arrays downward from the current candle 13 | ArraySetAsSeries(High, true); 14 | ArraySetAsSeries(Low, true); 15 | 16 | //Fill arrays with data for 100 candles 17 | CopyHigh(_Symbol, _Period, 0, 100, High); 18 | CopyLow(_Symbol, _Period, 0, 100, Low); 19 | 20 | //Calculate the highest candle 21 | HighestCandle = ArrayMaximum(High, 0, 100); 22 | 23 | //Calculate the lowest candle 24 | LowestCandle = ArrayMinimum(Low, 0, 100); 25 | 26 | //Create an array of prices 27 | MqlRates priceInformation[]; 28 | 29 | //Sort it from the current candle to oldest canndle 30 | ArraySetAsSeries(priceInformation, true); 31 | 32 | //Copy price data into the array 33 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), priceInformation); 34 | 35 | //Highest Line 36 | 37 | //Set object properties for a line 38 | ObjectCreate(_Symbol, "Line1", OBJ_HLINE, 0, 0, priceInformation[HighestCandle].high); 39 | ObjectSetInteger(0, "Line1", OBJPROP_COLOR, clrMaroon); 40 | ObjectSetInteger(0, "Line1", OBJPROP_WIDTH, 3); 41 | ObjectMove(_Symbol, "Line1", 0, 0, priceInformation[HighestCandle].high); 42 | 43 | //Lowest Line 44 | 45 | //Set object properties for a line 46 | ObjectCreate(_Symbol, "Line2", OBJ_HLINE, 0, 0, priceInformation[LowestCandle].low); 47 | ObjectSetInteger(0, "Line2", OBJPROP_COLOR, clrMaroon); 48 | ObjectSetInteger(0, "Line2", OBJPROP_WIDTH, 3); 49 | ObjectMove(_Symbol, "Line2", 0, 0, priceInformation[LowestCandle].low); 50 | 51 | //Calculate the trading range 52 | TradingRange = priceInformation[HighestCandle].high - priceInformation[LowestCandle].low; 53 | 54 | //Chart Output 55 | Comment("The current trading range is : ", TradingRange); 56 | 57 | 58 | } -------------------------------------------------------------------------------- /AdvancedTrailingStop.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | //Get the Ask Price 7 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 8 | 9 | //If we have less than two positions 10 | if(PositionsTotal() < 2) 11 | { 12 | //Open two test Buy positions 13 | trade.Buy(0.01, NULL, Ask, Ask - 1000 * _Point, Ask + 500 * _Point, NULL); 14 | } 15 | 16 | //Call the trailing stop module 17 | CheckTrailingStop(Ask); 18 | } 19 | 20 | void CheckTrailingStop(double Ask) 21 | { 22 | //Set the desired stop loss to 150 points 23 | double SL = NormalizeDouble(Ask - 150 * _Point, _Digits); 24 | 25 | //Check all open positions for the current symbol 26 | for(int i = PositionsTotal(); i >= 0; i--) 27 | { 28 | //Get position symbol 29 | string Symbol = PositionGetSymbol(i); 30 | 31 | //If chart symbol equals position symbol 32 | if(_Symbol == Symbol) 33 | { 34 | //Get the Ticket Number 35 | ulong PositionTicket = PositionGetInteger(POSITION_TICKET); 36 | 37 | //Get the current stop loss 38 | double CurrentStopLoss = PositionGetDouble(POSITION_SL); 39 | 40 | //If the current stop loss price is below 150 points from the Ask price 41 | if(CurrentStopLoss < SL) 42 | { 43 | //Modify the stop loss by 10 points 44 | trade.PositionModify(PositionTicket, CurrentStopLoss + 10 * _Point, 0); 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /AdvancedWPR.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(CheckEntry_WPR() == "Buy" && GetPositions_Buy() < 100) 10 | trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 11 | if(CheckEntry_WPR() == "Sell" && GetPositions_Sell() < 100) 12 | trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 13 | } 14 | 15 | string CheckEntry_WPR() 16 | { 17 | string Signal = ""; 18 | 19 | double WPRarray[]; 20 | 21 | int WPRdefinition = iWPR(_Symbol, _Period, 14); 22 | 23 | ArraySetAsSeries(WPRarray, true); 24 | 25 | CopyBuffer(WPRdefinition, 0, 0, 3, WPRarray); 26 | 27 | double WPRvalue = NormalizeDouble(WPRarray[0], 2); 28 | 29 | if(WPRvalue < -80.00 && WPRvalue > -100.00) 30 | { 31 | Signal = "Buy"; 32 | } 33 | 34 | if(WPRvalue > -20.00 && WPRvalue < 0) 35 | { 36 | Signal = "Sell"; 37 | } 38 | 39 | return Signal; 40 | } 41 | 42 | int GetPositions_Sell() 43 | { 44 | int numberOfSellPositions = 0; 45 | 46 | for(int i = PositionsTotal() -1; i >= 0; i--) 47 | { 48 | string CurrencyPair = PositionGetSymbol(i); 49 | 50 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 51 | 52 | if(Symbol() == CurrencyPair) 53 | { 54 | if(PositionDirection == POSITION_TYPE_SELL) 55 | { 56 | numberOfSellPositions = numberOfSellPositions + 1; 57 | } 58 | } 59 | } 60 | 61 | return numberOfSellPositions; 62 | } 63 | 64 | int GetPositions_Buy() 65 | { 66 | int numberOfBuyPositions = 0; 67 | 68 | for(int i = PositionsTotal() -1; i >= 0; i--) 69 | { 70 | string CurrencyPair = PositionGetSymbol(i); 71 | 72 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 73 | 74 | if(Symbol() == CurrencyPair) 75 | { 76 | if(PositionDirection == POSITION_TYPE_BUY) 77 | { 78 | numberOfBuyPositions = numberOfBuyPositions + 1; 79 | } 80 | } 81 | } 82 | 83 | return numberOfBuyPositions; 84 | } -------------------------------------------------------------------------------- /AdvanncedSMA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(Check_Entry_SMA() == "Buy" && GetPositions_Buy() < 100) 10 | trade.Buy(0.01, _Symbol, Ask, 0, Ask + (100 * _Point), NULL); 11 | if(Check_Entry_SMA() == "Sell" && GetPositions_Sell() < 100) 12 | trade.Sell(0.01, _Symbol, Bid, 0, Bid - (100 * _Point), NULL); 13 | 14 | Comment("Buy : ", GetPositions_Buy(), "\nSell: ", GetPositions_Sell()); 15 | } 16 | 17 | string Check_Entry_SMA() 18 | { 19 | string Signal = ""; 20 | 21 | MqlRates priceInformation[]; 22 | ArraySetAsSeries(priceInformation, true); 23 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 24 | 25 | double SMAArray[]; 26 | int SMADefinition = iMA(_Symbol, _Period, 20, 0, MODE_SMA, PRICE_CLOSE); 27 | ArraySetAsSeries(SMAArray, true); 28 | CopyBuffer(SMADefinition, 0, 0, 3, SMAArray); 29 | 30 | if(priceInformation[1].close > SMAArray[1] && priceInformation[2].close < SMAArray[2]) 31 | Signal = "Buy"; 32 | if(priceInformation[1].close < SMAArray[1] && priceInformation[2].close > SMAArray[2]) 33 | Signal = "Sell"; 34 | 35 | return Signal; 36 | } 37 | 38 | int GetPositions_Sell() 39 | { 40 | int numberOfSellPositions = 0; 41 | 42 | for(int i = PositionsTotal() -1; i >= 0; i--) 43 | { 44 | string CurrencyPair = PositionGetSymbol(i); 45 | 46 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 47 | 48 | if(Symbol() == CurrencyPair) 49 | { 50 | if(PositionDirection == POSITION_TYPE_SELL) 51 | { 52 | numberOfSellPositions = numberOfSellPositions + 1; 53 | } 54 | } 55 | } 56 | 57 | return numberOfSellPositions; 58 | } 59 | 60 | int GetPositions_Buy() 61 | { 62 | int numberOfBuyPositions = 0; 63 | 64 | for(int i = PositionsTotal() -1; i >= 0; i--) 65 | { 66 | string CurrencyPair = PositionGetSymbol(i); 67 | 68 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 69 | 70 | if(Symbol() == CurrencyPair) 71 | { 72 | if(PositionDirection == POSITION_TYPE_BUY) 73 | { 74 | numberOfBuyPositions = numberOfBuyPositions + 1; 75 | } 76 | } 77 | } 78 | 79 | return numberOfBuyPositions; 80 | } -------------------------------------------------------------------------------- /AdvfanceEMAcrossOver.mq5: -------------------------------------------------------------------------------- 1 | string checkEntry() 2 | { 3 | //Create an empty string 4 | string entry = ""; 5 | 6 | //Create two array of several prices 7 | double myMovingAverageArray1[]; 8 | double myMovingAverageArray2[]; 9 | 10 | //Define the properties of moving average 1 11 | int myMovingAverageDefinition1 = iMA(_Symbol, _Period, 20, 0, MODE_EMA, PRICE_CLOSE); 12 | 13 | //Define the properties of moving average 2 14 | int myMovingAverageDefinition2 = iMA(_Symbol, _Period, 50, 0, MODE_EMA, PRICE_CLOSE); 15 | 16 | //Sort the price array 1 from the current candle downwards 17 | ArraySetAsSeries(myMovingAverageArray1, true); 18 | 19 | //Sort the price array 2 from the current candle downwards 20 | ArraySetAsSeries(myMovingAverageArray2, true); 21 | 22 | //Define MA1 EA, one line, current candle, 3 candles, store result 23 | CopyBuffer(myMovingAverageDefinition1, 0, 0, 3, myMovingAverageArray1); 24 | 25 | //Define MA2 EA, one line, current candle, 3 candles, store result 26 | CopyBuffer(myMovingAverageDefinition2, 0, 0, 3, myMovingAverageArray2); 27 | 28 | //Calculate MA1 for the current candle 29 | double myMovingAverageValue1 = myMovingAverageArray1[0]; 30 | 31 | //Calculate MA2 for the current candle 32 | double myMovingAverageValue2 = myMovingAverageArray2[0]; 33 | 34 | //Check if the 20 candles EA is over the 50 candles EA 35 | if(myMovingAverageArray1[0] > myMovingAverageArray2[0] 36 | && myMovingAverageArray1[1] < myMovingAverageArray2[1]) 37 | entry = "BUY"; 38 | 39 | if(myMovingAverageArray1[0] < myMovingAverageArray2[0] 40 | && myMovingAverageArray1[1] > myMovingAverageArray2[1]) 41 | entry = "SELL"; 42 | 43 | //Return the entry signal 44 | return entry; 45 | 46 | } -------------------------------------------------------------------------------- /AverageDirectionalMovingIndex.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create a price array 4 | double myPriceArray[]; 5 | double PositiveDirectionalIndicatorArray[]; 6 | double NegativeDirectionalIndicatorArray[]; 7 | 8 | //Set the price array from the current candle downwards 9 | ArraySetAsSeries(myPriceArray, true); 10 | ArraySetAsSeries(PositiveDirectionalIndicatorArray, true); 11 | ArraySetAsSeries(NegativeDirectionalIndicatorArray, true); 12 | 13 | //Dine Average Directional Moving Index (ADX) 14 | int AverageDirectionalMovingIndexDefinition = iADX(_Symbol, _Period, 14); 15 | int PositiveDirectionalIndicatorDefinition = iADX(_Symbol, _Period, 14); 16 | int NegativeDirectionalIndicatorDefinition = iADX(_Symbol, _Period, 14); 17 | 18 | //Define EA, one line, current candle, 3 candles, store result 19 | CopyBuffer(AverageDirectionalMovingIndexDefinition, 0, 0, 3, myPriceArray); 20 | CopyBuffer(PositiveDirectionalIndicatorDefinition, 1, 0, 3, PositiveDirectionalIndicatorArray); 21 | CopyBuffer(NegativeDirectionalIndicatorDefinition, 2, 0, 3, NegativeDirectionalIndicatorArray); 22 | 23 | //Get the value 24 | double AverageDirectionalMovingIndexValue = NormalizeDouble(myPriceArray[0], 2); 25 | double PositiveDirectionalIndicatorValue = NormalizeDouble(PositiveDirectionalIndicatorArray[0], 2); 26 | double NegativeDirectionalIndicatorValue = NormalizeDouble(NegativeDirectionalIndicatorArray[0], 2); 27 | 28 | //Chart output 29 | Comment("ADX Value : ", AverageDirectionalMovingIndexValue, "\nPositive Directional Indicator (-DI) : ", 30 | PositiveDirectionalIndicatorValue, "\nNegaltive Directional Indicator (-DI) : ", NegativeDirectionalIndicatorValue); 31 | } -------------------------------------------------------------------------------- /AverageTrueRange.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | double AverageTrueRangeArray[]; 4 | int AverageTrueRangeDefinition = iATR(_Symbol, _Period, 14); 5 | ArraySetAsSeries(AverageTrueRangeArray, true); 6 | CopyBuffer(AverageTrueRangeDefinition, 0, 0, 3, AverageTrueRangeArray); 7 | double AverageTrueRangeValue = NormalizeDouble(AverageTrueRangeArray[0], 5); 8 | 9 | if(AverageTrueRangeValue > 0.00024) Comment("STRONG Average True Range Value. ATR : ", AverageTrueRangeValue); 10 | if(AverageTrueRangeValue < 0.00014) Comment("WEAK Average True Range Value. ATR : ", AverageTrueRangeValue); 11 | 12 | if(AverageTrueRangeValue > 0.00014 && AverageTrueRangeValue < 0.00014) 13 | Comment("ATR : ", AverageTrueRangeValue); 14 | } -------------------------------------------------------------------------------- /AwesomeOscillatorEA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(CheckEntry_AwesomeOscillator() == "Buy" && PositionsTotal() < 1) 10 | trade.Buy(0.1, NULL, Ask, 0, Ask + 300 * _Point, NULL); 11 | 12 | if(CheckEntry_AwesomeOscillator() == "Sell" && PositionsTotal() < 1) 13 | trade.Sell(0.1, NULL, Bid, 0, Bid - 300 * _Point, NULL); 14 | 15 | Comment("Awesome Oscillator Signal : ", CheckEntry_AwesomeOscillator()); 16 | 17 | } 18 | 19 | string CheckEntry_AwesomeOscillator() 20 | { 21 | string signal = ""; 22 | 23 | double priceArray[]; 24 | ArraySetAsSeries(priceArray, true); 25 | int AOHandler = iAO(_Symbol, _Period); 26 | CopyBuffer(AOHandler, 0, 0, 3, priceArray); 27 | double AwesomeOscillatorValue = NormalizeDouble(priceArray[0], 6); 28 | 29 | if(AwesomeOscillatorValue > 0) 30 | signal = "Buy"; 31 | if(AwesomeOscillatorValue < 0) 32 | signal = "Sell"; 33 | 34 | return signal; 35 | } -------------------------------------------------------------------------------- /BollingerBandsStandaloneEA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | while(GetEntryBollingerBandsStandalone() == "Buy" && GetPositions_Buy() < 100) 10 | { 11 | trade.Buy(0.01, NULL, Ask, 0, Ask + (300 * _Point), NULL); 12 | } 13 | 14 | while(GetEntryBollingerBandsStandalone() == "Sell" && GetPositions_Sell() < 100) 15 | { 16 | trade.Sell(0.01, NULL, Bid, 0, Bid - (300 * _Point), NULL); 17 | } 18 | 19 | WriteComment(); 20 | } 21 | 22 | string GetEntryBollingerBandsStandalone() 23 | { 24 | string signal = ""; 25 | 26 | double lowerBandArray[]; 27 | double upperBandArray[]; 28 | 29 | int BollingerBandsHandler = iBands(_Symbol, _Period, 20, 0, 2, PRICE_CLOSE); 30 | 31 | ArraySetAsSeries(lowerBandArray, true); 32 | ArraySetAsSeries(upperBandArray, true); 33 | 34 | CopyBuffer(BollingerBandsHandler, 2, 0, 3, lowerBandArray); 35 | CopyBuffer(BollingerBandsHandler, 1, 0, 3, upperBandArray); 36 | 37 | double upperBandValue = upperBandArray[0]; 38 | double lowerBandValue = lowerBandArray[0]; 39 | 40 | double upperBandValueLastButOne = upperBandArray[1]; 41 | double lowerBandValueLastButOne = lowerBandArray[1]; 42 | 43 | MqlRates priceInformation[]; 44 | ArraySetAsSeries(priceInformation, true); 45 | int priceData = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 46 | 47 | if(priceInformation[0].close > lowerBandValue && priceInformation[1].close < lowerBandValueLastButOne) 48 | signal = "Buy"; 49 | if(priceInformation[0].close < upperBandValue && priceInformation[1].close > upperBandValueLastButOne) 50 | signal = "Sell"; 51 | 52 | return signal; 53 | } 54 | 55 | void WriteComment() 56 | { 57 | Comment( 58 | "\nTotal Buy Positions : ", GetPositions_Buy(), 59 | "\nTotal Sell Positions : ", GetPositions_Sell(), 60 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 61 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 62 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 63 | "\nTotal Positions : ", PositionsTotal(), 64 | "\nSignal : ", GetEntryBollingerBandsStandalone() 65 | ); 66 | } 67 | 68 | int GetPositions_Sell() 69 | { 70 | int numberOfSellPositions = 0; 71 | 72 | for(int i = PositionsTotal() -1; i >= 0; i--) 73 | { 74 | string CurrencyPair = PositionGetSymbol(i); 75 | 76 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 77 | 78 | if(Symbol() == CurrencyPair) 79 | { 80 | if(PositionDirection == POSITION_TYPE_SELL) 81 | { 82 | numberOfSellPositions = numberOfSellPositions + 1; 83 | } 84 | } 85 | } 86 | 87 | return numberOfSellPositions; 88 | } 89 | 90 | int GetPositions_Buy() 91 | { 92 | int numberOfBuyPositions = 0; 93 | 94 | for(int i = PositionsTotal() -1; i >= 0; i--) 95 | { 96 | string CurrencyPair = PositionGetSymbol(i); 97 | 98 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 99 | 100 | if(Symbol() == CurrencyPair) 101 | { 102 | if(PositionDirection == POSITION_TYPE_BUY) 103 | { 104 | numberOfBuyPositions = numberOfBuyPositions + 1; 105 | } 106 | } 107 | } 108 | 109 | return numberOfBuyPositions; 110 | } -------------------------------------------------------------------------------- /BullsPowerOscillator.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array of several prices 4 | double myPriceArray[]; 5 | 6 | //Define Bulls Power Oscillator 7 | int BullsPowerDefinition = iBullsPower(_Symbol, _Period, 13); 8 | 9 | //Sort the array from the current candle downwards 10 | ArraySetAsSeries(myPriceArray, true); 11 | 12 | 13 | //Define EA, one line, current candle, 3 candles, store result 14 | CopyBuffer(BullsPowerDefinition, 0, 0, 3, myPriceArray); 15 | 16 | //Get the value of Bulls Power Oscillator 17 | //Float for human readable 18 | float BullsPowerValue = myPriceArray[0]; 19 | 20 | Comment("Bulls Power Value: ", BullsPowerValue); 21 | } -------------------------------------------------------------------------------- /BullsPowerOscillatorStandalone.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double BullsPowerValueArray[]; 7 | ArraySetAsSeries(BullsPowerValueArray, true); 8 | int BullsPowerHanndler = iBullsPower(_Symbol, _Period, 13); 9 | CopyBuffer(BullsPowerHanndler, 0, 0, 3, BullsPowerValueArray); 10 | double BullsPowerValue = BullsPowerValueArray[0]; 11 | 12 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 13 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 14 | 15 | if(BullsPowerValue > 0) 16 | trade.Buy(0.10, NULL, Ask, 0, Ask + 300 * _Point, NULL); 17 | if(BullsPowerValue < 0) 18 | trade.Sell(0.10, NULL, Bid, 0, Bid - 300 * _Point, NULL); 19 | 20 | Comment("Bulls Power : ", BullsPowerValue, "\nPositions : ", PositionsTotal()); 21 | 22 | } -------------------------------------------------------------------------------- /BuyLimit.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(OrdersTotal() == 0 && PositionsTotal() == 0) 10 | { 11 | trade.BuyLimit(0.01, Bid - (200 * _Point), _Symbol, 0, Ask + (200 * _Point), ORDER_TIME_GTC, 0, NULL); 12 | } 13 | } -------------------------------------------------------------------------------- /BuyStop.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | 8 | double balance = AccountInfoDouble(ACCOUNT_BALANCE); 9 | double equity = AccountInfoDouble(ACCOUNT_EQUITY); 10 | 11 | //Buy stop, 10 microlots, 100 points above Ask, no SL, 300 points TP, no expiration, no date, no comment 12 | if(balance == equity) 13 | trade.BuyStop(0.10, Ask + 100 * _Point, _Symbol, 0, Ask + 300 * _Point, ORDER_TIME_GTC, 0, 0); 14 | } -------------------------------------------------------------------------------- /ChartEventMouseDown.mq5: -------------------------------------------------------------------------------- 1 | void OnChartEvent(const int id, 2 | const long& lparam, 3 | const double& dparam, 4 | const string& sparam) 5 | { 6 | if(id == CHARTEVENT_KEYDOWN) 7 | { 8 | int keyPressed = TranslateKey((int) lparam); 9 | MessageBox("Key that was pressed is " + ShortToString(keyPressed), 10 | "Key Pressed Message", 11 | MB_CANCELTRYCONTINUE); 12 | } 13 | } -------------------------------------------------------------------------------- /ChartObject.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create a price array 4 | MqlRates priceInformation[]; 5 | 6 | //Sort the array from the current candle downwards 7 | ArraySetAsSeries(priceInformation, true); 8 | 9 | //Copy data into the array 10 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), priceInformation); 11 | 12 | //Static counter 13 | static int i; 14 | 15 | 16 | //Create the object of Arrow 17 | ObjectCreate(_Symbol, "myArrow", OBJ_ARROW, 0, TimeCurrent(), priceInformation[0].high); 18 | 19 | ObjectSetInteger(0, "myArrow", OBJPROP_WIDTH, 20); 20 | ObjectSetInteger(0, "myArrow", OBJPROP_ARROWCODE, i); 21 | ObjectSetInteger(0, "myArrow", OBJPROP_COLOR, clrBlue); 22 | 23 | //Move the object to the current candle high 24 | ObjectMove(_Symbol, "myArrow", 0, TimeCurrent(), priceInformation[0].high); 25 | 26 | //Chart output for the current counter value 27 | Comment("i has the value : ", i); 28 | 29 | i++; 30 | } -------------------------------------------------------------------------------- /Chartevent_Click.mq5: -------------------------------------------------------------------------------- 1 | void OnChartEvent(const int id, const long& lParam, const double& dParam, const string& sParam) 2 | { 3 | if(id==CHARTEVENT_CLICK) 4 | { 5 | MessageBox("Chart was clicked X-Value: " + lParam + " Y-Value: " + 6 | dParam, "Mouse click Message", MB_OKCANCEL); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /CheckEntryBollingerBands.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | BuyNow(); 7 | SellNow(); 8 | } 9 | 10 | void SellNow() 11 | { 12 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 13 | //Sell 14 | if(getRSI() > 70.00) 15 | { 16 | if(getMomentum() > 100.10) 17 | { 18 | if(getWilliamsPercentRange() > -1.00) 19 | { 20 | if(getCommodityChannelIndex() > 170.00) 21 | { 22 | if(getDeMarker() > 0.75) 23 | { 24 | if(checkEntryEMA() == "SELL") 25 | { 26 | if(CheckEntryBollinngerBands() == "Sell") 27 | { 28 | if(countPosition() < 100) 29 | { 30 | trade.Sell(0.03, NULL, Bid, Bid + 1000 * _Point, Bid - 300 * _Point, NULL); 31 | } 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | } 39 | 40 | } 41 | 42 | void BuyNow() 43 | { 44 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 45 | //Buy 46 | if(getRSI() < 30.00) 47 | { 48 | if(getMomentum() < 99.80) 49 | { 50 | if(getWilliamsPercentRange() < -99.00) 51 | { 52 | if(getCommodityChannelIndex() < -170.00) 53 | { 54 | if(getDeMarker() < 0.25) 55 | { 56 | if(checkEntryEMA() == "BUY") 57 | { 58 | if(CheckEntryBollinngerBands() == "Buy") 59 | { 60 | if(countPosition() < 100) 61 | { 62 | trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 63 | } 64 | } 65 | } 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } 72 | 73 | string CheckEntryBollinngerBands() 74 | { 75 | //We create an array for the prices 76 | MqlRates PriceInfo[]; 77 | 78 | //Sort the array from the current candle downwards 79 | ArraySetAsSeries(PriceInfo, true); 80 | 81 | //We fill the array with price data 82 | //For all candles in the chart: int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), PriceInfo); 83 | int Data = CopyRates(Symbol(), Period(), 0, 3, PriceInfo); 84 | 85 | //Create a string variable for the signal 86 | string signal = ""; 87 | 88 | //Create arrays for prices 89 | double UpperBandsArray[]; 90 | double MiddleBandArray[]; 91 | double LowerBandArray[]; 92 | 93 | //Define Bollinnger Bands 94 | int BollinngerBandsDefinition = iBands(_Symbol, _Period, 20, 0, 2, PRICE_CLOSE); 95 | 96 | //Copy price info into the arrays 97 | CopyBuffer(BollinngerBandsDefinition, 0, 0, 3, MiddleBandArray); 98 | CopyBuffer(BollinngerBandsDefinition, 1, 0, 3, UpperBandsArray); 99 | CopyBuffer(BollinngerBandsDefinition, 2, 0, 3, LowerBandArray); 100 | 101 | //Calculate EA for the last candle 102 | double MiddleBandValueLast = MiddleBandArray[0]; 103 | double UpperBandValueLast = UpperBandsArray[0]; 104 | double LowerBandValueLast = LowerBandArray[0]; 105 | 106 | //Calculate EA for the last but one candle 107 | double MiddleBandValueLastButOne = MiddleBandArray[1]; 108 | double UpperBandValueLastButOne = UpperBandsArray[1]; 109 | double LowerBandValueLastButOne = LowerBandArray[1]; 110 | 111 | //Buy signal 112 | if(PriceInfo[1].close < LowerBandValueLastButOne && PriceInfo[0].close > LowerBandValueLast) 113 | signal = "Buy"; 114 | 115 | //Sell Signal 116 | if(PriceInfo[1].close > UpperBandValueLastButOne && PriceInfo[0].close < UpperBandValueLast) 117 | signal = "Sell"; 118 | 119 | return signal; 120 | 121 | } 122 | 123 | int countPosition() 124 | { 125 | int PositionsForThisSymbol = 0; 126 | 127 | for(int i = PositionsTotal() - 1; i >= 0; i--) 128 | { 129 | string symbol = PositionGetSymbol(i); 130 | 131 | if(Symbol() == symbol) 132 | { 133 | PositionsForThisSymbol += 1; 134 | } 135 | } 136 | return PositionsForThisSymbol; 137 | } 138 | 139 | double getRSI() 140 | { 141 | //create an array for several prices 142 | double myRSIarray[]; 143 | 144 | //Define the properties of the RSI 145 | int myRSIdefinition = iRSI(_Symbol, _Period, 14, PRICE_CLOSE); 146 | 147 | //sort the price array from the current candle downwards 148 | ArraySetAsSeries(myRSIarray, true); 149 | 150 | //Defined EA, current candle, 3 candles, store result 151 | CopyBuffer(myRSIdefinition, 0, 0, 3, myRSIarray); 152 | 153 | //calculate EA for the current candle 154 | double myRSIvalue = NormalizeDouble(myRSIarray[0], 2); 155 | 156 | return myRSIvalue; 157 | } 158 | 159 | double getMomentum() 160 | { 161 | //Create a price array 162 | double myPriceArray[]; 163 | 164 | //Define the properties of the Momentum EA 165 | double iMomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 166 | 167 | //Sort the price array from the current candle downwards 168 | ArraySetAsSeries(myPriceArray, true); 169 | 170 | //Defined Momentum, 1 line, current candle, 3 cnadles, strore in array 171 | CopyBuffer(iMomentumDefinition, 0, 0, 3, myPriceArray); 172 | 173 | //Get the value of the current candle 174 | double myMomentumValue = NormalizeDouble(myPriceArray[0], _Digits); 175 | 176 | return myMomentumValue; 177 | 178 | //Chart output depending on the value 179 | //if(myMomentumValue > 100.0) Comment("STRONG MOMENTUM: ", myMomentumValue); 180 | //if(myMomentumValue < 99.9) Comment("WEAK MOMENTUM: ", myMomentumValue); 181 | //if(myMomentumValue <100.0 && myMomentumValue > 99.9) Comment("", myMomentumValue); 182 | } 183 | 184 | double getWilliamsPercentRange() 185 | { 186 | double WPRarray[]; 187 | int WPRdefinition = iWPR(_Symbol, _Period, 14); 188 | ArraySetAsSeries(WPRarray, true); 189 | CopyBuffer(WPRdefinition, 0, 0, 3, WPRarray); 190 | double WPRvalue = NormalizeDouble(WPRarray[0], 2); 191 | 192 | return WPRvalue; 193 | 194 | //Comment("WPR Value: ", WPRvalue); 195 | } 196 | 197 | double getCommodityChannelIndex() 198 | { 199 | double myPriceArray[]; 200 | int CommodityChannelIndexDefinition = iCCI(_Symbol, _Period, 14, PRICE_CLOSE); 201 | ArraySetAsSeries(myPriceArray, true); 202 | CopyBuffer(CommodityChannelIndexDefinition, 0, 0, 3, myPriceArray); 203 | double CommodityChannelIndexValue = myPriceArray[0]; 204 | 205 | return CommodityChannelIndexValue; 206 | 207 | //if(CommodityChannelIndexValue > 100) Comment("OVERBOUGTH"); 208 | //if(CommodityChannelIndexValue < -100) Comment("OVERSOLD"); 209 | //if(CommodityChannelIndexValue < 100 && CommodityChannelIndexValue > -100) Comment(""); 210 | } 211 | 212 | double getDeMarker() 213 | { 214 | //Create an array of several prices 215 | double myPriceArray[]; 216 | 217 | //Define the properties of DeMarker EA 218 | int DemarkerDefinition = iDeMarker(_Symbol, _Period, 14); 219 | 220 | //Sort the array from the current candle downwards 221 | ArraySetAsSeries(myPriceArray, true); 222 | 223 | //Define EA, one line, current candle, 3 candles, store result 224 | CopyBuffer(DemarkerDefinition, 0, 0, 3, myPriceArray); 225 | 226 | //Get the Value 227 | double DeMarkerValue = myPriceArray[0]; 228 | 229 | return DeMarkerValue; 230 | 231 | //if(DeMarkerValue > 0.7) Comment("Strong Trend: ", DeMarkerValue); 232 | //if(DeMarkerValue < 0.3) Comment("Weak Trend: ", DeMarkerValue); 233 | //if(DeMarkerValue < 0.7 && DeMarkerValue > 0.3) Comment(""); 234 | } 235 | 236 | string checkEntryEMA() 237 | { 238 | //Create an empty string 239 | string entry = ""; 240 | 241 | //Create two array of several prices 242 | double myMovingAverageArray1[]; 243 | double myMovingAverageArray2[]; 244 | 245 | //Define the properties of moving average 1 246 | int myMovingAverageDefinition1 = iMA(_Symbol, _Period, 20, 0, MODE_EMA, PRICE_CLOSE); 247 | 248 | //Define the properties of moving average 2 249 | int myMovingAverageDefinition2 = iMA(_Symbol, _Period, 50, 0, MODE_EMA, PRICE_CLOSE); 250 | 251 | //Sort the price array 1 from the current candle downwards 252 | ArraySetAsSeries(myMovingAverageArray1, true); 253 | 254 | //Sort the price array 2 from the current candle downwards 255 | ArraySetAsSeries(myMovingAverageArray2, true); 256 | 257 | //Define MA1 EA, one line, current candle, 3 candles, store result 258 | CopyBuffer(myMovingAverageDefinition1, 0, 0, 3, myMovingAverageArray1); 259 | 260 | //Define MA2 EA, one line, current candle, 3 candles, store result 261 | CopyBuffer(myMovingAverageDefinition2, 0, 0, 3, myMovingAverageArray2); 262 | 263 | //Calculate MA1 for the current candle 264 | double myMovingAverageValue1 = myMovingAverageArray1[0]; 265 | 266 | //Calculate MA2 for the current candle 267 | double myMovingAverageValue2 = myMovingAverageArray2[0]; 268 | 269 | //Check if the 20 candles EA is over the 50 candles EA 270 | if(myMovingAverageArray1[0] > myMovingAverageArray2[0] 271 | && myMovingAverageArray1[1] < myMovingAverageArray2[1]) 272 | entry = "BUY"; 273 | 274 | if(myMovingAverageArray1[0] < myMovingAverageArray2[0] 275 | && myMovingAverageArray1[1] > myMovingAverageArray2[1]) 276 | entry = "SELL"; 277 | 278 | //Return the entry signal 279 | return entry; 280 | } -------------------------------------------------------------------------------- /CheckEntry_MacD.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | string CheckEntryMacD() 5 | { 6 | string Signal = ""; 7 | 8 | double priceInformation[]; 9 | 10 | ArraySetAsSeries(priceInformation, true); 11 | 12 | int MacDdefinition = iMACD(_Symbol, _Period, 12, 26, 9, PRICE_CLOSE); 13 | 14 | CopyBuffer(MacDdefinition, 0, 0, 3, priceInformation); 15 | 16 | float MacDValue = priceInformation[0]; 17 | 18 | if(MacDValue < 0) 19 | Signal = "Buy"; 20 | 21 | if(MacDValue > 0) 22 | Signal = "Sell"; 23 | 24 | return Signal; 25 | } 26 | 27 | void OnTick() 28 | { 29 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 30 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 31 | 32 | if(CheckEntryMacD() == "Buy" && PositionsTotal() < 100) 33 | { 34 | trade.Buy(0.01, NULL, Ask, Ask - 300 * _Point, Ask + 100 * _Point, NULL); 35 | Comment("Buy Now. Total Positions : ", PositionsTotal()); 36 | } 37 | 38 | if(CheckEntryMacD() == "Sell" && PositionsTotal() < 100) 39 | { 40 | trade.Sell(0.01, NULL, Bid, Bid + 300 * _Point, Bid - 100 * _Point, NULL); 41 | Comment("Sell Now. Total Positions : ", PositionsTotal()); 42 | } 43 | 44 | Comment("MacD in Action"); 45 | } -------------------------------------------------------------------------------- /CheckFilter_Volumes.mq5: -------------------------------------------------------------------------------- 1 | string CheckFilter_Volumes() 2 | { 3 | string filter = ""; 4 | 5 | double priceArray[]; 6 | ArraySetAsSeries(priceArray, true); 7 | 8 | int VolumeHandler = iVolumes(_Symbol, _Period, VOLUME_TICK); 9 | CopyBuffer(VolumeHandler, 0, 0, 3, priceArray); 10 | 11 | float CurrentVolumeValue = (priceArray[0]); 12 | float PreviousVolumeValue = (priceArray[1]); 13 | 14 | if(CurrentVolumeValue > PreviousVolumeValue) 15 | { 16 | filter = "Positive"; 17 | } 18 | 19 | if(CurrentVolumeValue < PreviousVolumeValue) 20 | { 21 | filter = "Negative"; 22 | } 23 | 24 | return filter; 25 | } -------------------------------------------------------------------------------- /CheckSignal_BollingerBands.mq5: -------------------------------------------------------------------------------- 1 | string CheckSignal_BollinngerBands() 2 | { 3 | //We create an array for the prices 4 | MqlRates PriceInfo[]; 5 | 6 | //Sort the array from the current candle downwards 7 | ArraySetAsSeries(PriceInfo, true); 8 | 9 | //We fill the array with price data 10 | //For all candles in the chart: int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), PriceInfo); 11 | int Data = CopyRates(Symbol(), Period(), 0, 3, PriceInfo); 12 | 13 | //Create a string variable for the signal 14 | string signal = ""; 15 | 16 | //Create arrays for prices 17 | double UpperBandsArray[]; 18 | double MiddleBandArray[]; 19 | double LowerBandArray[]; 20 | 21 | //Define Bollinnger Bands 22 | int BollinngerBandsDefinition = iBands(_Symbol, _Period, 20, 0, 2, PRICE_CLOSE); 23 | 24 | //Copy price info into the arrays 25 | CopyBuffer(BollinngerBandsDefinition, 0, 0, 3, MiddleBandArray); 26 | CopyBuffer(BollinngerBandsDefinition, 1, 0, 3, UpperBandsArray); 27 | CopyBuffer(BollinngerBandsDefinition, 2, 0, 3, LowerBandArray); 28 | 29 | //Calculate EA for the last candle 30 | double MiddleBandValueLast = MiddleBandArray[0]; 31 | double UpperBandValueLast = UpperBandsArray[0]; 32 | double LowerBandValueLast = LowerBandArray[0]; 33 | 34 | //Calculate EA for the last but one candle 35 | double MiddleBandValueLastButOne = MiddleBandArray[1]; 36 | double UpperBandValueLastButOne = UpperBandsArray[1]; 37 | double LowerBandValueLastButOne = LowerBandArray[1]; 38 | 39 | //Buy signal 40 | if(PriceInfo[1].close < LowerBandValueLastButOne && PriceInfo[0].close > LowerBandValueLast) 41 | signal = "Buy"; 42 | 43 | //Sell Signal 44 | if(PriceInfo[1].close > UpperBandValueLastButOne && PriceInfo[0].close < UpperBandValueLast) 45 | signal = "Sell"; 46 | 47 | return signal; 48 | 49 | } -------------------------------------------------------------------------------- /CommodityChannelIndex.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | double myPriceArray[]; 4 | int CommodityChannelIndexDefinition = iCCI(_Symbol, _Period, 14, PRICE_CLOSE); 5 | ArraySetAsSeries(myPriceArray, true); 6 | CopyBuffer(CommodityChannelIndexDefinition, 0, 0, 3, myPriceArray); 7 | double CommodityChannelIndexValue = myPriceArray[0]; 8 | 9 | if(CommodityChannelIndexValue > 100) Comment("OVERBOUGTH"); 10 | if(CommodityChannelIndexValue < -100) Comment("OVERSOLD"); 11 | if(CommodityChannelIndexValue < 100 && CommodityChannelIndexValue > -100) Comment(""); 12 | } -------------------------------------------------------------------------------- /DeMarker.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array of several prices 4 | double myPriceArray[]; 5 | 6 | //Define the properties of DeMarker EA 7 | int DemarkerDefinition = iDeMarker(_Symbol, _Period, 14); 8 | 9 | //Sort the array from the current candle downwards 10 | ArraySetAsSeries(myPriceArray, true); 11 | 12 | //Define EA, one line, current candle, 3 candles, store result 13 | CopyBuffer(DemarkerDefinition, 0, 0, 3, myPriceArray); 14 | 15 | //Get the Value 16 | double DeMarkerValue = myPriceArray[0]; 17 | 18 | if(DeMarkerValue > 0.7) Comment("Strong Trend: ", DeMarkerValue); 19 | if(DeMarkerValue < 0.3) Comment("Weak Trend: ", DeMarkerValue); 20 | if(DeMarkerValue < 0.7 && DeMarkerValue > 0.3) Comment(""); 21 | } -------------------------------------------------------------------------------- /DoubleExponentialMovingAverage.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | MqlRates priceInformation[]; 7 | ArraySetAsSeries(priceInformation, true); 8 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 9 | 10 | double DoubleExponentialMovingAverageArray[]; 11 | int DoubleExponentialMovingAverageHandler = iDEMA(_Symbol, _Period, 14, 0, PRICE_CLOSE); 12 | ArraySetAsSeries(DoubleExponentialMovingAverageArray, true); 13 | CopyBuffer(DoubleExponentialMovingAverageHandler, 0, 0, 3, DoubleExponentialMovingAverageArray); 14 | 15 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 16 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 17 | 18 | double DoubleExponentialMovingAverageValue = DoubleExponentialMovingAverageArray[1]; 19 | 20 | if(DoubleExponentialMovingAverageValue < priceInformation[1].close && GetPositions_Buy() < 50) 21 | trade.Buy(0.01, NULL, Ask, 0, Ask + (300 * _Point), NULL); 22 | 23 | if(DoubleExponentialMovingAverageValue > priceInformation[1].close && GetPositions_Sell() < 50) 24 | trade.Sell(0.01, NULL, Bid, 0, Bid - (300 * _Point), NULL); 25 | } 26 | 27 | int GetPositions_Sell() 28 | { 29 | int numberOfSellPositions = 0; 30 | 31 | for(int i = PositionsTotal() -1; i >= 0; i--) 32 | { 33 | string CurrencyPair = PositionGetSymbol(i); 34 | 35 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 36 | 37 | if(Symbol() == CurrencyPair) 38 | { 39 | if(PositionDirection == POSITION_TYPE_SELL) 40 | { 41 | numberOfSellPositions = numberOfSellPositions + 1; 42 | } 43 | } 44 | } 45 | 46 | return numberOfSellPositions; 47 | } 48 | 49 | int GetPositions_Buy() 50 | { 51 | int numberOfBuyPositions = 0; 52 | 53 | for(int i = PositionsTotal() -1; i >= 0; i--) 54 | { 55 | string CurrencyPair = PositionGetSymbol(i); 56 | 57 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 58 | 59 | if(Symbol() == CurrencyPair) 60 | { 61 | if(PositionDirection == POSITION_TYPE_BUY) 62 | { 63 | numberOfBuyPositions = numberOfBuyPositions + 1; 64 | } 65 | } 66 | } 67 | 68 | return numberOfBuyPositions; 69 | } -------------------------------------------------------------------------------- /DynnamicPositionSize.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Equity = AccountInfoDouble(ACCOUNT_EQUITY); 7 | 8 | double DynamicPositionSize = NormalizeDouble(Equity / 1000000, 2); 9 | 10 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 11 | 12 | if(PositionsTotal() < 10 && OrdersTotal() < 10) 13 | { 14 | trade.BuyStop(DynamicPositionSize, Ask + 100 * _Point, NULL, 0, Ask + 300 * _Point, ORDER_TIME_GTC, 0, NULL); 15 | } 16 | 17 | Comment("Positionn Size: ", DynamicPositionSize); 18 | 19 | } -------------------------------------------------------------------------------- /EA_MA_Cross_Over.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | Trade_On_EA_MA_Cross_Over(); 7 | Comment("Total Positions: ", PositionsTotal()); 8 | } 9 | 10 | string EA_MA_Cross_Over(int smallMA, int bigMA) 11 | { 12 | string signal = ""; 13 | 14 | double smallMA_Array[], bigMA_Array[]; 15 | ArraySetAsSeries(smallMA_Array, true); 16 | ArraySetAsSeries(bigMA_Array, true); 17 | 18 | int smallMA_Handler = iMA(_Symbol, _Period, smallMA, 0, MODE_SMA, PRICE_CLOSE); 19 | int bigMA_Handler = iMA(_Symbol, _Period, bigMA, 0, MODE_SMA, PRICE_CLOSE); 20 | 21 | CopyBuffer(smallMA_Handler, 0, 0, 3, smallMA_Array); 22 | CopyBuffer(bigMA_Handler, 0, 0, 3, bigMA_Array); 23 | 24 | if(bigMA_Array[1] > smallMA_Array[1] && bigMA_Array[2] < smallMA_Array[2]) 25 | signal = "Buy"; 26 | if(bigMA_Array[1] < smallMA_Array[1] && bigMA_Array[2] > smallMA_Array[2]) 27 | signal = "Sell"; 28 | 29 | return signal; 30 | } 31 | 32 | void Trade_On_EA_MA_Cross_Over() 33 | { 34 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 35 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 36 | 37 | if(EA_MA_Cross_Over(20, 50) == "Buy" && PositionsTotal() < 100) 38 | trade.Buy(0.01, NULL, Ask, 0, Ask + 300 * _Point, NULL); 39 | if(EA_MA_Cross_Over(20, 50) == "Sell" && PositionsTotal() < 100) 40 | trade.Sell(0.01, NULL, Bid, 0, Bid - 300 * _Point, NULL); 41 | } -------------------------------------------------------------------------------- /Envelopes.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(CheckEntry_Envelopes() == "Buy" && GetPositions_Buy() < 100) 10 | trade.Buy(0.01, _Symbol, Ask, 0, Ask + (100 * _Point), NULL); 11 | if(CheckEntry_Envelopes() == "Sell" && GetPositions_Sell() < 100) 12 | trade.Sell(0.01, _Symbol, Bid, 0, Bid - (100 * _Point), NULL); 13 | 14 | Comment("Buy : ", GetPositions_Buy(), "\nSell: ", GetPositions_Sell()); 15 | } 16 | 17 | string CheckEntry_Envelopes() 18 | { 19 | string Signal = ""; 20 | 21 | MqlRates priceInformation[]; 22 | ArraySetAsSeries(priceInformation, true); 23 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 24 | 25 | double upperBandArray[]; 26 | double lowerBandArray[]; 27 | 28 | int EnvelopesHandler = iEnvelopes(_Symbol, _Period, 14, 0, MODE_SMA, PRICE_CLOSE, 0.100); 29 | 30 | ArraySetAsSeries(upperBandArray, true); 31 | ArraySetAsSeries(lowerBandArray, true); 32 | 33 | CopyBuffer(EnvelopesHandler, 0, 0, 3, upperBandArray); 34 | CopyBuffer(EnvelopesHandler, 1, 0, 3, lowerBandArray); 35 | 36 | double upperBandValue = NormalizeDouble(upperBandArray[0], 6); 37 | double lowerBandValue = NormalizeDouble(lowerBandArray[0], 6); 38 | 39 | if(priceInformation[1].close > upperBandValue) 40 | Signal = "Sell"; 41 | if(priceInformation[1].close < lowerBandValue) 42 | Signal = "Buy"; 43 | 44 | return Signal; 45 | } 46 | 47 | int GetPositions_Sell() 48 | { 49 | int numberOfSellPositions = 0; 50 | 51 | for(int i = PositionsTotal() -1; i >= 0; i--) 52 | { 53 | string CurrencyPair = PositionGetSymbol(i); 54 | 55 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 56 | 57 | if(Symbol() == CurrencyPair) 58 | { 59 | if(PositionDirection == POSITION_TYPE_SELL) 60 | { 61 | numberOfSellPositions = numberOfSellPositions + 1; 62 | } 63 | } 64 | } 65 | 66 | return numberOfSellPositions; 67 | } 68 | 69 | int GetPositions_Buy() 70 | { 71 | int numberOfBuyPositions = 0; 72 | 73 | for(int i = PositionsTotal() -1; i >= 0; i--) 74 | { 75 | string CurrencyPair = PositionGetSymbol(i); 76 | 77 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 78 | 79 | if(Symbol() == CurrencyPair) 80 | { 81 | if(PositionDirection == POSITION_TYPE_BUY) 82 | { 83 | numberOfBuyPositions = numberOfBuyPositions + 1; 84 | } 85 | } 86 | } 87 | 88 | return numberOfBuyPositions; 89 | } -------------------------------------------------------------------------------- /FirstProgram.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 7 | double Balance = AccountInfoDouble(ACCOUNT_BALANCE); 8 | double Equity = AccountInfoDouble(ACCOUNT_EQUITY); 9 | 10 | if(Equity >= Balance) 11 | trade.Sell((0.10, NULL, Bid, 0, (Bid - 100 * _Point), NULL); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /ForceIndex.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array of several prices 4 | double myPriceArray[]; 5 | 6 | //Sort the array from the current candle downwards 7 | ArraySetAsSeries(myPriceArray, true); 8 | 9 | //Define the properties of Force Index 10 | int ForceIndexDefinition = iForce(_Symbol, _Period, 13, MODE_SMA, VOLUME_TICK); 11 | 12 | //Define EA, one line, current candle, 3 candles, store result 13 | CopyBuffer(ForceIndexDefinition, 0, 0, 3, myPriceArray); 14 | 15 | //Get the value of the Force Index 16 | double ForceIndexValue = NormalizeDouble(myPriceArray[0], 6); 17 | 18 | if(ForceIndexValue > 0) Comment("Trending Upwards: ", ForceIndexValue); 19 | if(ForceIndexValue < 0) Comment("Trending downwards: ", ForceIndexValue); 20 | } -------------------------------------------------------------------------------- /FractalAdaptiveMovingAverage.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | TradeNowOn_FractalAdaptiveMovingAverage(); 7 | Comment( 8 | "\nTotal Buy Positions : ", GetPositions_Buy(), 9 | "\nTotal Sell Positions : ", GetPositions_Sell(), 10 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 11 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 12 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 13 | "\nTotal Positions : ", PositionsTotal() 14 | ); 15 | } 16 | 17 | void TradeNowOn_FractalAdaptiveMovingAverage() 18 | { 19 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 20 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 21 | 22 | if(CheckEntry_FractalAdaptiveMovingAverage() == "Buy" && GetPositions_Buy() < 100) 23 | trade.Buy(0.01, NULL, Ask, 0, Ask + (100 * _Point), NULL); 24 | if(CheckEntry_FractalAdaptiveMovingAverage() == "Sell" && GetPositions_Sell() < 100) 25 | trade.Sell(0.01, NULL, Bid, 0, Bid - (100 * _Point), NULL); 26 | } 27 | 28 | string CheckEntry_FractalAdaptiveMovingAverage() 29 | { 30 | string Signal = ""; 31 | 32 | MqlRates priceInformation[]; 33 | ArraySetAsSeries(priceInformation, true); 34 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 35 | 36 | double FractalAdaptiveMovingAverageArray[]; 37 | int FractalAdaptiveMovingAverageHandler = iFrAMA(_Symbol, _Period, 14, 0, PRICE_CLOSE); 38 | ArraySetAsSeries(FractalAdaptiveMovingAverageArray, true); 39 | CopyBuffer(FractalAdaptiveMovingAverageHandler, 0, 0, 3, FractalAdaptiveMovingAverageArray); 40 | double FractalAdaptiveMovingAverageValue = FractalAdaptiveMovingAverageArray[0]; 41 | 42 | if(FractalAdaptiveMovingAverageValue > priceInformation[1].high) 43 | Signal = "Buy"; 44 | if(FractalAdaptiveMovingAverageValue < priceInformation[1].low) 45 | Signal = "Sell"; 46 | 47 | return Signal; 48 | } 49 | 50 | int GetPositions_Buy() 51 | { 52 | int numberOfBuyPositions = 0; 53 | 54 | for(int i = PositionsTotal() - 1; i >= 0; i--) 55 | { 56 | string positionSymbol = PositionGetSymbol(i); 57 | int positionDirection = PositionGetInteger(POSITION_TYPE); 58 | 59 | if(positionSymbol == Symbol()) 60 | { 61 | if(positionDirection == POSITION_TYPE_BUY) 62 | { 63 | numberOfBuyPositions++; 64 | } 65 | } 66 | } 67 | return numberOfBuyPositions; 68 | } 69 | 70 | int GetPositions_Sell() 71 | { 72 | int numberOfSellPositions = 0; 73 | 74 | for(int i = PositionsTotal() - 1; i >= 0; i--) 75 | { 76 | string positionSymbol = PositionGetSymbol(i); 77 | int positionDirection = PositionGetInteger(POSITION_TYPE); 78 | 79 | if(positionSymbol == Symbol()) 80 | { 81 | if(positionDirection == POSITION_TYPE_SELL) 82 | { 83 | numberOfSellPositions++; 84 | } 85 | } 86 | } 87 | return numberOfSellPositions; 88 | } 89 | 90 | void CloseAllPositions() 91 | { 92 | for(int i = PositionsTotal() - 1; i >= 0; i--) 93 | { 94 | int ticket = PositionGetTicket(i); 95 | trade.PositionClose(ticket); 96 | } 97 | } -------------------------------------------------------------------------------- /GetSignal_All.mq5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monir71/Meta-Trader-MQL5-MQL4-Programming-Expert-Advisor-Robot/b86f2973f3d9a17970176e999cc58dacacbf8b87/GetSignal_All.mq5 -------------------------------------------------------------------------------- /HighestCandle.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double HighestCandle; 7 | double High[]; 8 | ArraySetAsSeries(High, true); 9 | CopyHigh(_Symbol, PERIOD_M1, 0, 11, High); 10 | HighestCandle = ArrayMaximum(High, 0, 11); 11 | Comment("\n\nHighest candle within last 10 candles: ", HighestCandle); 12 | } -------------------------------------------------------------------------------- /IchimokuH1GBPUSD.mq5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monir71/Meta-Trader-MQL5-MQL4-Programming-Expert-Advisor-Robot/b86f2973f3d9a17970176e999cc58dacacbf8b87/IchimokuH1GBPUSD.mq5 -------------------------------------------------------------------------------- /MacD.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array of several prices 4 | double myPriceArray[]; 5 | 6 | //Sort the array from the current candle downwards 7 | ArraySetAsSeries(myPriceArray, true); 8 | 9 | //Define the properties of MacD 10 | int MacDDefinition = iMACD(_Symbol, _Period, 12, 26, 9, PRICE_CLOSE); 11 | 12 | //Define EA, one line, current candle, 3 candles, store result 13 | CopyBuffer(MacDDefinition, 0, 0, 3, myPriceArray); 14 | 15 | //Get the value of MacD 16 | float MacDValue = myPriceArray[0]; 17 | 18 | Comment("MacD Value : ", MacDValue); 19 | } -------------------------------------------------------------------------------- /MacDStandaloneEA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | static int sellPositions = 10; 5 | static int buyPositions = 10; 6 | static int accountEquity = 2000; 7 | 8 | 9 | void OnTick() 10 | { 11 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 12 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 13 | 14 | double priceInfo[]; 15 | ArraySetAsSeries(priceInfo, true); 16 | 17 | int MacDHandler = iMACD(_Symbol, _Period, 12, 26, 9, PRICE_CLOSE); 18 | CopyBuffer(MacDHandler, 0, 0, 10, priceInfo); 19 | 20 | double macdValue = priceInfo[0]; 21 | double macdValueLastButOne = priceInfo[9]; 22 | double macdValueLastButOneCheck = priceInfo[8]; 23 | 24 | /* 25 | if(accountEquity < 1000 && GetPositions_Sell() == 10) 26 | { 27 | sellPositions = 20; 28 | } 29 | 30 | if(accountEquity < 1000 && GetPositions_Buy() == 10) 31 | { 32 | buyPositions = 20; 33 | } 34 | */ 35 | 36 | if(GetProfit_Buy() < -1500) 37 | { 38 | while(GetPositions_Sell() < sellPositions) 39 | { 40 | sellPositions = 20; 41 | buyPositions = 20; 42 | trade.Sell(0.1, NULL, Bid, 0, Bid - (500 * _Point), NULL); 43 | trade.Buy(0.1, NULL, Ask, 0, Ask + (200 * _Point), NULL); 44 | } 45 | } 46 | 47 | if(GetProfit_Sell() < -1500) 48 | { 49 | while(GetPositions_Buy() < buyPositions) 50 | { 51 | sellPositions = 20; 52 | buyPositions = 20; 53 | trade.Buy(0.1, NULL, Ask, 0, Ask + (500 * _Point), NULL); 54 | trade.Sell(0.1, NULL, Bid, 0, Bid - (200 * _Point), NULL); 55 | } 56 | } 57 | 58 | while(macdValue > 0 && macdValueLastButOneCheck > 0 && macdValueLastButOne < 0 && GetPositions_Sell() < sellPositions) 59 | { 60 | trade.Sell(0.1, NULL, Bid, 0, Bid - (300 * _Point), NULL); 61 | } 62 | 63 | while(macdValue < 0 && macdValueLastButOneCheck < 0 && macdValueLastButOne > 0 && GetPositions_Buy() < buyPositions) 64 | { 65 | trade.Buy(0.1, NULL, Ask, 0, Ask + (300 * _Point), NULL); 66 | } 67 | 68 | Comment( 69 | "MacD Index [0] = ", DoubleToString(priceInfo[0], 2), 70 | "\nMacD Index [1] = ", DoubleToString(priceInfo[1], 2), 71 | "\nMacD Index [2] = ", DoubleToString(priceInfo[2], 2), 72 | "\nMacD Index [3] = ", DoubleToString(priceInfo[3], 2), 73 | "\nMacD Index [4] = ", DoubleToString(priceInfo[4], 2), 74 | "\nMacD Index [5] = ", DoubleToString(priceInfo[5], 2), 75 | "\nMacD Index [6] = ", DoubleToString(priceInfo[6], 2), 76 | "\nMacD Index [7] = ", DoubleToString(priceInfo[7], 2), 77 | "\nMacD Index [8] = ", DoubleToString(priceInfo[8], 2), 78 | "\nMacD Index [9] = ", DoubleToString(priceInfo[9], 2), 79 | "\nBalance = ", AccountInfoDouble(ACCOUNT_BALANCE), 80 | "\nEquity = ", AccountInfoDouble(ACCOUNT_EQUITY), 81 | "\nBuy Positions : ", GetPositions_Buy(), 82 | "\nSell Positions : ", GetPositions_Sell(), 83 | "\nTotal Positions : ", PositionsTotal(), 84 | "\nSell Profit : ", GetProfit_Sell(), 85 | "\nBuy Profit : ", GetProfit_Buy() 86 | ); 87 | 88 | } 89 | 90 | int GetPositions_Sell() 91 | { 92 | int numberOfSellPositions = 0; 93 | 94 | for(int i = PositionsTotal() -1; i >= 0; i--) 95 | { 96 | string CurrencyPair = PositionGetSymbol(i); 97 | 98 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 99 | 100 | if(Symbol() == CurrencyPair) 101 | { 102 | if(PositionDirection == POSITION_TYPE_SELL) 103 | { 104 | numberOfSellPositions = numberOfSellPositions + 1; 105 | } 106 | } 107 | } 108 | 109 | return numberOfSellPositions; 110 | } 111 | 112 | double GetProfit_Sell() 113 | { 114 | int sellProfit = 0; 115 | 116 | for(int i = PositionsTotal() -1; i >= 0; i--) 117 | { 118 | string CurrencyPair = PositionGetSymbol(i); 119 | 120 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 121 | 122 | if(Symbol() == CurrencyPair) 123 | { 124 | if(PositionDirection == POSITION_TYPE_SELL) 125 | { 126 | sellProfit += PositionGetDouble(POSITION_PROFIT); 127 | } 128 | } 129 | } 130 | 131 | return sellProfit; 132 | } 133 | 134 | int GetPositions_Buy() 135 | { 136 | int numberOfBuyPositions = 0; 137 | 138 | for(int i = PositionsTotal() -1; i >= 0; i--) 139 | { 140 | string CurrencyPair = PositionGetSymbol(i); 141 | 142 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 143 | 144 | if(Symbol() == CurrencyPair) 145 | { 146 | if(PositionDirection == POSITION_TYPE_BUY) 147 | { 148 | numberOfBuyPositions = numberOfBuyPositions + 1; 149 | } 150 | } 151 | } 152 | 153 | return numberOfBuyPositions; 154 | } 155 | 156 | double GetProfit_Buy() 157 | { 158 | double buyProfit = 0; 159 | 160 | for(int i = PositionsTotal() -1; i >= 0; i--) 161 | { 162 | string CurrencyPair = PositionGetSymbol(i); 163 | 164 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 165 | 166 | if(Symbol() == CurrencyPair) 167 | { 168 | if(PositionDirection == POSITION_TYPE_BUY) 169 | { 170 | buyProfit += PositionGetDouble(POSITION_PROFIT); 171 | } 172 | } 173 | } 174 | 175 | return buyProfit; 176 | } -------------------------------------------------------------------------------- /MainModule.mq5: -------------------------------------------------------------------------------- 1 | #import "MyLibrary.ex5" 2 | void OpenBuyStop(); 3 | double GetProfitCurrencyPair(); 4 | #import 5 | 6 | void OnTick() 7 | { 8 | if(PositionsTotal() == 0) 9 | OpenBuyStop(); 10 | 11 | double profit = GetProfitCurrencyPair(); 12 | Comment("Profit : ", profit); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Momentum_TripleMA_WPR.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | TradeNowOnMomentum(); 7 | Comment(GetTripleMovingAverageSignal()); 8 | } 9 | 10 | string Check_Momentum_Entry() 11 | { 12 | string Signal = ""; 13 | 14 | double priceInformation[]; 15 | 16 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 17 | 18 | ArraySetAsSeries(priceInformation, true); 19 | 20 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 21 | 22 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 23 | 24 | if(MomentumValue > 100.00)//Over Bought 25 | { 26 | Signal = "Sell"; 27 | } 28 | 29 | if(MomentumValue < 100.00)//Over Sold 30 | { 31 | Signal = "Buy"; 32 | } 33 | 34 | return Signal; 35 | } 36 | 37 | void TradeNowOnMomentum() 38 | { 39 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 40 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 41 | 42 | if(Check_Momentum_Entry() == "Buy" && GetPositions_Buy() < 100 && GetTripleMovingAverageSignal() == "Buy Now!") 43 | { 44 | //For H1 45 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 46 | //For M1 47 | trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 48 | } 49 | 50 | if(Check_Momentum_Entry() == "Sell" && GetPositions_Sell() < 100 && GetTripleMovingAverageSignal() == "Sell Now!") 51 | { 52 | //For H1 53 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 54 | //For M1 55 | trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 56 | } 57 | } 58 | 59 | void CloseAllPositions() 60 | { 61 | for(int i = PositionsTotal() -1; i >= 0; i--) 62 | { 63 | int ticket = PositionGetTicket(i); 64 | trade.PositionClose(ticket); 65 | } 66 | } 67 | 68 | int GetPositions_Sell() 69 | { 70 | int numberOfSellPositions = 0; 71 | 72 | for(int i = PositionsTotal() -1; i >= 0; i--) 73 | { 74 | string CurrencyPair = PositionGetSymbol(i); 75 | 76 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 77 | 78 | if(Symbol() == CurrencyPair) 79 | { 80 | if(PositionDirection == POSITION_TYPE_SELL) 81 | { 82 | numberOfSellPositions = numberOfSellPositions + 1; 83 | } 84 | } 85 | } 86 | 87 | return numberOfSellPositions; 88 | } 89 | 90 | int GetPositions_Buy() 91 | { 92 | int numberOfBuyPositions = 0; 93 | 94 | for(int i = PositionsTotal() -1; i >= 0; i--) 95 | { 96 | string CurrencyPair = PositionGetSymbol(i); 97 | 98 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 99 | 100 | if(Symbol() == CurrencyPair) 101 | { 102 | if(PositionDirection == POSITION_TYPE_BUY) 103 | { 104 | numberOfBuyPositions = numberOfBuyPositions + 1; 105 | } 106 | } 107 | } 108 | 109 | return numberOfBuyPositions; 110 | } 111 | 112 | string GetTripleMovingAverageSignal() 113 | { 114 | double movingAverage100Array[]; 115 | double movingAverage50Array[]; 116 | double movingAverage10Array[]; 117 | 118 | int movingAverage100Definition = iMA(_Symbol, _Period, 100, 0, MODE_SMA, PRICE_CLOSE); 119 | int movingAverage50Definition = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); 120 | int movingAverage10Definition = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); 121 | 122 | ArraySetAsSeries(movingAverage100Array, true); 123 | ArraySetAsSeries(movingAverage50Array, true); 124 | ArraySetAsSeries(movingAverage10Array, true); 125 | 126 | CopyBuffer(movingAverage100Definition, 0, 0, 10, movingAverage100Array); 127 | CopyBuffer(movingAverage50Definition, 0, 0, 10, movingAverage50Array); 128 | CopyBuffer(movingAverage10Definition, 0, 0, 10, movingAverage10Array); 129 | 130 | string Signal = ""; 131 | 132 | if(movingAverage100Array[0] > movingAverage50Array[0]) 133 | if(movingAverage50Array[0] > movingAverage10Array[0]) 134 | Signal = "Buy Now!"; 135 | 136 | if(movingAverage100Array[0] < movingAverage50Array[0]) 137 | if(movingAverage50Array[0] < movingAverage10Array[0]) 138 | Signal = "Sell Now!"; 139 | 140 | return Signal; 141 | } 142 | 143 | string CheckEntry_WPR() 144 | { 145 | string Signal = ""; 146 | 147 | double WPRarray[]; 148 | 149 | int WPRdefinition = iWPR(_Symbol, _Period, 14); 150 | 151 | ArraySetAsSeries(WPRarray, true); 152 | 153 | CopyBuffer(WPRdefinition, 0, 0, 3, WPRarray); 154 | 155 | double WPRvalue = NormalizeDouble(WPRarray[0], 2); 156 | 157 | if(WPRvalue < -80.00 && WPRvalue > -100.00) 158 | { 159 | Signal = "Buy"; 160 | } 161 | 162 | if(WPRvalue > -20.00 && WPRvalue < 0) 163 | { 164 | Signal = "Sell"; 165 | } 166 | 167 | return Signal; 168 | } -------------------------------------------------------------------------------- /MonneyFlowIndex.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array of prices 4 | double myPriceArray[]; 5 | 6 | //Sort the array from the current candle downwards 7 | ArraySetAsSeries(myPriceArray, true); 8 | 9 | //Define Money Flow Index (MFI) 10 | int MoneyFlowIndexDefinition = iMFI(_Symbol, _Period, 14, VOLUME_TICK); 11 | 12 | //Define EA, one line, current candle, 3 candles, store result in array 13 | CopyBuffer(MoneyFlowIndexDefinition, 0, 0, 3, myPriceArray); 14 | 15 | //Get the value of MFI 16 | double MoneyFlowIndexValue = NormalizeDouble(myPriceArray[0], 2); 17 | 18 | if(MoneyFlowIndexValue > 80) Comment("OVER BOUGHT ", MoneyFlowIndexValue); 19 | if(MoneyFlowIndexValue < 20) Comment("OVER SOLD ", MoneyFlowIndexValue); 20 | if(MoneyFlowIndexValue < 80 && MoneyFlowIndexValue > 20) Comment("Money Flow Index Value ", MoneyFlowIndexValue); 21 | 22 | } -------------------------------------------------------------------------------- /MyExampleOne.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | while(GetPositions_Buy() < 10 && GetSignal() == "Buy") 10 | { 11 | trade.Buy(0.10, NULL, Ask, Ask - (200 * _Point), Ask + (300 * _Point), NULL); 12 | } 13 | 14 | while(GetPositions_Sell() < 10 && GetSignal() == "Sell") 15 | { 16 | trade.Sell(0.10, NULL, Bid, Bid + (200 * _Point), Bid - (300 * _Point), NULL); 17 | } 18 | } 19 | 20 | string GetSignal() 21 | { 22 | string signal = ""; 23 | 24 | double myMovingAverageArray4[]; 25 | double myMovingAverageArray6[]; 26 | double myMovingAverageArray5[]; 27 | double myMovingAverageArray1[]; 28 | double myMovingAverageArray2[]; 29 | double myMovingAverageArray3[]; 30 | 31 | int myMovingAverageArray4Definition = iMA(_Symbol, _Period, 84, 0, MODE_EMA, PRICE_CLOSE); 32 | int myMovingAverageArray6Definition = iMA(_Symbol, _Period, 78, 0, MODE_EMA, PRICE_CLOSE); 33 | int myMovingAverageArray5Definition = iMA(_Symbol, _Period, 40, 0, MODE_EMA, PRICE_CLOSE); 34 | int myMovingAverageArray1Definition = iMA(_Symbol, _Period, 9, 0, MODE_EMA, PRICE_CLOSE); 35 | int myMovingAverageArray2Definition = iMA(_Symbol, _Period, 8, 0, MODE_EMA, PRICE_CLOSE); 36 | int myMovingAverageArray3Definition = iMA(_Symbol, _Period, 3, 0, MODE_EMA, PRICE_CLOSE); 37 | //0 1 2 3 5 8 13 21 38 | ArraySetAsSeries(myMovingAverageArray4, true); 39 | ArraySetAsSeries(myMovingAverageArray6, true); 40 | ArraySetAsSeries(myMovingAverageArray5, true); 41 | ArraySetAsSeries(myMovingAverageArray1, true); 42 | ArraySetAsSeries(myMovingAverageArray2, true); 43 | ArraySetAsSeries(myMovingAverageArray3, true); 44 | 45 | CopyBuffer(myMovingAverageArray4Definition, 0, 0, 3, myMovingAverageArray4); 46 | CopyBuffer(myMovingAverageArray6Definition, 0, 0, 3, myMovingAverageArray6); 47 | CopyBuffer(myMovingAverageArray5Definition, 0, 0, 3, myMovingAverageArray5); 48 | CopyBuffer(myMovingAverageArray1Definition, 0, 0, 3, myMovingAverageArray1); 49 | CopyBuffer(myMovingAverageArray2Definition, 0, 0, 3, myMovingAverageArray2); 50 | CopyBuffer(myMovingAverageArray3Definition, 0, 0, 3, myMovingAverageArray3); 51 | 52 | if(myMovingAverageArray4[0] > myMovingAverageArray6[0] && 53 | myMovingAverageArray6[0] > myMovingAverageArray5[0] && 54 | myMovingAverageArray5[0] > myMovingAverageArray1[0] && 55 | myMovingAverageArray1[0] > myMovingAverageArray2[0] && 56 | myMovingAverageArray2[0] > myMovingAverageArray3[0]) 57 | { 58 | signal = "Sell"; 59 | } 60 | 61 | if(myMovingAverageArray4[0] < myMovingAverageArray6[0] && 62 | myMovingAverageArray6[0] < myMovingAverageArray5[0] && 63 | myMovingAverageArray5[0] < myMovingAverageArray1[0] && 64 | myMovingAverageArray1[0] < myMovingAverageArray2[0] && 65 | myMovingAverageArray2[0] < myMovingAverageArray3[0]) 66 | { 67 | signal = "Buy"; 68 | } 69 | 70 | return signal; 71 | } 72 | 73 | int GetPositions_Sell() 74 | { 75 | int numberOfSellPositions = 0; 76 | 77 | for(int i = PositionsTotal() -1; i >= 0; i--) 78 | { 79 | string CurrencyPair = PositionGetSymbol(i); 80 | 81 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 82 | 83 | if(Symbol() == CurrencyPair) 84 | { 85 | if(PositionDirection == POSITION_TYPE_SELL) 86 | { 87 | numberOfSellPositions = numberOfSellPositions + 1; 88 | } 89 | } 90 | } 91 | 92 | return numberOfSellPositions; 93 | } 94 | 95 | int GetPositions_Buy() 96 | { 97 | int numberOfBuyPositions = 0; 98 | 99 | for(int i = PositionsTotal() -1; i >= 0; i--) 100 | { 101 | string CurrencyPair = PositionGetSymbol(i); 102 | 103 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 104 | 105 | if(Symbol() == CurrencyPair) 106 | { 107 | if(PositionDirection == POSITION_TYPE_BUY) 108 | { 109 | numberOfBuyPositions = numberOfBuyPositions + 1; 110 | } 111 | } 112 | } 113 | 114 | return numberOfBuyPositions; 115 | } -------------------------------------------------------------------------------- /MyFramework1.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | //Import file 5 | #include "AdvfanceEMAcrossOver.mq5"; 6 | 7 | static double profit = AccountInfoDouble(ACCOUNT_BALANCE) * 2; 8 | 9 | void OnTick() 10 | { 11 | string signal = checkEntry(); 12 | 13 | double Bid = NormalizeDouble(SymbolInfoDouble(Symbol(), SYMBOL_BID), _Digits); 14 | double Ask = NormalizeDouble(SymbolInfoDouble(Symbol(), SYMBOL_ASK), _Digits); 15 | 16 | if(countPosition() < 10) 17 | { 18 | Comment("Signnal : "); 19 | if(profit >= AccountInfoDouble(ACCOUNT_BALANCE)) 20 | { 21 | if(signal == "BUY") 22 | trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 23 | } 24 | } 25 | 26 | //if(signal == "SELL") 27 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 28 | } 29 | 30 | int countPosition() 31 | { 32 | int PositionsForThisSymbol = 0; 33 | 34 | for(int i = PositionsTotal() - 1; i >= 0; i--) 35 | { 36 | string symbol = PositionGetSymbol(i); 37 | 38 | if(Symbol() == symbol) 39 | { 40 | PositionsForThisSymbol += 1; 41 | } 42 | } 43 | return PositionsForThisSymbol; 44 | } -------------------------------------------------------------------------------- /MyStrategyTester.mq5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monir71/Meta-Trader-MQL5-MQL4-Programming-Expert-Advisor-Robot/b86f2973f3d9a17970176e999cc58dacacbf8b87/MyStrategyTester.mq5 -------------------------------------------------------------------------------- /ObjectLabel.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | //get the ask price 7 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 8 | 9 | //Set object properties for a label 10 | ObjectCreate(_Symbol, "Label1", OBJ_LABEL, 0, 0, 0); 11 | 12 | ObjectSetString(0, "Label1", OBJPROP_FONT, "Arial"); 13 | 14 | ObjectSetString(0, "Label1", OBJPROP_TEXT, "Ask Value : " + Ask); 15 | 16 | ObjectSetInteger(0, "Label1", OBJPROP_XDISTANCE, 20); 17 | 18 | ObjectSetInteger(0, "Label1", OBJPROP_YDISTANCE, 20); 19 | 20 | ObjectSetInteger(0, "Label1", OBJPROP_FONTSIZE, 20); 21 | 22 | } -------------------------------------------------------------------------------- /ObjectOrientedLine.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create variable for highest candle 4 | int HighestCandle; 5 | 6 | //Create arrays for highest canndle 7 | double High[]; 8 | 9 | //Sort array downwards from the current candle 10 | ArraySetAsSeries(High, true); 11 | 12 | //Fill array with data of 100 candles 13 | CopyHigh(_Symbol, _Period, 0, 100, High); 14 | 15 | //Calculate the highest candle 16 | HighestCandle = ArrayMaximum(High, 0, 100); 17 | 18 | //Create an array for prices 19 | MqlRates priceInformation[]; 20 | 21 | //Sort the array from current candle to older candle 22 | ArraySetAsSeries(priceInformation, true); 23 | 24 | //Copy price data into the array 25 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), priceInformation); 26 | 27 | //Set object properties for a line 28 | ObjectCreate(_Symbol, "Line1", OBJ_HLINE, 0, 0, priceInformation[HighestCandle].high); 29 | 30 | //Set object color 31 | ObjectSetInteger(0, "Line1", OBJPROP_COLOR, clrRed); 32 | 33 | //Set object width 34 | ObjectSetInteger(0, "Line1", OBJPROP_WIDTH, 3); 35 | 36 | //Move the line 37 | ObjectMove(_Symbol, "Line1", 0, 0, priceInformation[HighestCandle].high); 38 | 39 | } -------------------------------------------------------------------------------- /OnBalanceVolumeEA.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | double priceArray[]; 4 | ArraySetAsSeries(priceArray, true); 5 | int OnBalanceVolumeHandler = iOBV(_Symbol, _Period, VOLUME_TICK); 6 | CopyBuffer(OnBalanceVolumeHandler, 0, 0, 3, priceArray); 7 | int OBV_Value = priceArray[0]; 8 | Comment("On Balance Volume Value : ", OBV_Value); 9 | } -------------------------------------------------------------------------------- /ParabolicSAAR.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | Comment("Parabolic SAR Signal: ", GetSignalParabolicSAR()); 4 | } 5 | 6 | string GetSignalParabolicSAR() 7 | { 8 | string signal = ""; 9 | 10 | MqlRates priceInfo[]; 11 | ArraySetAsSeries(priceInfo, true); 12 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInfo); 13 | 14 | double ParabolicSARarray[]; 15 | int ParabolicSARdefinition = iSAR(_Symbol, _Period, 0.02, 0.20); 16 | ArraySetAsSeries(ParabolicSARarray, true); 17 | CopyBuffer(ParabolicSARdefinition, 0, 0, 3, ParabolicSARarray); 18 | 19 | double ParabolicSARvalueCurrent = ParabolicSARarray[0]; 20 | double ParabolicSARvaluePrevious = ParabolicSARarray[1]; 21 | 22 | if(priceInfo[1].close > ParabolicSARvalueCurrent && priceInfo[2].close < ParabolicSARvaluePrevious) 23 | signal = "Buy"; 24 | 25 | if(priceInfo[1].close < ParabolicSARvalueCurrent && priceInfo[2].close > ParabolicSARvaluePrevious) 26 | signal = "Sell"; 27 | 28 | return signal; 29 | } -------------------------------------------------------------------------------- /PositionMultiplier.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | input int Number_Of_Positions = 1; 5 | 6 | void OnTick() 7 | { 8 | MqlRates priceInformation[]; 9 | ArraySetAsSeries(priceInformation, true); 10 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 11 | 12 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 13 | 14 | if(priceInformation[1].close > priceInformation[2].close) 15 | { 16 | if(PositionsTotal() < Number_Of_Positions) 17 | { 18 | for(int i = Number_Of_Positions - PositionsTotal(); i > 0; i--) 19 | { 20 | trade.Buy(0.01, NULL, Ask, 0, Ask + (300 * _Point), NULL); 21 | } 22 | } 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Meta-Trader-MQL5-MQL4-Programming-Expert-Advisor-Robot 2 | In the world of foreign exchange (forex) trading, an expert advisor (EA) is software that tells you when to make trades. You can even program the software to initiate and execute trades for you by using your trading criteria. Expert advisors are most often used within the MetaTrader 4 or 5 forex trading platforms 3 | -------------------------------------------------------------------------------- /RVIStandaloneEA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | while(GetRVISignal() == "Buy" && PositionsTotal() < 10) 10 | { 11 | trade.Buy(0.01, NULL, Ask, 0, Ask + (300 * _Point), NULL); 12 | } 13 | 14 | while(GetRVISignal() == "Sell" && PositionsTotal() < 10) 15 | { 16 | trade.Sell(0.01, NULL, Bid, 0, Bid - (300 * _Point), NULL); 17 | } 18 | } 19 | 20 | string GetRVISignal() 21 | { 22 | string signal = ""; 23 | 24 | double RVIarray0[]; 25 | double RVIarray1[]; 26 | 27 | int RVIHandler = iRVI(_Symbol, _Period, 10); 28 | 29 | ArraySetAsSeries(RVIarray0, true); 30 | ArraySetAsSeries(RVIarray1, true); 31 | 32 | CopyBuffer(RVIHandler, 0, 0, 3, RVIarray0); 33 | CopyBuffer(RVIHandler, 1, 0, 3, RVIarray1); 34 | 35 | double RVIvalue0 = NormalizeDouble(RVIarray0[0], 3); 36 | double RVIvalue1 = NormalizeDouble(RVIarray1[0], 3); 37 | 38 | if(RVIvalue0 < RVIvalue1 && RVIvalue0 < 0 && RVIvalue1 < 0) 39 | { 40 | signal = "Buy"; 41 | } 42 | 43 | if(RVIvalue0 > RVIvalue1 && RVIvalue0 > 0 && RVIvalue1 > 0) 44 | { 45 | signal = "Sell"; 46 | } 47 | 48 | return signal; 49 | } 50 | 51 | int GetPositions_Sell() 52 | { 53 | int numberOfSellPositions = 0; 54 | 55 | for(int i = PositionsTotal() -1; i >= 0; i--) 56 | { 57 | string CurrencyPair = PositionGetSymbol(i); 58 | 59 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 60 | 61 | if(Symbol() == CurrencyPair) 62 | { 63 | if(PositionDirection == POSITION_TYPE_SELL) 64 | { 65 | numberOfSellPositions = numberOfSellPositions + 1; 66 | } 67 | } 68 | } 69 | 70 | return numberOfSellPositions; 71 | } 72 | 73 | int GetPositions_Buy() 74 | { 75 | int numberOfBuyPositions = 0; 76 | 77 | for(int i = PositionsTotal() -1; i >= 0; i--) 78 | { 79 | string CurrencyPair = PositionGetSymbol(i); 80 | 81 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 82 | 83 | if(Symbol() == CurrencyPair) 84 | { 85 | if(PositionDirection == POSITION_TYPE_BUY) 86 | { 87 | numberOfBuyPositions = numberOfBuyPositions + 1; 88 | } 89 | } 90 | } 91 | 92 | return numberOfBuyPositions; 93 | } -------------------------------------------------------------------------------- /RandomEntry.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | string Signal = ""; 7 | 8 | MathSrand(GetTickCount()); 9 | 10 | double randomNumber = MathRand() % 2; 11 | 12 | if(randomNumber == 0) 13 | Signal = "Buy"; 14 | if(randomNumber == 1) 15 | Signal = "Sell"; 16 | 17 | Comment("Signal = ", Signal, "\nBuy = ", GetPositions_Buy(), "\nSell = ", GetPositions_Sell()); 18 | 19 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 20 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 21 | 22 | if(Signal == "Buy" && GetPositions_Buy() < 50) 23 | { 24 | for(int i = 50 - GetPositions_Buy(); i >= 1; i--) 25 | { 26 | trade.Buy(0.01, NULL, Ask, 0, Ask + (50 * _Point), NULL); 27 | } 28 | } 29 | 30 | if(Signal == "Sell" && GetPositions_Sell() < 50) 31 | { 32 | for(int i = 50 - GetPositions_Sell(); i >= 1; i--) 33 | { 34 | trade.Sell(0.01, NULL, Bid, 0, Bid - (50 * _Point), NULL); 35 | } 36 | } 37 | 38 | } 39 | 40 | int GetPositions_Sell() 41 | { 42 | int numberOfSellPositions = 0; 43 | 44 | for(int i = PositionsTotal() -1; i >= 0; i--) 45 | { 46 | string CurrencyPair = PositionGetSymbol(i); 47 | 48 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 49 | 50 | if(Symbol() == CurrencyPair) 51 | { 52 | if(PositionDirection == POSITION_TYPE_SELL) 53 | { 54 | numberOfSellPositions = numberOfSellPositions + 1; 55 | } 56 | } 57 | } 58 | 59 | return numberOfSellPositions; 60 | } 61 | 62 | int GetPositions_Buy() 63 | { 64 | int numberOfBuyPositions = 0; 65 | 66 | for(int i = PositionsTotal() -1; i >= 0; i--) 67 | { 68 | string CurrencyPair = PositionGetSymbol(i); 69 | 70 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 71 | 72 | if(Symbol() == CurrencyPair) 73 | { 74 | if(PositionDirection == POSITION_TYPE_BUY) 75 | { 76 | numberOfBuyPositions = numberOfBuyPositions + 1; 77 | } 78 | } 79 | } 80 | 81 | return numberOfBuyPositions; 82 | } -------------------------------------------------------------------------------- /RelativeStrengthIndex_RSI.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(Check_Entry_RSI() == "Buy" && GetPositions_Buy() < 100) 10 | trade.Buy(0.01, _Symbol, Ask, 0, Ask + (100 * _Point), NULL); 11 | if(Check_Entry_RSI() == "Sell" && GetPositions_Sell() < 100) 12 | trade.Sell(0.01, _Symbol, Bid, 0, Bid - (100 * _Point), NULL); 13 | 14 | Comment("Buy : ", GetPositions_Buy(), "\nSell: ", GetPositions_Sell()); 15 | } 16 | 17 | string Check_Entry_RSI() 18 | { 19 | string Signal = ""; 20 | 21 | double RSIArray[]; 22 | 23 | int RSIDefinition = iRSI(_Symbol, _Period, 14, PRICE_CLOSE); 24 | 25 | ArraySetAsSeries(RSIArray, true); 26 | 27 | CopyBuffer(RSIDefinition, 0, 0, 3, RSIArray); 28 | 29 | double RSIValue = NormalizeDouble(RSIArray[0], 2); 30 | 31 | if(RSIValue > 70.00) 32 | Signal = "Sell"; 33 | if(RSIValue < 30.00) 34 | Signal = "Buy"; 35 | 36 | return Signal; 37 | } 38 | 39 | int GetPositions_Sell() 40 | { 41 | int numberOfSellPositions = 0; 42 | 43 | for(int i = PositionsTotal() -1; i >= 0; i--) 44 | { 45 | string CurrencyPair = PositionGetSymbol(i); 46 | 47 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 48 | 49 | if(Symbol() == CurrencyPair) 50 | { 51 | if(PositionDirection == POSITION_TYPE_SELL) 52 | { 53 | numberOfSellPositions = numberOfSellPositions + 1; 54 | } 55 | } 56 | } 57 | 58 | return numberOfSellPositions; 59 | } 60 | 61 | int GetPositions_Buy() 62 | { 63 | int numberOfBuyPositions = 0; 64 | 65 | for(int i = PositionsTotal() -1; i >= 0; i--) 66 | { 67 | string CurrencyPair = PositionGetSymbol(i); 68 | 69 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 70 | 71 | if(Symbol() == CurrencyPair) 72 | { 73 | if(PositionDirection == POSITION_TYPE_BUY) 74 | { 75 | numberOfBuyPositions = numberOfBuyPositions + 1; 76 | } 77 | } 78 | } 79 | 80 | return numberOfBuyPositions; 81 | } -------------------------------------------------------------------------------- /RelativeVigorIndex.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array of Relative Vigor Index 4 | double RelativeVigorIndexArray[]; 5 | 6 | //Create an array of Relative Vigor Signal 7 | double RelativeVigorSignalArray[]; 8 | 9 | //Sort Relative Vigor Index array from the current candle downwards 10 | ArraySetAsSeries(RelativeVigorIndexArray, true); 11 | 12 | //Sort Relative Vigor Signal array from the current candle downwards 13 | ArraySetAsSeries(RelativeVigorSignalArray, true); 14 | 15 | //Define Relative Vigor Index 16 | int RelativeVigorIndex = iRVI(_Symbol, _Period, 10); 17 | 18 | //Define EA, line one, current candle, 3 candles, store result in Relative Vigor Index Array 19 | CopyBuffer(RelativeVigorIndex, 0, 0, 3, RelativeVigorIndexArray); 20 | 21 | //Define EA, line two, current candle,3 candles. store result in Relative Vigor Signal Array 22 | CopyBuffer(RelativeVigorIndex, 1, 0, 3, RelativeVigorSignalArray); 23 | 24 | //Get the value of the Relative Vigor Index 25 | double RelativeVigorIndexValue = RelativeVigorIndexArray[0]; 26 | 27 | //Get the value of the Relative Vigor Signal 28 | double RelativeVigorSignalValue = RelativeVigorSignalArray[0]; 29 | 30 | //Chart Output 31 | if(RelativeVigorIndexValue > RelativeVigorSignalValue && RelativeVigorIndexValue > 0) 32 | Comment("Up Trend\n\nRelative Vigor Index: ", RelativeVigorIndexValue, 33 | "\nRelative Vigor Index Signal: ", RelativeVigorSignalValue); 34 | 35 | if(RelativeVigorIndexValue < RelativeVigorSignalValue && RelativeVigorIndexValue < 0) 36 | Comment("Down Trend\n\nRelative Vigor Index: ", RelativeVigorIndexValue, 37 | "\nRelative Vigor Index Signal: ", RelativeVigorSignalValue); 38 | } -------------------------------------------------------------------------------- /SellLimit.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(PositionsTotal() == 0 && OrdersTotal() == 0) 10 | trade.SellLimit(0.01, Ask + (200 * _Point), _Symbol, 0, Bid - (200 * _Point), ORDER_TIME_GTC, 0, 0); 11 | 12 | } -------------------------------------------------------------------------------- /ShiftedMovingAverage.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | while(GetShiftedMovingAverageSignal() == "Buy") 10 | trade.Buy(0.01, NULL, Ask, 0, Ask + 200 * _Point, NULL); 11 | while(GetShiftedMovingAverageSignal() == "Sell") 12 | trade.Sell(0.01, NULL, Bid, 0, Bid - 200 * _Point, NULL); 13 | 14 | } 15 | 16 | string GetShiftedMovingAverageSignal() 17 | { 18 | string signal = ""; 19 | 20 | double movingAverageArray[], shiftedMovingAverageArray[]; 21 | ArraySetAsSeries(movingAverageArray, true); 22 | ArraySetAsSeries(shiftedMovingAverageArray, true); 23 | int movingAverageHandler = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); 24 | int shiftedMovingAverageHandler = iMA(_Symbol, _Period, 51, 20, MODE_SMA, PRICE_CLOSE); 25 | CopyBuffer(movingAverageHandler, 0, 0, 3, movingAverageArray); 26 | CopyBuffer(shiftedMovingAverageHandler, 0, 0, 3, shiftedMovingAverageArray); 27 | double movingAverageValue = movingAverageArray[0]; 28 | double shiftedMovingAverageValue = shiftedMovingAverageArray[0]; 29 | 30 | MqlRates PriceInfo[]; 31 | ArraySetAsSeries(PriceInfo, true); 32 | int Data = CopyRates(Symbol(), Period(), 0, 3, PriceInfo); 33 | 34 | if(PriceInfo[1].close > shiftedMovingAverageValue && PriceInfo[2].close < shiftedMovingAverageValue) 35 | signal = "Buy"; 36 | if(PriceInfo[1].close < shiftedMovingAverageValue && PriceInfo[2].close > shiftedMovingAverageValue) 37 | signal = "Sell"; 38 | 39 | return signal; 40 | } 41 | 42 | string GetSignal_BollinngerBands() 43 | { 44 | //We create an array for the prices 45 | MqlRates PriceInfo[]; 46 | 47 | //Sort the array from the current candle downwards 48 | ArraySetAsSeries(PriceInfo, true); 49 | 50 | //We fill the array with price data 51 | //For all candles in the chart: int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), PriceInfo); 52 | int Data = CopyRates(Symbol(), Period(), 0, 3, PriceInfo); 53 | 54 | //Create a string variable for the signal 55 | string signal = ""; 56 | 57 | //Create arrays for prices 58 | double UpperBandsArray[]; 59 | double MiddleBandArray[]; 60 | double LowerBandArray[]; 61 | 62 | //Define Bollinnger Bands 63 | int BollinngerBandsDefinition = iBands(_Symbol, _Period, 20, 0, 2, PRICE_CLOSE); 64 | 65 | //Copy price info into the arrays 66 | CopyBuffer(BollinngerBandsDefinition, 0, 0, 3, MiddleBandArray); 67 | CopyBuffer(BollinngerBandsDefinition, 1, 0, 3, UpperBandsArray); 68 | CopyBuffer(BollinngerBandsDefinition, 2, 0, 3, LowerBandArray); 69 | 70 | //Calculate EA for the last candle 71 | double MiddleBandValueLast = MiddleBandArray[0]; 72 | double UpperBandValueLast = UpperBandsArray[0]; 73 | double LowerBandValueLast = LowerBandArray[0]; 74 | 75 | //Calculate EA for the last but one candle 76 | double MiddleBandValueLastButOne = MiddleBandArray[1]; 77 | double UpperBandValueLastButOne = UpperBandsArray[1]; 78 | double LowerBandValueLastButOne = LowerBandArray[1]; 79 | 80 | //Buy signal 81 | if(PriceInfo[1].close < LowerBandValueLastButOne && PriceInfo[0].close > LowerBandValueLast) 82 | signal = "Buy"; 83 | 84 | //Sell Signal 85 | if(PriceInfo[1].close > UpperBandValueLastButOne && PriceInfo[0].close < UpperBandValueLast) 86 | signal = "Sell"; 87 | 88 | return signal; 89 | 90 | } 91 | 92 | string GetEntry_AwesomeOscillator() 93 | { 94 | string signal = ""; 95 | 96 | double priceArray[]; 97 | ArraySetAsSeries(priceArray, true); 98 | int AOHandler = iAO(_Symbol, _Period); 99 | CopyBuffer(AOHandler, 0, 0, 3, priceArray); 100 | double AwesomeOscillatorValue = NormalizeDouble(priceArray[0], 6); 101 | 102 | if(AwesomeOscillatorValue > 0) 103 | signal = "Buy"; 104 | if(AwesomeOscillatorValue < 0) 105 | signal = "Sell"; 106 | 107 | return signal; 108 | } 109 | 110 | string Check_Momentum_Entry() 111 | { 112 | string Signal = ""; 113 | 114 | double priceInformation[]; 115 | 116 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 117 | 118 | ArraySetAsSeries(priceInformation, true); 119 | 120 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 121 | 122 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 123 | 124 | if(MomentumValue > 100.00)//Over Bought 125 | { 126 | Signal = "Sell"; 127 | } 128 | 129 | if(MomentumValue < 100.00)//Over Sold 130 | { 131 | Signal = "Buy"; 132 | } 133 | 134 | return Signal; 135 | } -------------------------------------------------------------------------------- /SignalStcking.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | //||||||||||||||||||||||||||||||||||||||||||||||||||| 7 | //||| Four (04) Moving Average ||| 8 | //||||||||||||||||||||||||||||||||||||||||||||||||||| 9 | 10 | double movingAverageArray1[]; 11 | double movingAverageArray2[]; 12 | double movingAverageArray3[]; 13 | double movingAverageArray4[]; 14 | 15 | int movingAverageHandler1 = iMA(_Symbol, _Period, 50, 0, MODE_EMA, PRICE_CLOSE); 16 | int movingAverageHandler2 = iMA(_Symbol, _Period, 100, 0, MODE_EMA, PRICE_CLOSE); 17 | int movingAverageHandler3 = iMA(_Symbol, _Period, 150, 0, MODE_EMA, PRICE_CLOSE); 18 | int movingAverageHandler4 = iMA(_Symbol, _Period, 200, 0, MODE_EMA, PRICE_CLOSE); 19 | 20 | ArraySetAsSeries(movingAverageArray1, true); 21 | ArraySetAsSeries(movingAverageArray2, true); 22 | ArraySetAsSeries(movingAverageArray3, true); 23 | ArraySetAsSeries(movingAverageArray4, true); 24 | 25 | CopyBuffer(movingAverageHandler1, 0, 0, 3, movingAverageArray1); 26 | CopyBuffer(movingAverageHandler2, 0, 0, 3, movingAverageArray2); 27 | CopyBuffer(movingAverageHandler3, 0, 0, 3, movingAverageArray3); 28 | CopyBuffer(movingAverageHandler4, 0, 0, 3, movingAverageArray4); 29 | 30 | double movingAverageValue1 = movingAverageArray1[0]; 31 | double movingAverageValue2 = movingAverageArray2[0]; 32 | double movingAverageValue3 = movingAverageArray3[0]; 33 | double movingAverageValue4 = movingAverageArray4[0]; 34 | 35 | //||||||||||||||||||||||||||||||||||||||||||||||||||| 36 | //||| Price Information ||| 37 | //||||||||||||||||||||||||||||||||||||||||||||||||||| 38 | 39 | MqlRates priceInformation[]; 40 | ArraySetAsSeries(priceInformation, true); 41 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 42 | 43 | //||||||||||||||||||||||||||||||||||||||||||||||||||| 44 | //||| Preparing to Trade ||| 45 | //||||||||||||||||||||||||||||||||||||||||||||||||||| 46 | 47 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 48 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 49 | 50 | //||||||||||||||||||||||||||||||||||||||||||||||||||| 51 | //||| Verifying Conditions ||| 52 | //||||||||||||||||||||||||||||||||||||||||||||||||||| 53 | 54 | if(movingAverageValue1 > movingAverageValue2 && 55 | movingAverageValue2 > movingAverageValue3 && 56 | movingAverageValue3 > movingAverageValue4 && 57 | movingAverageValue4 < priceInformation[0].close && 58 | movingAverageValue4 > priceInformation[1].close) 59 | { 60 | if(PositionsTotal() < 100) 61 | { 62 | trade.Buy(0.01, NULL, Ask, 0, Ask + (200 * _Point), NULL); 63 | } 64 | } 65 | 66 | if(movingAverageValue1 < movingAverageValue2 && 67 | movingAverageValue2 < movingAverageValue3 && 68 | movingAverageValue3 < movingAverageValue4 && 69 | movingAverageValue4 > priceInformation[0].close && 70 | movingAverageValue4 < priceInformation[1].close) 71 | { 72 | if(PositionsTotal() < 100) 73 | { 74 | trade.Sell(0.01, NULL, Bid, 0, Bid - (200 * _Point), NULL); 75 | } 76 | } 77 | 78 | Comment("Moving Aveage Value 1: ", movingAverageValue1, 79 | "Moving Aveage Value 2 : ", movingAverageValue2, 80 | "Moving Aveage Value 3 : ", movingAverageValue3, 81 | "Moving Aveage Value 4: ", movingAverageValue4); 82 | } -------------------------------------------------------------------------------- /SiimpleEMACrossover.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | //Create an array for several prices 7 | double myExponentialMovingAverageArray1[], myExponentialMovingAverageArraay2[]; 8 | 9 | //Define the properties of the exponential moving aveage array 1 10 | int myExponentialMovingAverage1 = iMA(_Symbol, _Period, 20, 0, MODE_EMA, PRICE_CLOSE); 11 | 12 | //Define the properties of the exponential moving average array 2 13 | int myExponentialMovingAverage2 = iMA(_Symbol, _Period, 50, 0, MODE_EMA, PRICE_CLOSE); 14 | 15 | //Sort the price of Exonnential Moving Average Array 1 from the current candle downwards 16 | ArraySetAsSeries(myExponentialMovingAverageArray1, true); 17 | 18 | //Sort the price of Exponnential Moving Average Array 2 from the current candle downwards 19 | ArraySetAsSeries(myExponentialMovingAverageArraay2, true); 20 | 21 | //Defined EMA, one line, current candle, 3 candles, store result 22 | CopyBuffer(myExponentialMovingAverage1, 0, 0, 3, myExponentialMovingAverageArray1); 23 | 24 | //Defined EMA, one line, current candle, 3 candles, stroe result 25 | CopyBuffer(myExponentialMovingAverage2, 0, 0, 3, myExponentialMovingAverageArraay2); 26 | 27 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 28 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 29 | 30 | //Check the 20 candles EMA is above than 50 candles EMA 31 | if((myExponentialMovingAverageArray1[0] > myExponentialMovingAverageArraay2[0]) && 32 | (myExponentialMovingAverageArray1[1] < myExponentialMovingAverageArraay2[1])) 33 | { 34 | if(countPosition() < 5) 35 | { 36 | trade.Buy(0.01, NULL, Ask, (Ask - 50 * _Point), (Ask + 100 * _Point), NULL); 37 | } 38 | } 39 | 40 | 41 | if((myExponentialMovingAverageArray1[0] < myExponentialMovingAverageArraay2[0]) && 42 | (myExponentialMovingAverageArray1[1] > myExponentialMovingAverageArraay2[1])) 43 | { 44 | if(countPosition() < 5) 45 | { 46 | trade.Sell(0.01, NULL, Bid, (Bid + 50 * _Point), (Bid - 100 * _Point), NULL); 47 | } 48 | } 49 | 50 | 51 | } 52 | 53 | int countPosition() 54 | { 55 | int PositionsForThisSymbol = 0; 56 | 57 | for(int i = PositionsTotal() - 1; i >= 0; i--) 58 | { 59 | string symbol = PositionGetSymbol(i); 60 | 61 | if(Symbol() == symbol) 62 | { 63 | PositionsForThisSymbol += 1; 64 | } 65 | } 66 | return PositionsForThisSymbol; 67 | } -------------------------------------------------------------------------------- /SimpleArrowEA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | static int buyCounter = 0; 5 | static int sellCounter = 0; 6 | 7 | void OnTick() 8 | { 9 | MqlRates priceInformation[]; 10 | ArraySetAsSeries(priceInformation, true); 11 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), priceInformation); 12 | 13 | int numberOfCandles = Bars(Symbol(), Period()); 14 | string numberOfCandlesText = IntegerToString(numberOfCandles); 15 | 16 | int highestCandleNumber = iHighest(NULL, 0, MODE_HIGH, 200, 1); 17 | int lowestCandleNumber = iLowest(NULL, 0, MODE_LOW, 200, 1); 18 | 19 | double highestPrice = priceInformation[highestCandleNumber].high; 20 | double lowestPrice = priceInformation[lowestCandleNumber].low; 21 | 22 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 23 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 24 | 25 | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 26 | //||||||||||||||||| Buy Counter |||||||||||||||| 27 | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 28 | 29 | if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 0) 30 | { 31 | while(buyCounter < 10) 32 | { 33 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 34 | buyCounter++; 35 | } 36 | } 37 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 10) 38 | { 39 | while(buyCounter < 20) 40 | { 41 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 42 | buyCounter++; 43 | } 44 | } 45 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 20) 46 | { 47 | while(buyCounter < 30) 48 | { 49 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 50 | buyCounter++; 51 | } 52 | } 53 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 30) 54 | { 55 | while(buyCounter < 40) 56 | { 57 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 58 | buyCounter++; 59 | } 60 | } 61 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 40) 62 | { 63 | while(buyCounter < 50) 64 | { 65 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 66 | buyCounter++; 67 | } 68 | } 69 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 50) 70 | { 71 | while(buyCounter < 60) 72 | { 73 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 74 | buyCounter++; 75 | } 76 | } 77 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 60) 78 | { 79 | while(buyCounter < 70) 80 | { 81 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 82 | buyCounter++; 83 | } 84 | } 85 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 70) 86 | { 87 | while(buyCounter < 80) 88 | { 89 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 90 | buyCounter++; 91 | } 92 | } 93 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 80) 94 | { 95 | while(buyCounter < 90) 96 | { 97 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 98 | buyCounter++; 99 | } 100 | } 101 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 90) 102 | { 103 | while(buyCounter < 100) 104 | { 105 | trade.Buy(0.01, NULL, Ask, 0, Ask + (30 * _Point), NULL); 106 | buyCounter++; 107 | } 108 | } 109 | else if(priceInformation[0].low < lowestPrice && GetPositions_Buy() == 100) 110 | { 111 | buyCounter = 0; 112 | } 113 | else 114 | { 115 | //buyCounter = 0; 116 | } 117 | 118 | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 119 | //||||||||||||||||| Sell Counter |||||||||||||||| 120 | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 121 | 122 | if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 0) 123 | { 124 | while(sellCounter < 10) 125 | { 126 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 127 | sellCounter++; 128 | } 129 | } 130 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 10) 131 | { 132 | while(sellCounter < 20) 133 | { 134 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 135 | sellCounter++; 136 | } 137 | } 138 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 20) 139 | { 140 | while(sellCounter < 30) 141 | { 142 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 143 | sellCounter++; 144 | } 145 | } 146 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 30) 147 | { 148 | while(sellCounter < 40) 149 | { 150 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 151 | sellCounter++; 152 | } 153 | } 154 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 40) 155 | { 156 | while(sellCounter < 50) 157 | { 158 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 159 | sellCounter++; 160 | } 161 | } 162 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 50) 163 | { 164 | while(sellCounter < 60) 165 | { 166 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 167 | sellCounter++; 168 | } 169 | } 170 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 60) 171 | { 172 | while(sellCounter < 70) 173 | { 174 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 175 | sellCounter++; 176 | } 177 | } 178 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 70) 179 | { 180 | while(sellCounter < 80) 181 | { 182 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 183 | sellCounter++; 184 | } 185 | } 186 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 80) 187 | { 188 | while(sellCounter < 90) 189 | { 190 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 191 | sellCounter++; 192 | } 193 | } 194 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 90) 195 | { 196 | while(sellCounter < 100) 197 | { 198 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 199 | sellCounter++; 200 | } 201 | } 202 | else if(priceInformation[0].high > highestPrice && GetPositions_Sell() == 100) 203 | { 204 | sellCounter = 0; 205 | } 206 | else 207 | { 208 | //sellCounter = 0; 209 | } 210 | 211 | /* 212 | while(GetPositions_Buy() < 100) 213 | { 214 | //ObjectCreate(0, numberOfCandlesText, OBJ_ARROW_BUY, 0, TimeCurrent(), (priceInformation[0].low)); 215 | 216 | 217 | } 218 | 219 | while(priceInformation[0].high > highestPrice && GetPositions_Sell() < 100) 220 | { 221 | //ObjectCreate(0, numberOfCandlesText, OBJ_ARROW_SELL, 0, TimeCurrent(), (priceInformation[0].high)); 222 | trade.Sell(0.01, NULL, Bid, 0, Bid - (30 * _Point), NULL); 223 | } 224 | */ 225 | 226 | Comment("Number of Candles : ", numberOfCandles, 227 | "\nHighest Candle Number : ", highestCandleNumber, 228 | "\nHighest Price : ", highestPrice, 229 | "\nLowest Candle Number : ", lowestCandleNumber, 230 | "\nLowest Price : ", lowestPrice, 231 | "\nTotal Buy Positions : ", GetPositions_Buy(), 232 | "\nTotal Sell Positions : ", GetPositions_Sell(), 233 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 234 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 235 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 236 | "\nTotal Positions : ", PositionsTotal(), 237 | "\nBuy Counter : ", buyCounter, 238 | "\nSell Counter : ", sellCounter 239 | ); 240 | 241 | } 242 | 243 | int GetPositions_Sell() 244 | { 245 | int numberOfSellPositions = 0; 246 | 247 | for(int i = PositionsTotal() -1; i >= 0; i--) 248 | { 249 | string CurrencyPair = PositionGetSymbol(i); 250 | 251 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 252 | 253 | if(Symbol() == CurrencyPair) 254 | { 255 | if(PositionDirection == POSITION_TYPE_SELL) 256 | { 257 | numberOfSellPositions = numberOfSellPositions + 1; 258 | } 259 | } 260 | } 261 | 262 | return numberOfSellPositions; 263 | } 264 | 265 | int GetPositions_Buy() 266 | { 267 | int numberOfBuyPositions = 0; 268 | 269 | for(int i = PositionsTotal() -1; i >= 0; i--) 270 | { 271 | string CurrencyPair = PositionGetSymbol(i); 272 | 273 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 274 | 275 | if(Symbol() == CurrencyPair) 276 | { 277 | if(PositionDirection == POSITION_TYPE_BUY) 278 | { 279 | numberOfBuyPositions = numberOfBuyPositions + 1; 280 | } 281 | } 282 | } 283 | 284 | return numberOfBuyPositions; 285 | } -------------------------------------------------------------------------------- /SimpleBWMFI.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | double BillWilliamsMarketFacilitationIndexArray[]; 4 | int BillWilliamsMarketFacilitationIndexHandler = iBWMFI(_Symbol, PERIOD_H1, VOLUME_TICK); 5 | ArraySetAsSeries(BillWilliamsMarketFacilitationIndexArray, true); 6 | CopyBuffer(BillWilliamsMarketFacilitationIndexHandler, 0, 0, 3, BillWilliamsMarketFacilitationIndexArray); 7 | double BillWilliamsMarketFacilitationIndexValue = BillWilliamsMarketFacilitationIndexArray[0]; 8 | Comment("Bill Williams Market Facilitation Index Value : ", BillWilliamsMarketFacilitationIndexValue); 9 | } -------------------------------------------------------------------------------- /SimpleBearsPowerIndicator.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array of prices 4 | double priceArray[]; 5 | 6 | //Bears Power Definition 7 | int BearsPowerDefinition = iBearsPower(_Symbol, _Period, 13); 8 | 9 | //Sort prices from the current candle downwards 10 | ArraySetAsSeries(priceArray, true); 11 | 12 | //Define EA, one line, current candle, 3 candles, store result 13 | CopyBuffer(BearsPowerDefinition, 0, 0, 3, priceArray); 14 | 15 | //Get the value of the ccurrent candle 16 | float BearsPowerValue = priceArray[0]; 17 | 18 | Comment("Bears Power Value: ", BearsPowerValue); 19 | } -------------------------------------------------------------------------------- /SimpleBollingerBands.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array for several prices 4 | double UpperBandArray[]; 5 | double MiddleBandArray[]; 6 | double LowerBandArray[]; 7 | 8 | //Sort the price array from the current candle downwards 9 | ArraySetAsSeries(UpperBandArray, true); 10 | ArraySetAsSeries(MiddleBandArray, true); 11 | ArraySetAsSeries(LowerBandArray, true); 12 | 13 | //Define Bollinger Bands 14 | int BollingerBandsDefiniition = iBands(_Symbol, _Period, 20, 0, 2, PRICE_CLOSE); 15 | 16 | //Copy price info into the array 17 | CopyBuffer(BollingerBandsDefiniition, 1, 0, 3, UpperBandArray); 18 | CopyBuffer(BollingerBandsDefiniition, 0, 0, 3, MiddleBandArray); 19 | CopyBuffer(BollingerBandsDefiniition, 2, 0, 3, LowerBandArray); 20 | 21 | //Calculate EA for the current candle 22 | double UpperBandValue = UpperBandArray[0]; 23 | double MiddleBandValue = MiddleBandArray[0]; 24 | double LowerBandValue = LowerBandArray[0]; 25 | 26 | //Chart output of the current EA 27 | Comment("Upper Bollinger Band Value: ", UpperBandValue, "\n\nMiddle Bollinger Band Value: ", 28 | MiddleBandValue, "\n\nLower Band Value: ", LowerBandValue); 29 | 30 | } -------------------------------------------------------------------------------- /SimpleBuy.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Balance = AccountInfoDouble(ACCOUNT_BALANCE); 8 | double Equity = AccountInfoDouble(ACCOUNT_EQUITY); 9 | 10 | if(Equity >= Balance) 11 | { 12 | trade.Buy(0.10, NULL, Ask, 0, (Ask + 100 * _Point), NULL); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SimpleCancelOrder.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 7 | 8 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 9 | 10 | double Balance = AccountInfoDouble(ACCOUNT_BALANCE); 11 | 12 | double Equity = AccountInfoDouble(ACCOUNT_EQUITY); 13 | 14 | if(PositionsTotal() == 0 && OrdersTotal() == 0) 15 | { 16 | trade.BuyStop(0.01, Ask + 200 * _Point, NULL, 0, Ask + 300 * _Point, ORDER_TIME_GTC, 0, NULL); 17 | 18 | trade.SellStop(0.01, Bid - 200 * _Point, NULL, 0, Bid - 300 * _Point, ORDER_TIME_GTC, 0, NULL); 19 | } 20 | 21 | if(Balance != Equity) 22 | { 23 | CancelOrder(); 24 | } 25 | 26 | } 27 | 28 | void CancelOrder() 29 | { 30 | for(int i = OrdersTotal() - 1; i >= 0; i--) 31 | { 32 | ulong OrderTicket = OrderGetTicket(i); 33 | 34 | trade.OrderDelete(OrderTicket); 35 | } 36 | } -------------------------------------------------------------------------------- /SimpleChaikinEA.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(Check_Entry_Chaikin() == "Buy" && GetPositions_Buy() < 100 && Check_Momentum_Entry() == "Buy") 10 | trade.Buy(0.01, _Symbol, Ask, 0, Ask + (500 * _Point), NULL); 11 | if(Check_Entry_Chaikin() == "Sell" && GetPositions_Sell() < 100 && Check_Momentum_Entry() == "Sell") 12 | trade.Sell(0.01, _Symbol, Bid, 0, Bid - (500 * _Point), NULL); 13 | 14 | Comment("Buy : ", GetPositions_Buy(), "\nSell: ", GetPositions_Sell()); 15 | } 16 | 17 | string Check_Entry_Chaikin() 18 | { 19 | string Signal = ""; 20 | 21 | double ChaikinArray[]; 22 | int ChaikinDefinition = iChaikin(_Symbol, _Period, 3, 10, MODE_EMA, VOLUME_TICK); 23 | ArraySetAsSeries(ChaikinArray, true); 24 | CopyBuffer(ChaikinDefinition, 0, 0, 3, ChaikinArray); 25 | 26 | double chaikinValue = ChaikinArray[0]; 27 | double previousChaikinValue = ChaikinArray[1]; 28 | 29 | if(chaikinValue > 10 && previousChaikinValue < 10) 30 | Signal = "Sell"; 31 | if(chaikinValue < -10 && previousChaikinValue > -10) 32 | Signal = "Buy"; 33 | 34 | return Signal; 35 | } 36 | 37 | int GetPositions_Sell() 38 | { 39 | int numberOfSellPositions = 0; 40 | 41 | for(int i = PositionsTotal() -1; i >= 0; i--) 42 | { 43 | string CurrencyPair = PositionGetSymbol(i); 44 | 45 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 46 | 47 | if(Symbol() == CurrencyPair) 48 | { 49 | if(PositionDirection == POSITION_TYPE_SELL) 50 | { 51 | numberOfSellPositions = numberOfSellPositions + 1; 52 | } 53 | } 54 | } 55 | 56 | return numberOfSellPositions; 57 | } 58 | 59 | int GetPositions_Buy() 60 | { 61 | int numberOfBuyPositions = 0; 62 | 63 | for(int i = PositionsTotal() -1; i >= 0; i--) 64 | { 65 | string CurrencyPair = PositionGetSymbol(i); 66 | 67 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 68 | 69 | if(Symbol() == CurrencyPair) 70 | { 71 | if(PositionDirection == POSITION_TYPE_BUY) 72 | { 73 | numberOfBuyPositions = numberOfBuyPositions + 1; 74 | } 75 | } 76 | } 77 | 78 | return numberOfBuyPositions; 79 | } 80 | 81 | string Check_Momentum_Entry() 82 | { 83 | string Signal = ""; 84 | 85 | double priceInformation[]; 86 | 87 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 88 | 89 | ArraySetAsSeries(priceInformation, true); 90 | 91 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 92 | 93 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 94 | 95 | if(MomentumValue > 100.00)//Over Bought 96 | { 97 | Signal = "Sell"; 98 | } 99 | 100 | if(MomentumValue < 100.00)//Over Sold 101 | { 102 | Signal = "Buy"; 103 | } 104 | 105 | return Signal; 106 | } -------------------------------------------------------------------------------- /SimpleCustomDateTime.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | string myTime; 4 | myTime = GetTime(); 5 | Comment(myTime); 6 | } 7 | 8 | string GetTime() 9 | { 10 | string GetTimeWithSeconds; 11 | GetTimeWithSeconds = TimeToString(TimeLocal(), TIME_DATE|TIME_SECONDS); 12 | return GetTimeWithSeconds; 13 | } -------------------------------------------------------------------------------- /SimpleDoji.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | MqlRates PriceInformation[]; 4 | 5 | ArraySetAsSeries(PriceInformation, true); 6 | 7 | int Data = CopyRates(Symbol(), Period(), 0, Bars(_Symbol, _Period), PriceInformation); 8 | 9 | if(PriceInformation[1].open == PriceInformation[1].close) 10 | { 11 | Comment("DOJI"); 12 | } 13 | else 14 | { 15 | Comment(""); 16 | } 17 | } -------------------------------------------------------------------------------- /SimpleEnvelopes.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create price array 4 | MqlRates priceInformation[]; 5 | 6 | //Sort it from current candle to oldest 7 | ArraySetAsSeries(priceInformation, true); 8 | 9 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), priceInformation); 10 | 11 | 12 | 13 | //Create two bands of envelopes 14 | double UpperBandArray[], LowerBandArray[]; 15 | 16 | //Sort the price arrays from the current candle downwards 17 | ArraySetAsSeries(UpperBandArray, true); 18 | ArraySetAsSeries(LowerBandArray, true); 19 | 20 | //Define envelopes 21 | int EnvelopesDefinition = iEnvelopes(_Symbol, _Period, 14, 0, MODE_SMA, PRICE_CLOSE, 0.100); 22 | 23 | //Copy prices information into the array 24 | CopyBuffer(EnvelopesDefinition, 0, 0, 3, UpperBandArray); 25 | CopyBuffer(EnvelopesDefinition, 1, 0, 3, LowerBandArray); 26 | 27 | //Calculate EA for the current candle 28 | double UpperBandValue = NormalizeDouble(UpperBandArray[0], 6); 29 | double LowerBandValue = NormalizeDouble(LowerBandArray[0], 6); 30 | 31 | //Chart output of the EA 32 | if(priceInformation[0].close > UpperBandValue) Comment("UPPER SIGNAL"); 33 | if(priceInformation[0].close < LowerBandValue) Comment("LOWER SIGNAL"); 34 | 35 | if(priceInformation[0].close < UpperBandValue && priceInformation[0].close > LowerBandValue) 36 | Comment("Upper Band Value: ", UpperBandValue, "\n\nLower Band Value: ", LowerBandValue); 37 | 38 | } -------------------------------------------------------------------------------- /SimpleExternalSignal.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | 8 | int ExternalFile = FileOpen("Signal.txt", FILE_READ|FILE_ANSI|FILE_COMMON, "|", CP_ACP); 9 | 10 | string BuySignal = FileReadString(ExternalFile); 11 | 12 | FileClose(ExternalFile); 13 | 14 | if(PositionsTotal() == 0 && BuySignal == "BUY IT NOW") 15 | { 16 | trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 17 | } 18 | } -------------------------------------------------------------------------------- /SimpleHighestLowesAndAverageCandle.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | int highestCandleIndex; 4 | int lowestCandleIndex; 5 | 6 | double highestCandleValue; 7 | double lowestCandleValue; 8 | double AverageCandleValue; 9 | 10 | double highArray[]; 11 | double lowArray[]; 12 | 13 | ArraySetAsSeries(highArray, true); 14 | ArraySetAsSeries(lowArray, true); 15 | 16 | CopyHigh(_Symbol, _Period, 0, 50, highArray); 17 | CopyLow(_Symbol, _Period, 0, 50, lowArray); 18 | 19 | highestCandleIndex = ArrayMaximum(highArray, 0, WHOLE_ARRAY); 20 | lowestCandleIndex = ArrayMinimum(lowArray, 0, WHOLE_ARRAY); 21 | 22 | MqlRates priceInformation[]; 23 | ArraySetAsSeries(priceInformation, true); 24 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), priceInformation); 25 | 26 | highestCandleValue = NormalizeDouble(priceInformation[highestCandleIndex].high, 6); 27 | lowestCandleValue = NormalizeDouble(priceInformation[lowestCandleIndex].low, 6); 28 | AverageCandleValue = NormalizeDouble((highestCandleValue + lowestCandleValue) / 2, 6); 29 | 30 | Comment("High : ", highestCandleValue, "\nLow: ", lowestCandleValue, "\nAverage : ", AverageCandleValue); 31 | 32 | } -------------------------------------------------------------------------------- /SimpleIchimoku.mq5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monir71/Meta-Trader-MQL5-MQL4-Programming-Expert-Advisor-Robot/b86f2973f3d9a17970176e999cc58dacacbf8b87/SimpleIchimoku.mq5 -------------------------------------------------------------------------------- /SimpleMomentum.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create a price array 4 | double myPriceArray[]; 5 | 6 | //Define the properties of the Momentum EA 7 | double iMomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 8 | 9 | //Sort the price array from the current candle downwards 10 | ArraySetAsSeries(myPriceArray, true); 11 | 12 | //Defined Momentum, 1 line, current candle, 3 cnadles, strore in array 13 | CopyBuffer(iMomentumDefinition, 0, 0, 3, myPriceArray); 14 | 15 | //Get the value of the current candle 16 | double myMomentumValue = NormalizeDouble(myPriceArray[0], _Digits); 17 | 18 | //Chart output depending on the value 19 | if(myMomentumValue > 100.0) Comment("STRONG MOMENTUM: ", myMomentumValue); 20 | if(myMomentumValue < 99.9) Comment("WEAK MOMENTUM: ", myMomentumValue); 21 | if(myMomentumValue <100.0 && myMomentumValue > 99.9) Comment("", myMomentumValue); 22 | } -------------------------------------------------------------------------------- /SimpleMouseClickEvent.mq5: -------------------------------------------------------------------------------- 1 | void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam) 2 | { 3 | if(id == CHARTEVENT_CLICK) 4 | { 5 | Comment("You pressed pouse at X=", lparam, " and Y=", dparam); 6 | } 7 | } -------------------------------------------------------------------------------- /SimpleMovingAverage.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | Comment("Signal ", GetSignalMovingAverage()); 4 | } 5 | 6 | string GetSignalMovingAverage() 7 | { 8 | string signal = ""; 9 | 10 | MqlRates priceInfo[]; 11 | ArraySetAsSeries(priceInfo, true); 12 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInfo); 13 | 14 | double movingAverageArray[]; 15 | ArraySetAsSeries(movingAverageArray, true); 16 | int movingAverageHandler = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); 17 | CopyBuffer(movingAverageHandler, 0, 0, 3, movingAverageArray); 18 | 19 | double movingAverageValue = movingAverageArray[0]; 20 | 21 | if(priceInfo[1].close > movingAverageValue && priceInfo[2].close < movingAverageValue) 22 | signal = "Buy"; 23 | if(priceInfo[1].close < movingAverageValue && priceInfo[2].close > movingAverageValue) 24 | signal = "Sell"; 25 | 26 | return signal; 27 | } -------------------------------------------------------------------------------- /SimpleNewCandle.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create a price array 4 | MqlRates priceData[]; 5 | 6 | //Sort the array from the current candle downwards 7 | ArraySetAsSeries(priceData, true); 8 | 9 | //Copy candle prices for 3 candles into the array 10 | CopyRates(_Symbol, _Period, 0, 3, priceData); 11 | 12 | //Create a counter for the candle 13 | static int candleCounter; 14 | 15 | //Create a DateTime variable for the last TimeStamp 16 | static datetime timeStampLastCheck; 17 | 18 | //Create datetime variable for the current candle 19 | datetime timeStampCurrentCandle; 20 | 21 | //Read timestamp for current candle in array 22 | timeStampCurrentCandle = priceData[0].time; 23 | 24 | //if the currrent timestamp different from last time 25 | if(timeStampCurrentCandle != timeStampLastCheck) 26 | { 27 | //Remember current timestamp for next time 28 | timeStampLastCheck = timeStampCurrentCandle; 29 | 30 | //Add 1 to the candleCounter 31 | candleCounter += 1; 32 | } 33 | 34 | //Chart output 35 | Comment("\n\nCounted candle since start: ", candleCounter); 36 | 37 | } -------------------------------------------------------------------------------- /SimpleOrderHistoryProfit.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 7 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 8 | 9 | if(PositionsTotal() < 1) 10 | { 11 | trade.Buy(0.10, NULL, Ask, 0, Ask + (300 * _Point), NULL); 12 | trade.Sell(0.10, NULL, Bid, 0, Bid - (300 * _Point), NULL); 13 | } 14 | 15 | string myLastProfit = GetLastProfit(); 16 | 17 | Comment("My last profit was: \n", myLastProfit); 18 | } 19 | 20 | string GetLastProfit() 21 | { 22 | uint TotalNumberOfDeals = HistoryDealsTotal(); 23 | ulong TicketNumber = 0; 24 | long OrderType, DealEntry; 25 | double OrderProfit = 0; 26 | string MySymbol = ""; 27 | string PositionDirection = ""; 28 | string MyResult = ""; 29 | 30 | //Get the History 31 | HistorySelect(0, TimeCurrent()); 32 | 33 | //Go through all the deals 34 | for(uint i = 0; i < TotalNumberOfDeals; i++) 35 | { 36 | //We look for a ticket number 37 | if((TicketNumber = HistoryDealGetTicket(i)) > 0) 38 | { 39 | //Get the Profit 40 | OrderProfit = HistoryDealGetDouble(TicketNumber, DEAL_PROFIT); 41 | //Get the type 42 | OrderType = HistoryDealGetInteger(TicketNumber, DEAL_TYPE); 43 | //Get the Currency Pair 44 | MySymbol = HistoryDealGetString(TicketNumber, DEAL_SYMBOL); 45 | //Get the deal entry typre to check for close type 46 | DealEntry = HistoryDealGetInteger(TicketNumber, DEAL_ENTRY); 47 | 48 | //Ifcurremcy pair fits 49 | if(MySymbol == _Symbol) 50 | //If it is a buy or sell order 51 | if(OrderType == ORDER_TYPE_BUY || OrderType == ORDER_TYPE_SELL) 52 | //If the order was closed 53 | if(DealEntry == 1) 54 | { 55 | //Set sell order type if close type was buy 56 | if(OrderType == ORDER_TYPE_BUY) 57 | PositionDirection = "SELL TRADE"; 58 | //Set buy order type if close type was sell 59 | if(OrderType == ORDER_TYPE_SELL) 60 | PositionDirection = "BUY TRADE"; 61 | MyResult += "Profit : " + OrderProfit + " Ticket : " + TicketNumber + " Position Direction : " + PositionDirection + "\n"; 62 | } 63 | } 64 | } 65 | return MyResult; 66 | } -------------------------------------------------------------------------------- /SimplePositionCount.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | int PositionsForThisSymbol = 0; 7 | 8 | for(int i = PositionsTotal() - 1; i >= 0; i--) 9 | { 10 | string symbol = PositionGetSymbol(i); 11 | 12 | if(Symbol() == symbol) 13 | { 14 | PositionsForThisSymbol += 1; 15 | } 16 | } 17 | 18 | Comment("\n\nPositions for this currency pair:", PositionsForThisSymbol); 19 | 20 | } -------------------------------------------------------------------------------- /SimplePriceInfo.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create an array 4 | MqlRates PriceInformation[]; 5 | 6 | //Sort it from current candle to older candle 7 | ArraySetAsSeries(PriceInformation, true); 8 | 9 | //Copy price data into the array 10 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), PriceInformation); 11 | 12 | if(PriceInformation[1].close > PriceInformation[2].close) 13 | { 14 | Comment("Price is UP"); 15 | } 16 | 17 | if(PriceInformation[1].close < PriceInformation[2].close) 18 | { 19 | Comment("Price is DOWN"); 20 | } 21 | } -------------------------------------------------------------------------------- /SimpleRSI.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //create an array for several prices 4 | double myRSIarray[]; 5 | 6 | //Define the properties of the RSI 7 | int myRSIdefinition = iRSI(_Symbol, _Period, 14, PRICE_CLOSE); 8 | 9 | //sort the price array from the current candle downwards 10 | ArraySetAsSeries(myRSIarray, true); 11 | 12 | //Defined EA, current candle, 3 candles, store result 13 | CopyBuffer(myRSIdefinition, 0, 0, 3, myRSIarray); 14 | 15 | //calculate EA for the current candle 16 | double myRSIvalue = NormalizeDouble(myRSIarray[0], 2); 17 | 18 | //Chart output of the current EA 19 | Comment("RSI Value: ", myRSIvalue); 20 | } -------------------------------------------------------------------------------- /SimpleRSIBollingerBandEntry.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | //Empty Chart output 7 | Comment(""); 8 | 9 | //Create arrays for RSI and 1 Bollinger Band 10 | double myRSIarray[], lowerBollingerBand[]; 11 | 12 | //Define RSI settings 13 | int myRSIDefinition = iRSI(_Symbol, _Period, 14, PRICE_CLOSE); 14 | 15 | //Sort price data from current candle downwards 16 | ArraySetAsSeries(myRSIarray, true); 17 | 18 | //Define EA, current acndle, 3 candles and save in array 19 | CopyBuffer(myRSIDefinition, 0, 0, 3, myRSIarray); 20 | 21 | //Calculate RSI Value of the current candle 22 | double myRSIvalue = NormalizeDouble(myRSIarray[0], 2); 23 | 24 | //------------------------------------------------------------------ 25 | 26 | //Sort current candle downwards 27 | ArraySetAsSeries(lowerBollingerBand, true); 28 | 29 | //Define bollinger band 30 | int lowerBollingerBandDefinition = iBands(_Symbol, _Period, 20, 0, 2, PRICE_CLOSE); 31 | 32 | //Define EA, lower BB Band, current candle, 3 candles and save in array 33 | CopyBuffer(lowerBollingerBandDefinition, 0, 0, 3, lowerBollingerBand); 34 | 35 | //Calculate EA for the last candle 36 | double lowerBollingerBandValue = lowerBollingerBand[0]; 37 | 38 | //get the ask price 39 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 40 | 41 | if(myRSIvalue < 30) 42 | if(Ask < lowerBollingerBandValue) 43 | Comment("\n\n\n\nOverSold and Below Lower Band"); 44 | } -------------------------------------------------------------------------------- /SimpleRSIBollingerEntry.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double LowerBandArray[]; 7 | ArraySetAsSeries(LowerBandArray, true); 8 | int BollingerBandDefinition = iBands(_Symbol, _Period, 20, 0, 2, PRICE_CLOSE); 9 | CopyBuffer(BollingerBandDefinition, 2, 0, 3, LowerBandArray); 10 | double LowerBandValue = LowerBandArray[0]; 11 | Comment("Lover Band Value: ", LowerBandValue); 12 | 13 | double myRSIArray[]; 14 | ArraySetAsSeries(myRSIArray, true); 15 | int myRSIDefinition = iRSI(_Symbol, _Period, 14, PRICE_CLOSE); 16 | CopyBuffer(myRSIDefinition, 0, 0, 3, myRSIArray); 17 | double myRSIValue = NormalizeDouble(myRSIArray[0], 2); 18 | Comment("\n\nMy RSI Value: ", myRSIValue); 19 | 20 | Comment(""); 21 | 22 | double Ask =NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 23 | 24 | if(LowerBandValue < 30 && myRSIValue < 30) 25 | { 26 | Comment("\nLower Band: ", LowerBandValue, " and RSI : ", myRSIValue, "\nBUY BUY BUY !!!"); 27 | trade.Buy(0.10, NULL, Ask, 0, (Ask + 100 * _Point), NULL); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /SimpleRectangle.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | double highestCandleArray[]; 4 | double lowestCandleArray[]; 5 | 6 | ArraySetAsSeries(highestCandleArray, true); 7 | ArraySetAsSeries(lowestCandleArray, true); 8 | 9 | CopyHigh(_Symbol, _Period, 0, 30, highestCandleArray); 10 | CopyLow(_Symbol, _Period, 0, 30, lowestCandleArray); 11 | 12 | int highestCandleIndex = ArrayMaximum(highestCandleArray, 0, WHOLE_ARRAY); 13 | int lowestCandleIndex = ArrayMinimum(lowestCandleArray, 0, WHOLE_ARRAY); 14 | 15 | MqlRates priceInformation[]; 16 | ArraySetAsSeries(priceInformation, true); 17 | int Data = CopyRates(Symbol(), Period(), 0, Bars(Symbol(), Period()), priceInformation); 18 | 19 | ObjectDelete(_Symbol, "Rectangle"); 20 | 21 | ObjectCreate( 22 | _Symbol, 23 | "Rectangle", 24 | OBJ_RECTANGLE, 25 | 0, 26 | priceInformation[30].time, 27 | priceInformation[highestCandleIndex].high, 28 | priceInformation[0].time, 29 | priceInformation[lowestCandleIndex].low 30 | ); 31 | 32 | ObjectSetInteger(0, "Rectangle", OBJPROP_COLOR, clrBlue); 33 | ObjectSetInteger(0, "Rectangle", OBJPROP_FILL, clrBlue); 34 | 35 | } -------------------------------------------------------------------------------- /SimpleStandardDeviation.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | //Create a price array 4 | double StadardDeviationArray[]; 5 | 6 | //Standard Deviation Definition 7 | int StandardDeviationDefinition = iStdDev(_Symbol, _Period, 20, 0, MODE_SMA, PRICE_CLOSE); 8 | 9 | //Sort the price array from the current candle downwards 10 | ArraySetAsSeries(StadardDeviationArray, true); 11 | 12 | //Define EA, current candle, 3 candles, store result 13 | CopyBuffer(StandardDeviationDefinition, 0, 0, 3, StadardDeviationArray); 14 | 15 | //Calculate EA from the current candle 16 | double StandardDeviationValue = NormalizeDouble(StadardDeviationArray[0], 6); 17 | 18 | Comment("Standard Deviation: ", StandardDeviationValue); 19 | } -------------------------------------------------------------------------------- /SimpleSwapInfo.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double SwapLongTrades = SymbolInfoDouble(Symbol(), SYMBOL_SWAP_LONG); 7 | double SwapShortTrades = SymbolInfoDouble(Symbol(), SYMBOL_SWAP_SHORT); 8 | 9 | Comment("Swap for Long trades: ", SwapLongTrades, "\n\n", "Swap for short trades: ", SwapShortTrades); 10 | } -------------------------------------------------------------------------------- /SimpleSymbolInfo.mq5: -------------------------------------------------------------------------------- 1 | void OnTick() 2 | { 3 | int Spread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD); 4 | 5 | double Ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK); 6 | 7 | double Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID); 8 | 9 | double lastLow = SymbolInfoDouble(Symbol(), SYMBOL_LASTLOW); 10 | 11 | double lastHigh = SymbolInfoDouble(Symbol(), SYMBOL_LASTHIGH); 12 | 13 | double minVolume = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN); 14 | 15 | double maxVolume = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MAX); 16 | 17 | double volumeStep = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_STEP); 18 | 19 | double swapLongTrade = SymbolInfoDouble(Symbol(), SYMBOL_SWAP_LONG); 20 | 21 | double swapShortTrade = SymbolInfoDouble(Symbol(), SYMBOL_SWAP_SHORT); 22 | 23 | Comment( 24 | "Spread : ", Spread, "\n", 25 | "Ask : ", Ask, "\n", 26 | "Bid : ", Bid, "\n", 27 | "Last Low : ", lastLow, "\n", 28 | "Last High : ", lastHigh, "\n", 29 | "Minimum Volume : ", minVolume, "\n", 30 | "Maximum Volume : ", maxVolume, "\n", 31 | "Volume Step : ", volumeStep, "\n", 32 | "SWAP Long Trade : ", swapLongTrade, "\n", 33 | "Swap Short Trade : ", swapShortTrade,"\n", 34 | "SWAP Long Trade : ", swapLongTrade 35 | ); 36 | } -------------------------------------------------------------------------------- /SimpleTimeBasedEntry.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | datetime time = TimeLocal(); 7 | 8 | string HoursAndMinutes = TimeToString(time, TIME_MINUTES); 9 | 10 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 11 | 12 | if(PositionsTotal() == 0 && StringSubstr(HoursAndMinutes, 0, 5) == "15:00") 13 | { 14 | trade.Buy(0.1, NULL, Ask, 0, Ask + 300 * _Point, NULL); 15 | } 16 | 17 | Comment(HoursAndMinutes); 18 | } -------------------------------------------------------------------------------- /SimpleTripleExponentialMovinngAverage.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | TradeOnnTripleExponentialMovingAverage(); 7 | 8 | Comment( 9 | "\nTotal Buy Positions : ", GetPositions_Buy(), 10 | "\nTotal Sell Positions : ", GetPositions_Sell(), 11 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 12 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 13 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 14 | "\nTotal Positions : ", PositionsTotal() 15 | ); 16 | } 17 | 18 | void TradeOnnTripleExponentialMovingAverage() 19 | { 20 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 21 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 22 | 23 | if(CheckEntry_TripleExponentialMovingAverage() == "Buy" && GetPositions_Buy() < 100) 24 | trade.Buy(0.01, NULL, Ask, 0, Ask + (300 * _Point), NULL); 25 | if(CheckEntry_TripleExponentialMovingAverage() == "Sell" && GetPositions_Sell() < 100) 26 | trade.Sell(0.01, NULL, Bid, 0, Bid - (300 * _Point), NULL); 27 | } 28 | 29 | string CheckEntry_TripleExponentialMovingAverage() 30 | { 31 | string Signal = ""; 32 | 33 | MqlRates priceInformation[]; 34 | ArraySetAsSeries(priceInformation, true); 35 | int Data = CopyRates(Symbol(), Period(), 0, 3, priceInformation); 36 | 37 | double TripleExponentialMovingAverageArray[]; 38 | int TripleExponentialMovingAverageHandler = iTEMA(_Symbol, _Period, 14, 0, PRICE_CLOSE); 39 | ArraySetAsSeries(TripleExponentialMovingAverageArray, true); 40 | CopyBuffer(TripleExponentialMovingAverageHandler, 0, 0, 3, TripleExponentialMovingAverageArray); 41 | double TripleExponentialMovingAverageValue = NormalizeDouble(TripleExponentialMovingAverageArray[0], 2); 42 | 43 | if(TripleExponentialMovingAverageValue > priceInformation[1].close) 44 | Signal = "Sell"; 45 | if(TripleExponentialMovingAverageValue < priceInformation[1].close) 46 | Signal = "Buy"; 47 | 48 | return Signal; 49 | } 50 | 51 | int GetPositions_Buy() 52 | { 53 | int numberOfPositionsBuy = 0; 54 | 55 | for(int i = PositionsTotal() - 1; i >= 0; i--) 56 | { 57 | string currenyPair = PositionGetSymbol(i); 58 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 59 | if(currenyPair == _Symbol) 60 | if(PositionDirection == POSITION_TYPE_BUY) 61 | numberOfPositionsBuy++; 62 | } 63 | return numberOfPositionsBuy; 64 | } 65 | 66 | int GetPositions_Sell() 67 | { 68 | int numberOfPositionsSell = 0; 69 | 70 | for(int i = PositionsTotal() - 1; i >= 0; i--) 71 | { 72 | string currencyPair = PositionGetSymbol(i); 73 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 74 | 75 | if(currencyPair == _Symbol) 76 | if(PositionDirection == POSITION_TYPE_SELL) 77 | numberOfPositionsSell++; 78 | } 79 | return numberOfPositionsSell; 80 | } 81 | 82 | void CloseAllPositions() 83 | { 84 | for(int i = PositionsTotal() - 1; i >= 0; i--) 85 | { 86 | ulong ticket = PositionGetTicket(i); 87 | trade.PositionClose(ticket); 88 | } 89 | } -------------------------------------------------------------------------------- /SimpleVolumesFilter.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | #include "CheckFilter_Volumes.mq5"; 5 | #include "CheckSignal_BollingerBands.mq5"; 6 | 7 | void OnTick() 8 | { 9 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 10 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 11 | 12 | if(CheckSignal_BollinngerBands() == "Buy" && GetPositions_Buy() < 10 && CheckFilter_Volumes() == "Positive") 13 | { 14 | //For H1 15 | trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 16 | //For M1 17 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 18 | } 19 | 20 | if(CheckSignal_BollinngerBands() == "Sell" && GetPositions_Sell() < 10 && CheckFilter_Volumes() == "Positive") 21 | { 22 | //For H1 23 | trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 24 | //For M1 25 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 26 | } 27 | 28 | Comment( 29 | "\nTotal Buy Positions : ", GetPositions_Buy(), 30 | "\nTotal Sell Positions : ", GetPositions_Sell(), 31 | "\nAccount Balance : ", AccountInfoDouble(ACCOUNT_BALANCE), 32 | "\nAccount Equity : ", AccountInfoDouble(ACCOUNT_EQUITY), 33 | "\nAccount Profit : ", AccountInfoDouble(ACCOUNT_PROFIT), 34 | "\nTotal Positions : ", PositionsTotal() 35 | ); 36 | } 37 | 38 | int GetPositions_Sell() 39 | { 40 | int numberOfSellPositions = 0; 41 | 42 | for(int i = PositionsTotal() -1; i >= 0; i--) 43 | { 44 | string CurrencyPair = PositionGetSymbol(i); 45 | 46 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 47 | 48 | if(Symbol() == CurrencyPair) 49 | { 50 | if(PositionDirection == POSITION_TYPE_SELL) 51 | { 52 | numberOfSellPositions = numberOfSellPositions + 1; 53 | } 54 | } 55 | } 56 | 57 | return numberOfSellPositions; 58 | } 59 | 60 | int GetPositions_Buy() 61 | { 62 | int numberOfBuyPositions = 0; 63 | 64 | for(int i = PositionsTotal() -1; i >= 0; i--) 65 | { 66 | string CurrencyPair = PositionGetSymbol(i); 67 | 68 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 69 | 70 | if(Symbol() == CurrencyPair) 71 | { 72 | if(PositionDirection == POSITION_TYPE_BUY) 73 | { 74 | numberOfBuyPositions = numberOfBuyPositions + 1; 75 | } 76 | } 77 | } 78 | 79 | return numberOfBuyPositions; 80 | } -------------------------------------------------------------------------------- /StochasticOscillator.mq5: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| Best use of Stochastic Oscillator | 3 | //| Copyright 2021, Strength & Honour Corporation | 4 | //| https://www.StrengthAndHonour.com | 5 | //+------------------------------------------------------------------+ 6 | #include 7 | CTrade trade; 8 | 9 | //+------------------------------------------------------------------+ 10 | //| | 11 | //+------------------------------------------------------------------+ 12 | void OnTick() 13 | { 14 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 15 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 16 | 17 | if(CheckEntry_StochasticOscillator() == "Buy" && GetPositions_Buy() < 100 && Check_Momentum_Entry() == "Buy") 18 | { 19 | //For H1 20 | //trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 21 | //For M1 22 | trade.Buy(0.01, NULL, Ask, 0, Ask + 300 * _Point, NULL); 23 | } 24 | 25 | if(CheckEntry_StochasticOscillator() == "Sell" && GetPositions_Sell() < 100 && Check_Momentum_Entry() == "Sell") 26 | { 27 | //For H1 28 | //trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 29 | //For M1 30 | trade.Sell(0.01, NULL, Bid, 0, Bid - 300 * _Point, NULL); 31 | } 32 | } 33 | 34 | //+------------------------------------------------------------------+ 35 | //| | 36 | //+------------------------------------------------------------------+ 37 | string CheckEntry_StochasticOscillator() 38 | { 39 | string Signal = ""; 40 | 41 | double KArray[]; 42 | double DArray[]; 43 | 44 | int StochasticOscillatorHandler = iStochastic(_Symbol, _Period, 5, 3, 3, MODE_SMA, STO_LOWHIGH); 45 | 46 | ArraySetAsSeries(KArray, true); 47 | ArraySetAsSeries(DArray, true); 48 | 49 | CopyBuffer(StochasticOscillatorHandler, 0, 0, 3, KArray); 50 | CopyBuffer(StochasticOscillatorHandler, 1, 0, 3, DArray); 51 | 52 | double KValue0 = KArray[0]; 53 | double DValue0 = DArray[0]; 54 | 55 | double KValue1 = KArray[1]; 56 | double DValue1 = DArray[1]; 57 | 58 | if(KValue0 < 20 && DValue0 < 20) 59 | if(KValue0 > DValue0 && KValue1 < DValue1) 60 | Signal = "Buy"; 61 | 62 | if(KValue0 > 80 && DValue0 > 80) 63 | if(KValue0 < DValue0 && KValue1 > DValue1) 64 | Signal = "Sell"; 65 | 66 | return Signal; 67 | } 68 | 69 | //+------------------------------------------------------------------+ 70 | //| | 71 | //+------------------------------------------------------------------+ 72 | string Check_Momentum_Entry() 73 | { 74 | string Signal = ""; 75 | 76 | double priceInformation[]; 77 | 78 | int MomentumDefinition = iMomentum(_Symbol, _Period, 14, PRICE_CLOSE); 79 | 80 | ArraySetAsSeries(priceInformation, true); 81 | 82 | CopyBuffer(MomentumDefinition, 0, 0, 3, priceInformation); 83 | 84 | double MomentumValue = NormalizeDouble(priceInformation[0], 2); 85 | 86 | if(MomentumValue > 100.00)//Over Bought 87 | { 88 | Signal = "Sell"; 89 | } 90 | 91 | if(MomentumValue < 100.00)//Over Sold 92 | { 93 | Signal = "Buy"; 94 | } 95 | 96 | return Signal; 97 | } 98 | 99 | //+------------------------------------------------------------------+ 100 | //| | 101 | //+------------------------------------------------------------------+ 102 | void CloseAllPositions() 103 | { 104 | for(int i = PositionsTotal() -1; i >= 0; i--) 105 | { 106 | int ticket = PositionGetTicket(i); 107 | trade.PositionClose(ticket); 108 | } 109 | } 110 | 111 | //+------------------------------------------------------------------+ 112 | //| | 113 | //+------------------------------------------------------------------+ 114 | int GetPositions_Sell() 115 | { 116 | int numberOfSellPositions = 0; 117 | 118 | for(int i = PositionsTotal() -1; i >= 0; i--) 119 | { 120 | string CurrencyPair = PositionGetSymbol(i); 121 | 122 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 123 | 124 | if(Symbol() == CurrencyPair) 125 | { 126 | if(PositionDirection == POSITION_TYPE_SELL) 127 | { 128 | numberOfSellPositions = numberOfSellPositions + 1; 129 | } 130 | } 131 | } 132 | 133 | return numberOfSellPositions; 134 | } 135 | 136 | //+------------------------------------------------------------------+ 137 | //| | 138 | //+------------------------------------------------------------------+ 139 | int GetPositions_Buy() 140 | { 141 | int numberOfBuyPositions = 0; 142 | 143 | for(int i = PositionsTotal() -1; i >= 0; i--) 144 | { 145 | string CurrencyPair = PositionGetSymbol(i); 146 | 147 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 148 | 149 | if(Symbol() == CurrencyPair) 150 | { 151 | if(PositionDirection == POSITION_TYPE_BUY) 152 | { 153 | numberOfBuyPositions = numberOfBuyPositions + 1; 154 | } 155 | } 156 | } 157 | 158 | return numberOfBuyPositions; 159 | } 160 | //+------------------------------------------------------------------+ 161 | 162 | -------------------------------------------------------------------------------- /TrendBasedSellStop.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | void OnTick() 5 | { 6 | double movingAverageArray[]; 7 | 8 | ArraySetAsSeries(movingAverageArray, true); 9 | 10 | int movingAverageDefinition = iMA(_Symbol, _Period, 100, 0, MODE_SMA, PRICE_CLOSE); 11 | 12 | CopyBuffer(movingAverageDefinition, 0, 0, 10, movingAverageArray); 13 | 14 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 15 | 16 | double Trend100 = (movingAverageArray[0] - movingAverageArray[1]); 17 | 18 | if(Trend100 < 0) 19 | if(PositionsTotal() == 0 && OrdersTotal() == 0) 20 | trade.SellStop(0.10, Bid - 100 * _Point, NULL, 0, Bid - 300 * _Point, ORDER_TIME_GTC, 0, NULL); 21 | } -------------------------------------------------------------------------------- /TrendFilter.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 5 | |||||||||||| |||||||||||||||||| 6 | |||||||||||| NOT CLEAR! |||||||||||||||||| 7 | |||||||||||| |||||||||||||||||| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 9 | 10 | input double filter = 0.0001; 11 | 12 | void OnTick() 13 | { 14 | double MovingAverageArray[]; 15 | 16 | int MovingAverageHandler = iMA(_Symbol, _Period, 20, 0, MODE_SMA, PRICE_CLOSE); 17 | 18 | ArraySetAsSeries(MovingAverageArray, true); 19 | 20 | CopyBuffer(MovingAverageHandler, 0, 0, 10, MovingAverageArray); 21 | 22 | double MovingAverageValue = MovingAverageArray[0] - MovingAverageArray[9]; 23 | 24 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 25 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 26 | 27 | if(MovingAverageValue > filter && PositionsTotal() < 100) 28 | trade.Buy(0.01, NULL, Ask, 0, Ask + 500 * _Point, NULL); 29 | 30 | if(MovingAverageValue > (filter * -1) && PositionsTotal() < 100) 31 | trade.Sell(0.01, NULL, Bid, 0, Bid - 500 * _Point, NULL); 32 | 33 | Comment("Value: ", MovingAverageValue, "\nFilter : ", filter); 34 | } -------------------------------------------------------------------------------- /TripleMovingAverage.mq5: -------------------------------------------------------------------------------- 1 | #include 2 | CTrade trade; 3 | 4 | static int BuyOrSell = 0; 5 | 6 | void OnTick() 7 | { 8 | double movingAverage100Array[]; 9 | double movingAverage50Array[]; 10 | double movingAverage10Array[]; 11 | 12 | int movingAverage100Definition = iMA(_Symbol, _Period, 100, 0, MODE_SMA, PRICE_CLOSE); 13 | int movingAverage50Definition = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE); 14 | int movingAverage10Definition = iMA(_Symbol, _Period, 10, 0, MODE_SMA, PRICE_CLOSE); 15 | 16 | ArraySetAsSeries(movingAverage100Array, true); 17 | ArraySetAsSeries(movingAverage50Array, true); 18 | ArraySetAsSeries(movingAverage10Array, true); 19 | 20 | CopyBuffer(movingAverage100Definition, 0, 0, 10, movingAverage100Array); 21 | CopyBuffer(movingAverage50Definition, 0, 0, 10, movingAverage50Array); 22 | CopyBuffer(movingAverage10Definition, 0, 0, 10, movingAverage10Array); 23 | 24 | string Signal = ""; 25 | 26 | if(movingAverage100Array[0] > movingAverage50Array[0]) 27 | if(movingAverage50Array[0] > movingAverage10Array[0]) 28 | Signal = "Buy Now!"; 29 | 30 | if(movingAverage100Array[0] < movingAverage50Array[0]) 31 | if(movingAverage50Array[0] < movingAverage10Array[0]) 32 | Signal = "Sell Now!"; 33 | 34 | double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 35 | double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); 36 | 37 | if((GetPositions_Buy() < 100) && (Signal == "Buy Now!")) 38 | trade.Buy(0.01, NULL, Ask, 0, Ask + 100 * _Point, NULL); 39 | 40 | if((GetPositions_Sell() < 100) && (Signal == "Sell Now!")) 41 | trade.Sell(0.01, NULL, Bid, 0, Bid - 100 * _Point, NULL); 42 | 43 | Comment("TOTAL BUY POSITIONS: ", GetPositions_Buy(), "\nTOTAL SELL POSITIONS: ", GetPositions_Sell()); 44 | } 45 | 46 | void CloseAllPositions() 47 | { 48 | for(int i = PositionsTotal() -1; i >= 0; i--) 49 | { 50 | int ticket = PositionGetTicket(i); 51 | trade.PositionClose(ticket); 52 | } 53 | } 54 | 55 | int GetPositions_Sell() 56 | { 57 | int numberOfSellPositions = 0; 58 | 59 | for(int i = PositionsTotal() -1; i >= 0; i--) 60 | { 61 | string CurrencyPair = PositionGetSymbol(i); 62 | 63 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 64 | 65 | if(Symbol() == CurrencyPair) 66 | { 67 | if(PositionDirection == POSITION_TYPE_SELL) 68 | { 69 | numberOfSellPositions = numberOfSellPositions + 1; 70 | } 71 | } 72 | } 73 | 74 | return numberOfSellPositions; 75 | } 76 | 77 | int GetPositions_Buy() 78 | { 79 | int numberOfBuyPositions = 0; 80 | 81 | for(int i = PositionsTotal() -1; i >= 0; i--) 82 | { 83 | string CurrencyPair = PositionGetSymbol(i); 84 | 85 | int PositionDirection = PositionGetInteger(POSITION_TYPE); 86 | 87 | if(Symbol() == CurrencyPair) 88 | { 89 | if(PositionDirection == POSITION_TYPE_BUY) 90 | { 91 | numberOfBuyPositions = numberOfBuyPositions + 1; 92 | } 93 | } 94 | } 95 | 96 | return numberOfBuyPositions; 97 | } --------------------------------------------------------------------------------