1
focar em
0
Seguidores

Gostaria de perguntar, depois de definir uma variável global, por que o valor da função subsequente sempre permanece inalterado?

Criado em: 2018-11-13 17:27:58, atualizado em: 2018-11-14 09:11:29
comments   2
hits   1680
var STATE_IDLE = 0;
var STATE_LONG = 1;
var STATE_SHORT = 2;
var State = STATE_IDLE;

function Trade(currentState, nextState) {

    if (currentState === STATE_IDLE) {
        if (nextState === STATE_LONG) {
            exchange.SetDirection("buy");
            AmountOP = InitAccount.Stocks * 10 / 2;
            exchange.Buy(_C(exchange.GetTicker).Sell, AmountOP);
            State = STATE_LONG;
        }

Há outras condições para executar que também mudam o valor do estado, mas por que é sempre 0 e não muda?