protected override void OnBarUpdate()
{
if (Close[0]>Close[1];
{
EnterLong(1);
TradeATR=ATR(14)[1];
}
}
This way, the correct value is given to TradeATR, I confirmed it. Then, here's the second part of my code:
else if (State == State.Configure)
{
SetProfitTarget(CalculationMode.Currency, TradeATR*5);
SetStopLoss(CalculationMode.Currency, TradeATR*2);
}
However, this for some reason doesn't pick up the current TradeATR value, it just assumes that TradeATR is 0. It works a number (say 100), but not a variable TradeATR.
How to properly do what I want and how to pass a variable from OnBarUpdate() to OnStateChange()?
Thank you in advance!
Comment