Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
So... I have been looking to automate something i am doing manually for higher timeframe charts. Which to be precise is to mark "zones" on higher timeframes after i see 3 consecutive bricks in one direction after a reversal renko bar.
The general idea can be understood and seen quickly from the attached chart. Whenever there is a reversal bar, if there are 3 bars moving in the same direction (including the reversal bar) i mark the lower end with an extending rectangle.
(Too be fair depending on the constellation, brick size etc sometimes i will only mark the tail/wick and sometimes the entire structure but for discussion purposes i chose to make the illustrated example rather simple).
Now the question remains is how do i implement this in the most efficient way in ACSIL? I have taken a look at the Autotrendline study Sierrachart has coded for some clues/ideas/references but it seems right now the most effective way would be to let a Loop run where every bar is compared with the previous bar and the next 3 following bar.
I.e It would compare bar at index X to the previous bar at X-1 if X's Close > X-1 Close then the first condition is met.
and then obviously (x+1 close > x close) and (x+2 Close > X+1 Close)
So if Conditions:
1) X Close > X-1 Close
2) X+1 Close > X Close
3) X+2 Close > X+1 Close
Are met then we would use the ACSIL reference code to draw an extending rectangle With the lower and upper line parameters of X-1 Close (lower rectangle line) and X Open (upper rectangle line).
Now the question is how would i most effectively implement this? Does anyone have tutorials or examples of ACSIL coded studied that do something similar? Because my biggest problem right now is the Indexing of the seperate bars.
I would appreciate insight/help into this from anybody.
Can you help answer these questions from other members on NexusFi?
I've never drawn tools in ascil before, so I would just draw two lines and fill them. The lines will be draw from the current index, but you want to go back, so I think you can create a custom index just for previous 3 bars and make two additional lines that are equal to the current lines. Never done it before though, so you will have to try it out, but I'm thinking something like:
The lines will overlap starting on the current index, but I don't think that will cause problems. If you don't want to use lines, then you will have to study up on the tools, cuz I can't help you there, and I'm sure there is a better way to do it if someone else wants to chime in.
Yes obviously you can inverse the conditions to get the opposite for shorts.
I have thought a little bit more about the implementation, i will need to read up on how ACSIL handles indexing and then i guess the only remaining issues are "overpainting" or adding too many rectangles as the loop continues/repeats itself from the base index and obviously how to make this more resource friendly and implement it.
I will write some Pseudocode for this entire thing and i guess try to implement it then ultimately =/
Anyone got pointers/suggestion on already existing code to look at or what to read?
Yeah, I would go with filled lines because then you won't be limited to the number of instances, whereas the tool will slow you down the more you add. I did this quickly as a proof of concept, need to flesh it out, but it seems to work ok.
int Index = sc.Index;
for(int i = 1; i<=2; i++)
{
Plot2[Index-i] = Plot1[sc.Index];
}
This loop, why does it simply count to two and thus sets the values of index-1 and index-2 i.e the two bars before the current indexed bars to the same value as the current indexed bars?
What is the point of this or why is this crucial/necessary for the code to work?
1. The index check is not technically needed, because SC will guard against accessing bad array indexes. However, it is good practice to not access values that do not exist, especially if they affect your overall logic moving forward (i.e. you do not want to generate bogus data that then feeds forward).
2. Vegas can explain his intent, but he is basically back propagating the values for the next calculation.
3. The assignment of sc.DataStartIndex really belongs in the SetDefaults block. (minor)
4. While I said that drawings would not slow you down, this code is a good example where I would not use them just because the code is so simple, and drawings would add some complexity. Only add them if you need to.