MACD Signal Order Entry & Exit

 

Currently using a pre-packaged email notice for the MACD. When the MACD crosses it send an email. I want to create code to do this.

I am familiar with Python but new to MT4.

Nothing yet. I need some really intensive help here.

  1. Locate MACD Trend reversal/Cross-over
  2. Enter an order base on step 1.
  3. Exit trade upon a inverse cross-over.
  4. Repeat the aobe steps 24 hours/day.
 
wcrowder: I want to  … Nothing yet. I need some really intensive help here.
Help you with what? You haven't stated a problem, you stated a want. You have only four choices:
  1. Search for it.
  2. Beg at
  3. 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.
  4. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help
          urgent help.
 
William Roeder:
Help you with what? You haven't stated a problem, you stated a want. You have only four choices:
  1. Search forit.
  2. Beg at
  3. 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.
  4. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help
          urgent help.

I can code some. I am teaching myself python and I am doing ok and I want to learn how to do this. I have no formal education in code. I am self-taught and I find more python resources than mt4, so I have done more iwth python just to understand how computers work.

My issue is:

1. what baked in functions to mt4 will I use/should I look at?

what built in code functions exist that I can/could use?

I just need a point in the right direction.

 
  1. All of them
  2. All of them
  3. Read the documentation.

Only then can you

  1. get the MACD cross
  2. Open orders
  3. Close orders
 

William,


I did what you said and come up with the folloqing code:


void OnTick()
{
    // string for the signal
   string signal= "";
    //define the MACD
   double MACD=iMACD(NULL,0,12,26,9,PRICE_CLOSE, MODE_MAIN,0);
    //if it is above 0
   if (MACD>0)
{
    signal="It is going up.";
}
//if it is below 0
   if (MACD<0)
{
    signal="It is going down.";
}
// chart output
Comment("MACD: ", MACD,"\n", "Signal :", signal);
  
   if (MACD>0)

 OrderSend (
                      _Symbol,                 //Pair to use
                      OP_BUY,                //buy or sell operator
                      0.10,                   // how much
                      Bid,                     // price to pay
                      3,                    // slippage ??
                      Ask+300*_Point,         // Stop Loss
                      Ask-150*_Point,         // Take Prof
                      NULL,                   // use if you want to ID the trade
                      0,                       // Magic Number
                      0,                         // Expiration, 0 for no expiration
                      Green
                    ); 

}


However, I am not sure how to fix a few items:

1. I want to  use TP (fixed) and a trialing stop. I dont understand the datatype it ask for in the handbooks and guides. I am using Ask+300*_Point becuase I saw it on a video and it works, but I am more familiar w/ PIPS.

2. In the back-test I get error 130 if I change even the slightest code data, like ASK price, etc.


Thank you, again.

 
I got it. I got my SL and TP mixed up w/ my + and - symbols.
Reason: