If you are interested to learn to code:
Quickstart for newbies: https://www.mql5.com/en/articles/496
and: https://www.mql5.com/en/articles/100
cookbook: https://www.mql5.com/en/search#!keyword=cookbook
Bear in mind there's virtually nothing that hasn't already been programmed for MT4/MT5 and is ready for you - so searching gives better results than AI or ChatGPT!
And her you can find what to do if the programs compiles without an error but does not do what it should:
Code debugging: https://www.metatrader5.com/en/metaeditor/help/development/debug
Error Handling and Logging in MQL5: https://www.mql5.com/en/articles/2041
Tracing, Debugging and Structural Analysis of Source Code, scroll down to: "Launching and Debuggin": https://www.mql5.com/en/articles/272
Tips from a professional programmer (Part I): Code storing, debugging and compiling. Working with projects and logs
https://www.mql5.com/en/articles/9266
Tips from a professional programmer (Part II): Storing and exchanging parameters between an Expert Advisor, scripts and external programs
https://www.mql5.com/en/articles/9327
Tips from a professional programmer (Part III): Logging. Connecting to the Seq log collection and analysis system
https://www.mql5.com/en/articles/10475
- www.mql5.com
Please don't post randomly in any section. Your question is not related to the section you posted. I have moved your topic to the correct section — Expert Advisors and Automated Trading
Do your EA need the lines on the chart? Would it be possible to calculate the prices of the two lines and check the ticks againts these variable values - it a lot faster and easier.
the 2 lines need to be there for visualize the prev week High and low. all i need to do is when the price going higher than prev week high start searching for daily rsi conditions (2 days before RSI < yesterday RSI && today RSI < yesterday RSI. But i dont want to checking all the time the current price. If it passes once above the line start checking for the daily rsi conditions. And once these conditions come true start checking for 2 prev 4h_candle rsi (iRSI[2] < 1 prev 4h_candle rsi (iRSI[1] && current 4h_candle rsi (iRSI[0]).
I also tried to make it throw this code changes but it didnt work.
// Get prev 1 minute candle close price double last_low_1m = iLow(_Symbol,PERIOD_M1,1); double last_high_1m = iHigh(_Symbol, PERIOD_M1,1); // if conditions to check if the current price has gone above or belong the previous weeks High and Low. if(last_high_1m > lastWeekHigh || last_low_1m > lastWeekHigh) { bool high_trigger = true; while(high_trigger == true) { ); Print("currentPrice > lastWeekHigh TRUE...currentPrice > lastWeekHigh TRUE...currentPrice > lastWeekHigh TRUE..."); if(D2_before_RSI_Daily < yestRSIValue_Daily && yestRSIValue_Daily > myRSIValue_Daily) { bool daily_rsi_trigger = true; while(daily_rsi_trigger==true) { Print("D2_before_RSI_Daily < yestRSIValue_Daily && yestRSIValue_Daily > myRSIValue_Daily TRUE.......D2_before_RSI_Daily < yestRSIValue_Daily && yestRSIValue_Daily > myRSIValue_Daily TRUE.......D2_before_RSI_Daily < yestRSIValue_Daily && yestRSIValue_Daily > myRSIValue_Daily TRUE......."); if(prev_2_cancle_RSI_4H < prev_candle_RSIValue_4H && prev_candle_RSIValue_4H > myRSIValue_4H) { bool h4_rsi_trigger = true; while(h4_rsi_trigger == true) { Print("prev_2_cancle_RSI_4H < prev_candle_RSIValue_4H && prev_candle_RSIValue_4H > myRSIValue_4H TRUE.......prev_2_cancle_RSI_4H < prev_candle_RSIValue_4H && prev_candle_RSIValue_4H > myRSIValue_4H TRUE.......prev_2_cancle_RSI_4H < prev_candle_RSIValue_4H && prev_candle_RSIValue_4H > myRSIValue_4H TRUE......."); if(iTime(_Symbol, PERIOD_H4, 0) == TimeCurrent()) { Print("A LONG TRADE...A LONG TRADE...A LONG TRADE...A LONG TRADE...A LONG TRADE..."); high_trigger = false; daily_rsi_trigger = false; h4_rsi_trigger = false; }//4th if HIGH }// while 3rd }//3rd if HIGH }// while 2nd }//2nd if HIGH }// while 1st }//1st if HIGH
- dio1zervas #: I also tried to make it throw this code changes but it didnt work.
“Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
How To Ask Questions The Smart Way. (2004)
When asking about code
Be precise and informative about your problem -
Drop your loops. If the condition isn't true, nothing is changing. Return and wait for a new tick and reevaluate.
- dio1zervas: Any help or ideas would be appreciated.
int myRsiDefinition_4H = iRSI(_Symbol,PERIOD_H4,14,PRICE_CLOSE); ArraySetAsSeries(myRsiArray_4H,true); CopyBuffer(myRsiDefinition_4H,0,0,3,myRsiArray_4H);
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
How to call indicators in MQL5 - MQL5 Articles (2010)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
so i have created an expert that is drawing 2 horizontal lines in the prev weeks close Highest and Lowest value.
I want to check if the price has gone above the prev weeks high and if so to check if the daily rsi 2 days ago is < yesterday's rsi value and if yesterday's rsi value is > than current todays rsi value.
if this condition is true i want to check the 4h timeframe rsi for the same patern and wait for the current 4h candle to close to open a trade. Below is my code that i think its not that good.
Any help or ideas would be appreciated.
(Note the code is not completed)