How to select the order that have profit? - page 3

 

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,.........);

}

}

//====================================================================================//

Reason: