Hello everyone,
I am trying to code a small indicator in which if Price > SMA30 > SMA50 > SMA100, then a small comment on the upper left corner shows as TRADEABLE. If not, it shows as NOT TRADEABLE.
Funnily enough, even though I think everything is properly coded, only the NOT TRADEABLE message appears despite the conditions being met.
I would very greatly appreciate if anyone could have a quick look at this because I am just going nuts here. I cannot figure out whether the !#%#@'ing bug is.
Thank you in advance
Following I copy/paste the code:
--------------------------
//+------------------------------------------------------------------+
//| Trend Filter.mq4 |
//| Copyright 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//PFX MAs variables definition for 30 minutes chart
double a30=iMA(NULL,PERIOD_M30,30,0,MODE_SMA,PRICE_CLOSE,0);
double b30=iMA(NULL,PERIOD_M30,50,0,MODE_SMA,PRICE_CLOSE,0);
double c30=iMA(NULL,PERIOD_M30,100,0,MODE_SMA,PRICE_CLOSE,0);
double p=PRICE_CLOSE;
//PFX MAs variables definition for Hourly chart
double a60=iMA(NULL,PERIOD_H1,30,0,MODE_SMA,PRICE_CLOSE,0);
double b60=iMA(NULL,PERIOD_H1,50,0,MODE_SMA,PRICE_CLOSE,0);
double c60=iMA(NULL,PERIOD_H1,100,0,MODE_SMA,PRICE_CLOSE,0);
//PFX MAs variables definition for 4H chart
double a240=iMA(NULL,PERIOD_H4,30,0,MODE_SMA,PRICE_CLOSE,0);
double b240=iMA(NULL,PERIOD_H4,50,0,MODE_SMA,PRICE_CLOSE,0);
double c240=iMA(NULL,PERIOD_H4,100,0,MODE_SMA,PRICE_CLOSE,0);
//PFX MAs variables definition for Daily chart
double aDaily=iMA(NULL,PERIOD_D1,30,0,MODE_SMA,PRICE_CLOSE,0);
double bDaily=iMA(NULL,PERIOD_D1,50,0,MODE_SMA,PRICE_CLOSE,0);
double cDaily=iMA(NULL,PERIOD_D1,100,0,MODE_SMA,PRICE_CLOSE,0);
string Filter30 = "not tradeable";
if(a30>b30 && b30>c30 && p>c30) Filter30="TRADEABLE";
if(a30<b30 && b30<c30 && p<c30) Filter30="TRADEABLE";
Comment("30 minutes chart is ", Filter30);
//----
//----
return(0);
}
//+------------------------------------------------------------------+
I am trying to code a small indicator in which if Price > SMA30 > SMA50 > SMA100, then a small comment on the upper left corner shows as TRADEABLE. If not, it shows as NOT TRADEABLE.
Funnily enough, even though I think everything is properly coded, only the NOT TRADEABLE message appears despite the conditions being met.
I would very greatly appreciate if anyone could have a quick look at this because I am just going nuts here. I cannot figure out whether the !#%#@'ing bug is.
Thank you in advance
Following I copy/paste the code:
--------------------------
//+------------------------------------------------------------------+
//| Trend Filter.mq4 |
//| Copyright 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//PFX MAs variables definition for 30 minutes chart
double a30=iMA(NULL,PERIOD_M30,30,0,MODE_SMA,PRICE_CLOSE,0);
double b30=iMA(NULL,PERIOD_M30,50,0,MODE_SMA,PRICE_CLOSE,0);
double c30=iMA(NULL,PERIOD_M30,100,0,MODE_SMA,PRICE_CLOSE,0);
double p=PRICE_CLOSE;
//PFX MAs variables definition for Hourly chart
double a60=iMA(NULL,PERIOD_H1,30,0,MODE_SMA,PRICE_CLOSE,0);
double b60=iMA(NULL,PERIOD_H1,50,0,MODE_SMA,PRICE_CLOSE,0);
double c60=iMA(NULL,PERIOD_H1,100,0,MODE_SMA,PRICE_CLOSE,0);
//PFX MAs variables definition for 4H chart
double a240=iMA(NULL,PERIOD_H4,30,0,MODE_SMA,PRICE_CLOSE,0);
double b240=iMA(NULL,PERIOD_H4,50,0,MODE_SMA,PRICE_CLOSE,0);
double c240=iMA(NULL,PERIOD_H4,100,0,MODE_SMA,PRICE_CLOSE,0);
//PFX MAs variables definition for Daily chart
double aDaily=iMA(NULL,PERIOD_D1,30,0,MODE_SMA,PRICE_CLOSE,0);
double bDaily=iMA(NULL,PERIOD_D1,50,0,MODE_SMA,PRICE_CLOSE,0);
double cDaily=iMA(NULL,PERIOD_D1,100,0,MODE_SMA,PRICE_CLOSE,0);
string Filter30 = "not tradeable";
if(a30>b30 && b30>c30 && p>c30) Filter30="TRADEABLE";
if(a30<b30 && b30<c30 && p<c30) Filter30="TRADEABLE";
Comment("30 minutes chart is ", Filter30);
//----
//----
return(0);
}
//+------------------------------------------------------------------+