Watch how to download trading robots for free
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

Trailing Function - script for MetaTrader 4

Kailash Bai Mina
Published by:
Kailash Bai Mina
Views:
1950
Rating:
votes: 18
Published:
2021.11.09 00:49
Updated:
2021.11.09 00:52

Function : 

//+------------------------------------------------------------------+
//|Trailing                                                          |
//+------------------------------------------------------------------+
void Trailing(int Trailing_Pips)
 {
  for(int i=OrdersTotal()-1; i>=0; i--)
   {
    if(OrderSelect(i,SELECT_BY_POS))
     {
      if(OrderType()==OP_BUY)
       {
        if(OrderStopLoss()>=OrderOpenPrice())
         {
          if(Bid-OrderStopLoss()>Trailing_Pips*Point()*10)
           {
            int OM = OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Trailing_Pips*Point()*10,OrderTakeProfit(),0);
           }
         }
        else
         {
          if(Bid-OrderOpenPrice()>=Trailing_Pips*Point()*10)
           {
            int OM = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0);
           }
         }
       }
      if(OrderType()==OP_SELL)
       {
        if(OrderStopLoss()<=OrderOpenPrice() && OrderStopLoss()!=0)
         {
          if(OrderStopLoss()-Bid>Trailing_Pips*Point()*10)
           {
            int OM = OrderModify(OrderTicket(),OrderOpenPrice(),Trailing_Pips*Point()*10+Bid,OrderTakeProfit(),0);
           }
         }
        else
         {
          if(OrderOpenPrice()-Bid>=Trailing_Pips*Point()*10)
           {
            int OM = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0);
           }
         }
       }
     }
   }
 }
    Correlation Calculator Panel Correlation Calculator Panel

    Calculator

    MyRsi with NET MyRsi with NET

    MyRsi with Noise Elimination Technology - by John Ehlers : metatrader 4 version

    Trailing Step Function Trailing Step Function

    This Is Just A Normal Trailing Step Function.

    DMH DMH

    Directional Movement using Hann windowing - metatrader 4 version