Results 1 to 2 of 2
 0 Attachment(s)    

Thread: Add reverse order

  1. #1

    Default Add reverse order

    Hi funyoo and other
    I cant figure out how to add on reverse order in EA..

    i found this code from Ten Stoch Wave EA
    PHP Code:
    extern bool Reverse=false
    PHP Code:
    {if(ReverseSV=1; else BV=1; break;}} 
    PHP Code:
    {if(ReverseBV=1; else SV=1; break;} 
    but how can i put inside this testing ea?

    PHP Code:
    //+------------------------------------------------------------------+
    //|                                                      MyStoch.mq4 |
    //|                      Copyright © 2006, MetaQuotes Software Corp. |
    //|                                        http://www.alpari-idc.ru/ |
    //+------------------------------------------------------------------+
    #property copyright "Copyright © 2006, MetaQuotes Software Corp."
    #property link      "http://www.alpari-idc.ru/"

    #include <stdlib.mqh>
    #include <WinUser32.mqh>

    #define MAGICMA 20050610
    extern double Lots         =0.1;
    extern double TakeProfit   =10;
    extern double StopLoss     =1000;
    extern double TrailingStop =100;

    int res;

    double Points;
    double iStoch1;
    double iStoch2;

    //+------------------------------------------------------------------+
    //| expert initialization function                                   |
    //+------------------------------------------------------------------+
    int init()
      {
    //----
       
    Points=MarketInfo("EURUSD",MODE_POINT);

    //----
       
    return(0);
      }
      
      
    //+-------------------------------------+
      //проверяем наличие открытых ордеров
      //+-------------------------------------+
      
    int CalculateCurrentOrders(string symbol)
      {
      
      
    int buys=0,sells=0;
      for(
    int i=0;i<OrdersTotal();i++)
      {
      if(
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)break;
      if(
    OrderSymbol()=="EURUSD"&&OrderMagicNumber()==MAGICMA)
      {
      if(
    OrderType()==OP_BUYbuys++;
      if(
    OrderType()==OP_SELLsells++;
      }
      }
      if(
    buys>0)return(buys);
      else return(-
    sells);
      }
      
    //+----------------------------------------------+
      //открываем ордер
      //+----------------------------------------------+
        
    void CheckForOpen()
      {
        
    iStoch1=iStochastic("EURUSD",0,7,10,4,MODE_SMA,0,MODE_MAIN,0);
         
    iStoch2=iStochastic("EURUSD",0,7,10,4,MODE_SMA,0,MODE_MAIN,1);
      
    //---------------------------------------------------------------------------------------------------//
      
    if(iStoch2<iStoch1&&iStoch1>=10&&iStoch1<15)
      
    res=OrderSend("EURUSD",OP_BUY,Lots,Ask,3,Ask-StopLoss*Points,Ask+TakeProfit*Points,"",MAGICMA,0,Blue);
      
    //---------------------------------------------------------------------------------------------------//
      
    if(iStoch2>iStoch1&&iStoch1<=95&&iStoch1>90)
      
    res=OrderSend("EURUSD",OP_SELL,Lots,Bid,3,Bid+StopLoss*Points,Bid-TakeProfit*Points,"",MAGICMA,0,Red);
      
    //---------------------------------------------------------------------------------------------------//

      
    return;
      }
      
    //---------------------------------------------------------------------+
      //Закрываем ордера
      //---------------------------------------------------------------------+
      
    void CheckForClose()
      {
     
         
    int total=OrdersTotal();
         
    int ordertype;
         
    int ticket;
         
    int index;
         
    //double priceClose;
         
         
    if(iStoch1<50)
         for( 
    index=total-1;index>=0;index--)
         if(
    OrderSelect(index,SELECT_BY_POS))
          {
            
    ordertype=OrderType();
            
    ticket=OrderTicket();
         if(
    ordertype==OP_SELL&&OrderMagicNumber()==MAGICMA)
         
    OrderClose(ticket,OrderLots(),Ask,3,Red);
         else break;
          }
          
         if(
    iStoch1>50)
         for( 
    index=total-1;index>=0;index--)
         if(
    OrderSelect(index,SELECT_BY_POS))
          {
            
    ordertype=OrderType();
            
    ticket=OrderTicket();
         if(
    ordertype==OP_BUY&&OrderMagicNumber()==MAGICMA)
         
    OrderClose(ticket,OrderLots(),Bid,3,Red);
         else break;
          }
                 
              
      
      }
     

    //+------------------------------------------------------------------+
    //| expert start function                                            |
    //+------------------------------------------------------------------+

    void start()
      {
    //----

      
    if(Bars<100||IsTradeAllowed()==false)return;
      if(
    CalculateCurrentOrders("EURUSD")==0)CheckForOpen();
      else 
    CheckForClose();
      
    //----
       //return;
      
    }

    //+------------------------------------------------------------------+ 
    ???

  2. #2

    Wink do search above for reverse

    Quote Originally Posted by darkkiller View Post
    Hi funyoo and other
    I cant figure out how to add on reverse order in EA..
    Hi darkkiller, have a look at a thread nearby about adding reverse function.

    Reverse system code

    Mr funyoo's logic made more sense to me and should be able to be fitted into your above ea with just a little work.
    Give it a go.

    cheers bt2

Similar Threads

  1. Replies: 2
    Last Post: 08-04-2014, 19:03
  2. Open oppsite order if order don't take profit
    By luisneves in forum MQL programming
    Replies: 0
    Last Post: 12-06-2012, 17:09
  3. Can you help with this reverse
    By rusty1975 in forum Ideas for expert advisors
    Replies: 4
    Last Post: 05-25-2010, 10:48
  4. Go/reverse
    By bellco in forum Ideas for expert advisors
    Replies: 7
    Last Post: 01-14-2010, 00:56
  5. Reverse D RSI SYS
    By asafc12345 in forum Expert advisors backtesting
    Replies: 0
    Last Post: 11-01-2009, 18:29

Tags for this Thread

100, add, alpari, eurusd, expert, funyoo, how to, index, main, mq4, mql, programming, sells, sma, software, stoch, stoploss, trailingstop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •