Hozzászólások

8 bejegyzés megtekintése - 1-8 / 8
  • Szerző
    Bejegyzés
  • kapanyanyimonyok
    Tag
    Bejegyzések száma: 9

    Megy, mint szél :-)

    kapanyanyimonyok
    Tag
    Bejegyzések száma: 9

    Juhééééé. Müxik :-) :-)
    Az a röhej az egészben, hogy a hivatalos MT4 Code Base oldalról töltöttem le a legújabb RenkoLiveChart alkotást és nem volt jó :-(

    Köszönöm a segítséget.

    Üdv.

    kapanyanyimonyok
    Tag
    Bejegyzések száma: 9

    Comment-ben kiírtam a képernyőre amit mondtál.
    Sima charton szépen írja folyamatosan a dolgokat. Renkón viszont semmit nem tesz ki, még a szöveget se. Olyan érzetem van, hogy még egy tick-et sem kap. Pedig, mint följebb írtam, a Bid/Ask ár mozog.

    kapanyanyimonyok
    Tag
    Bejegyzések száma: 9

    3-at adtam mindenhol, de így se köt.

    kapanyanyimonyok
    Tag
    Bejegyzések száma: 9

    Nem. Pedig megtaláltam a doksiban, hogy van ilyen, hogy nem standard timeframe. Beállítottam mindent 3-ra az offline charton is meg a robotban is, de tojik rá :-(

    kapanyanyimonyok
    Tag
    Bejegyzések száma: 9

    Van egy ötletem, Nem az, hogy mikor levizsgálja a HA-t, nincs timeframe megadva. De mit kéne ide írni offline esetben?

    double HA1a=iCustom(Symbol(),0,”Heiken Ashi”……

    kapanyanyimonyok
    Tag
    Bejegyzések száma: 9

    Igen, tök egyszerre megy. Van bid és ask is.

    kapanyanyimonyok
    Tag
    Bejegyzések száma: 9

    Beteszem ide, hátha belefér :-)

    //+------------------------------------------------------------------+
    //|                                            Heiken Ashi EA v2.mq4 |
    //|                              Copyright © 2009, TradingSytemForex |
    //|                                http://www.tradingsystemforex.com |
    //+------------------------------------------------------------------+
    
    #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 "Heiken Ashi EA"
    
    //extern string S1a="---------------- Heiken Ashi smoothed Settings";
    //extern int MaMetod=2;
    //extern int MaPeriod=6;
    //extern int MaMetod2=3;
    //extern int MaPeriod2=2;
    
    extern string S1b="---------------- PSAR Filter";
    
    extern bool PSARFilter=false;
    extern double Step=0.02;
    extern double Maximum=0.2;
    
    extern string S1c="---------------- MA Trend Filter";
    
    extern bool MATrendFilter=false;
    extern int MATrendTimeFrame=1440;
    extern int MATrendPeriod=21;
    extern int MATrendMethod=1;
    extern int MATrendPrice=0;
    
    extern string S2="---------------- Money Management";
    
    extern double Lots=0.2;//|-----------------------lots size
    extern bool RiskMM=false;//|---------------------risk management
    extern double RiskPercent=1;//|------------------risk percentage
    
    extern string S3="---------------- Order Management";
    
    extern int StopLoss=0;//|------------------------stop loss
    extern int TakeProfit=0;//|----------------------take profit
    extern bool HideSL=false;//|---------------------hide stop loss
    extern bool HideTP=false;//|---------------------hide take profit
    extern int TrailingStop=0;//|--------------------trailing stop
    extern int TrailingStep=0;//|--------------------trailing step
    extern int BreakEven=0;//|-----------------------break even
    extern int MaxOrders=100;//|---------------------maximum orders allowed
    extern int Slippage=3;//|------------------------slippage
    extern int Magic=2014;//|------------------------magic number
    
    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
    
    
    datetime PreviousBarTime1;
    datetime PreviousBarTime2;
    
    double maxEquity,minEquity,Balance=0.0;
    
    //|---------initialization
    
    int init()
    {
      /*if(Comments)Comment("\nLoading...");*/
      return(0);
    }
    
    
    int start()
    {
    
    //|---------trailing stop
    
       if(TrailingStop>0)MoveTrailingStop();
    
    //|---------break even
    
       if(BreakEven>0)MoveBreakEven();
       
    //|---------signal conditions
    
       int limit=1;
       for(int i=1;i<=limit;i++)
       {
       
       //|---------main signal
     
          double SAR=iSAR(NULL,0,Step,Maximum,i);
          double HA1a=iCustom(Symbol(),0,"Heiken Ashi",Red,LimeGreen,Red,LimeGreen,2,i+1);
          double HA2a=iCustom(Symbol(),0,"Heiken Ashi",Red,LimeGreen,Red,LimeGreen,3,i+1);
          double HA1= iCustom(Symbol(),0,"Heiken Ashi",Red,LimeGreen,Red,LimeGreen,2,i);
          double HA2= iCustom(Symbol(),0,"Heiken Ashi",Red,LimeGreen,Red,LimeGreen,3,i);
          
          double MA1=iMA(Symbol(),MATrendTimeFrame,MATrendPeriod,0,MATrendMethod,MATrendPrice,i+1);
          double MA2=iMA(Symbol(),MATrendTimeFrame,MATrendPeriod,0,MATrendMethod,MATrendPrice,i);
    
          string BUY="false";
          string SELL="false";
    
          if(HA2a<HA1a&&HA2>HA1&&(MATrendFilter==false||(MATrendFilter&&MA2>MA1))&&(PSARFilter==false||(PSARFilter&&Ask>SAR)))BUY="true";
          if(HA2a>HA1a&&HA2<HA1&&(MATrendFilter==false||(MATrendFilter&&MA2<MA1))&&(PSARFilter==false||(PSARFilter&&Bid<SAR)))SELL="true";
          
          string SignalBUY="false";
          string SignalSELL="false";
          
          if(BUY=="true"/*&&MABUY=="true"*/)if(ReverseSystem)SignalSELL="true";else SignalBUY="true";
          if(SELL=="true"/*&&MASELL=="true"*/)if(ReverseSystem)SignalBUY="true";else SignalSELL="true";
          
       }
    
    //|---------risk management
    
       if(RiskMM)CalculateMM();
    
    //|---------open orders
    
       double SL,TP,SLH,TPH,SLP,TPP,OPP;
       int Ticket,TicketH,TicketP,Expire=0;
       /*if(Expiration>0)Expire=TimeCurrent()+(Expiration*60)-5;*/
       
       if(OrdersTotal()<MaxOrders)
       {  
          if(SignalBUY=="true"&&NewBarBuy())
          {
             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;
             
             Ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,EAName,Magic,0,Blue);
             if(Hedge)TicketH=OrderSend(Symbol(),OP_SELL,Lots,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=="true"&&NewBarSell())
          {
             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;
             
             Ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,EAName,Magic,0,Red);
             if(Hedge)TicketH=OrderSend(Symbol(),OP_BUY,Lots,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);*/
          }
       }
    
    //|---------close orders
       
       if(Hedge==false)
       {
          if((SELL=="true")||(ReverseSystem==false&&HideSL&&StopLoss>0&&OrderType()==OP_BUY&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(ReverseSystem==false&&HideTP&&TakeProfit>0&&OrderType()==OP_BUY&&(Bid-OrderOpenPrice())/Point>=TakeProfit)||(ReverseSystem&&HideSL&&StopLoss>0&&OrderType()==OP_SELL&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(ReverseSystem&&HideTP&&TakeProfit>0&&OrderType()==OP_SELL&&(OrderOpenPrice()-Ask)/Point>=TakeProfit))
          {
             if(ReverseSystem)CloseSellOrders(Magic);else CloseBuyOrders(Magic);
          }
          if((BUY=="true")||(ReverseSystem==false&&HideSL&&StopLoss>0&&OrderType()==OP_SELL&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(ReverseSystem==false&&HideTP&&TakeProfit>0&&OrderType()==OP_SELL&&(OrderOpenPrice()-Ask)/Point>=TakeProfit)||(ReverseSystem&&HideSL&&StopLoss>0&&OrderType()==OP_BUY&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(ReverseSystem&&HideTP&&TakeProfit>0&&OrderType()==OP_BUY&&(Bid-OrderOpenPrice())/Point>=TakeProfit))
          {
             if(ReverseSystem)CloseBuyOrders(Magic);else CloseSellOrders(Magic);
          }
       }
       else
       {
          if((HideSL&&StopLoss>0&&OrderType()==OP_BUY&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(HideTP&&TakeProfit>0&&OrderType()==OP_BUY&&(Bid-OrderOpenPrice())/Point>=TakeProfit))
          {
             CloseBuyOrders(Magic);
          }
          if((HideSL&&StopLoss>0&&OrderType()==OP_SELL&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(HideTP&&TakeProfit>0&&OrderType()==OP_SELL&&(OrderOpenPrice()-Ask)/Point>=TakeProfit))
          {
             CloseSellOrders(Magic);
          }
       }
       
    
    //|---------not enough money warning
    
       int err=0;
       if(Ticket<0)
       {
          if(GetLastError()==134)
          {
             err=1;
             Print("Not enough money!");
          }
          return (-1);
       }
       
       return(0);
    }
    
    //|---------close buy orders
    
    int CloseBuyOrders(int Magic)
    {
      int result,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);
            switch(OrderType())
            {
              case OP_BUYLIMIT:
              case OP_BUYSTOP:
              result=OrderDelete(OrderTicket());
            }
          }
        }
      }
      return(0);
    }
    
    //|---------close sell orders
    
    int CloseSellOrders(int Magic)
    {
      int result,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);
            switch(OrderType())
            {
              case OP_SELLLIMIT:
              case OP_SELLSTOP:
              result=OrderDelete(OrderTicket());
            }
          }
        }
      }
      return(0);
    }
    
    //|---------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)  
                {                 
                   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)  
                {                 
                   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);
    }
    
8 bejegyzés megtekintése - 1-8 / 8