Download MetaTrader 5

coding problem

To add comments, please log in or register
Freelance service: the safe way to order a trading robot. Try it!
joe
63
joe 2013.11.19 22:07 

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
14519
whroeder1 2013.11.19 22:35  
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
63
joe 2013.11.21 16:19  

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
63
joe 2013.11.21 16:20  

DECOMPILED (stolen) CODE removed.

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.11.21 16:37  
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
63
joe 2013.11.21 17:05  
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
63
joe 2013.11.21 17:15  
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
14519
whroeder1 2013.11.21 17:17  
  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
63
joe 2013.11.21 18:11  

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
18001
Simon Gniadkowski 2013.11.21 18:17  
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
63
joe 2013.11.21 18:49  

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