Code to Use to define True or Fals

 

Hey guys,

Need a little help. Still learning on coding.

So i'm trying to create an indicator. but i have a problem. i have tried to google for answer but can't find it. hope someone here does know. i use the GVGet and GVSet function so will get a better picture

//Ex.

(iOpen(NULL,PERIOD_H1,0)<iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0) && iClose(NULL,PERIOD_H1,0)>iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0)) {GVSet("buy",1);}

(iOpen(NULL,PERIOD_H1,0)>iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0) && iClose(NULL,PERIOD_H1,0)<iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0)) {GVSet("sell",1);}

(iOpen(NULL,PERIOD_H1,0)<iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0) && iClose(NULL,PERIOD_H1,0)>iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0)) {GVSet("sell",0);}

(iOpen(NULL,PERIOD_H1,0)>iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0) && iClose(NULL,PERIOD_H1,0)<iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0)) {GVSet("buy",0);}
//than i will have my code as below for the indicator

if(GVGet("buy")==1 && iOpen(NULL,PERIOD_M15,0)<iMA(NULL,PERIOD_M15,50,0,MODE_EMA,PRICE_CLOSE,0) && iClose(NULL,PERIOD_M15,0)>iMA(NULL,PERIOD_M15,50,0,MODE_EMA,PRICE_CLOSE,0)) // then i will have my indicator arrow or so on

if(GVGet("sell")==1 && iOpen(NULL,PERIOD_M15,0)>iMA(NULL,PERIOD_M15,50,0,MODE_EMA,PRICE_CLOSE,0) && iClose(NULL,PERIOD_M15,0)<iMA(NULL,PERIOD_M15,50,0,MODE_EMA,PRICE_CLOSE,0)) // then i will have my indicator arrow or so on




I'm trying to code the above rules into indicator. tried google for answer but can't find it. Thank you for helping

 
Mohammad Rizal Bin Rahmat:
Need a little help.
So i'm trying to create an indicator. but i have a problem.
i have tried to google for answer but can't find it.
hope someone here does know.
i use the GVGet and GVSet function so will get a better picture
I'm trying to code the above rules into indicator.
tried google for answer but can't find it.
Thank you for helping
  1. Help you with what? You haven't stated a problem. Show us your attempt (using SRC) and state the nature of your problem.
              No free help
              urgent help.
    Help you with what? You haven't stated a problem.
    Find what?
    Knows what?
    Unknown functions. There are no mind readers here and our crystal balls are cracked.
    No rules stated.
    Find what?
    Help you with what? You haven't stated a problem.

  2. Why did you post your MT4 question in the Root / MT5 Indicators 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.

  3. Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling (or moving my eyes) back and forth trying to read it. Don't copy and paste code, write self-documenting code:
    double H1open    =  iOpen(NULL,PERIOD_H1,0);
    double H1EMA     =    iMA(NULL,PERIOD_H1,50,0,MODE_EMA,PRICE_CLOSE,0);
    double H1close   = iClose(NULL,PERIOD_H1,0);
    bool isH1crossUp = H1open<H1EMA && H1close>H1EMA;
    bool isH1crossDn = H1open>H1EMA && H1close<H1EMA;
    
      (isH1crossUp) {GVSet("buy",1);}
      (isH1crossDn) {GVSet("sell",1);}
      (isH1crossUp) {GVSet("sell",0);}
      (isH1crossDn) {GVSet("buy",0);}
    //than i will have my code as below for the indicator
    
    double   M15open     =  iOpen(NULL,PERIOD_M15,0);
    double   M15EMA      =    iMA(NULL,PERIOD_M15,50,0,MODE_EMA,PRICE_CLOSE,0);
    double   M15close    = iClose(NULL,PERIOD_M15,0);
    bool   isM15CrossUp  = M15open<M15EMA && M15close>M15EMA;
    bool   isM15CrossDn  = M15open>M15EMA && M15close<M15EMA;
    
    if(GVGet("buy")==1 && isM15CrossUp) // then i will have my indicator arrow or so on
    if(GVGet("sell")==1 && isM15CrossDn) // then i will have my indicator arrow or so on

  4. Those GVSet lines do not compile. Don't post code that doesn't compile. You know what an if statement is.
  5. Why do you want to sell when the H1 closes above the EMA or below the EMA? Makes no sense.
  6. Those if lines do not compile, where is your code that draws the arrows. Don't post code that doesn't compile or indicate that you have purposely left out ...
  7. What is the purpose of the GVs? Why not just use Booleans?
    if(isH1crossUp && isM15crossUp) // then i will have my indicator arrow or so on
    
  8. On MT4: Unless the current chart is the specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

  9. You are looking at bar zero. You will get intermittent signals as price fluctuates around the EMA. Perhaps you want to use the closed candle.