[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 222

 
ramirez17:

Please indicate an error.


division by 0 - there should be a zero divide in the logbook

on the first pass

i+Sell_bars-1
you are out of the allowable Bars size
 
ramirez17, it is easier to find maxima/minima in stochastics and replace the stochastic formula with their ratio
 
maxstah:

Hello, could you please tell me where to find an indicator that re-draws the daily bars so that they start at a different time.

For example: Terminal time is 00:00. In the input parameters of indicator we put: +4. Now the daily bars start at 4:00.

Thank you in advance.

MT4 has a built-in converter. Service -> Quotes archive.
 

Hello.

I have a question as a beginner:

how to get the current Profit data for open positions; how to get the current balance data.

 
Roger:
Like, the new Pinocchio is looking for a reliable Field of Wonder. Don't be ridiculous.)

Like, clever petrosian wants to make a joke...))
 

Guys, where's the error.... I've already addressed it... here's the code...

When trading on termenal with floating spread(one more digit added) the advisor writes an error, wrong lot ... and with fixed spread, everything is fine and trades ...

 GBPUSD,H1: OrderSend error 131

but here's the code itself.... where is the error???

 if(ExistPositions() > 0)   {
   for(cnt=0;cnt<OrdersTotal();cnt++)  { 
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderType()==OP_BUY)  {
         if(Ask-OrderOpenPrice() > (TrailingStop * Point))  { 
            if(OrderStopLoss() < (Ask - TrailingStop * Point)) { 
               OrderModify(OrderTicket(),
                           OrderOpenPrice(),
                           Ask - TrailingStop * Point,
                           Ask + sTakeProfit * Point,0,Aqua);
            return(0);  } // close for if(OrderStopLoss() < (Ask - TrailingStop * Point))
                        } // close for if(Ask-OrderOpenPrice() > (TrailingStop * Point))
                } // close for if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderType()==OP_SELL) {
                        if(OrderOpenPrice() - Bid > (TrailingStop * Point))   { 
                                if(OrderStopLoss() > (Bid + TrailingStop * Point))   { 
                           OrderModify(OrderTicket(),
                                       OrderOpenPrice(),
                                       Bid + TrailingStop * Point,
                                       Bid - sTakeProfit * Point,0,Magenta);
            return(0);  } 
                        } // close for if(OrderOpenPrice() - Bid > (TrailingStop * Point))
                 } // close for if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
          } // close for for(cnt=0;cnt<total;cnt++)
   } // close for if(TradesThisSymbol > 0)
}

bool ExistPositions() {
        for (int i=0; i<OrdersTotal(); i++) {
                if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
                        if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
                                return(True);
                        }
                } 
        } 
        return(false);
}



void OpenBuy() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
   ldStop = GetStopLossBuy(); 
   ldTake = GetTakeProfitBuy(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenBuy); 
   if (UseSound) PlaySound(NameFileSound); 
} 
void OpenSell() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 

   ldLot = GetSizeLot(); 
   ldStop = GetStopLossSell(); 
   ldTake = GetTakeProfitSell(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenSell); 
   if (UseSound) PlaySound(NameFileSound); 
} 
string GetCommentForOrder() {   return(Name_Expert); } 
double GetSizeLot() {   return(Lots); } 
double GetStopLossBuy() {       return (Bid-sStopLoss*Point);} 
double GetStopLossSell() {      return(Ask+sStopLoss*Point); } 
double GetTakeProfitSell() {    return(Bid-sTakeProfit*Point); } 
double GetTakeProfitBuy() {     return(Bid+sTakeProfit*Point); } 

return(0);

//+------------------------------------------------------------------+
 
Vovo4ka:

Like, clever petrosian wants to make a joke...))

www.dukascopy.com mt4 and java technology, minimum deposit is 1000 greenbacks, found out recently myself.
 
todem:

www.dukascopy.com mt4 and java technology, minimum dept 1000 green, found out myself recently.

Many thanks.
 
If the indicator is in an infinite loop with sleep, then you need to insert a function like if(!deinit)?
 
Vovo4ka:

Guys where's the error.... already addressed...here's the code...

when trading on thermals with floating spread (one more digit added) the advisor writes an error, wrong lot...

but here's the code itself.... where is the error???


do lot normalisation

double GetSizeLot() {   return(NormalizeDouble(Lots,2)); }