Can you spot what is wrong with my simple EA?

 

This is supposed to be two loops. The first determines if a trade is below an externally set profit. Seems to work. the second loop is supposed to check in the order comments to see if that order number appears and if it does it should not send another counter buy or sell order. Reading of the comment seems to be a problem as seen in the test print statment. ie nothing shows up. I've tried a few differnt ways with the comments ie string to double, to integer. Is it ok to have a second order select loop inside the first? I don't get it. Thanks for your looking.

//+------------------------------------------------------------------+
//| Rappeler.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net/"

extern double lotmultiplier= 2.0; //factor to apply to number of opposite orders
extern double entry= -2000.00 ; //profit in $ below which protective order is placed
extern double safeloss=12.0; // stoploss in points for protective orders
extern double takeprofit=20.0; // take profit in points for protective orders
extern int magicnum=77777; // magic number
int type, n,i,num_orders; // order type counters
double profit; // order profit in $
double lots; // open order lots
string EURUSD;
int hedged_num; //OrderTicket()
int comment; // order comment
datetime expiration=0; //20
color green;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//30| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{ //40
for (i=0; i<OrdersTotal();i++)
{
OrderSelect (i, SELECT_BY_POS,MODE_TRADES);
if(OrderProfit()<=entry) // cycle to find orders with profit less than entry profit
{
type=OrderType();// keeping current variable values to send into next loop
lots=OrderLots();
hedged_num=OrderTicket();
num_orders = OrdersTotal();
for(n=num_orders; n<=1; n--) // loop to check if order is currently hedged or hedge it if not
OrderSelect(n, SELECT_BY_POS,MODE_TRADES);
comment=StrToInteger(OrderComment());
Print (n,",",hedged_num,",",type,",",lots,",",OrderComment(),",",comment);
if (hedged_num!=comment)
{
if (type==0)OrderSend(Symbol(),OP_SELL,lots*lotmultiplier,Bid,3,Bid+safeloss/10000,
Bid-takeprofit/10000,DoubleToStr(hedged_num,0),magicnum,expiration,Green);
//60 if order is a buy then sell lotmultiplier*open lots at market.
if (type==1)OrderSend(Symbol(),OP_BUY,lots*lotmultiplier,Ask,3,Ask-safeloss/10000,
Ask+takeprofit/10000,DoubleToStr(hedged_num,0),magicnum,expiration,Green);
// if order is a sell then buy lotmultiplier*open lots at market.
}
}
}
return(0);
} //
//70+------------------------------------------------------------------+