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

 
sergeev:

normalise your _lots

Thank you! It helped.
 
Hello! I have a question about exporting data to Excel. I need the indicator (or script) to automatically export the current values of "Balance", "Funds", etc. to Excel at the beginning of each day. Can you tell me how to implement this? Or at least where to read about it. Search did not produce any results, so I'm asking here. Thank you.
 
Gerkl:
Hello! I have a question about exporting data to Excel. I need the indicator (or script) to automatically export the current values of "Balance", "Funds", etc. to Excel at the beginning of each day. Can you tell me how to implement this? Or at least where to read about it. Search did not produce any results, so I'm asking here. Thank you.
You can save a csv file with Expert, Excel will process it quite successfully.
 
splxgf:
You can save a csv file with an expert and Excel will process it quite successfully.
Can you tell me how to do this? And where to learn more about it. Thank you.
 
Gerkl:
Can you tell me how to do this? And where can I find out more about it? Thank you.
https://docs.mql4.com/ru/files
 

Please advise how to make an indicator in the EA not to be drawn on a chart?

I.e. the lines of the indicator would not be drawn on the chart. The indicator is called like this:

indikator_1=iMA(NULL,60,maTrendPeriodv_1,0,MODE_SMA,PRICE_CLOSE,0);
 
Thank you. Although it doesn't tell me much, it will be looked into.
 
belck:

Please advise how to make an indicator in the EA not to be drawn on a chart?

I.e. the lines of the indicator would not be drawn on the chart. The indicator is called like this:

indikator_1=iMA(NULL,60,maTrendPeriodv_1,0,MODE_SMA,PRICE_CLOSE,0);
Unless you put it on the chart yourself, it will not be reflected when the EA is running. How did you do this?
 

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. I need your help.

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

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

if(KVADRAT==1)
{
double Lot=GetLot(MaxRisk);
Print("Lot=",Lot);
if(Lot==0)
{
Print("not enough funds");
return(0);
}
NewOrder(OP_BUYSTOP, Lot, TakeProfit, StopLoss);
NewOrder(OP_SELLSTOP, Lot, TakeProfit, StopLoss);
KVADRAT=0;
}

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

//+---------Функция расчета лота---------------------------------------+
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,int TakeProfit,int StopLoss)
{
double TP=0;//takeProfit
double SL=0;// stopLoss
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_BUY)
{
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_SELL)
{
PR=NormalizeDouble(Bid,Digits);
if(TakeProfit>0)TP=NormalizeDouble(Bid-TakeProfit*Point,Digits);
if(StopLoss>0)SL=NormalizeDouble(Ask+StopLoss*Point,Digits);
}
Print("TakeProfit=",TakeProfit," StopLoss=",StopLoss," StopLevel=",MarketInfo(Symbol(),MODE_STOPLEVEL));
tic=OrderSend(Symbol(),Cmd,Lot,PR,3,SL,TP,"",0,0,CLR_NONE);
if(tic<0)Print("order open error:",GetLastError()); Print("Cmd-",Cmd, "Lot=",Lot, "PR=",PR, "SL=",SL, "TP=",TP);
return(tic);
}

 
DhP:
Do some magic with this function.

* gone to do magic *
Reason: