Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Facebook !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Experts

Trailing Stop by Fixed Parabolic SAR - expert pour MetaTrader 5

Vues:
8446
Note:
(38)
Publié:
2022.07.08 17:10
Mise à jour:
2022.07.08 18:03
Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

Modify to allow direct specification of the starting point of the Parabolic SAR.

Fixed Parabolic SAR


Parameters

param

  • Trailing Mode ・・・ None / Trailing Fixed / Trailing Fixed Parabolic SAR
calcuration part of Parabolic SAR

bool CSampleExpert::LongModifiedEx(void)
  {
   bool res=false;
//--- check for trailing stop
   if(m_trailing_max < m_last_bar.high)
     {
      double tp=m_position.TakeProfit();
      double sl=m_position.StopLoss();

      //--- calcurate ParabolicSAR
      m_trailing_max = m_last_bar.high;
      m_trailing_step = fmin(InpPSAR_Maximum, m_trailing_step + InpPSAR_Step);
      double sar_stop = sl + (m_trailing_max - sl)* m_trailing_step;
      sar_stop=NormalizeDouble(sar_stop,m_symbol.Digits());
      //---

      if((sl==0.0 || sl < sar_stop) && sar_stop < m_symbol.Bid())
        {
         //--- modify position
         if(m_trade.PositionModify(Symbol(),sar_stop,tp))
            printf("Long position by %s to be modified",Symbol());
         else
           {
            printf("Error modifying position by %s : '%s'",Symbol(),m_trade.ResultComment());
            printf("Modify parameters : SL=%f,TP=%f",sar_stop,tp);
           }
         //--- modified and must exit from expert
         res=true;
        }
     }
//--- result
   return(res);
  } 

    New Bar Event New Bar Event

    Allows you to determine the occurrence of a new bar event in a multicurrency Expert Advisor

    Two pending orders 2 Two pending orders 2

    Two pending orders at the beginning of the day

    Symbol Trade Made Simple With Functions Symbol Trade Made Simple With Functions

    This library shows useful informations and do a lot of functions to a symbol.

    The Predictive Moving Average The Predictive Moving Average

    The Predictive Moving Average was created by John Ehlers (“Rocket Science For Traders”, pg.212″).