Long/short after a period of time.
#4
Quote: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?

The first thing: you say "var timesig = candle.start.format('D');", you probably want to create a variable once and set it's value. If you are fine with knowing whether you signaled a "long" before you need to track that as well, you have a few options:

- you can set the timesig to something like false after you signal a short, now you can simply check if this value is not false, if it is not that means you signaled previously.
- you can track the current advice, have a look at the example strategies because most do that. After that simply check if the current advice is not long before you set that.
- you can track it in another boolean.

Note that question has little to do with Gekko and more with javascript. I suggest familiarizing yourself with javascript.
  Reply


Messages In This Thread
Long/short after a period of time. - by slav - 10-08-2018, 12:32 AM
RE: Long/short after a period of time. - by slav - 10-08-2018, 12:18 PM
RE: Long/short after a period of time. - by askmike - 10-08-2018, 02:31 PM

Forum Jump:


Users browsing this thread: