Mon compte
Déjà membre ? S'identifier
Non inscrit ? S'inscrire
 
+ Répondre à la discussion
Affichage des résultats 1 à 2 sur 2
  1. #1
    Membre lvl 50 dany31000 est sur la route de la réputation...
    Date d'inscription
    November 2009
    Messages
    52
    Pouvoir de réputation
    5

    fonctionne pas trailingStop ET Breakeven fonctionne pas trailingStop ET Breakeven

    bonjours a tous,

    j'ai un probleme mon tralingStop et le breakEven ne fonction pas quelque a une idée ?
    Dernière modification par dany31000 ; 05/12/2010 à 16h10.

  2. #2
    Membre lvl 50 dany31000 est sur la route de la réputation...
    Date d'inscription
    November 2009
    Messages
    52
    Pouvoir de réputation
    5

    SVP Un coup d'oeil  pourquoi le trailing ne marche pas ni breakeven SVP Un coup d'oeil pourquoi le trailing ne marche pas ni breakeven

    Citation Envoyé par dany31000 Voir le message
    bonjours a tous,

    j'ai un probleme mon tralingStop et le breakEven ne fonction pas quelque a une idée ?

    /*-----------------------------+
    | |
    | Shared by Aptrafx.com |
    | |
    +------------------------------*/

    //+------------------------------------------------------------------+
    //| Hi_Buy_Lo_Sell |
    //|This EA will take the previous bar hi and low, set a stop buy on |
    //|the high price, set a stop sell at the low price, and close |
    //|pending trades at EOD. |
    //+------------------------------------------------------------------+

    //---- input parameters
    extern int EOD=24;
    extern int BreakEven=60;
    extern int StopLoss=250;
    extern int TrailingStopStep=60;
    extern int TakeProfit=300;
    extern double Lots=1;
    extern int Pips=5;
    extern int timeframe=0;

    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    //----
    int i,Ticket,LastOrderTime,StartTime,StartTime1,EODTim e,MN;

    //Settings for each currency pair. Copy "else if" to create more.
    if (!IsTesting()){
    if (Symbol()=="EURUSD"){
    StopLoss=20;
    BreakEven=50;
    TakeProfit=0;
    }
    else if (Symbol()=="GBPUSD"){
    StopLoss=20;
    BreakEven=50;
    TakeProfit=0;
    }
    else { //default
    StopLoss=20;
    BreakEven=50;
    TakeProfit=0;
    }
    }

    // Ron's mod for lot increasement based on StartingBalance
    // this will trade 1.0, then 1.1, then 1.2 etc as balance grows
    // or 0.9 then 0.8 then 0.7 as balance shrinks



    //Count time
    if(CurTime()==StrToTime("00:00")) {
    StartTime1=StrToTime("00:00");
    if(DayOfWeek()==5) EODTime=MathMin(StrToTime("22:55"),StrToTime(EOD+" :00"));
    else if (EOD==24) EODTime=StrToTime("23:59");
    else EODTime=StrToTime(EOD+":00")-60;
    }

    //Set orders
    if(CurTime()>=StartTime1 && CurTime()<StartTime1+300){
    MN=1;
    StartTime=StartTime1;
    SetOrders(MN,StartTime);
    }

    //Manage of open orders
    for (i=0;i<OrdersTotal();i++){
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(CurTime()<=GlobalVariableGet("LastOrderTime")+1 0) Sleep(10000);
    if(CurTime()>=EODTime){
    //if(OrderSymbol()==Symbol() && OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
    //if(OrderSymbol()==Symbol() && OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
    if(OrderSymbol()==Symbol() && OrderType()==OP_BUYSTOP) OrderDelete(OrderTicket());
    if(OrderSymbol()==Symbol() && OrderType()==OP_SELLSTOP) OrderDelete(OrderTicket());
    GlobalVariableSet("LastOrderTime",CurTime());
    }
    else {
    if(TrailingStopStep==0){ //move at break even ("BE") if profit>BE
    if(OrderSymbol()==Symbol() && OrderType()==OP_BUY){
    if(High[0]-OrderOpenPrice()>=BreakEven*Point && OrderStopLoss()!=OrderOpenPrice()){
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice(),OrderTakeProfit(),0,Green);
    GlobalVariableSet("LastOrderTime",CurTime());
    }
    }
    if(OrderSymbol()==Symbol() && OrderType()==OP_SELL){
    if(OrderOpenPrice()-Low[0]>=BreakEven*Point && OrderStopLoss()!=OrderOpenPrice()){
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice(),OrderTakeProfit(),0,Green);
    GlobalVariableSet("LastOrderTime",CurTime());
    }
    }
    }
    else { //use trailing stop
    if(OrderSymbol()==Symbol() && OrderType()==OP_BUY){
    if(High[0]-OrderStopLoss()>=(StopLoss+TrailingStopStep)*Point ){
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderSt opLoss()+TrailingStopStep*Point,OrderTakeProfit(), 0,Green);
    GlobalVariableSet("LastOrderTime",CurTime());
    }
    }
    if(OrderSymbol()==Symbol() && OrderType()==OP_SELL){
    if(OrderStopLoss()-Low[0]>=(StopLoss+TrailingStopStep)*Point){
    OrderModify(OrderTicket(),OrderOpenPrice(),OrderSt opLoss()-TrailingStopStep*Point,OrderTakeProfit(),0,Green);
    GlobalVariableSet("LastOrderTime",CurTime());
    }
    }
    }
    }
    }

    //Reset global variables at EOD
    if(CurTime()>=EODTime) GlobalVariablesDeleteAll();

    return(0);
    }
    //+------------------------------------------------------------------+

    int SetOrders(int MN,int StartTime){
    int i,Ticket,LastOrderTime,Bought=0,Sold=0,ShiftToStar t,ShiftToBeginOfRange,timeframe;
    double EntryLong,EntryShort,SLLong,SLShort,TPLong=0,TPSho rt=0;

    if(timeframe==0) {timeframe=Period();}
    //Determine entry and stop.
    EntryLong =High[1];
    EntryShort =Low[1];
    SLLong =MathMax(EntryLong-StopLoss*Point,EntryShort);
    SLShort =MathMin(EntryShort+StopLoss*Point,EntryLong);

    if (TakeProfit>0)
    {
    TPLong =EntryLong+TakeProfit*Point;
    TPShort =EntryShort-TakeProfit*Point;
    }

    //Check Orders
    for (i=0;i<OrdersTotal();i++)
    {
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol() && (OrderType()==OP_BUYSTOP) && OrderMagicNumber()==MN) OrderDelete(OrderTicket());
    if(OrderSymbol()==Symbol() && (OrderType()==OP_SELLSTOP) && OrderMagicNumber()==MN) OrderDelete(OrderTicket());
    }
    // if(Bought==0)
    // { //no buy order
    Ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,EntryLon g,3,SLLong,TPLong,"Hi_Buy_Lo_Sell",MN,0,Green);
    if(Ticket<0 && GetLastError()==130)
    Ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,SLLong ,TPLong,"Hi_Buy_Lo_Sell",MN,0,Green);
    GlobalVariableSet("LastOrderTime",OrderOpenTime()) ;
    // }
    // if(Sold==0)
    // { //no sell order
    Ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,EntrySh ort,3,SLShort,TPShort,"Hi_Buy_Lo_Sell",MN,0,Green) ;
    if(Ticket<0 && GetLastError()==130)
    Ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,SLSho rt,TPShort,"Hi_Buy_Lo_Sell",MN,0,Green);
    GlobalVariableSet("LastOrderTime",OrderOpenTime()) ;
    // }
    }

    ni le trailing stop marche , ni le breakeven ne marche quelqu'un a une idée ????

Discussions similaires

  1. Recherche EA Breakeven
    Par hanzooo dans le forum Systèmes de Trading Auto
    Réponses: 3
    Dernier message: 12/02/2010, 08h52
  2. Est ce que MT4 fonctionne en stand alone ?
    Par Tradator dans le forum Utilisation des Plateformes de Trading
    Réponses: 2
    Dernier message: 21/01/2010, 14h32
  3. Cherche Indicateur Breakeven
    Par CHNOPE dans le forum Trading Divers
    Réponses: 6
    Dernier message: 09/01/2010, 14h38
  4. Comment fonctionne QQE
    Par comeback dans le forum Trading Divers
    Réponses: 4
    Dernier message: 26/03/2009, 13h12
  5. TrailingStop
    Par un6oitil dans le forum Systèmes de Trading Auto
    Réponses: 1
    Dernier message: 27/10/2008, 20h47

Ajouter aux Favoris | Plan du site | Archives | Forex | Contact