Support Resistance EA

To add comments, please log in or register
kekdge
11
kekdge  

I got this EA from online somewhere. It seems to take only Buy orders. Any suggestion why it doesn't take sell trades?


//+------------------------------------------------------------------+

//|                                                    openorder.mq4 |

//|                      Copyright © 2010, MetaQuotes Software Corp. |

//|                                        http://www.metaquotes.net |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2010, MetaQuotes Software Corp."

#property link      "http://www.metaquotes.net"



double   bar;

bool     a;

bool     stopbuy,stopsell;

double   sup,res,high,low;

//+------------------------------------------------------------------+

//| expert initialization function                                   |

//+------------------------------------------------------------------+

int init()

  {

//----

   stopsell=false;

   stopbuy=false;



//----

   return(0);

  }

//+------------------------------------------------------------------+

//| expert deinitialization function                                 |

//+------------------------------------------------------------------+

int deinit()

  {

//----

   

//----

   return(0);

  }

//+------------------------------------------------------------------+

//| expert start function                                            |

//+------------------------------------------------------------------+

int start()

  {

//----

   if (Bid>=12315*Point && bar!=Bars && a==false)

      {

         OrderSend(Symbol(),OP_SELL,0.1,Ask,5,0,0,0,0,0,Green);

         a=true;

         res = Ask;

         sup = Ask;

      }

      

   if (bar!=Bars && stopbuy==true)

      {

         OrderSend(Symbol(),OP_BUYSTOP,0.1,res,5,0,0,0,0,0,Green);

         stopbuy=false;

      }

   if (bar!=Bars && stopsell==true)

      {

         OrderSend(Symbol(),OP_SELLSTOP,0.1,sup,5,0,0,0,0,0,Green);

         stopsell=false;

      }

      

   if (OrdersTotal()>0)

      {

         for (int z=OrdersTotal();z>=0;z--)

            {

               OrderSelect(z,SELECT_BY_POS,MODE_TRADES);

               if (OrderType()==OP_BUY || OrderType()==OP_SELL)

                  {

                     double openprice=OrderOpenPrice();

                     high = openprice + 50*Point;

                     low = openprice - 50*Point;

                     if (sup>low)

                        {

                           stopsell=1;

                           sup=low;

                        }

                        else sup=sup;

                     if (res<high)

                        {

                           stopbuy=1;

                           res=high;

                        }

                        else res=res;

                  }

            }

      }

      

    



//----

   return(0);

  }

//+------------------------------------------------------------------+
MetaQuotes Software Corp.
MetaQuotes Software Corp.
  • www.metaquotes.net
Millions of traders and hundreds of brokers cannot be wrong — they have chosen MetaTrader 5 for trading Forex and financial markets! Learn more
Files:
To add comments, please log in or register