Help coding simple indicator

To add comments, please log in or register
freecbc3
26
freecbc3  

hello,

i'm trying to code an indicator derived a alert on next candle as previous candle


mean if current candle in green to send a alert as buy in next candle

and if last candle is red to send a sell in next candle 


any help please

Marco vd Heijden
Moderator
13015
Marco vd Heijden  

You didn't specify a language.

And what have you tried so far ? 

freecbc3
26
freecbc3  
i need it ..mq4 for mt4
William Roeder
21834
William Roeder  
  1. freecbc3: i'm trying to code … any help please
    Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

  2. freecbc3: i need it ..mq4 for mt4

    Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

Keith Watford
Moderator
23395
Keith Watford  
In future please post in the correct section
I will move this topic to the MQL4 and Metatrader 4 section.
freecbc3
26
freecbc3  
William Roeder:
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

  2. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

i am sry wiliam i am new here

i hope some one can code it 

Jean Francois Le Bas
1219
Jean Francois Le Bas  
freecbc3:

hello,

i'm trying to code an indicator derived a alert on next candle as previous candle


mean if current candle in green to send a alert as buy in next candle

and if last candle is red to send a sell in next candle 


any help please

if (iClose(NULL,0,i+1) > iOpen(NULL,0,i+1))

        Alert("Buy");

else if (iClose(NULL,0,i+1) < iOpen(NULL,0,i+1))

        Alert("Sell");
freecbc3
26
freecbc3  
Jean Francois Le Bas:

first of all thanks you Jean Francois 

i just need it to save in file .mq4 and its should work ?

as i try it and didnt work 

William Roeder
21834
William Roeder  
  1. freecbc3: its should work ? as i try it and didnt work 
    MT4: Learn to code it.
    MT5: Begin learning to code it.
    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.

  2. freecbc3: i hope some one can code it 
    or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum

We're not going to code it for you.
mt4ski
246
mt4ski  
//+------------------------------------------------------------------+
//|                                                       alert.mq4  |
//|                                                        freecbc3  |
//|                             https://www.mql5.com/en/forum/341397 |
//+------------------------------------------------------------------+
#property copyright "freecbc3"
#property link      "https://www.mql5.com/en/forum/341397"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
 
   if (iClose(NULL,0,1) > iOpen(NULL,0,1))

        Alert("Buy");

   else if (iClose(NULL,0,1) < iOpen(NULL,0,1))

        Alert("Sell");
   
  }
//+------------------------------------------------------------------+
Files:
alert.mq4 2 kb
Keith Watford
Moderator
23395
Keith Watford  
mt4ski:
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   static datetime barTime=0;
   if(barTime!=Time[0])
     {
      barTime=Time[0];
      if(iClose(NULL,0,1) > iOpen(NULL,0,1))
         Alert("Buy");
      else
         if(iClose(NULL,0,1) < iOpen(NULL,0,1))
            Alert("Sell");
     }
  }
//+------------------------------------------------------------------+

Checking for a new bar will avoid getting alerts every tick.

12
To add comments, please log in or register