Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12
 1 Attachment(s)    

Thread: Squeeze_Break EA

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

    Default

    Quote Originally Posted by paciola View Post
    Hi Funyoo
    yes it works very well, thank you.
    But I would like that the stop loss changes for every value og SMA 200, in every new bar. So in a long trend as the SMA rises the stop rises too.
    Is it possible technically?
    Hi paciola,

    Try this :

    Code:
    void movetrailingstop(){
       double sma200=iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,1);
       double ask=MarketInfo(Symbol(),MODE_ASK);
       double bid=MarketInfo(Symbol(),MODE_BID);
       int dg=MarketInfo(Symbol(),MODE_DIGITS);
       double pt=MarketInfo(Symbol(),MODE_POINT);
       int total=OrdersTotal();
       if(total>0){
          for(int i=0;i<total;i++){
             OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
             if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==magic){
                if(OrderType()==OP_BUY){
                   if(NormalizeDouble(ask,dg)>NormalizeDouble(sma200+15*pt,dg)
                   && (NormalizeDouble(OrderStopLoss(),dg)<NormalizeDouble(sma200,dg))||(OrderStopLoss()==0)){
                      OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(sma200,dg),OrderTakeProfit(),0,Blue);
                      return(0);
                   }
                }
                else{
                   if(NormalizeDouble(bid,dg)<NormalizeDouble(sma200-15*pt,dg)
                   && (NormalizeDouble(OrderStopLoss(),dg)>(NormalizeDouble(sma200,dg)))||(OrderStopLoss()==0)){                 
                      OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(sma200,dg),OrderTakeProfit(),0,Red);
                      return(0);
                   }
                }
             }
          }
       }
    }

  2. #12

    Default

    Thank you Funyoo
    you are a great man.
    Davide

Similar Threads

  1. Squeeze_Break.mq4 Expert Advisor
    By Salomonrule in forum Ideas for expert advisors
    Replies: 0
    Last Post: 01-02-2012, 14:50

Tags for this Thread

expert, funyoo, guide, how to, indicator, metatrader, mql, programming, sma, squeeze, stop, stoploss, thank you, time, trend

Posting Permissions

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