Results 1 to 6 of 6
 0 Attachment(s)    

Thread: Reverse system code

  1. #1

    Default Reverse system code

    Hi funyoo,

    If it's no trouble could educate me, on how to code the reverse system that you have in the EA's please.

    Thanks in advance.

  2. #2

    Default

    Hi funyoo,

    Here's a code for a pending order EA, I think it's based on daily timeframe. Could you code in the reverse system. Looks pretty simple but tried codeing your part but don't seem to work maybe you could plug it in

    Cheers.

    if(Hour() == StartHour)
    {
    if(TradeTime != iTime(NULL,PERIOD_D1,0))
    {
    TradeTime = iTime(NULL,PERIOD_D1,0);

    double BuyStop = Open[0]+Trap*Point;
    double SellStop = Open[0]-Trap*Point;

    Ticket = OrderSend(Symbol(),OP_BUYSTOP,LotsMM,BuyStop,3,Buy Stop-StopLoss*Point,BuyStop+TakeProfit*Point,NULL,Magic ,TradeTime+EndHour*60*60,Blue);
    Ticket = OrderSend(Symbol(),OP_SELLSTOP,LotsMM,SellStop,3,S ellStop+StopLoss*Point,SellStop-TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*6 0,Red);
    }
    }



    for(i=0; i<OrdersTotal(); i++)
    {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false ) break;
    if(OrderMagicNumber()!=Magic || OrderSymbol()!=Symbol()) continue;


    if(OrderSymbol()==Symbol())
    {
    if(OrderType()==OP_BUY)
    {
    if(Bid-OrderOpenPrice()>SteppingStop*Point)
    {
    if(OrderStopLoss()<OrderOpenPrice())
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice()+PipsProtect*Point,0,Yellow);
    }
    }
    if(Bid-OrderOpenPrice()>TrailingStop*Point)
    {
    if(OrderStopLoss()<Bid-TrailingStop*Point)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(TrailingStop-PipsProtect)*Point,0,White);
    return(0);
    }
    }
    }
    if(OrderType()==OP_SELL)
    {
    if(OrderOpenPrice()-Ask>SteppingStop*Point)
    {
    if(OrderStopLoss()>OrderOpenPrice())
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice()-PipsProtect*Point,0,Yellow);
    }
    }
    if(OrderOpenPrice()-Ask>TrailingStop*Point)
    {
    if(OrderStopLoss()>Ask+TrailingStop*Point)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Tr ailingStop-PipsProtect)*Point,0,White);
    return(0);
    }
    }
    }
    if(TimeCurrent()>TradeTime+EndHour*60*60)
    {
    if(OrderType() == OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,3,Magenta );
    if(OrderType() == OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,Magenta );
    }
    }
    }
    //----


    return(0);
    }

  3. #3
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    In the extern parameters add :

    Code:
    extern bool ReverseSystem=false;
    Then replace this :

    Code:
    double BuyStop = Open[0]+Trap*Point;
    double SellStop = Open[0]-Trap*Point;
    
    Ticket = OrderSend(Symbol(),OP_BUYSTOP,LotsMM,BuyStop,3,BuyStop-StopLoss*Point,BuyStop+TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*60,Blue);
    Ticket = OrderSend(Symbol(),OP_SELLSTOP,LotsMM,SellStop,3,SellStop+StopLoss*Point,SellStop-TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*6 0,Red);
    By :

    Code:
    if(ReverseSystem) {
    
    double BuyLimit = Open[0]-Trap*Point;
    double SellLimit = Open[0]+Trap*Point;
      
    Ticket = OrderSend(Symbol(),OP_BUYLIMIT,LotsMM,BuyLimit,3,BuyLimit-StopLoss*Point,BuyLimit+TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*60,Blue);
    Ticket = OrderSend(Symbol(),OP_SELLLIMIT,LotsMM,SellLimit,3,SellLimit+StopLoss*Point,SellLimit-TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*6 0,Red);
    
    }
    
    else {
    
    double BuyStop = Open[0]+Trap*Point;
    double SellStop = Open[0]-Trap*Point;
     
    Ticket = OrderSend(Symbol(),OP_BUYSTOP,LotsMM,BuyStop,3,BuyStop-StopLoss*Point,BuyStop+TakeProfit*Point,NULL,Magic ,TradeTime+EndHour*60*60,Blue);
    Ticket = OrderSend(Symbol(),OP_SELLSTOP,LotsMM,SellStop,3,SellStop+StopLoss*Point,SellStop-TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*6 0,Red);
    
    }

  4. #4

    Default

    Thanks funyoo could you slot in the hedge coding with the SL and TP, might be a better strategy. Thanks again.

  5. #5

    Default

    Hi funyoo when you have time, could you slot in your usual hedge code that you use in your other EA's with TP and SL into this coding. Thanks again.

    if(Hour() == StartHour)
    {
    if(TradeTime != iTime(NULL,PERIOD_D1,0))
    {
    TradeTime = iTime(NULL,PERIOD_D1,0);

    double BuyStop = Open[0]+Trap*Point;
    double SellStop = Open[0]-Trap*Point;

    Ticket = OrderSend(Symbol(),OP_BUYSTOP,LotsMM,BuyStop,3,Buy Stop-StopLoss*Point,BuyStop+TakeProfit*Point,NULL,Magic ,TradeTime+EndHour*60*60,Blue);
    Ticket = OrderSend(Symbol(),OP_SELLSTOP,LotsMM,SellStop,3,S ellStop+StopLoss*Point,SellStop-TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*6 0,Red);
    }
    }



    for(i=0; i<OrdersTotal(); i++)
    {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false ) break;
    if(OrderMagicNumber()!=Magic || OrderSymbol()!=Symbol()) continue;


    if(OrderSymbol()==Symbol())
    {
    if(OrderType()==OP_BUY)
    {
    if(Bid-OrderOpenPrice()>SteppingStop*Point)
    {
    if(OrderStopLoss()<OrderOpenPrice())
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice()+PipsProtect*Point,0,Yellow);
    }
    }
    if(Bid-OrderOpenPrice()>TrailingStop*Point)
    {
    if(OrderStopLoss()<Bid-TrailingStop*Point)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(TrailingStop-PipsProtect)*Point,0,White);
    return(0);
    }
    }
    }
    if(OrderType()==OP_SELL)
    {
    if(OrderOpenPrice()-Ask>SteppingStop*Point)
    {
    if(OrderStopLoss()>OrderOpenPrice())
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice()-PipsProtect*Point,0,Yellow);
    }
    }
    if(OrderOpenPrice()-Ask>TrailingStop*Point)
    {
    if(OrderStopLoss()>Ask+TrailingStop*Point)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Tr ailingStop-PipsProtect)*Point,0,White);
    return(0);
    }
    }
    }
    if(TimeCurrent()>TradeTime+EndHour*60*60)
    {
    if(OrderType() == OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,3,Magenta );
    if(OrderType() == OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,Magenta );
    }
    }
    }
    //----


    return(0);
    }

  6. #6
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Hi claypot,

    For pending orders, it is not the same usual code. You have to do that !

    In the extern parameters add this :

    Code:
    extern bool Hedge=false;
    After that :

    Code:
    Ticket = OrderSend(Symbol(),OP_BUYSTOP,LotsMM,BuyStop,3,Buy Stop-StopLoss*Point,BuyStop+TakeProfit*Point,NULL,Magic ,TradeTime+EndHour*60*60,Blue);
    Ticket = OrderSend(Symbol(),OP_SELLSTOP,LotsMM,SellStop,3,S ellStop+StopLoss*Point,SellStop-TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*6 0,Red);
    Add this :

    Code:
    if(Hedge)
    {
        Ticket = OrderSend(Symbol(),OP_SELLLIMIT,LotsMM,BuyStop,3,Buy Stop+StopLoss*Point,BuyStop-TakeProfit*Point,NULL,Magic ,TradeTime+EndHour*60*60,Blue);
        Ticket = OrderSend(Symbol(),OP_BUYLIMIT,LotsMM,SellStop,3,S ellStop-StopLoss*Point,SellStop+TakeProfit*Point,NULL,Magic,TradeTime+EndHour*60*6 0,Red);
    }

Similar Threads

  1. Help reverse this code
    By 100pipsv3.1[1]ea in forum Ideas for expert advisors
    Replies: 0
    Last Post: 08-13-2012, 12:32
  2. Reverse When In DD
    By Pheniox in forum Ideas for expert advisors
    Replies: 1
    Last Post: 12-27-2010, 19:34
  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. Need to learn to 'reverse system'
    By newboy in forum MQL programming
    Replies: 0
    Last Post: 03-07-2010, 05:29
  5. Reverse
    By srahmat in forum Ideas for expert advisors
    Replies: 1
    Last Post: 08-12-2009, 11:31

Tags for this Thread

coding, funyoo, hedge, how to, magic, sells, simple, stoploss, strategy, system, time, 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
  •