10-08-2018, 12:18 PM
(This post was last modified: 10-08-2018, 12:49 PM by slav.
Edit Reason: be more specific
)
(10-08-2018, 06:22 AM)askmike Wrote: Inside your check function you want to register the time (the candle time, this way your strategy will also work in backtests) you do an advice. And every following check you want to see if you did a trade x time ago, and if so do another one.
I'm trying to register the time of a long trade by assigning it to a variable, but that value is changing every time conditions for 'long' are met.
for eg.
if(macd2 > macdSignal2 && macd2 < 0) {
this.advice('long');
var timesig = candle.start.format('D');
}
I need to keep timesig at the time of the first trade and prevent it from changing every time it wants to take a long position, which it can't because it's already long.
Can I determine if this long trade already happened before?