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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.
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 can I find out more about it? Thank you.
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:
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:
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);
}
Do some magic with this function.
* gone to do magic *