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.
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?
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.
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!
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.
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…
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.
The confusion might be on the term “price” which I meant “close” and encoded incorreclty as well
Appreciate any possible solution to this topic. Many thabks in advance.
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