bool buy_condition_1 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, 1) < 20 ;
bool buy_condition_2 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, 0) > 20 ;
This does not work exactly as the above quote.
Please help me with an alternative code.
Have you misunderstood something? I think that there is no problem in particular.
Please try the following program.
//+------------------------------------------------------------------+ //| TestIndicator.mq4 | //| Naguisa Unada | //| None | //+------------------------------------------------------------------+ #property copyright "Naguisa Unada" #property link "https://www.mql5.com/en/users/unadajapon/news" #property version "1.00" #property strict #property indicator_separate_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_level1 20 #property indicator_level2 80 //--- plot Line #property indicator_label1 "Line" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot Arrow #property indicator_label2 "Arrow" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrAqua #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- input parameters //--- indicator buffers double Line_Buffer[]; double Arrow_Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0, Line_Buffer); SetIndexBuffer(1, Arrow_Buffer); SetIndexArrow(1, 159); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- int i, limit; if (prev_calculated == 0) limit = rates_total - 11; else limit = rates_total - prev_calculated; for (i = limit; i >= 0; i--) { Line_Buffer[i] = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, i); bool buy_condition_1 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, i + 1) < 20 ; bool buy_condition_2 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, i) > 20 ; if (buy_condition_1 && buy_condition_2) Arrow_Buffer[i] = 20; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Have you misunderstood something? I think that there is no problem in particular.
Please try the following program.
Thanks I will try this now
// Init function int init(){ open = 0; RealPoint = RealPipPoint(Symbol()); } // Start function int start(){ if (open == Open[0]) return 0; open = Open[0]; //long OrderSelect(LongTicket,SELECT_BY_TICKET); if(OrderCloseTime() != 0 || LongTicket == 0) { bool buy_condition_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1) > 0 ; bool buy_condition_2 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, 1) < 20 ; bool buy_condition_3 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, 0) > 20 ; if( buy_condition_1 && buy_condition_2 && buy_condition_3 ){ OrderSelect(ShortTicket,SELECT_BY_TICKET);Naguisa Unada:
Have you misunderstood something? I think that there is no problem in particular.
Please try the following program.
Sorry if I sound stupid but please I am still learning, this got me more confused especially the i+1.... below is where I got stuck initially
/
Hello,
I am a beginner with programming completely, but myself I would use more than two indicators to place orders. I plan on having 5 to 7 indicators to tell me about the securities I place positions on.
Sorry if I sound stupid but please I am still learning, this got me more confused especially the i+1.... below is where I got stuck initially
I changed 1 to i + 1 and 0 to i to output consecutive data, but it's the same for output one point of data. You have no mistake.
I changed 1 to i + 1 and 0 to i to output consecutive data, but it's the same for output one point of data. You have no mistake.
Ok, but this does not work exactly like this quote:
- "Generally, the area above 80 indicates an overbought region, while the area below 20 is considered an oversold region. A sell signal is given when the oscillator is above the 80 level and then crosses back below 80. Conversely, a buy signal is given when the oscillator is below 20 and then crossed back above 20. 80 and 20 are the most common levels used but can be adjusted as needed".
Ok, but this does not work exactly like this quote:
- "Generally, the area above 80 indicates an overbought region, while the area below 20 is considered an oversold region. A sell signal is given when the oscillator is above the 80 level and then crosses back below 80. Conversely, a buy signal is given when the oscillator is below 20 and then crossed back above 20. 80 and 20 are the most common levels used but can be adjusted as needed".
-
Don't double post!
General rules and best pratices of the Forum. - General - MQL5 programming forum - When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum // Init function int init(){...} // Start function int start(){...
Start using the new Event Handling Functions.
Event Handling Functions - Functions - Language Basics - MQL4 ReferenceOrderSelect(LongTicket,SELECT_BY_TICKET);
Check your return codes for errors and report them.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articlesif(OrderCloseTime() != 0 || LongTicket == 0) { bool buy_condition_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1) > 0 ; bool buy_condition_2 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, 1) < 20 ; bool buy_condition_3 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 1, MODE_MAIN, 0) > 20 ;
Again, all you are doing is setting variables. Unless you write code that opens orders, n o t h i n g w i l l e v e r h a p p e n.
============
Stochastic
The beginning
- Stochastic Oscillator, the beginning
After
- Stochastic thread.
- Stochastic Trader thread
- Multi pair indicators thread
(Multi pair MACD, Multi pair CoeffOfLine, Multi pair RSi, Multi pair Stochastic, Multi pair WPR (Williams % range), Multi pair Laguerre RSI, Multi pair Wilders DMI, Multi pair dss, and more) - Stochastic RSI for MT5 - the post
- Stochastic rsi (oma) colored or MT5 - the post:
- RSI types: Cuttler's RSI; Ehlers' smoothed RSI; Harris' RSI; Rapid RSI; RSI; RSX; Slow RSI
- levels: floating; quantile; fixed - Round price DOC indicator for MT5 - the post: Added 2 parameters : price (so we can chose the price we would like to use - in the original it is Close) and T3Original (false for Fulks/Matulich calculation which is faster then the original Tim Tillson calculation).
============
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have been learning the MQL4 and so far I have made some progress however, I have this challenge I encountered while trying to code the below:
I tried this code (below), but it does not take all the signals:
This does not work exactly as the above quote.
Please help me with an alternative code.