Storing a met condition in a previous bar

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • #115967 quote
    Vonasi
    Moderator
    Master

    On the 3rd the average cross happened and crossflag was set to 1 and averagecrosslong was set to 1 but abovebollinger is 0.

    On the 4th crossflag is still valid but abovebollinger is still 0 so no order is sent.

    On the 5th crossflag switches to 0 because an order is sent to buy and abovebollinger is set to 1 because that condition is now true.

    On the open of the 6th a trade is opened.

    Everything is as it should be.

    I would suggest graphing the value of the averages in your code and double check that they are the same as those on your chart.

    #115968 quote
    Mike Boorman
    Participant
    Average

    So I’ve graphed the instrument values (see first screengrab). Now we can see the problem (finally!)

    “Boll middle” is listed as 10,158

    “Average[21]” is listed as 10,274

    They are different values, but I’ve been working on the basis that Average[21] in code should refer to the black “Boll Middle” line. I’m using “Average[21]” because it is suggested to me as the code for the middle bollinger (as you can see from the other screengrab).

    What is the code I should use to make sure I call up “Boll Middle” from Pro Order?

    Screen-Shot-2020-01-05-at-21.21.35.png Screen-Shot-2020-01-05-at-21.21.35.png Screen-Shot-2020-01-05-at-21.23.50.png Screen-Shot-2020-01-05-at-21.23.50.png
    #115974 quote
    Vonasi
    Moderator
    Master

    Check in your Bollinger Band indicator settings that everything is the same. Perhaps you have it set to use a simple average instead of an exponential average or maybe it is based on a different price to closing price?

    Also consider using BOLLINGERUP and BOLLINGERDOWN and calculating the mid point between them.

    .

    #115978 quote
    Mike Boorman
    Participant
    Average

    It’s just the standard 21, 0.1 based on close (see screengrab). I’ve tried every combination in that box to try and return the value of 10,274, but none of them do. I can’t understand why indicator Average[21] is returning 10,274. There is also disparity between the EMoving Average 8 reading and my coded ExponentialAverage[8].

    Is “Average[21](close)” the right syntax here? Or is there something else I should use?

    Screen-Shot-2020-01-05-at-22.48.44.png Screen-Shot-2020-01-05-at-22.48.44.png
    #115980 quote
    Vonasi
    Moderator
    Master

    You have something set wrong as your code uses a simple 21 period moving average of closing price. I have drawn it on my own chart four ways and they are all identical.

    • Simple Bollinger mid line.
    • Average[21](close) returned
    • Average[21,0](close) returned
    • and the PRT built in average indicator.
    Screenshot_2.png Screenshot_2.png
    #115982 quote
    Mike Boorman
    Participant
    Average

    These are the only settings I can see for the Bollinger (see screengrabs). What should I change?

    Screen-Shot-2020-01-05-at-23.25.03.png Screen-Shot-2020-01-05-at-23.25.03.png Screen-Shot-2020-01-05-at-23.24.52.png Screen-Shot-2020-01-05-at-23.24.52.png
    #115985 quote
    Vonasi
    Moderator
    Master

    They are all the same for me!!!!

    Mike Boorman thanked this post
    Screenshot_3.png Screenshot_3.png
    #116060 quote
    Mike Boorman
    Participant
    Average

    I tried to create a new chart from scratch and I got the same disparity. I then created a whole load of charts on different markets and there was no problem! It seems this is exclusive to the Bitcoin DFB chart (XBTUSD) on PRT linked to IG.

    Thank you for your help. It is useful for me in future to know that I can graph instruments to double check unusual results.

    #116076 quote
    Vonasi
    Moderator
    Master

    Yes GRAPH and GRAPHONPRICE are very useful debugging tools.

    I would send a technical report to PRT via your platform regarding the Bitcoin averaging problem if I was you (although it will go via IG so PRT may never receive it!)

    #116198 quote
    Mike Boorman
    Participant
    Average

    On a similar theme to the above system, I’m trying to store met conditions for an entry that will only occur a number of bars after the first condition.

    There are three entry rules for this system:

    RSI goes above 80

    RSI then drops below 75

    RSI then rises above 80 again

    I’ve coded it with similar principles to how you coded the two-rule code earlier in this thread, but I knew that it wouldn’t work because in code the first rule appears exactly the same as the third rule. When I use only the first two rules, it correctly enters when RSI drops below 75, so how do I store the first two conditions and then code a third rule to work after the first two? I’m aware that I can change the first and second rules to only act in previous bars with [5] or [6] for example, but this seems messy. Is there a clean way of creating three rules that act sequentially?

    DEFPARAM CumulateOrders = False
    
    firstshortrule = RSI[6](close) >80
    secondshortrule = RSI[6](close) <75
    thirdshortrule = RSI[6](close) >80
    
    
    if firstshortrule and not firstshortrule[1] then
    rise = 1
    endif
    
    if secondshortrule and not secondshortrule[1] then
    drop = 1
    endif
    
    if thirdshortrule and not thirdshortrule[1] then
    secondrise = 1
    endif
    
    if rise = 1 and drop = 1 then
    tworules = 1
    endif
    if tworules = 1 and secondrise = 1 then
    sellshort 1 perpoint at market
    
    rise = 0
    drop = 0
    tworules= 0
    secondrise = 0
    endif
    
    set stop ptrailing 15
Viewing 10 posts - 16 through 25 (of 25 total)
  • You must be logged in to reply to this topic.

Storing a met condition in a previous bar


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 24 replies,
has 3 voices, and was last updated by Mike Boorman
6 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/03/2020
Status: Active
Attachments: 14 files
Logo Logo
Loading...