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

 
mamba5:

During testing EA I get error 130 - wrong stops. In the NewOrder function external variables TakeProfit and StopLoss should be passed, and it seems to me I have done everything to achieve this, but as print shows zeros are passed. I understand the reason of this error lies here but I have not been able to find it yet. Please help me.

extern int TakeProfit=100;
extern int StopLoss=100;

....................................

NewOrder(OP_BUYSTOP, Lot, TakeProfit, StopLoss);
NewOrder(OP_SELLSTOP, Lot, TakeProfit, StopLoss);

int NewOrder(int Cmd,double Lot,int TakeProfit,int StopLoss)

The problem here is that there are global variables StopLoss and they are passed to the procedure as parameters. It's better to rename them in the procedure.

 
fore-x:

Как в mql4 из одного индикатора управлять более чем 8 буферами обмена, существует ли способ обхода данного ограничения?

Ну, как пример, мне нужно построить более 8 индикаторных линий, но из одной программы.

Zhunko:

Trend lines.

And more details? At least give me a link where to read?
 
splxgf:

The problem here is that there are global StopLoss variables and they are also passed to the procedure as parameters. It is better to rename them in the procedure.


You are right. It is really more logical. Corrected:

//+----------Функция открытия ордера-----------------------------------+
int NewOrder(int Cmd,double Lot,int TaPr,int StLo)
{
 double TP=0;// тейкпрофит
 double SL=0;// стоплос
 double PR=0;// цена
 while(!IsTradeAllowed())Sleep(100);
 if(TaPr<MarketInfo(Symbol(),MODE_STOPLEVEL))  
    TaPr=MarketInfo(Symbol(),MODE_STOPLEVEL);
 if(StLo<MarketInfo(Symbol(),MODE_STOPLEVEL))  
    StLo=MarketInfo(Symbol(),MODE_STOPLEVEL);
 if(Cmd==OP_BUY)
   {
    PR=NormalizeDouble(Ask, Digits);
    if(TaPr>0)TP=NormalizeDouble(Ask,Digits)+NormalizeDouble(TaPr*Point,Digits);
    if(StLo>0)SL=NormalizeDouble(Bid,Digits)-NormalizeDouble(StLo*Point,Digits);
   }
 if(Cmd==OP_SELL)
   {
    PR=NormalizeDouble(Bid, Digits);
    if(TaPr>0)TP=NormalizeDouble(Bid,Digits)-NormalizeDouble(TaPr*Point,Digits);
    if(StLo>0)  SL=NormalizeDouble(Ask,Digits)+NormalizeDouble(StLo*Point,Digits);
   }
 Print("TaPr=",TaPr," StLo=",StLo," StopLevel=",MarketInfo(Symbol(),MODE_STOPLEVEL));
 tic=OrderSend(Symbol(),Cmd,Lot,PR,3,SL,TP,"",0,0,CLR_NONE);
 if(tic<0)Print("ошибка открытия ордера:",GetLastError()); Print("Cmd-",Cmd," Lot=",Lot," PR=",PR," SL=",SL," TP=",TP);
return(tic);
}
But it didn't help much. TaPr and StLo= 100, but PR, SL and TP are zero for some reason.....
Files:
 

Hello, can you help me write a condition so that the order opens only once, at this point it opens on every tick

   topOrder=OrderSend(Symbol(),OP_BUYSTOP,1,Hinput,3,Price_high-(height_box/100*sl),Price_high+(height_box/100*tp),"my order #",16384,0,Green);
                     if (topOrder<0)
                        {
                           Print("Верхний ордер ошибка #", GetLastError());
                           return(0);
                        }

I just need to do something to make it look like this: if I already have an order already placed, it won't open another one without an OrderComment, I have no idea what to do with it yet

Thanks in advance

 
fore-x:
How about more details? At least give me a link where to read?
What link? You connect the bars with the trend lines. Then you will be independent of the buffers with their glitches.
 
artmedia70:
Unless you put it on the chart yourself, it will not be reflected during the EA. How did you do this?
I am running the EA in the tester. When the tester finishes, the information of the indicator lines appears.
 
mamba5:


You're right. It does make more sense that way. Corrected:

But it didn't help much. TaPr and StLo= 100, but PR, SL and TP are zero for some reason.....


  NewOrder(OP_BUYSTOP, Lot, TakeProfit, StopLoss);
  NewOrder(OP_SELLSTOP, Lot, TakeProfit, StopLoss);
if(Cmd==OP_BUY)
   {
    PR=NormalizeDouble(Ask, Digits);
    if(TaPr>0)TP=NormalizeDouble(Ask,Digits)+NormalizeDouble(TaPr*Point,Digits);
    if(StLo>0)SL=NormalizeDouble(Bid,Digits)-NormalizeDouble(StLo*Point,Digits);
   }
 if(Cmd==OP_SELL)
   {
    PR=NormalizeDouble(Bid, Digits);
    if(TaPr>0)TP=NormalizeDouble(Bid,Digits)-NormalizeDouble(TaPr*Point,Digits);
    if(StLo>0)  SL=NormalizeDouble(Ask,Digits)+NormalizeDouble(StLo*Point,Digits);
   }
 

please advise how to calculate loss-making trades.

i.e. trades that were closed by a stop loss.

and reset the counter after a profitable trade.

I.e. after closing on Take Profit to reset the counter to zero.

Initial counter digit = 1

int Schetcik = 1;

All trades, both buy and sell, should be counted.

 
Vinin:



Thank you! ))) Couldn't see the error until so clearly compared
 
belck:

please advise how to calculate loss-making trades.

i.e. trades that were closed by a stop loss.

and reset the counter after a profitable trade.

I.e. after closing on Take Profit to reset the counter to zero.

Initial counter digit = 1

All trades, both buy and sell, should be counted.


Closing on a stop loss does not mean that the trade is losing, and vice versa. Unless, of course, stops and takes were set at the opening and have not been touched again.
Reason: