• Home
  • Forums
  • News
  • Market
  • Login
  • Join
  • User/Email: Password:
  • 10:11am
  • Search
Menu
  • Forums
  • News
  • Market
  • Login
  • Join
  • 10:11am
Search
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Forex Factory

Options

Search

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

Need help with 10M chart - got it already but need some help! 1 reply

I need help about afl to mql4!!! please help to me 0 replies

need help with a simple MA crossover EA. anyone can help? 7 replies

Help me out? I need the help of you. 20 replies

Need help Custom Indicator (MetaTrader4) 4 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

Need help on this indicator

  • Post #1
  • Quote
  • First Post: Aug 14, 2018 12:32am Aug 14, 2018 12:32am
  •  SLaKerZ
  • | Joined Apr 2013 | Status: Member | 66 Posts
Hi,

I'm trying to create an indicator but having problem on this part

Basically i have few rules

Inserted Code
input bool D_MACD = false;//DAILY MACD
input bool H4_MACD = false;//H4 MACD
input bool H1_MACD = false;//H1 MACD
input bool M30_MACD = false;//M30 MACD
input bool M15_MACD = false;//M15 MACD
input bool M5_MACD = false;//M5 MACD
input bool M1_MACD = false;//M1 MACD

------------------------------------------------------------------

Inserted Code
      if(
         (D_MACD && iMACD(_Symbol,PERIOD_D1,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_D1,Time[i]))>0.0) &&
         (H4_MACD && iMACD(_Symbol,PERIOD_H4,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_H4,Time[i]))>0.0) &&
         (H1_MACD && iMACD(_Symbol,PERIOD_H1,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_H1,Time[i]))>0.0) &&
         (M30_MACD && iMACD(_Symbol,PERIOD_M30,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_M30,Time[i]))>0.0) &&
         (M15_MACD && iMACD(_Symbol,PERIOD_M15,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_M15,Time[i]))>0.0) &&
         (M5_MACD && iMACD(_Symbol,PERIOD_M5,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_M5,Time[i]))>0.0) &&
         (M1_MACD && iMACD(_Symbol,PERIOD_M1,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_M1,Time[i]))>0.0) &&
         )
        {ArrDnBuffer[i]=iLow(_Symbol,_Period,i)+10*pix_y();}

if i want to use the H1_MACD and M30_MACD, i set true and i will get the indication. I know the && is wrong. i tried google to use the correct Operations.

Thank you
  • Post #2
  • Quote
  • Aug 14, 2018 12:38am Aug 14, 2018 12:38am
  •  FerruFx
  • Joined May 2007 | Status: MT4/MT5 EAs/Indicators/Alerts coder | 6,633 Posts
Quoting SLaKerZ
Disliked
Hi, I'm trying to create an indicator but having problem on this part Basically i have few rules input bool D_MACD = false;//DAILY MACD input bool H4_MACD = false;//H4 MACD input bool H1_MACD = false;//H1 MACD input bool M30_MACD = false;//M30 MACD input bool M15_MACD = false;//M15 MACD input bool M5_MACD = false;//M5 MACD input bool M1_MACD = false;//M1 MACD ------------------------------------------------------------------ if( (D_MACD && iMACD(_Symbol,PERIOD_D1,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_D1,Time))>0.0)...
Ignored
You should instead write:

Inserted Code
if(
(!D_MACD || iMACD(_Symbol,PERIOD_D1,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_D1,Time[i]))>0.0) &&
(!H4_MACD || iMACD(_Symbol,PERIOD_H4,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_H4,Time[i]))>0.0) &&
(!H1_MACD || iMACD(_Symbol,PERIOD_H1,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_H1,Time[i]))>0.0) &&
(!M30_MACD || iMACD(_Symbol,PERIOD_M30,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_M30,Time[i]))>0.0) &&
(!M15_MACD || iMACD(_Symbol,PERIOD_M15,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_M15,Time[i]))>0.0) &&
(!M5_MACD || iMACD(_Symbol,PERIOD_M5,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_M5,Time[i]))>0.0) &&
(!M1_MACD || iMACD(_Symbol,PERIOD_M1,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,iBarShift(_Symbol,PERIOD_M1,Time[i]))>0.0)  )
{ArrDnBuffer[i]=iLow(_Symbol,_Period,i)+10*pix_y();}
MT4/MT5 EAs/Indicators/Alerts coder
  • Post #3
  • Quote
  • Aug 14, 2018 12:51am Aug 14, 2018 12:51am
  •  SLaKerZ
  • | Joined Apr 2013 | Status: Member | 66 Posts
Sir FerruFx

