coding problem

 

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

 
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.
 

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 :



 

DECOMPILED (stolen) CODE removed.

 
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.
 
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.
 
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);
}
 
  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.
 

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..

 
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.
 

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