Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1067
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
Tuta.
I don't have one. But there is definitely a file somewhere, I get the information recorded from it.
Please help me to compile to mt4
FileClose' - expression of 'void' type is illegal TickToCVS~.mq4 84 12
I don't have one. But there is definitely a file somewhere and I get the information recorded from it.
This is the EMPTY_VALUE value
Look for where it is popping up.
My screenshot shows that the menu is from MetaEditor and your screenshot is from MT.
Hi guys, my question is, I can't modify an order. There are two aspects to it, I don't understand the mathematics of modification, so please explain it to me.
The way I see it, SL= IF ORDERSELEKT,Bid-ORDERSTOPLOS*POINT,DIGITS
the second aspect.learned from XBMS video
how i didn't try to change the values of the variables in the tester eror 130 not the right stop loss and shit like this
2016.06.28 21:42:23.402 2016.06.23 00:00 trade RSI inputs: Lots=0.1; Slippage=5; StopLoss=10; TakeProfit=30; RSIPeriod=7; Magic=1087;
although there is a multiplication from digits and function on the case of wrong SL
extern double Lots = 0.1;
extern int Slippage = 10;
extern int StopLoss = 10;
extern int TakeProfit =30;
extern int RSIPeriod = 7;
extern int Magic =1087;
double MaRSI;
int TP,SL;
bool tfu;
//+------------------------------------------------------------------+
//| Expert initialisation function |
//+------------------------------------------------------------------+
int OnInit()
{
if(Digits == 3||Digits == 5)
{
Slippage *= 10;
TakeProfit *= 10;
StopLoss *= 10;
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//+------------------------------------------------------------------+
//open sell
//+------------------------------------------------------------------+
MaRSI=iRSI(Symbol(),0, RSIPeriod,PRICE_CLOSE,1);
if(CountTrades() <= 0&MaRSI<=30 )
{
if( SendOrder(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0, "test",Magic,0,Green))
{ int ticket = OrderTicket();
SL = NormalizeDouble( Ask - StopLoss*Point,Digits);
TP = NormalizeDouble( Ask + TakeProfit*Point,Digits);
ModifyOrder(ticket,OrderOpenPrice(),SL,TP,0,Black);
}
}// if(CountTrades <= 0&MaRSI>=70 )
//+------------------------------------------------------------------+
//open buy
//+------------------------------------------------------------------+
}//ONTICK
//+------------------------------------------------------------------+
//+order counter
//+------------------------------------------------------------------+
int CountTrades ()
{
int count = 0;
for(int i = OrdersTotal()-1;i>=0;i--)
{
if( OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)//if the order is ours
count++;//increase counter
}//select order by index
}// order.i===first order.
return(count);//returns the number of orders
}// function
//+------------------------------------------------------------------+
//order placing function with error handling
//+------------------------------------------------------------------+
int SendOrder( string symbol,int cmd,double volume,double price,int slippage,double stoploss,
double takeprofit,string comment,int magic=0,datetime expiration=0,color arrow_color=CLR_NONE)
{
int err = GetLastError();
err =0;
bool exit_cikl = false;
int ticket = -1;
int Retry = 10; //number of attempts to set an order
int cnt = 0; //try count
if(cmd == OP_BUY || cmd == OP_SELL)
{
while(!exit_cikl)
{
ticket = OrderSend(symbol,cmd,volume,price,slippage,stoploss,takeprofit,comment,magic,expiration,arrow_color);
err= GetLastError();
switch(err)
{
case ERR_NO_ERROR:
exit_cikl = true;
break;
{ case ERR_SERVER_BUSY:
case ERR_NO_CONNECTION:
case ERR_INVALID_PRICE:
case ERR_OFF_QUOTES:
case ERR_BROKER_BUSY:
case ERR_TRADE_CONTEXT_BUSY:
cnt++;
break;
case ERR_PRICE_CHANGED:
case ERR_REQUOTE:
RefreshRates();
continue;
default:
exit_cikl = true;
break;
}// switch switch(err)
if(cnt > Retry)
exit_cikl = true;
if(!exit_cikl)
{
Sleep(1000);
RefreshRates();
}//if we don't exit the loop if(!exit_cikl)
else
{
if(err != ERR_NO_ERROR)
{
Print("Error : " + IntegerToString(err));
}// if there is still an error if(err != ERR_NO_ERROR)
}// OTHERWISE
if(err==ERR_NO_ERROR)
{
if( OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)==true)
return(ticket);
}// if(err==ERR_NO_ERROR)
Print("Error opening order after " + IntegerToString(cnt) +"attempts");
return(-1);
} //cycle while
}// if the order type is Buy or Sell
return(ticket);
}// SendOrder function
//-------------------------------------------------------------------------------------------------------------
//function modify order
//------------------------------------------------------------------------------------------------------------
ModifyOrder(int ticket,double price,double stoploss,double takeprofit,datetime expiration,colour arrow_color)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
price = NormalizeDouble(price,Digits);
stoploss = NormalizeDouble(stoploss,Digits);
takeprofit = NormalizeDouble(takeprofit,Digits);
CheckValidStop(Symbol(),price,stoploss);//function to change the minimum stop
int err = GetLastError();
err = 0 ;
int Retry = 10;
int cnt = 0;
bool exit_cikl = false;
bool result;
while(!exit_cikl)
{
result = OrderModify(ticket, price,stoploss,takeprofit,expiration, arrow_color);
err = GetLastError();
if(result == true)
{
Print("Order #"+ IntegerToString(ticket), "successfully modified");
return(true);
}
switch(err)
{
case ERR_NO_ERROR:
exit_cikl = true;
break;
{ case ERR_SERVER_BUSY:
case ERR_NO_CONNECTION:
case ERR_INVALID_PRICE:
case ERR_OFF_QUOTES:
case ERR_BROKER_BUSY:
case ERR_TRADE_CONTEXT_BUSY:
cnt++;
break;
case ERR_PRICE_CHANGED:
case ERR_REQUOTE:
RefreshRates();
continue;
default:
exit_cikl = true;
break;
}// switch switch(err)
}// while(!exit_cikl)
if ( err != ERR_NO_ERROR)
{
Print("Error modifying order # " + IntegerToString(ticket));
Print("Error code: " + IntegerToString(err));
}
}//(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
else
{
Print("Order selection failed, ticket = " + IntegerToString(ticket));
return(false);
}//if something goes wrong
return(true);
}// function modify
//----------------------------------------------------------------------------------------------------
//ChtckValidStop
//--------------------------------------------------------------------------------------------------
void CheckValidStop(string symbol,double price,double& sl)
{
if(sl==0)
return;
double min_stop_server = MarketInfo(symbol,MODE_STOPLEVEL)*MarketInfo(symbol,MODE_POINT);
if(MathAbs(price-sl) <= min_stop_server)
{
if(price>sl)
sl = price - min_stop_server;
else sl = sl + min_stop_server;
}// if(MathAbs(price-sl) <= min_stop_server)
sl = NormalizeDouble(sl,MarketInfo(symbol,MODE_DIGITS))
}// function
PLEASE ADVISE!!!
There are two orders in the trading history: 1) SELL № tic 415 STOPLOSS 1.1000 lot 0.01 2) SELL № tic 418 STOPLOSS 1.1000 lot 0.02
I have to assign the variables X=tick, Y=STOPLOSS and B=lot if the Asc price is equal to the STOPLOSS of the SELL order. How to assign first values to the first order, and then to the second one. With me it always assigns a value to the first order.
PLEASE ADVISE!!!
There are two orders in the trading history: 1) SELL № tic 415 STOPLOSS 1.1000 lot 0.01 2) SELL № tic 418 STOPLOSS 1.1000 lot 0.02
I have to assign the variables X=tick, Y=STOPLOSS and B=lot if the Asc price is equal to the STOPLOSS of the SELL order. How to assign first values to the first order, and then to the second one. With me it always assigns a value to the first order.
This topic is designed to help those who already have something written, but it doesn't work quite the way I want it to. Please submit your code so that the others here can see what's wrong and help.
And if you want to be written to order, that's where it's at.
The modification is described here - it's a textbook chapter