Media con Livelli

Sezione dedicata a metatrader (ed altre piattaforme) ed al suo linguaggio di programmazione per il trading automatico
Rispondi
texcs
Messaggi: 144
Iscritto il: 29/05/2014, 23:08

Media con Livelli

Messaggio da texcs »

Buona sera a tutti sto creando un ea che funziona su una media con "livello superiore e inferiore" ora il codice è il seguente:

Codice: Seleziona tutto

     int BuySell=0;
     double SLBuy = 0, TPBuy=0, SLSell = 0, TPSell =0, Vol=0;
     double Ma = iMA(NULL, 0, MediaPeriod, 0, TipoMedia, PRICE_CLOSE, 0);
     bool ticket;
     double  LivelloDownBuy = Ma +  (Level_Negativo_Down_buy * Point());
     double  LivelloUpSell = Ma +  (Level_Positivo_Up_Sell * Point());
     if((OrdiniAperti() == false))
     {
        if(Open[1] < Close[1]  && Close[1] < LivelloDownBuy && Open[1] > LivelloDownBuy)  //buy
           {
            BuySell =1;
            SLBuy = Low[0] - dStopLevel - StopLoss  * p;
            TPBuy =Ma;//Bid + TakeProfit * 10 * Point;
           //Comment("Buy" + "\nentrata: " + NormalizeDouble(Ask,Digits)+ "\nSL Buy" + SLBuy + "\nTake Profit:"+DoubleToString(TPBuy,Digits)+"\nStopLevel " + dStopLevel +"\nCalcola Size " + Vol);

            ticket = OrderSend(Symbol(),OP_BUY,Lotti,Ask,0,SLBuy, TPBuy,"MovingAvarageLevels Buy",MagicNumber,0,Blue);
            if(ticket == false)
               Print("Error modifying order!, error#", GetLastError());
           }
        if(Open[1] >Close[1] && Open[1] >LivelloUpSell && Close[1] < LivelloUpSell)//sell
           {
            BuySell =-1;
            SLSell =High[0]+ dStopLevel+ StopLoss *p; 
            TPSell =Ma;       //Ask - TakeProfit * 10 * Point;

            //Vol=CalcolaSize(OprationRisk,Ask + StopLoss);
            //Comment("Sell" "\nBid: " + Bid + "\nSL Sell" + SLSell+ "\nTP Sell" + TPSell + "\nStopLevel " + dStopLevel +"\nCalcola Size " + Vol+ "\n StopLoss:" +  StopLoss+  "\nPoint" + Point + "\n StopLoss * Point"+  StopLoss * Point);

            ticket = OrderSend(Symbol(),OP_SELL,Lotti,Bid,0,SLSell, TPSell, "MovingAvarageLevels Sell ",MagicNumber,0,Red);
            if(ticket == false)
               Print("Error modifying order!, error#", GetLastError());
           }

     }
     else if(OrdiniAperti() == true)
     {
      TpModify(Ma);
     }

      } 
      
Non riesco a capire perchè apre solo operazioni sell non riesco a trovare l'errore qualcuno mi può dare una mano?
Rispondi

Chi c’è in linea

Visitano il forum: Nessuno e 0 ospiti