Need Help!....MQL5 Programming

 
#property version   "1.00"
#include <Trade\Trade.mqh>
CTrade trade;
#define Ask SymbolInfoDouble(Symbol(),SYMBOL_ASK)
#define Bid SymbolInfoDouble(Symbol(),SYMBOL_BID)
void OnTick()

{

//INDICATORS
double EMA14 = iMA(NULL,PERIOD_M1,14,0,MODE_EMA,PRICE_CLOSE); // EXPOTNTIAL MOVING AVERAGE PERIOD 14
double SMV1 = iMA(NULL,PERIOD_M1,1,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 1
double SMV3 = iMA(NULL,PERIOD_M1,3,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 3
double SMV8 = iMA(NULL,PERIOD_M1,8,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 8
//stochastic setting//
double Stocha = iStochastic(NULL,PERIOD_M1,1,1,1,MODE_EMA,STO_CLOSECLOSE); //stochastich period 1
//_________________________________________________________________________//
if (PositionsTotal() <= 2)
while (Ask > EMA14) && (SMV1 && SMV3 && SMV8 == Stocha))
{
trade.Buy(0.20,NULL,Ask,0,Ask+100 * _Point,NULL);
}

} 

Stochastic Oscillator - Oscillators - MetaTrader 5 Help
Stochastic Oscillator - Oscillators - MetaTrader 5 Help
  • www.metatrader5.com
The Stochastic Oscillator Technical Indicator compares where a security’s price closed relative to its price range over a given time period. The...
Files:
Capture.JPG  134 kb
 
Bico Buzwani:


Please insert the code correctly: when editing a message, press the button    Codeand paste your code into the pop-up window

 
so where is your code? cant see it
 
#property version   "1.00"
#include <Trade\Trade.mqh>
CTrade trade;
#define Ask SymbolInfoDouble(Symbol(),SYMBOL_ASK)
#define Bid SymbolInfoDouble(Symbol(),SYMBOL_BID)
void OnTick()

{

//INDICATORS
double EMA14 = iMA(NULL,PERIOD_M1,14,0,MODE_EMA,PRICE_CLOSE); // EXPOTNTIAL MOVING AVERAGE PERIOD 14
double SMV1 = iMA(NULL,PERIOD_M1,1,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 1
double SMV3 = iMA(NULL,PERIOD_M1,3,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 3
double SMV8 = iMA(NULL,PERIOD_M1,8,0,MODE_SMA,PRICE_CLOSE); //SIMPLE MOVING AVERAGE 8
//stochastic setting//
double Stocha = iStochastic(NULL,PERIOD_M1,1,1,1,MODE_EMA,STO_CLOSECLOSE); //stochastich period 1
//_________________________________________________________________________//
if (PositionsTotal() <= 2)
while (Ask > EMA14) && (SMV1 && SMV3 && SMV8 == Stocha))
{
trade.Buy(0.20,NULL,Ask,0,Ask+100 * _Point,NULL);
}

}
Vladimir Karputov #:

Please insert the code correctly: when editing a message, press the button    and paste your code into the pop-up window

 
Bico Buzwani :

You have made a gross mistake. In MQL5, you need to create an indicator handle (this is done once in OnInit), and the data is received using CopyBuffer.

 
How to start with MQL5
How to start with MQL5
  • 2020.03.05
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 
double EMA14 = iMA(NULL,PERIOD_M1,14,0,MODE_EMA,PRICE_CLOSE); // EXPOTNTIAL MOVING AVERAGE PERIOD 14

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.03.08)
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020.07.05)
          How to call indicators in MQL5 - MQL5 Articles (2010)

 

Thank you

 
William Roeder #:

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.03.08)
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020.07.05)
          How to call indicators in MQL5 - MQL5 Articles (2010)

Many thanks
Reason: