Trailing profit i Trailing step

O jezykach programowania w platformach i nie tylko.
maciejka
Bywalec
Bywalec
Posty: 18
Rejestracja: 28 kwie 2011, 21:00

Trailing profit i Trailing step

Nieprzeczytany post autor: maciejka »

Witam,

u jakich brokerów dostępnę są poniższe funkcje?

Trailing profit i Trailing step

Mam konto w XTB i chciałbym przetestować znaleziona w sieci strategie Ichimoku Kinko Hyo, ale niestety wywala mi błędy z powyższych powodów.

Dla chętnych wklejam link do strategii opartej o wartości Ichimoku Kinko Hyo

http://www.tradingsystemforex.com/exper ... er-ea.html

Awatar użytkownika
kris007
Pasjonat
Pasjonat
Posty: 551
Rejestracja: 23 sty 2008, 22:50

Nieprzeczytany post autor: kris007 »

oj coś kombinujesz :) strategia jest na mt4 i działa na mt4.
Poniżej image z testera

Osobiście mocno bym się zastanowił przed zapuszczeniem tej strategii na live.
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.

maciejka
Bywalec
Bywalec
Posty: 18
Rejestracja: 28 kwie 2011, 21:00

Nieprzeczytany post autor: maciejka »

Kris007 - dziękuję za szybka odpowiedź.
na jakiej platformie przetestowałeś ten EA?

w XTB wywala mi bład nr 4107 : http://www.earnforex.com/blog/2011/01/o ... cktesting/
podobno błąd ten występuje tylko podczas analizy historycznej. W demo i realu już nie.

oraz błąd nr 130 :http://www.earnforex.com/blog/2008/10/o ... hat-to-do/

znalazłem odpowiedź na te błędy w powyższych linkach, ale niestety nie mam wystarczającej wiedzy aby poprawić samodzielnie te błędy w programie.

Awatar użytkownika
Kenia
Gaduła
Gaduła
Posty: 145
Rejestracja: 29 cze 2010, 18:12

Nieprzeczytany post autor: Kenia »

maciejka pisze:błąd nr 130
zacznij od tego aby podnieść Take Profit, Trailing Stop lub Stop Loss do sensownej wartości. brokerzy zabezpieczają się przed skalperami stosując minimalną wartość tych parametrów. Jesli masz niżej to tester nie może wykonać działania.
maciejka pisze: XTB wywala mi bład nr 4107
nie znam XTB ale chodzi o 4 lub 5 cyfr po przecinku. kwotowanie do 4 cyfr TP,TS, SL co najmniej 10, kwotowanie do 5 cyfr, TP, TS, SL co najmniej 100(nie 95 lub 105 ale okrągłe dziesiątki)

Awatar użytkownika
kris007
Pasjonat
Pasjonat
Posty: 551
Rejestracja: 23 sty 2008, 22:50

Nieprzeczytany post autor: kris007 »

maciejka pisze:Kris007 - dziękuję za szybka odpowiedź.
na jakiej platformie przetestowałeś ten EA?
na xtb, patrz lewy dolny róg image, ustawienia z pliku .set, ustawienia są dla 4 cyfr.

maciejka
Bywalec
Bywalec
Posty: 18
Rejestracja: 28 kwie 2011, 21:00

Nieprzeczytany post autor: maciejka »

Witam,

poniżej wkleiłem moje ustawienia.
nie wiem gdzie robię błąd, bo dalej mam błąd nr 130
na czerwono wkleiłem wartości, które korygowałem.

z góry dziękuje za pomoc.

Kod: Zaznacz cały

#property copyright "Copyright ˆ 2009, TradingSytemForex"
#property link "http://www.tradingsystemforex.com"

//|----------------------------------------------you can modify this expert
//|----------------------------------------------you can change the name
//|----------------------------------------------you can add "modified by you"
//|----------------------------------------------but you are not allowed to erase the copyrights

#define EAName "Cronex TDM EA"

extern string S1a="---------------- TF1 Settings";

bool TradeAsLongAs=false;
extern int TimeFrame1=0;
extern int TF1Tenkan=9;
extern int TF1Kijun=26;
extern int TF1Senkou=52;
extern int TF1FlatSE=7;
extern int TF1DeMarker=25;
extern int TF1FastMA=14;
extern int TF1SlowMA=25;
extern double MaxPriceRange=40;
extern int OpenShift=10;
extern double GapPips=60;

extern string S1b="---------------- TF2 Settings";

extern int TimeFrame2=30;
extern int TF2Tenkan=9;
extern int TF2Kijun=26;
extern int TF2Senkou=52;
extern int TF2FlatSE=7;
extern int TF2DeMarker=25;
extern int TF2FastMA=14;
extern int TF2SlowMA=25;

extern string S1c="---------------- TF3 Settings";

extern int TimeFrame3=15;
extern double MinATRRange=5;
extern int ATRPeriod=14;

extern string S2="---------------- Money Management";

extern double Lots=0.1;//|-----------------------lots size
extern bool RiskMM=false;//|---------------------risk management
extern double RiskPercent=1;//|------------------risk percentage
extern bool Martingale=false;//|-----------------martingale
extern double Multiplier=2.0;//|-----------------multiplier martingale
extern double MinLots=0.1;//|-------------------minlots
extern double MaxLots=100;//|--------------------maxlots

/*
extern bool BasketProfitLoss=false;//|-----------use basket loss/profit
extern int BasketProfit=100000;//|---------------if equity reaches this level, close trades
extern int BasketLoss=9999;//|-------------------if equity reaches this negative level, close trades
*/

extern string S3="---------------- Order Management";

extern int StopLoss=5;//|------------------------stop loss
extern int TakeProfit=5;//|----------------------take profit
extern bool HideSL=false;//|---------------------hide stop loss
extern bool HideTP=false;//|---------------------hide take profit
extern int TrailingProfit=[color=red]15[/color];//|------------------trailing stop after profit reached // [color=red]było 0[/color]
extern int TrailingStop=15;//|--------------------trailing stop //[color=red] było 0[/color]
extern int TrailingStep=15;//|--------------------trailing step//[b] było 0[/b]
extern int BreakEven=0;//|-----------------------break even
extern int MaxOrders=100;//|---------------------maximum orders allowed
extern int Slippage=3;//|------------------------slippage
extern int Magic=2009;//|------------------------magic number

/*
extern string S4="---------------- MA Filter";

extern bool MAFilter=false;//|-------------------moving average filter
extern int MAPeriod=20;//|-----------------------ma filter period
extern int MAMethod=0;//|------------------------ma filter method
extern int MAPrice=0;//|-------------------------ma filter price
*/

extern string S5="---------------- Time Filter";

extern bool TradeOnSunday=true;//|---------------time filter on sunday
extern bool MondayToThursdayTimeFilter=false;//|-time filter the week
extern int MondayToThursdayStartHour=0;//|-------start hour time filter the week
extern int MondayToThursdayEndHour=24;//|--------end hour time filter the week
extern bool FridayTimeFilter=false;//|-----------time filter on friday
extern int FridayStartHour=0;//|-----------------start hour time filter on friday
extern int FridayEndHour=21;//|------------------end hour time filter on friday

extern string S6="---------------- Extras";

extern bool Hedge=false;//|----------------------enter an opposite trade
extern int HedgeSL=0;//|-------------------------stop loss
extern int HedgeTP=0;//|-------------------------take profit
extern bool ReverseSystem=false;//|--------------buy instead of sell, sell instead of buy

/*
extern bool ReverseAtStop=false;//|--------------buy instead of sell, sell instead of buy
extern int Expiration=240;//|--------------------expiration in minute for the reverse pending order
extern bool Comments=true;//|--------------------allow comments on chart
*/

datetime PreviousBarTime1;
datetime PreviousBarTime2;

double maxEquity,minEquity,Balance=0.0;
double LotsFactor=1;
double InitialLotsFactor=1;
int digits;
double point;

//|---------initialization

