i created an EA but it contains a while loop, but when i run it, my CPU load goes to 100%, even backtesting won't start. Can someone show what i am doing wrong in my code to prevent this, and so that i can backtest normally?
when ready =1 it should continue with the rest of my code. i just placed this in it, so it wont start trading when attaching the EA, but waits for first signal/cross first.
Inserted Code
//Wait for first VALID signal and enter trade - WHILE loop
while (ready==0)
{
//Create waiting label
ObjectCreate("wait", OBJ_LABEL, 0, 0, 0);// Creating obj.
ObjectSet("wait", OBJPROP_CORNER, 1); // Reference corner
ObjectSet("wait", OBJPROP_XDISTANCE, 5);// X coordinate
ObjectSet("wait", OBJPROP_YDISTANCE, 15);// Y coordinate
ObjectSetText("wait", "Waiting for signal..",15,"Arial Bold",White);
Trendlord=iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,1);
BarClose=iClose(NULL,0,1);
BarOpen=iOpen(NULL,0,1);
if (BarOpen > Trendlord&& BarClose < Trendlord)
{
OrderSend(Symbol(),OP_SELL,Lotsize,Bid,50,NULL,NULL,NULL,MagicNumber,0,Red);
ObjectDelete("wait");
ready = 1;
}
if (BarOpen < Trendlord&& BarClose > Trendlord)
{
OrderSend(Symbol(),OP_BUY,Lotsize,Ask,50,NULL,NULL,NULL,MagicNumber,0,Blue);
ObjectDelete("wait");
ready = 1;
}
} when ready =1 it should continue with the rest of my code. i just placed this in it, so it wont start trading when attaching the EA, but waits for first signal/cross first.