Alright, another Python guy!
First off, MQL5 doesn't have init, deinit, and start event handlers so make sure you check the docs and use the correct ones. Also, if you know python and you're trying to make the switch to MQL then stick to the high level programming you're used to. The standard library has indicator classes that take care of all the low level abstractions behind the scenes. This would by the closest thing to "pythonic" in MQL.
//+------------------------------------------------------------------+ //| Mql5Help.mq5 | //| nicholishen | //| https://www.forexfactory.com/nicholishen | //+------------------------------------------------------------------+ #property copyright "nicholishen" #property link "https://www.forexfactory.com/nicholishen" #property version "1.00" #define MAGIC 123456 #include <Trade\Trade.mqh> #include <Indicators\Indicators.mqh> CiBands g_bands; CiRSI g_rsi; CIndicators g_indicators; CTrade g_trade; CPositionInfo g_pi; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { if(!g_bands.Create(_Symbol, _Period, 20, 0, 2, PRICE_CLOSE) || !g_rsi.Create(_Symbol, _Period, 14, PRICE_CLOSE) || !g_indicators.Add(&g_bands) || !g_indicators.Add(&g_rsi) ) return INIT_FAILED; g_trade.SetExpertMagicNumber(MAGIC); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { g_indicators.Refresh(); MqlTick tick; double close[]; ArraySetAsSeries(close, true); if(!SymbolInfoTick(_Symbol, tick) || CopyClose(_Symbol, _Period, 0, 2, close) != 2 ) return; if(!g_pi.SelectByMagic(_Symbol, MAGIC)){ if(close[1] < g_bands.Lower(1) && close[0] > g_bands.Lower(0)){ if(!g_trade.Buy(...)){ ... } } else if(close[1] > g_bands.Upper(1) && close[0] < g_bands.Upper(0)){ if(!g_trade.Sell(...)){ ... } } } }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
So I did some research and found this video on youtube-
https://www.youtube.com/watch?v=o4jVeJdYTkM
And that got me thinking, what if I could combine all the indicators I use for manual trading into one program. I know python and how it works, but I don't know c so I'm having some trouble understanding the mql language. For manual trading I have bollinger bands, rsi, cci, and stochastic. I can provide more information on my manual trading but I'm really stuck on what to do here. I would also like to include a stoploss function inside of this ea since it will be automatically trading on 5 min candles.The first part is bollinger bands, and the second is supposed to close the program after 15 min.
Here is the code:
Any help on this program, or errors, or ideas, or documentation on adding multiple indicators would be much appreciated!