Short Term Volatility

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #13162 quote
    wolf
    Participant
    Junior

    Hi, Im having trouble coding a system where it will open a position after a stock has risen/fallen 1% in the last 30 minutes.

    Any help is welcome since I have been struggling to code anything that works.

    Thank you

    Jem

    #13172 quote
    Nicolas
    Keymaster
    Master

    There is a specific instruction for Variation that you can use easily to make what you want to do.

    On a 30 minutes chart, the code would be :

    condition = Variation(close)>=1
    
    IF condition THEN 
     BUY 1 SHARE AT MARKET 
    ENDIF
    wolf thanked this post
    #13175 quote
    wolf
    Participant
    Junior

    ok great thank you, but what if i wanted the last 30 minutes but on a 5 minute chart?

     

    Thanks

    #13180 quote
    Nicolas
    Keymaster
    Master

    You can code it like this, make the summation of the last 6 Variation (6 x 5minutes candlesticks = 30 minutes) :

    condition = summation[6](Variation(close))>=1

    Didn’t test it though, but it should work ok.

    wolf thanked this post
    #13181 quote
    wolf
    Participant
    Junior

    Hi Nicolas,

    I’ve tested it and it seems to work but still unsure as it is the weekend, but thank you for your help.

    I would greatly appreciate it if you could breakdown the part of code listed below since I might need to adjust some conditions at a later date.

    Thanks

    Code:

    condition = summation[100](Variation(close))>=1

    IF condition THEN
    buy 1 share at market
    ENDIF

    #13182 quote
    Nicolas
    Keymaster
    Master

    You want me to explain each line?

    wolf thanked this post
    #13183 quote
    wolf
    Participant
    Junior

    no sorry just this part please ‘summation[100](Variation(close))>=1’

    #13196 quote
    Nicolas
    Keymaster
    Master

    Summation calculate the sum over the last X periods (100 in this case) of the value under brackets.

    But in this statement, we test if this summation is superior or equal to 1. So if it’s true, the ‘condition’ variable is set to 1 (which is “true” in PRT language).

    wolf thanked this post
    #13201 quote
    wolf
    Participant
    Junior

    ok thank you, so if i wanted to adjust the code to look for 2% changes instead of 1%, what part should i alter.

    #13202 quote
    wolf
    Participant
    Junior

    Also it doesnt seem to work with stocks that have fallen x % it only shows stocks that have gone up

    #13206 quote
    wolf
    Participant
    Junior

    Hi Nicolas,

    After doing some testing ive found out it works alot better in a screener format, ive only changed the code from ‘buy 1 share at market’ to ‘screener’ and ive found these issues:

    • Code doesn’t display stocks that have fallen, only risen
    • It doesn’t work alot of the time, for example to test the code, I found some examples where the stock has risen 1% or more in the last few hours of Friday’s trading day and adjusted the screener to the same amount of hours and the stock wont appear in the screener when it should.
    • It works well when candles our on ‘daily’ (still only stocks that have risen) but when I put it on 10 mintues or 5 minutes I have many issues.

    Any help is welcome, thank you

    #13208 quote
    Nicolas
    Keymaster
    Master

    Yes this code is only for rising 1%, if you want to catch the falling stocks, just change the formula to find the ones that are <=-1% .. that’s all 🙂

    I believe you have not real time access, only EOD?

    wolf thanked this post
    #13209 quote
    wolf
    Participant
    Junior

    Just added the falling stock code, and everything has gone crazy lol. Have I done something wrong? as it now picks stocks that havnt moved more than 1% in the last 30 mins. Ive attached a picture where you can see my code, the stock and the screener on the left.

    Thanks for your help 🙂

    Image: https://gyazo.com/925f98b99649fb9601bb6d8a7874e259

    #13215 quote
    Nicolas
    Keymaster
    Master

    Ouch…what have you done? 😨
    I’ll fix this tomorrow or maybe later.
    You can also upload pictures here FYI.

    wolf thanked this post
    #13216 quote
    wolf
    Participant
    Junior

    Clearly im good at breaking stuff haha
    Anytime before monday would be hugely appreciated.
    I saw you could but the program i use gives me a web link but ill upload the images instead from now on 🙂

Viewing 15 posts - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.

Short Term Volatility


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
wolf @wolf Participant
Summary

This topic contains 22 replies,
has 2 voices, and was last updated by wolf
9 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/16/2016
Status: Active
Attachments: No files
Logo Logo
Loading...