Thank you so much for the 2nd guidance from you... Appreciate it sir.. Will test it out
1
  • Post #4
  • Quote
  • Aug 14, 2018 12:59am Aug 14, 2018 12:59am
  •  FerruFx
  • Joined May 2007 | Status: MT4/MT5 EAs/Indicators/Alerts coder | 6,633 Posts
Quoting SLaKerZ
Disliked
Sir FerruFx Thank you so much for the 2nd guidance from you... Appreciate it sir.. Will test it out
Ignored
MT4/MT5 EAs/Indicators/Alerts coder
  • Post #5
  • Quote
  • Edited at 4:20am Aug 14, 2018 3:09am | Edited at 4:20am
  •  rockit
  • Joined Oct 2013 | Status: Member | 665 Posts
I think the issue is much more complicated:
If you want to have all the indicator conditions for which the switch is true, to be true for to have the indication, irrespective of the other set of switches, you need to have a logic that can deal with all the possible combinations of switches.
Therefore I propose to make an integer number from the switches and an integer number from the indicator conditions, in such a way that each switch/condition corresponds to one bit; and if the numbers match, the indication is given.
..
  • Post #6
  • Quote
  • Aug 15, 2018 2:13am Aug 15, 2018 2:13am
  •  SLaKerZ
  • | Joined Apr 2013 | Status: Member | 66 Posts
Hi Sir FeruFX,

What do i need to add in to the indicator so that it will be able to work on broker that is using prefix? Thank you

Hi Sir Rockit,

A good idea too... will try both to gain learning experience... thank you
  • Post #7
  • Quote
  • Aug 15, 2018 2:27am Aug 15, 2018 2:27am
  •  FerruFx
  • Joined May 2007 | Status: MT4/MT5 EAs/Indicators/Alerts coder | 6,633 Posts
Quoting SLaKerZ
Disliked
Hi Sir FeruFX, What do i need to add in to the indicator so that it will be able to work on broker that is using prefix? Thank you Hi Sir Rockit, A good idea too... will try both to gain learning experience... thank you
Ignored
If you are using _Symbol ... there's no need to add any pre/suffix ... It is already included in _Symbol
MT4/MT5 EAs/Indicators/Alerts coder
  • Post #8
  • Quote
  • Aug 15, 2018 3:50am Aug 15, 2018 3:50am
  •  rockit
  • Joined Oct 2013 | Status: Member | 665 Posts
Quoting SLaKerZ
Disliked
Rockit, A good idea too... will try both to gain learning experience... thank you
Ignored
And you should because I think FerruFX's code does not deliver. Here is why:
The inner or operator reqires only one of its operands to result true
(thus both will be checked) in order to render the condition true, making the
switch* irrelevant in the case the indicator check results true. And likewise,
making the indicator check irrelevant in the case the switch results true..
What is more, he inverts the switch, so that the condition renders true(!) when
the switch is set to false.. Could not be more wrong.
Here an example: Suppose you set all switches to false (meaning you want not
consider any indicator readings). Now FerruFX's code will invert all switches
rendering the whole conditional to true and you will get an "indication" (where as
you have demanded none).
*the xx_MACD stuff
..
  • Post #9
  • Quote
  • Aug 15, 2018 4:20am Aug 15, 2018 4:20am
  •  FerruFx
  • Joined May 2007 | Status: MT4/MT5 EAs/Indicators/Alerts coder | 6,633 Posts
Quoting rockit
Disliked
{quote} And you should because I think FerruFX's code does not deliver. Here is why: The inner or operator reqires only one of its operands to result true (thus both will be checked) in order to render the condition true, making the switch* irrelevant in the case the indicator check results true. And likewise, making the indicator check irrelevant in the case the switch results true.. What is more, he inverts the switch, so that the condition renders true(!) when the switch is set to false.. Could not be more wrong. Here an example: Suppose you...
Ignored
With all due respect, you are wrong ...
MT4/MT5 EAs/Indicators/Alerts coder
  • Post #10
  • Quote
  • Aug 15, 2018 4:49am Aug 15, 2018 4:49am
  •  rockit
  • Joined Oct 2013 | Status: Member | 665 Posts
Quoting FerruFx
Disliked
{quote} With all due respect, you are wrong ...
Ignored
No problem. Can you state your reasoning, please?
Here is a test script:
Inserted Code
#property strict
void OnStart()
{
    bool sw = false;
    double f = -1;
    if(!sw || f > 0)
        Print("rockit is right!");
    else
        Print("rockit is wrong indeed..");
}
..
  • Post #11
  • Quote
  • Aug 15, 2018 6:31am Aug 15, 2018 6:31am
  •  FerruFx
  • Joined May 2007 | Status: MT4/MT5 EAs/Indicators/Alerts coder | 6,633 Posts
