[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 407

 
costy_:

BASE FLETCHING... :-)

and also a BASE TREND ))

if eur goes down and dol goes down, flat


:-)
 
costy_:
have swap spreads been factored into the thinking?
Yeah, that's right. It's because of the spreads. No swaps, positions are short. So the Expert Advisor should be even more resilient so that profits prevail over losses. Thank you, I will try it.
 
costy_:
On the fact that after the for...

Yeah.... "Exhaustive" answer. Every event has to have a reason. Professionals, encountering some malfunctions know what to pay attention to. Looked through the algorithm several times, but I can not find the cause That's why I turn to the pros for advice - what could be the reason?
 

I am trying to open a pending order like this:

//+---------Функция расчета лота---------------------------------------+
double GetLot(int Risk)
{
double Free=AccountFreeMargin();
double One_Lot=MarketInfo(Symbol(),MODE_MARGINREQUIRED);
double Min_Lot=MarketInfo(Symbol(),MODE_MINLOT);
double Max_Lot=MarketInfo(Symbol(),MODE_MAXLOT);
double Step=MarketInfo(Symbol(),MODE_LOTSTEP);
double Lot=MathFloor(Free*Risk/100/One_Lot/Step)*Step;
if(Lot<Min_Lot)Lot=Min_Lot;
if(Lot>Max_Lot)Lot=Max_Lot;
if(Lot*One_Lot>Free)return(0.0);
return(Lot);
}

//+----------Функция открытия ордера-----------------------------------+
int NewOrder(int Cmd,double Lot)
{
double TP=0;//takeprofit
double SL=0;// stop loss
double PR=0;// price
while(!IsTradeAllowed())Sleep(100);
if(TakeProfit<MarketInfo(Symbol(),MODE_STOPLEVEL))
TakeProfit=MarketInfo(Symbol(),MODE_STOPLEVEL);
if(StopLoss<MarketInfo(Symbol(),MODE_STOPLEVEL))
StopLoss=MarketInfo(Symbol(),MODE_STOPLEVEL);
if(Cmd==OP_BUYSTOP)
{
PR=NormalizeDouble(Ask,Digits);
if(TakeProfit>0)TP=NormalizeDouble(Ask+TakeProfit*Point,Digits);
if(StopLoss>0)SL=NormalizeDouble(Bid-StopLoss*Point,Digits);
}
if(Cmd==OP_SELLSTOP)
{
PR=NormalizeDouble(Bid,Digits);
if(TakeProfit>0)TP=NormalizeDouble(Bid-TakeProfit*Point,Digits);
if(StopLoss>0)SL=NormalizeDouble(Ask+StopLoss*Point,Digits);
}
tic=OrderSend(Symbol(),Cmd,Lot,PR,3,SL,TP,"",0,0,CLR_NONE);
if(tic<0)Print("Error opening order:",GetLastError()); Print("Cmd-",Cmd, "Lot=",Lot, "PR=",PR, "SL=",SL, "TP=",TP);
return(tic);
}

When I check it, I get a message:

2011.12.06 23:36:50 2010.01.06 16:19 Big Dog 1.01 EURUSD,M15: invalid lots amount for OrderSend function

2011.12.06 23:36:50 2010.01.06 16:19 Big Dog 1.01 EURUSD,M15: OrderSend error 4051

2011.12.06 23:36:51 2010.01.07 17:20 Big Dog 1.01 EURUSD,M15: Faulty order open:405

2011.12.06 23:36:51 2010.01.07 17:20 Big Dog 1.01 EURUSD,M15: Cmd-5Lot=0PR=1.4316SL=1.4419TP=1.4216

Obviously, it is something with the calculation of lots, but I do not understand what))) Please advise

 
LOA:

Yep.... "Exhaustive" answer. Every event has to have a reason. Professionals, when encountering some malfunction, know what to look out for. I looked through the algorithm several times, but cannot find the reason. That's why I'm asking the pros for advice - what may be the reason?

Well, where is the indicator?! (I'm guessing by coffee grounds tel. https://www.mql5.comhttps://www.mql5.com/ru/)

Well if you list everything, the letters will run out.

continue break return see if and when there is an interrupt for and when it happens. works with the opening of the bar....

"encountering some problems know what to pay attention to" they don't pay attention but start debugging, start debugging your indicator too, e.g. via print (moreover with someone else's and so 15 pages long, more than 50 called functions...)

Print("дошли до инициализации, сделаем ресайз запишем все 0.0 size="+ArrayRange(buf,0)+" resize= "+ArrayResize(buf,Bars)+"  "+ArrayInitialize(buf,0.0)) ;

 

Hello.

I have created an array:

double fibo[]={-10.09,-5.854,-4.98,-4.108,-3.236,-2.618,-2.11,-1.618,-1.11,-0.618,-0.382,0,0.118,0.236,0.382,0.5,0.618,0.764,0.882,1,1.382,1.618,2.11,2.618,3.11,3.618,4.236,5.108,5.98,6.854,11.09};

However, for some reason its first value goes to zero (-10.09 becomes 0). I found a way out of the situation by doing this:

double fibo[]={,-10.09,-5.854,-4.98,-4.108,-3.236,-2.618,-2.11,-1.618,-1.11,-0.618,-0.382,0,0.118,0.236,0.382,0.5,0.618,0.764,0.882,1,1.382,1.618,2.11,2.618,3.11,3.618,4.236,5.108,5.98,6.854,11.09};

Can you please tell me what this is about? Very much I want to understand.

Thank you in advance.

 
nemo811:

Hello.

I have created an array:

However, for some reason its first value goes to zero (-10.09 becomes 0). I found a way out of the situation by doing this:

Can you please tell me what this is about? Very much I want to understand.

Thank you in advance.

I have not zeroed with index = 0

double fibo[]={-10.09,-5.854,-4.98,-4.108,-3.236,-2.618,-2.11,-1.618,-1.11,-0.618,-0.382,0,0.118,0.236,0.382,0.5,0.618,0.764,0.882,1,1.382,1.618,2.11,2.618,3.11,3.618,4.236,5.108,5.98,6.854,11.09};
Alert(fibo[0]);

2011.12.06 20:00:47 MA_TF AUDUSD,M30: Alert: -10.09


 

Here is the problematic part of the code:

  if (FIBO)
   {
    double fibo[]={-10.09,-5.854,-4.98,-4.108,-3.236,-2.618,-2.11,-1.618,-1.11,-0.618,-0.382,0,0.118,0.236,0.382,0.5,0.618,0.764,0.882,1,1.382,1.618,2.11,2.618,3.11,3.618,4.236,5.108,5.98,6.854,11.09};
    double fiboPoint = 0;
    for(i=1;i<ArraySize(fibo)+1;i++)
     {
      fiboPoint = NormalizeDouble(MinAsia+Asia*fibo[i],Digits);
      double v = 0;
      if (fibo[i]<0) v=(MathAbs(fibo[i])+1)*100;
      else v=fibo[i]*100;
      string kk;
      kk=StringConcatenate (DoubleToStr(fiboPoint,Digits)," / ",DoubleToStr(v,1),"%");
      string k=DoubleToStr (i,0);
      ObjectCreate (nameF+k, OBJ_TREND, 0,0,0,0,0,0,0);
      ObjectSet (nameF+k, OBJPROP_RAY, false);
      ObjectSet (nameF+k, OBJPROP_TIME1, TimeBegAsia);
      ObjectSet (nameF+k, OBJPROP_PRICE1, fiboPoint);
      ObjectSet (nameF+k, OBJPROP_TIME2, FlowTime);
      ObjectSet (nameF+k, OBJPROP_PRICE2, fiboPoint);
      ObjectCreate (nameFT+k, OBJ_TEXT, 0,0,0,0,0,0,0);
      ObjectSet (nameFT+k, OBJPROP_TIME1, TimeBegAsia);
      ObjectSet (nameFT+k, OBJPROP_PRICE1, fiboPoint);
      ObjectSetText (nameFT+k,kk,8,"Arial");
     }
   }

Here is the problem described above: the line derived from the value -10.09 is not drawn (it takes the value of MinAsia).

 
nemo811:

Here's the problematic part of the code:

tuz

for(i=0;i<ArraySize(fibo)/**/-/**/1;i++)
 
mamba5:

I am trying to open a pending order like this:

//+---------Функция расчета лота---------------------------------------+

When I check it, I get a message:

2011.12.06 23:36:50 2010.01.06 16:19 Big Dog 1.01 EURUSD,M15: invalid lots amount for OrderSend function

2011.12.06 23:36:50 2010.01.06 16:19 Big Dog 1.01 EURUSD,M15: OrderSend error 4051

2011.12.06 23:36:51 2010.01.07 17:20 Big Dog 1.01 EURUSD,M15: Faulty order open:405

2011.12.06 23:36:51 2010.01.07 17:20 Big Dog 1.01 EURUSD,M15: Cmd-5Lot=0PR=1.4316SL=1.4419TP=1.4216

Obviously, it is something with the calculation of lots, but I do not understand what))) Please advise


Use the long proven functions to open orders for both the tester and the real tout
Reason: