help
help
31 Aug 2020, 17:03
hi this is my bot
when the 3 moving averages and the stochastic are all upwards it must go buy
when the 3 moving averages and the stochastic are all down it must go sell
the problem is that the while loop is not even seen. why?
the program goes buy if the 50 period moving average (Mv50) is up and sell if it is down
thanks
if (Mv50.Result.Last(1) > Mv50.Result.LastValue)
{
while (Mv10.Result.Last(1) < Mv10.Result.LastValue && Mv1.Result.Last(1) < Mv1.Result.LastValue && St.PercentD.LastValue < St.PercentK.LastValue)
{
Print("Waiting for trigger");
System.Threading.Thread.Sleep(10000);
}
ExecuteOrder(position.Quantity * 2, TradeType.Sell);
}
else
{
while (Mv10.Result.Last(1) > Mv10.Result.LastValue && Mv1.Result.Last(1) > Mv1.Result.LastValue && St.PercentD.LastValue > St.PercentK.LastValue)
{
Print("Waiting for trigger");
System.Threading.Thread.Sleep(10000);
}
ExecuteOrder(position.Quantity * 2, TradeType.Buy);
}
Replies
luca.tocchi
31 Aug 2020, 18:06
RE:
PanagiotisCharalampous said:
Hi Luca,
This will never trigger because you have programmed an infinite while loop. There is no way for the condition to become true.
Best Regards,
Panagiotis
what should i correct?
I thought that if the condition is true he waits, if it is false he exits the cycle
@luca.tocchi
PanagiotisCharalampous
01 Sep 2020, 07:58
Hi Luca,
You need to rewrite the code from scratch. This one does not make any sense. How will the condition be updated if it the code does not exit the loop?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
31 Aug 2020, 17:08
Hi Luca,
This will never trigger because you have programmed an infinite while loop. There is no way for the condition to become true.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous