Gap strategy coding

Hi everyone,

I’m trying to code a gap strategy with the following:

  • if I have a strong day yesterday (i.e up > 5%) + today gap up > 5%
    then I go short after 9:30 with a stop 2 ticks above the high during the first 30min
    And the exact reverse for a long
    The code I have so far is :
    Enter short when ((open-close)/close)>5% and close-open>5%
    Exit short when time >= 9:30 and

Unfortunately, I get an error (Enter is not defined). Not sure how to access yesterday’s data while working today with a one minute time frame. Also I don’t understand how I can create moving stops.

If anyone could point me in the right direction, I would be grateful. Thanks

Hi and welcome to the community. It’s great to see you giving QuantScript a try!

Regarding your issue:

Writing “5%” does not do what you expect it to.

In QuantScript, “%” is a modulo operator - it accepts two numbers and returns the remainder after division.

e.g. 5 % 2 gives you 1.

More info here: https://docs.proquant.com/docs/operators/binary/mod

Let me know if I can help with anything else.

Cheers!

1 Like

Thanks a lot for your response, I forgot about % acting as an operator. I have modified the code accordingly:
Enter short when ((open-close)/close)>0.05 and close-open>0.05
Exit short when time >= 9:30
I still cannot run it. The debug mode is greyed out, how can I found out what is wrong with the code?

Thanks a lot.

Help with QS - if open price = x%

Should help