Download MetaTrader 5

coding problem

To add comments, please log in or register
joe
64
joe  

hi,


i'm trying to code a indicator that will spot wide spread candle.

Like 2 ATR on the same window of a chart, the first showing average range and the 2nd the actual candle's range, and when the actual candle spread is higher than the average it would alert me. (there are others conditions, but that's where i get stuck).

the issue is that type of code would work for an ea, not an indicator (i think, i'm no programmer).


can someone show me a way to do it right??

thanks

whroeder1
16333
whroeder1  
You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
joe
64
joe  

hi,

i'm trying to learn to code, so this is probably not the cleanest code you've seen, but thanks for the help.

here is my attempt :



joe
64
joe  

DECOMPILED (stolen) CODE removed.

Simon Gniadkowski
Moderator
18042
Simon Gniadkowski  
jopopo:

DECOMPILED (stolen) CODE removed.

Do not post DECOMPILED (stolen) CODE, or code derived from DECOMPILED CODE again or you will receive a permanent BAN.
joe
64
joe  
ok just found that decompiled code on some forum, and try to modify it for private use, didn't know that was forbidden. sincere apology.
joe
64
joe  
anyway, here is the problem i'm working on, on my own, and was looking for help
extern double Atrperiod = 12;

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

int start() {

   double avspread;
   double spread;

      avspread = (iHigh(NULL,NULL,Atrperiod) - iLow(NULL,NULL,Atrperiod))/Atrperiod;
      spread = (iHigh(NULL,NULL,1) - iLow(NULL,NULL,1));

     
      if (spread < avspread)
     
   }
   return (0);
}
whroeder1
16333
whroeder1  
  1. You can not compile decompiled code any more.

    Decompiled code is stolen code. Either you are a thief or the receiver of stolen (intellectual) property.

    Either way we will not be an accomplice after the fact to theft.

    See also https://www.mql5.com/en/forum/134317

    If you post decompiled code again, you will be banned.


  2. RTFM what is the 2nd and 3rd arguments to iHigh and what are you passing?
  3. jopopo: anyway, here is the problem i'm working on, on my own, and was looking for help
    What problem? you haven't said any, you haven't posted any code. You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
joe
64
joe  

i just want to be able to compare the bar current+1 with the bar spread average on a n period of time.

from the code i've post above, when i ask it to draw a arrow from the condition i've coded, nothing appear..

Simon Gniadkowski
Moderator
18042
Simon Gniadkowski  
jopopo:

i just want to be able to compare the bar current+1 with the bar spread average on a n period of time.

from the code i've post above, when i ask it to draw a arrow from the condition i've coded, nothing appear..

To calculate an average you normally sum the values and divided by the number of values, you aren't summing any values you are just taking one and dividing it by 12 so it is not surprising that it is less than your spread value.
joe
64
joe  

OK, i thought that ihigh(null,null,12) will sum every high of the 12th past bars...

there must be a better way than high+1 + high+2 .... but i don't find it

12
To add comments, please log in or register