I'm testing a number of buy signals in an EA and want to send an algorithm as a "string" to execute. If I copy and paste the string into the buy signal it works but if I keep it as a variable it does not work, or works differently. It should work exactly the same. In this example, if I copy and paste OpenTradeSignal 1 without the quotes which is (Close[1] > Close[X]) into the parenthesis where BuySignal is, it works fine, but if I want it to read from the code it doesn't. What am I doing wrong here?
Inserted Code
extern int OpenTradeSignal = 1;
//////////
string BuySignal;
string SellSignal;
if (OpenTradeSignal == 1)
BuySignal = "(Close[1] > Close[X])";
SellSignal = "(Close[1] < Close[X])";
if (OpenTradeSignal == 2)
BuySignal = "(Close[1] < Close[X])";
SellSignal = "(Close[1] > Close[X])";
if (BuySignal)
{ Comment(TimeToStr(TimeCurrent(),TIME_SECONDS), " X > Y BUY SIGNAL ", Ask);
Print(TimeToStr(TimeCurrent(),TIME_SECONDS), " X > Y BUY SIGNAL ", Ask);
{
if (countL1 < NP)
fBuy1();
}
}
if (SellSignal)
{ Comment(TimeToStr(TimeCurrent(),TIME_SECONDS), " X < Y SELL SIGNAL ", Bid);
// Print(TimeToStr(TimeCurrent(),TIME_SECONDS), " X < Y SELL SIGNAL ", Bid);
{
if (countS1 < NP)
fSell1();