Indicator Trouble W/ MACD:

To add comments, please log in or register
wcrowder
38
wcrowder  

On the screenshot attached you can see two places I want to focus in on. I have used the function in Mt4 (MACD>0) & (MACD<0). But the value when MACD = 0 is not this specific crossover, as I thought it was.


Does anyone know what my points (A & B) in the screenshot are called? Or how to locate them using mt4ql?
Files:
William Roeder
19843
William Roeder  
  1. 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.

  2. Exactly what you labeled them as — MACD crossover.

  3. double v1 = iMACD(…, MODE_MAIN,1),
           v2 = iMACD(…, MODE_MAIN,2),
           s1 = iMACD(…, MODE_SIGNAL, 1),
           s2 = iMACD(…, MODE_SIGNAL, 2);
    bool wasUp = v2 > s2,
          isUp = v1 > s1,
         crossed = isUp != wasUp;

wcrowder
38
wcrowder  
William Roeder:
  1. 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.

  2. Exactly what you labeled them as — MACD crossover.


Sorry for posting in the wrong section. I am very new to code do you mind taking your response a step further and explaining to me what you wrote here?

What are v1-v2 & s1-s2?


Are you replacing the MACD>0 w/ your example and if so please desribe it to me. I really appreciate your time, truly.
William Roeder
19843
William Roeder  
wcrowder:What are v1-v2 & s1-s2? Are you replacing the MACD>0
  1. Variables.
  2. Yes
  1. MT4: Learn to code it.
    MT5: Learn to code. 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. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum
wcrowder
38
wcrowder  

1. I am trying to learn it. I am reading guides, readin forums and posting to forums.

2. They are varibales, but what is deliniating them? How can I indicate what line is signal and which is MACD?

All I need to make is a short order based on this cross. I do not know how to make it compare the values in the parenthesis.


void OnTick()
{
double v1 = iMACD(NULL,0,12,26,9,PRICE_CLOSE, MODE_MAIN,1),
       v2 = iMACD(NULL,0,12,26,9,PRICE_CLOSE, MODE_MAIN,2),
       s1 = iMACD(NULL,0,12,26,9,PRICE_CLOSE, MODE_MAIN,1),
       s2 = iMACD(NULL,0,12,26,9,PRICE_CLOSE, MODE_MAIN,2);
bool wasUp = v2 > s2,
      isUp = v1 > s1,
     crossed = isUp != wasUp;

//if(signal line goes above MACD)<--------------
   OrderSend (
                      _Symbol,                     //Pair to use
                      OP_SELL,                     //buy or sell operator
                      0.15,                        //how much
                      Bid,                         //price to pay 
                      3,                           //slippage ??
                      Ask+200*_Point,              // Stop Loss
                      Bid-125*_Point,              // Take Prof
                      NULL,                        // use if you want to ID the trade
                      0,                           // Magic Number
                      0,                           // Expiration, 0 for no expiration
                      Green
                    );  

}
Pavel Shutovskiy
76573
Pavel Shutovskiy  
wcrowder:

1. I am trying to learn it. I am reading guides, readin forums and posting to forums.

2. They are varibales, but what is deliniating them? How can I indicate what line is signal and which is MACD?

All I need to make is a short order based on this cross. I do not know how to make it compare the values in the parenthesis.


William Roeder gave you the right example, and you made a mistake, missed MODE_SIGNAL  in variables s1 and s2

wcrowder
38
wcrowder  
Pavel Shutovskiy:

William Roeder gave you the right example, and you made a mistake, missed MODE_SIGNAL  in variables s1 and s2

Pavel,

Yeah, I see that now! Thank you. My question is how to make my if statement know when the corss happens.

I am assuming its along theses lines:

if ( signal_period<macd) 

or

If (signal>macd)

Pavel Shutovskiy
76573
Pavel Shutovskiy  
wcrowder:

Pavel,

Yeah, I see that now! Thank you. My question is how to make my if statement know when the corss happens.

I am assuming its along theses lines:

if ( signal_period<macd) 

or

If (signal>macd)

if(crossed)

You already have a solution provided by William Roeder

wcrowder
38
wcrowder  
Pavel Shutovskiy:

You already have a solution provided by William Roeder


I think I see. My background has no formal programming education so this is hard for me. Appreciate you both being patientwith me.
To add comments, please log in or register