double Profit, Lots, Ticket;// Do you see where I have put these ones and defined them?? I have made them global variables, out of start() function!!!!!!!!!!!!!!!!!!!
start(){
Trade(); Do you see this function reference???????????????????
Total=OrdersTotal();
for(i=Total-1; i>=0; i--)// here we are referring to the most recently opened trade
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
extern in StopLoss=20;
extern TakeProfit=100;
int i, Total;
double Profit, Lots, Ticket;// Do you see where I have put these ones and defined them?? I have made them global variables, out of start() function!!!!!!!!!!!!!!!!!!!
start(){
Trade(); Do you see this function reference???????????????????
Total=OrdersTotal();
for(i=Total-1; i>=0; i--)// here we are referring to the most recently opened trade
if( OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==True && OrderSymbol()==Symbol()){
Profit=OrderProfit(); Lots=OrderLots(); Ticket=OrderTicket();// Do you see where they are now???????????????????????????????
}
}
//=========================================Trade Function=================================//
int Trade(){
//What do you want to do with that trade??
if(Profit>0)//MEANS THE TRADE IS PROFITABLE; ok lets close it as an example
{
OrderClose(OrderSymbol(), Ticket,.........);
}
}
//====================================================================================//