int init()
{
   //|---------martingale initialization
  
   int tempfactor,total=OrdersTotal();
   if(tempfactor==0 && total>0)
   {
      for(int cnt=0;cnt<total;cnt++)
      {
         if(OrderSelect(cnt,SELECT_BY_POS))
         {
            if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
            {
               tempfactor=NormalizeDouble(OrderLots()/Lots,1+(MarketInfo(Symbol(),MODE_MINLOT)==0.1));// [color=red]było 0.01[/color]
               break;
            }
         }
      }
   }
   int histotal=OrdersHistoryTotal();

   if(tempfactor==0&&histotal>0)
   {
      for(cnt=0;cnt<histotal;cnt++)
      {
         if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY))
         {
            if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
            {
               tempfactor=NormalizeDouble(OrderLots()/Lots,1+(MarketInfo(Symbol(),MODE_MINLOT)==0.1));// [color=red]było 0.01[/color]
               break;
            }
         }
      }
   }
   
   if(tempfactor>0)
   LotsFactor=tempfactor;
   
   if(Digits<4)
   {
      point=0.01;
      digits=2;
   }
   else
   {
      point=0.0001; // [color=red]nie wiem czy ta wartośc jest OK[/color]
      digits=4;
   }

   /*if(Comments)Comment("\nLoading...");*/
   return(0);
}

//|---------deinitialization

/*int deinit()
{
  return(0);
}*/

int start()
{

//|---------trailing stop

   if(TrailingStop>0)MoveTrailingStop();

//|---------break even

   if(BreakEven>0)MoveBreakEven();
   
/*
//|---------basket profit loss

   if(BasketProfitLoss)
   {
      double CurrentProfit=0,CurrentBasket=0;
      CurrentBasket=AccountEquity()-AccountBalance();
      if(CurrentBasket>maxEquity)maxEquity=CurrentBasket;
      if(CurrentBasket<minEquity)minEquity=CurrentBasket;
      if(CurrentBasket>=BasketProfit||CurrentBasket<=(BasketLoss*(-1)))
      {
         CloseBuyOrders(Magic);
         CloseSellOrders(Magic);
         return(0);
      }
   }
*/

//|---------signal conditions

   int limit=1;
   for(int i=1;i<=limit;i++)
   {
   
/*
   //|---------moving average filter

      double MAF=iMA(Symbol(),0,MAPeriod,0,MAMethod,MAPrice,i);

      bool MABUY=false;bool MASELL=false;

      if((MAFilter==false)||(MAFilter&&Bid>MAF))MABUY=true;
      if((MAFilter==false)||(MAFilter&&Ask<MAF))MASELL=true;


   //|---------last price
   
      double LastBuyOpenPrice=0;
      double LastSellOpenPrice=0;
      int BuyOpenPosition=0;
      int SellOpenPosition=0;
      int TotalOpenPosition=0;
      int cnt=0;

      for(cnt=0;cnt<OrdersTotal();cnt++) 
      {
         OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic&&OrderCloseTime()==0) 
         {
            TotalOpenPosition++;
            if(OrderType()==OP_BUY) 
            {
               BuyOpenPosition++;
               LastBuyOpenPrice=OrderOpenPrice();
            }
            if(OrderType()==OP_SELL) 
            {
               SellOpenPosition++;
               LastSellOpenPrice=OrderOpenPrice();
            }
         }
      }
*/
   //|---------main signal

      double CTS=iCustom(Symbol(),TimeFrame1,"Cronex Taichi",TF1Tenkan,TF1Kijun,TF1Senkou,TF1FlatSE,0,i);
      double CTR=iCustom(Symbol(),TimeFrame1,"Cronex Taichi",TF1Tenkan,TF1Kijun,TF1Senkou,TF1FlatSE,1,i);
      double CTL=iCustom(Symbol(),TimeFrame1,"Cronex Taichi",TF1Tenkan,TF1Kijun,TF1Senkou,TF1FlatSE,2,i);
      double CTD=iCustom(Symbol(),TimeFrame1,"Cronex Taichi",TF1Tenkan,TF1Kijun,TF1Senkou,TF1FlatSE,3,i);
      
      double CDS=iCustom(Symbol(),TimeFrame1,"Cronex DeMarker",TF1DeMarker,TF1FastMA,TF1SlowMA,0,i);
      double CDR=iCustom(Symbol(),TimeFrame1,"Cronex DeMarker",TF1DeMarker,TF1FastMA,TF1SlowMA,1,i);
      double CDB=iCustom(Symbol(),TimeFrame1,"Cronex DeMarker",TF1DeMarker,TF1FastMA,TF1SlowMA,2,i);
      
      double CTS5=iCustom(Symbol(),TimeFrame2,"Cronex Taichi",TF2Tenkan,TF2Kijun,TF2Senkou,TF2FlatSE,0,i);
      double CTR5=iCustom(Symbol(),TimeFrame2,"Cronex Taichi",TF2Tenkan,TF2Kijun,TF2Senkou,TF2FlatSE,1,i);
      double CTL5=iCustom(Symbol(),TimeFrame2,"Cronex Taichi",TF2Tenkan,TF2Kijun,TF2Senkou,TF2FlatSE,2,i);
      double CTD5=iCustom(Symbol(),TimeFrame2,"Cronex Taichi",TF2Tenkan,TF2Kijun,TF2Senkou,TF2FlatSE,3,i);
      
      double CDS5=iCustom(Symbol(),TimeFrame2,"Cronex DeMarker",TF2DeMarker,TF2FastMA,TF2SlowMA,0,i);
      double CDR5=iCustom(Symbol(),TimeFrame2,"Cronex DeMarker",TF2DeMarker,TF2FastMA,TF2SlowMA,1,i);
      double CDB5=iCustom(Symbol(),TimeFrame2,"Cronex DeMarker",TF2DeMarker,TF2FastMA,TF2SlowMA,2,i);
      
      double ATR=iATR(NULL,TimeFrame3,ATRPeriod,i);
      
      
      bool BUY=false;
      bool SELL=false;

      if(
      CTS>CTR&&CTS>CTD&&CDS>CDB&&CDB>CDR
      &&CTS5>CTR5&&CTS5>CTD5&&CDS5>CDB5&&CDB5>CDR5
      &&(iClose(Symbol(),TimeFrame1,i)-iClose(Symbol(),TimeFrame1,i+OpenShift))<(MaxPriceRange*point)
      &&ATR>MinATRRange*point
      )BUY=true;
      if(
      CTS<CTL&&CTS<CTD&&CDS<CDB&&CDB<CDR
      &&CTS5<CTL5&&CTS5<CTD5&&CDS5<CDB5&&CDB5<CDR5
      &&(iClose(Symbol(),TimeFrame1,i+OpenShift)-iClose(Symbol(),TimeFrame1,i))<(MaxPriceRange*point)
      &&ATR>MinATRRange*point
      )SELL=true;
      
      bool SignalBUY=false;
      bool SignalSELL=false;
      
      if(BUY/*&&MABUY*/)if(ReverseSystem)SignalSELL=true;else SignalBUY=true;
      if(SELL/*&&MASELL*/)if(ReverseSystem)SignalBUY=true;else SignalSELL=true;
      
   }

//|---------risk management

   if(RiskMM)CalculateMM();


//|---------close orders
   
   if(Hedge==false&&SELL)
   {
      if(ReverseSystem)CloseSellOrders(Magic);else CloseBuyOrders(Magic);
   }
   if(Hedge==false&&BUY)
   {
      if(ReverseSystem)CloseBuyOrders(Magic);else CloseSellOrders(Magic);
   }
   
   //|---------hidden sl-tp
   
   if(Hedge==false&&HideSL&&StopLoss>0)
   {
      CloseBuyOrdersHiddenSL(Magic);CloseSellOrdersHiddenSL(Magic);
   }
   if(Hedge==false&&HideTP&&TakeProfit>0)
   {
      CloseBuyOrdersHiddenTP(Magic);CloseSellOrdersHiddenTP(Magic);
   }
   
//|---------time filter

   if((TradeOnSunday==false&&DayOfWeek()==0)||(MondayToThursdayTimeFilter&&DayOfWeek()>=1&&DayOfWeek()<=4&&!(Hour()>=MondayToThursdayStartHour&&Hour()<MondayToThursdayEndHour))||(FridayTimeFilter&&DayOfWeek()==5&&!(Hour()>=FridayStartHour&&Hour()<FridayEndHour)))
   {
      return(0);
   }
   
//|---------open orders

   double SL,TP,SLH,TPH,SLP,TPP,OPP,ILots;
   int Ticket,TicketH,TicketP,Expire=0;
   /*if(Expiration>0)Expire=TimeCurrent()+(Expiration*60)-5;*/

   if((CountOrders(OP_BUY,Magic)+CountOrders(OP_SELL,Magic))<MaxOrders)
   {  
      if((SignalBUY&&((TradeAsLongAs==false && NewBarBuy())||(TradeAsLongAs)))/*||(SignalBUY&&CountOrders(OP_BUY,Magic)<1)*/)
      {
         if(HideSL==false&&StopLoss>0){SL=Ask-StopLoss*point;/*OPP=Bid-StopLoss*point;SLP=Bid;*/}else {SL=0;/*SLP=0;*/}
         if(HideTP==false&&TakeProfit>0){TP=Ask+TakeProfit*point;/*TPP=Bid-(TakeProfit*2)*point;*/}else {TP=0;/*TPP=0;*/}
         if(HideSL==false&&HedgeSL>0)SLH=Bid+HedgeSL*point;else SLH=0;
         if(HideTP==false&&HedgeTP>0)TPH=Bid-HedgeTP*point;else TPH=0;
         if(Martingale)ILots=NormalizeDouble(Lots*MartingaleFactor(),2);else ILots=Lots;
         if(ILots<MinLots)ILots=MinLots;if(ILots>MaxLots)ILots=MaxLots;
         
         Ticket=OrderSend(Symbol(),OP_BUY,ILots,Ask,Slippage,SL,TP,EAName,Magic,0,Blue);
         if(Hedge)TicketH=OrderSend(Symbol(),OP_SELL,ILots,Bid,Slippage,SLH,TPH,EAName,Magic,0,Red);
         /*if(ReverseAtStop&&StopLoss>0)TicketP=OrderSend(Symbol(),OP_SELLSTOP,Lots,OPP,Slippage,SLP,TPP,EAName,Magic,Expire,Red);*/
      }
      if((SignalSELL&&((TradeAsLongAs==false && NewBarSell())||(TradeAsLongAs)))/*||(SignalSELL&&CountOrders(OP_SELL,Magic)<1)*/)
      {
         if(HideSL==false&&StopLoss>0){SL=Bid+StopLoss*point;/*OPP=Ask+StopLoss*point;SLP=Ask;*/}else {SL=0;/*SLP=0;*/}
         if(HideTP==false&&TakeProfit>0){TP=Bid-TakeProfit*point;/*TPP=Ask+(TakeProfit*2)*point;*/}else {TP=0;/*TPP=0;*/}
         if(HideSL==false&&HedgeSL>0)SLH=Ask-HedgeSL*point;else SLH=0;
         if(HideTP==false&&HedgeTP>0)TPH=Ask+HedgeTP*point;else TPH=0;
         if(Martingale)ILots=NormalizeDouble(Lots*MartingaleFactor(),2);else ILots=Lots;
         if(ILots<MinLots)ILots=MinLots;if(ILots>MaxLots)ILots=MaxLots;
         
         Ticket=OrderSend(Symbol(),OP_SELL,ILots,Bid,Slippage,SL,TP,EAName,Magic,0,Red);
         if(Hedge)TicketH=OrderSend(Symbol(),OP_BUY,ILots,Ask,Slippage,SLH,TPH,EAName,Magic,0,Blue);
         /*if(ReverseAtStop&&StopLoss>0)TicketP=OrderSend(Symbol(),OP_BUYSTOP,Lots,OPP,Slippage,SLP,TPP,EAName,Magic,Expire,Red);*/
      }
   }

//|---------not enough money warning

   int err=0;
   if(Ticket<0)
   {
      if(GetLastError()==134)
      {
         err=1;
         Print("Not enough money!");
      }
      return (-1);
   }
   
/*
   if(Comments)
   {
      Comment("\nCopyright ˆ 2009, TradingSytemForex",
              "\n\nL o t s                   =  " + DoubleToStr(Lots,2),
              "\nB a l a n c e         =  " + DoubleToStr(AccountBalance(),2),
              "\nE q u i t y            =  " + DoubleToStr(AccountEquity(),2));
   }
*/

   return(0);
}

//|---------close buy orders

int CloseBuyOrders(int Magic)
{
  int total=OrdersTotal();

  for (int cnt=total-1;cnt>=0;cnt--)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUY)
      {
        OrderClose(OrderTicket(),OrderLots(),Bid,3);
      }
    }
  }
  return(0);
}

int CloseBuyOrdersHiddenTP(int Magic)
{
  int total=OrdersTotal();

  for (int cnt=total-1;cnt>=0;cnt--)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUY&&Bid>(OrderOpenPrice()+TakeProfit*point))
      {
        OrderClose(OrderTicket(),OrderLots(),Bid,3);
      }
    }
  }
  return(0);
}

int CloseBuyOrdersHiddenSL(int Magic)
{
  int total=OrdersTotal();

  for (int cnt=total-1;cnt>=0;cnt--)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_BUY&&Bid<(OrderOpenPrice()-StopLoss*point))
      {
        OrderClose(OrderTicket(),OrderLots(),Bid,3);
      }
    }
  }
  return(0);
}

//|---------close sell orders

int CloseSellOrders(int Magic)
{
  int total=OrdersTotal();

  for(int cnt=total-1;cnt>=0;cnt--)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_SELL)
      {
        OrderClose(OrderTicket(),OrderLots(),Ask,3);
      }
    }
  }
  return(0);
}


int CloseSellOrdersHiddenTP(int Magic)
{
  int total=OrdersTotal();

  for(int cnt=total-1;cnt>=0;cnt--)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_SELL&&Ask<(OrderOpenPrice()-TakeProfit*point))
      {
        OrderClose(OrderTicket(),OrderLots(),Ask,3);
      }
    }
  }
  return(0);
}

int CloseSellOrdersHiddenSL(int Magic)
{
  int total=OrdersTotal();

  for(int cnt=total-1;cnt>=0;cnt--)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
    {
      if(OrderType()==OP_SELL&&Ask>(OrderOpenPrice()+StopLoss*point))
      {
        OrderClose(OrderTicket(),OrderLots(),Ask,3);
      }
    }
  }
  return(0);
}

//|---------count orders

int CountOrders(int Type,int Magic)
{
   int _CountOrd;
   _CountOrd=0;
   for(int i=0;i<OrdersTotal();i++)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol())
      {
         if((OrderType()==Type&&(OrderMagicNumber()==Magic)||Magic==0))_CountOrd++;
      }
   }
   return(_CountOrd);
}

//|---------trailing stop

void MoveTrailingStop()
{
   int cnt,total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
   {
      OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
      {
         if(OrderType()==OP_BUY)
         {
            if(TrailingStop>0&&Ask>NormalizeDouble(OrderOpenPrice()+TrailingProfit*point,digits))  
            {                 
               if((NormalizeDouble(OrderStopLoss(),digits)<NormalizeDouble(Bid-point*(TrailingStop+TrailingStep),digits))||(OrderStopLoss()==0))
               {
                  OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-point*TrailingStop,digits),OrderTakeProfit(),0,Blue);
                  return(0);
               }
            }
         }
         else 
         {
            if(TrailingStop>0&&Bid<NormalizeDouble(OrderOpenPrice()-TrailingProfit*point,digits))  
            {                 
               if((NormalizeDouble(OrderStopLoss(),digits)>(NormalizeDouble(Ask+point*(TrailingStop+TrailingStep),digits)))||(OrderStopLoss()==0))
               {
                  OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+point*TrailingStop,digits),OrderTakeProfit(),0,Red);
                  return(0);
               }
            }
         }
      }
   }
}

//|---------break even

void MoveBreakEven()
{
   int cnt,total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
   {
      OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()<=OP_SELL&&OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
      {
         if(OrderType()==OP_BUY)
         {
            if(BreakEven>0)
            {
               if(NormalizeDouble((Bid-OrderOpenPrice()),digits)>BreakEven*point)
               {
                  if(NormalizeDouble((OrderStopLoss()-OrderOpenPrice()),digits)<0)
                  {
                     OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+0*point,digits),OrderTakeProfit(),0,Blue);
                     return(0);
                  }
               }
            }
         }
         else
         {
            if(BreakEven>0)
            {
               if(NormalizeDouble((OrderOpenPrice()-Ask),digits)>BreakEven*point)
               {
                  if(NormalizeDouble((OrderOpenPrice()-OrderStopLoss()),digits)<0)
                  {
                     OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-0*point,digits),OrderTakeProfit(),0,Red);
                     return(0);
                  }
               }
            }
         }
      }
   }
}

//|---------allow one action per bar

bool NewBarBuy()
{
   if(PreviousBarTime1<Time[0])
   {
      PreviousBarTime1=Time[0];
      return(true);
   }
   return(false);
}

bool NewBarSell()
{
   if(PreviousBarTime2<Time[0])
   {
      PreviousBarTime2=Time[0];
      return(true);
   }
   return(false);
}

//|---------calculate money management

void CalculateMM()
{
   double MinLots=MarketInfo(Symbol(),MODE_MINLOT);
   double MaxLots=MarketInfo(Symbol(),MODE_MAXLOT);
   Lots=AccountFreeMargin()/100000*RiskPercent;
   Lots=MathMin(MaxLots,MathMax(MinLots,Lots));
   if(MinLots<0.1)Lots=NormalizeDouble(Lots,2);
   else
   {
     if(MinLots<1)Lots=NormalizeDouble(Lots,1);
     else Lots=NormalizeDouble(Lots,0);
   }
   if(Lots<MinLots)Lots=MinLots;
   if(Lots>MaxLots)Lots=MaxLots;
   return(0);
}

//|---------martingale

int MartingaleFactor()
{
   int histotal=OrdersHistoryTotal();
   if (histotal>0)
   {
      for(int cnt=histotal-1;cnt>=0;cnt--)
      {
         if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY))
         {
            if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
            {
               if(OrderProfit()<0)
               {
                  LotsFactor=LotsFactor*Multiplier;
                  return(LotsFactor);
               }
               else
               {
                  LotsFactor=InitialLotsFactor;
                  if(LotsFactor<=0)
                  {
                     LotsFactor=1;
                  }
                  return(LotsFactor);
               }
            }
         }
      }
   }
   return(LotsFactor);
}
Ostatnio zmieniony 02 maja 2011, 11:44 przez maciejka, łącznie zmieniany 1 raz.

Awatar użytkownika
Kenia
Gaduła
Gaduła
Posty: 145
Rejestracja: 29 cze 2010, 18:12

Nieprzeczytany post autor: Kenia »

przetestowałem twój EA na M5 EURUSD, faktycznie generuje błąd 130 (3 razy).
przetestowałem także jeszcze raz ten wklejony link z pierwszego postu i działa, nie generuje błędu (3 transakcje w tym 1 zamknieta, 2 otwarte). Sprobuj porównać parametry domyślne z tymi przez Ciebie zastosowanymi

Awatar użytkownika
siersciuch
Pasjonat
Pasjonat
Posty: 407
Rejestracja: 06 kwie 2010, 20:31

Nieprzeczytany post autor: siersciuch »

maciejka edytuj swojego posta, zaznacz cały kod i kliknij guzik "Code", bedzie przejrzyściej
jeżeli będziesz uparty, prawdopodobnie częściej odniesiesz sukces, niż doznasz porażki.

maciejka
Bywalec
Bywalec
Posty: 18
Rejestracja: 28 kwie 2011, 21:00

Nieprzeczytany post autor: maciejka »

Kenia pisze:przetestowałem twój EA na M5 EURUSD, faktycznie generuje błąd 130 (3 razy).
przetestowałem także jeszcze raz ten wklejony link z pierwszego postu i działa, nie generuje błędu (3 transakcje w tym 1 zamknieta, 2 otwarte). Sprobuj porównać parametry domyślne z tymi przez Ciebie zastosowanymi
jeśli można wiedzieć na jakiej platformie testowałeś ten EA?
u mnie w xtb wywala masakryczną ilość błędów nr 130 w dzienniku

Awatar użytkownika
Kenia
Gaduła
Gaduła
Posty: 145
Rejestracja: 29 cze 2010, 18:12

Nieprzeczytany post autor: Kenia »

admiral markets

ODPOWIEDZ