Good day
Actually I'm working on EA based on several Indicators signal , I'm facing the following issues with this project
When I try to add multiple currency string my input ENUM_TIMEFRAMES time_frame =PERIOD_H1 will start to indicate error
Also ordersend implementation not working also please help fix
//+------------------------------------------------------------------+
//| FXTIDYLUCKYSTAR_EA_DIVERGENCE.mq4 |
//| Copyright 2021,FXTIDYLUCKYSTAR. |
//| TIDYLUCKYSTAR@GMAIL.COM |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021,FXTIDYLUCKYSTAR."
#property link "TIDYLUCKYSTAR@GMAIL.COM"
#property version "1.00"
#property strict
//--- input parameters
input double Lots =0.06;
input double TakeProfit =200;
input double StopLoss =100;
input int magicnumber =01;
input int comment =5;
input ENUM_TIMEFRAMES time_frame =PERIOD_H1;
input int ma_period1 = 155;
//input int ma_period2 = 100;
input int ma_shift = 0;
input ENUM_MA_METHOD ma_method = MODE_EMA;
input ENUM_APPLIED_PRICE ma_applied_price = PRICE_CLOSE;
input int ma_time_shift = 0;
input int AO_shift = 0;
input string separator3 = "*** BBands Settings ****";
input int Bands_period = 20;
input int Bands_shift = 0;
input double Bands_deviation = 2.0;
input ENUM_APPLIED_PRICE Bands_applied_price = PRICE_CLOSE;
input int Bands_mode = 0; // 0 = main, 1 = Upper Line, 2 = Lower Line
input int Bands_timeshift = 0;
input string separator2 = "*** Ichimoku Settings ****";
input int Tenkan_sen = 3;
input int Kijun_sen = 26;
input int Senkou_SpanB = 52;
input int ikh_shift = 0;
input string separator1CCI = "*** CCI Settings ***";
input int fastEMA = 12;
input int slowEMA = 26;
input int signalSMA = 9;
input string separator2CCI = "*** Indicator Settings ***";
input bool drawIndicatorTrendLines = false;
input bool drawPriceTrendLines = false;
input bool displayAlert = false;
input bool alertsON = false;
input int cci_bar = 1; // change to 0 if you want current, but this may repaint
input string separator00 = "*** EWO OSMA Settings ***";
input int OSMA_fastEMA = 5;
input int OSMA_slowEMA = 34;
input int OSMA_signal = 5;
input string separator01 = "*** Indicator Settings ***";
input double positiveSensitivity = 0.0001;
input double negativeSensitivity = -0.0001;
input double historyBarsCount = 0;
input bool drawDivergenceLines = false;
//input bool displayAlert = false;
input string separator10 = "*** MACD Settings ***";
input int MACD_fastEMA = 12;
input int MACD_slowEMA = 26;
input int MACD_signalSMA = 9;
input string separator11 = "*** Indicator Settings ***";
//input bool drawIndicatorTrendLines = false;
//input bool drawPriceTrendLines = false;
//input bool displayAlert = false;
//input bool alertsON = false;
input string separator20 = "*** OBV Settings ***";
input int RSIPeriod = 6;
input string separator21 = "*** Indicator Settings ***";
//input bool drawIndicatorTrendLines = false;
//input bool drawPriceTrendLines = false;
//input bool displayAlert = true;
input bool displayHiddenDiv = false;
//input bool alertsON = true;
input string separator31 = "*** RSI Settings ***";
//input int RSIPeriod = 6;
input string separator32 = "*** Indicator Settings ***";
//input bool drawIndicatorTrendLines = false;
//input bool drawPriceTrendLines = false;
//input bool displayAlert = true;
//input bool displayHiddenDiv = true;
//input bool alertsON = true;
input int KPeriod = 5;
input int DPeriod = 3;
input int Slowing = 3;
input bool DrawPriceLines=false;
input bool DrawArrows=false;
//input bool displayHiddenDiv = true;
//input bool drawDivergenceLines=true;
//input bool displayAlert=false;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetTimer(60);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
int direction = CheckDirection();
//PlaceTrade(direction);
// AdjustStops;
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
//int direction = CheckDirection();
}
//+------------------------------------------------------------------+
int CheckDirection()
{
// The initial request is for 6 different indicators to validate a particular situation, and if 3 or more are in agreement, then allow for trade
// Since I don't have the MQ5 indicators, nor will attempt to conver them to MQ4, I am building this proof of concept framework so that you can
// swap out the indicators for whatever it is that you are using.
static int MAcheck = 0; // 0= neutral, 1 = long, -1 = short
//static int StochCheck = 0;
static int OSMAcheck = 0;
static int OSMA2check = 0;
static int RSIcheck = 0;
static int Ichicheck = 0;
static int CCIcheck = 0;
static int MACDcheck = 0;
static int OBVcheck = 0;
static int EWOcheck = 0;
//MAcheck
if(Low[1] > iMA(Symbol(),time_frame,ma_period1,ma_shift,ma_method,ma_applied_price,0)&& High[1] > iMA(Symbol(),time_frame,ma_period1,ma_shift,ma_method,ma_applied_price,0))
if(Low[0] <= iMA(Symbol(),time_frame,ma_period1,ma_shift,ma_method,ma_applied_price,0))
MAcheck = 1;
else
MAcheck = 0;
if(Low[1] < iMA(Symbol(),time_frame,ma_period1,ma_shift,ma_method,ma_applied_price,0)&& High[1] < iMA(Symbol(),time_frame,ma_period1,ma_shift,ma_method,ma_applied_price,0))
if(High[0] >= iMA(Symbol(),time_frame,ma_period1,ma_shift,ma_method,ma_applied_price,0))
MAcheck = -1;
else
MAcheck = 0;
// CCI_FXTIDYLUCKYSTAR check
if(iCustom(Symbol(),time_frame,"tidy/CCI_FXTIDYLUCKYSTAR",separator1CCI,fastEMA,slowEMA,signalSMA,separator2CCI,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,alertsON,0,cci_bar) != EMPTY_VALUE)
CCIcheck = 1;
if(iCustom(Symbol(),time_frame,"tidy/CCI_FXTIDYLUCKYSTAR",separator1CCI,fastEMA,slowEMA,signalSMA,separator2CCI,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,alertsON,1,cci_bar) != EMPTY_VALUE)
CCIcheck = -1;
if(iCustom(Symbol(),time_frame,"tidy/CCI_FXTIDYLUCKYSTAR",separator1CCI,fastEMA,slowEMA,signalSMA,separator2CCI,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,alertsON,0,cci_bar) == EMPTY_VALUE &&
iCustom(Symbol(),time_frame,"tidy/CCI_FXTIDYLUCKYSTAR",separator1CCI,fastEMA,slowEMA,signalSMA,separator2CCI,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,alertsON,1,cci_bar) == EMPTY_VALUE)
CCIcheck = 0;
// EWO_FXTIDYLUCKYSTAR check
if (iCustom(Symbol(),time_frame,"tidy/EWO_FXTIDYLUCKYSTAR",separator00,OSMA_fastEMA,OSMA_slowEMA,OSMA_signal,separator01,positiveSensitivity,negativeSensitivity,historyBarsCount,drawDivergenceLines,displayAlert,2,1) !=EMPTY_VALUE)
EWOcheck = 1;
if(iCustom(Symbol(),time_frame,"tidy/EWO_FXTIDYLUCKYSTAR",separator00,OSMA_fastEMA,OSMA_slowEMA,OSMA_signal,separator01,positiveSensitivity,negativeSensitivity,historyBarsCount,drawDivergenceLines,displayAlert,3,1) != EMPTY_VALUE)
EWOcheck = -1;
if (iCustom(Symbol(),time_frame,"tidy/EWO_FXTIDYLUCKYSTAR",separator00,OSMA_fastEMA,OSMA_slowEMA,OSMA_signal,separator01,positiveSensitivity,negativeSensitivity,historyBarsCount,drawDivergenceLines,displayAlert,2,1) == EMPTY_VALUE &&
iCustom(Symbol(),time_frame,"tidy/EWO_FXTIDYLUCKYSTAR",separator00,OSMA_fastEMA,OSMA_slowEMA,OSMA_signal,separator01,positiveSensitivity,negativeSensitivity,historyBarsCount,drawDivergenceLines,displayAlert,3,1) == EMPTY_VALUE)
EWOcheck = 0;
// OSMA_FXTIDYLUCKYSTAR_V2.0 check
if (iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.0",separator00,OSMA_fastEMA,OSMA_slowEMA,OSMA_signal,separator01,positiveSensitivity,negativeSensitivity,historyBarsCount,drawDivergenceLines,displayAlert,alertsON,2,1) !=EMPTY_VALUE)
OSMAcheck = 1;
if(iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.0",separator00,OSMA_fastEMA,OSMA_slowEMA,OSMA_signal,separator01,positiveSensitivity,negativeSensitivity,historyBarsCount,drawDivergenceLines,displayAlert,alertsON,3,1) != EMPTY_VALUE)
OSMAcheck = -1;
if (iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.0",separator00,OSMA_fastEMA,OSMA_slowEMA,OSMA_signal,separator01,positiveSensitivity,negativeSensitivity,historyBarsCount,drawDivergenceLines,displayAlert,alertsON,2,1) == EMPTY_VALUE &&
iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.0",separator00,OSMA_fastEMA,OSMA_slowEMA,OSMA_signal,separator01,positiveSensitivity,negativeSensitivity,historyBarsCount,drawDivergenceLines,displayAlert,alertsON,3,1) == EMPTY_VALUE)
OSMAcheck = 0;
// v2.1
if (iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,2,1) !=EMPTY_VALUE)
OSMA2check = 1;
if (iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,3,1) !=EMPTY_VALUE)
OSMA2check = -1;
if (iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,2,1) ==EMPTY_VALUE &&
iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,2,1) ==EMPTY_VALUE)
OSMA2check = 0;
// OBV_FXTIDYLUCKYSTAR
if(iCustom(Symbol(),0,"tidy/OBV_FXTIDYLUCKYSTAR",separator20,RSIPeriod,separator21,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,displayHiddenDiv,alertsON,0,1) != EMPTY_VALUE)
OBVcheck = 1;
if(iCustom(Symbol(),0,"tidy/OBV_FXTIDYLUCKYSTAR",separator20,RSIPeriod,separator21,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,displayHiddenDiv,alertsON,1,1) != EMPTY_VALUE)
OBVcheck = -1;
if(iCustom(Symbol(),0,"tidy/OBV_FXTIDYLUCKYSTAR",separator20,RSIPeriod,separator21,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,displayHiddenDiv,alertsON,0,1) == EMPTY_VALUE &&
iCustom(Symbol(),0,"tidy/OBV_FXTIDYLUCKYSTAR",separator20,RSIPeriod,separator21,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,displayHiddenDiv,alertsON,1,1) == EMPTY_VALUE)
OBVcheck = 0;
//RSI_FXTIDYLUCKYSTAR
if(iCustom(Symbol(),0,"tidy/RSI_FXTIDYLUCKYSTAR",separator20,RSIPeriod,separator21,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,displayHiddenDiv,alertsON,0,1) != EMPTY_VALUE)
RSIcheck = 1;
if(iCustom(Symbol(),0,"tidy/RSI_FXTIDYLUCKYSTAR",separator20,RSIPeriod,separator21,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,displayHiddenDiv,alertsON,1,1) != EMPTY_VALUE)
RSIcheck = -1;
if(iCustom(Symbol(),0,"tidy/RSI_FXTIDYLUCKYSTAR",separator20,RSIPeriod,separator21,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,displayHiddenDiv,alertsON,0,1) == EMPTY_VALUE &&
iCustom(Symbol(),0,"tidy/RSI_FXTIDYLUCKYSTAR",separator20,RSIPeriod,separator21,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,displayHiddenDiv,alertsON,1,1) == EMPTY_VALUE)
RSIcheck = 0;
if(iIchimoku(Symbol(),time_frame,Tenkan_sen,Kijun_sen,Senkou_SpanB,MODE_TENKANSEN,ikh_shift) > iIchimoku(Symbol(),time_frame,Tenkan_sen,Kijun_sen,Senkou_SpanB,MODE_KIJUNSEN,ikh_shift))
{
if(Close[0] <= Tenkan_sen)
Ichicheck = 1; // Buy condition if bar <= Tenkan_sen as long as Tenkan_sen > Kijun_Sen
else
Ichicheck = 0; // Neutral state
}
if(iIchimoku(Symbol(),time_frame,Tenkan_sen,Kijun_sen,Senkou_SpanB,MODE_TENKANSEN,ikh_shift) < iIchimoku(Symbol(),time_frame,Tenkan_sen,Kijun_sen,Senkou_SpanB,MODE_KIJUNSEN,ikh_shift))
{
if(Close[0] >= Tenkan_sen)
Ichicheck = -1; // Sell condition if bar >= Tenkan_sen as long as Tenkan_sen < Kijun_Sen
else
Ichicheck = 0; // Neutral state
}
// MACD_FXTIDYLUCKYSTAR
if(iCustom(Symbol(),0,"tidy/MACD_FXTIDYLUCKYSTAR",separator10,MACD_fastEMA,MACD_slowEMA,MACD_signalSMA,separator11,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,alertsON,0,1) != EMPTY_VALUE)
MACDcheck = 1;
if(iCustom(Symbol(),0,"tidy/MACD_FXTIDYLUCKYSTAR",separator10,MACD_fastEMA,MACD_slowEMA,MACD_signalSMA,separator11,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,alertsON,1,1) != EMPTY_VALUE)
MACDcheck = -1;
if(iCustom(Symbol(),0,"tidy/MACD_FXTIDYLUCKYSTAR",separator10,MACD_fastEMA,MACD_slowEMA,MACD_signalSMA,separator11,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,alertsON,0,1) == EMPTY_VALUE && iCustom(Symbol(),0,"tidy/MACD_FXTIDYLUCKYSTAR",separator10,MACD_fastEMA,MACD_slowEMA,MACD_signalSMA,separator11,drawIndicatorTrendLines,drawPriceTrendLines,displayAlert,alertsON,1,1) == EMPTY_VALUE)
MACDcheck = 0;
//STOCHASTIC_FXTIDYLUCKYSTAR - not usable
/*
if(iCustom(Symbol(),0,"tidy/STOCHASTIC_FXTIDYLUCKYSTAR",KPeriod,DPeriod,Slowing,DrawPriceLines,DrawArrows,displayHiddenDiv,drawDivergenceLines,displayAlert,1,0) != EMPTY_VALUE)
StochCheck = 1;
if(iCustom(Symbol(),0,"tidy/STOCHASTIC_FXTIDYLUCKYSTAR",KPeriod,DPeriod,Slowing,DrawPriceLines,DrawArrows,displayHiddenDiv,drawDivergenceLines,displayAlert,2,0) != EMPTY_VALUE)
StochCheck = -1;
if(iCustom(Symbol(),0,"tidy/STOCHASTIC_FXTIDYLUCKYSTAR",KPeriod,DPeriod,Slowing,DrawPriceLines,DrawArrows,displayHiddenDiv,drawDivergenceLines,displayAlert,1,0) == EMPTY_VALUE &&
iCustom(Symbol(),0,"tidy/STOCHASTIC_FXTIDYLUCKYSTAR",KPeriod,DPeriod,Slowing,DrawPriceLines,DrawArrows,displayHiddenDiv,drawDivergenceLines,displayAlert,2,0) == EMPTY_VALUE)
StochCheck = 0;
*/
//stochastic-divergence-indicator - not usable
/*
if(iCustom(Symbol(),0,"tidy/stochastic-divergence-indicator",KPeriod,DPeriod,Slowing,DrawPriceLines,DrawArrows,drawDivergenceLines,displayAlert,1,0) !=EMPTY_VALUE)
StochCheck = 1;
if(iCustom(Symbol(),0,"tidy/stochastic-divergence-indicator",KPeriod,DPeriod,Slowing,DrawPriceLines,DrawArrows,drawDivergenceLines,displayAlert,2,0) !=EMPTY_VALUE)
StochCheck = -1;
if(iCustom(Symbol(),0,"tidy/stochastic-divergence-indicator",KPeriod,DPeriod,Slowing,DrawPriceLines,DrawArrows,drawDivergenceLines,displayAlert,1,0) ==EMPTY_VALUE &&
iCustom(Symbol(),0,"tidy/stochastic-divergence-indicator",KPeriod,DPeriod,Slowing,DrawPriceLines,DrawArrows,drawDivergenceLines,displayAlert,2,0) ==EMPTY_VALUE)
StochCheck = 0;
*/
double sanity = iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,2,1);
double sanity2 = iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,3,1);
// Comment("OSMA2check is :, ", OSMA2check, "OSMAcheck is: ", OSMAcheck,"MAcheck is : ",MAcheck, ", CCIcheck is: ", CCIcheck, ", EWOcheck is: ", EWOcheck, ", RSIcheck is: ", RSIcheck, ", OBVcheck is: ", OBVcheck, "Ichicheck is: ", Ichicheck, "\n MACDcheck is: ," ,MACDcheck ," sanity check is: ", DoubleToStr(sanity,5), " sanity2 :, ",DoubleToStr(sanity2,5));
if(Ichicheck == 1 && MAcheck == 1)
{
if((OSMAcheck + OSMA2check + RSIcheck + CCIcheck +MACDcheck + OBVcheck + EWOcheck)/7 >= 3)
int ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,StopLoss,TakeProfit,comment,magicnumber,DodgerBlue);;
else
return(0);
}
if(Ichicheck == -1 && MAcheck == -1)
{
if((OSMAcheck + OSMA2check + RSIcheck + CCIcheck +MACDcheck + OBVcheck + EWOcheck)/7 <= 3)
return(2);
else
return(0);
}
else
return (0);
} // End Check Direction
- Indicators: FX5_MACD_Divergence
- What's the Error in my EA?
- calling osMA custom indicator
-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon. - Iwegbuna Chidera Clinton: When I try to add multiple currency string my input ENUM_TIMEFRAMES time_frame =PERIOD_H1 will start to indicate errorWhat error? Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problemWith the information you've provided — we can only guess. And you haven't provided any useful information for that.
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Iwegbuna Chidera Clinton:
Good day
Good day
Actually I'm working on EA based on several Indicators signal , I'm facing the following issues with this project
When I try to add multiple currency string my input ENUM_TIMEFRAMES time_frame =PERIOD_H1 will start to indicate error
Also ordersend implementation not working also please help fix
@ Iwegbuna Chidera Clinton
Without these indicators it seems impossible to control
exm. STOCHASTIC_FXTIDYLUCKYSTAR and other indicators
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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