Quoting rockit
Disliked
{quote} No problem. Can you state your reasoning, please? Here is a test script: #property strict void OnStart() { bool sw = false; double f = -1; if(!sw || f > 0) Print("rockit is right!"); else Print("rockit is wrong indeed.."); }
Ignored
In his request, his need was to be able to set some of the TFs but not necessary all ... So my solution check only the selected MACDs and give the final result = true only if the selected MACDs validate the condition.

if(!D_MACD || iMACD(...)) ... If selected, iMACD condition is checked .... If not selected (!), iMACD condition is not checked.
MT4/MT5 EAs/Indicators/Alerts coder
1
  • Post #12
  • Quote
  • Aug 15, 2018 9:54am Aug 15, 2018 9:54am
  •  SLaKerZ
  • | Joined Apr 2013 | Status: Member | 66 Posts
thank you for your Comment rockit and FerruFx.. i learn few things here... my issue have been settle...

Now i am having issue with the prefix...

Inserted Code
extern string pairs="AUDUSD,AUDJPY,CADJPY,CADCHF,CHFJPY


Inserted Code
   Background_Color=(color)ChartGetInteger(0,CHART_COLOR_BACKGROUND);
   pairs = StringTrimLeft(pairs);
   pairs = StringTrimRight(pairs);
   while(true && !IsStopped())
     {
      if(StringSubstr(pairs,StringLen(pairs)-1)==",")
         pairs=StringSubstr(pairs,0,StringLen(pairs)-1);
      else break;
     }
   int pos=0,p=1;
   while(true && !IsStopped())
     {
      pos=StringFind(pairs,",",0);
      ArrayResize(pair,p,100);
      pair[p-1]=StringTrimLeft(StringTrimRight(StringSubstr(pairs,0,pos)));
      pairs=StringSubstr(pairs,pos+1);
      if(pos<1)break;
      p++;
     }
  • Post #13
  • Quote
  • Edited at 1:20pm Aug 15, 2018 12:53pm | Edited at 1:20pm
  •  rockit
  • Joined Oct 2013 | Status: Member | 665 Posts
Quoting FerruFx
Disliked
So my solution check only the selected MACDs and give the final result = true only if the selected MACDs validate the condition.
Ignored
Yes, I see now. I agree. Please excuse my ignorance. However, there is one special case: if non are selected (will evaluate to true nevertheless), but I guess that this special case is not intended.
..
1
  • Post #14
  • Quote
  • Aug 15, 2018 7:43pm Aug 15, 2018 7:43pm
  •  FerruFx
  • Joined May 2007 | Status: MT4/MT5 EAs/Indicators/Alerts coder | 6,633 Posts
Quoting rockit
Disliked
{quote} Yes, I see now. I agree. Please excuse my ignorance. However, there is one special case: if non are selected (will evaluate to true nevertheless), but I guess that this special case is not intended.
Ignored
Exactly.
MT4/MT5 EAs/Indicators/Alerts coder
  • Post #15
  • Quote
  • Aug 15, 2018 9:09pm Aug 15, 2018 9:09pm
  •  SLaKerZ
  • | Joined Apr 2013 | Status: Member | 66 Posts
Thank you Sir FerruFx and Rockit. This info is good for me as still learning..

The prefix above is the code which i believe i need to add on for the prefix
  • Post #16
  • Quote
  • Aug 16, 2018 8:34am Aug 16, 2018 8:34am
  •  One day!
  • Joined Jul 2009 | Status: ...or there about! | 220 Posts
Thanks FerruFx and rockit for that discussion. I was struggling with the logic, until I came across precedence rules. It all makes sense now.

A couple of links for anyone like me: http://www.cplusplus.com/doc/tutorial/operators/ & https://docs.mql4.com/basis/operations/rules
1
  • Post #17
  • Quote
  • Last Post: Aug 16, 2018 9:57am Aug 16, 2018 9:57am
  •  FerruFx
  • Joined May 2007 | Status: MT4/MT5 EAs/Indicators/Alerts coder | 6,633 Posts
Quoting One day!
Disliked
Thanks FerruFx and rockit for that discussion. I was struggling with the logic, until I came across precedence rules. It all makes sense now. A couple of links for anyone like me: http://www.cplusplus.com/doc/tutorial/operators/ & https://docs.mql4.com/basis/operations/rules
Ignored
MT4/MT5 EAs/Indicators/Alerts coder
Thread Tools Search this Thread
Show Printable Version Show Printable Version
Email This Thread Email This Thread
Search this Thread:

Advanced Search

  • Platform Tech
  • /
  • Need help on this indicator
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About CC
  • Mission
  • Products
  • User Guide
  • Blog
  • Contact
CC Products
  • Forums
  • News
  • Market
CC Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow CC
  • Facebook
  • Twitter

CC Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Forex Factory

Crypto Craft® is a brand of Fair Economy, Inc.

Terms of Service / ©2019