store data based on event and use for future calculation

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #153788 quote
    theo123
    Participant
    Junior

    Hi,

    Im wondering if data (eg. Donchian Channel Down) in a given event (price > donchian channel middle) can be collected everytime the event happened and used it in the future calculation.

    Say, there are 4x an event happen in a given timeframe.  Note: counter or data collection, will reset if price crosses under donchianMiddle

    EventTrigger = price crosses over dochianMiddle
    DCDatEVENT = DonchianDown

    I intend to have 2 calcuations:

    Calcuation will be for maximum: 2nd time event happen, get the max of DCDatEVENT (first and second); 3rd time (max of the last 3), 4th time (max of all 4).  What is the code for this?

    Use the latest DCDatEvent as stop loss

    appreciate any response.

    #153828 quote
    Nicolas
    Keymaster
    Master

    Note: counter or data collection, will reset if price crosses under donchianMiddle

    Ok, but in order for the price to cross over the Middle line, it needs first to cross under, so how do you want to store multiple price levels if you reset everything before any consecutive event?

    #153832 quote
    theo123
    Participant
    Junior

    Hi Nicolas,

    Im looking at crosses under as an early exit points.

    But there are cases that I see that there are no crosses under that happens but price opens lower than the middle and crosses over.

    #153835 quote
    Nicolas
    Keymaster
    Master

    price > donchian channel middle

    is different from

    price crosses over donchian channel middle

    please define what is the condition to use the DonchianChannelDown as a stoploss.

    By the way, it will never trigger as you “early exit” when you cross the middle line!

    #153840 quote
    theo123
    Participant
    Junior

    yes, they are differentand  those are the scenarios that im lookimg for ie.  4 times the PRICE<MIDDLE, then later after candles or right after PRICE CROSSES OVER MIDDLE without crossing the donchiandown.

    so in addition to above, buy and sell codes will be like this.

    if not longonmarket and EventTrigger then
    buy 1 at matket
    set stop loss at DCDatEVENT
    end if
    
    if longonmarket and price crosses under DonchianMiddle then
    sell at market
    endif

    the one I would like to add in the sell code are the either of the 2 options stated in the initial post based on succeeding DCDatEvent during possible 2 or more events of price crosses over donchianmiddle

    -as per the initial post, it should either the maximum of all previous DCDatEvent  or the latest DCDatEvent.

    #153856 quote
    Nicolas
    Keymaster
    Master

    But there are cases that I see that there are no crosses under that happens but price opens lower than the middle and crosses over.

    If the price was above and now below, it is a crossover.

    Well, at this point, I think a picture would be way better to explain what you want, cause I’m lost now…

    #153861 quote
    theo123
    Participant
    Junior

    Hi Nicola,

    Please see attached.  there will be instances that there is no cross under of price since open of the candlestick is already below donchianmiddle.

    sample-2.png sample-2.png
    #153863 quote
    theo123
    Participant
    Junior

    The confusion might be on the term “price” which I meant “close” and encoded incorreclty as well

    #154039 quote
    theo123
    Participant
    Junior

    Appreciate any possible solution to this topic.  Many thabks in advance.

    #154134 quote
    theo123
    Participant
    Junior

    Found a psoosible solution but not working fully as intended.  create an indicator first to know how ot would look like.

    note, this is for target2: use the latest donchianmiddle during triggerevent

    DonchianDown=LOWEST[10](LOW[1])
    DonchianUp=highest[10](high[1])
    donchianMiddle =(DonchianDown+DonchianUp)/2
    EventTrigger = close crosses over donchianMiddle
    DCDatEVENT = DonchianDown
    
    if EventTrigger then
    exitLIne=DCDatEVENT
    mybarindex=BARINDEX
    ENDIF
    if NOT EventTrigger then
    exitLIne=DCDatEVENT[mybarindex]
    endif
    
    return exitline

    appreciate who could advice tge changes required to the code.  i dont know why it goes up after 10bars

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

store data based on event and use for future calculation


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
theo123 @theo123 Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by theo123
5 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/15/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...