Help with coding indicator pls  [SOLVED]

Questions about MultiCharts and user contributed studies.
aczk
Posts: 71
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Help with coding indicator pls

Postby aczk » 29 Nov 2022

I am trying to code an indicator that adds up the delta (in data 2, as bar delta (in ticks & bid ask traded) when candles are green/up.

For example (refers to red box in attached screenshot of ES 5 min chart):
1. There are three green candles
2. The delta of these three are: 61, 157 & 26.
3. Add up to 244
4. Then diplay all three plots of the three green candles as 244. (currently it adds consecutively)

Desired outcome as dotted yellow box.

Same for down and red delta

Any thought, been banging my head against this for hours yesterday.
Thx
Code so far

Code: Select all

vars: CountGreenDelta(0), CountRedDelta(0), MaxGreenDelta(0); // green candles so we start adding up the data 2 bar delta (in ticks & bid ask traded) if c>c[1] then begin CountGreenDelta = CountGreenDelta + close of data2; end; // reset if red bar if c<c[1] then CountGreenDelta = 0; // Plot plot1(CountGreenDelta); plot3(0,"zero line",white);
Image
Attachments
Untitled.png
(57.41 KiB) Not downloaded yet

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Help with coding indicator pls

Postby TJ » 29 Nov 2022

For example (refers to red box in attached screenshot of ES 5 min chart):
1. There are three green candles
2. The delta of these three are: 61, 157 & 26.
3. Add up to 244
4. Then diplay all three plots of the three green candles as 244. (currently it adds consecutively)
You are doing well, but don't just stop there . . .
You have to write out the operation of each and every possible scenario.

eg.
1. what do you want to do with the 4th green candle?
2. what do you want to do if the 4th candle is red?
3. what do you want to do if the 4th and 5th candles are green?
4. what do you want to do if the 4th and 5th candles are red?
5. what do you want to do if the 4th is red and the 5th is green?
6. . . .

People cannot read your mind.

aczk
Posts: 71
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Re: Help with coding indicator pls

Postby aczk » 29 Nov 2022

Hi
ok I try

1. If a fourth green candle forms then add the delta in as well and so on, until a red candle forms.
2. Then reset the green count and start counting the red delta while the candles are down/red
etc.

So add up the deltas until an opposing candle forms.
I pretty much got that right, but I only want to show the last and highest delta count in each sequence/swing. Not sure how to make the previous two green plot in the red box the same as the third highest/max plot?
Does this make sense?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Help with coding indicator pls

Postby TJ » 29 Nov 2022

....
I pretty much got that right, but I only want to show the last and highest delta count in each sequence/swing. Not sure how to make the previous two green plot in the red box the same as the third highest/max plot?
Does this make sense?
I don't understand what you are talking about.
You need to draw a mock-up, with notes and arrows highlighting the salient points of the chart.

aczk
Posts: 71
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Re: Help with coding indicator pls

Postby aczk » 30 Nov 2022

ok i tried a drawing
Attachments
drawing.png
(88.26 KiB) Not downloaded yet

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Help with coding indicator pls

Postby TJ » 30 Nov 2022

You can try this print routine:
(I am not in front of my MC, I have not tested the code. Please give it a try and let me know the results.)

Code: Select all

Var: CandleDelta(0), CandleDeltaSum(0), GreenCandle(false), CountBars(0), BarColor(0); CandleDelta = c - (c of data2); GreenCandle = c > (c of data2); If GreenCandle then BarColor = green else BarColor = red; If (GreenCandle = True and GreenCandle[1] = False) or (GreenCandle = False and GreenCandle[1] = True) then Begin // Reset CountBars = 0; CandleDeltaSum = CandleDelta; plot1(CandleDeltaSum, Barcolor); end else Begin // continue CandleDeltaSum = CandleDeltaSum + CandleDelta; For value1 = 0 to CountBars Begin plot1[CountBars] (CandleDeltaSum, BarColor); End; end; CountBars = CountBars + 1; plot3(0,"zero line",white);

aczk
Posts: 71
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Re: Help with coding indicator pls  [SOLVED]

Postby aczk » 06 Dec 2022

tons of merry thanks!!

Had to change it up a bit, but pretty much shows what I want now.

thx


Return to “MultiCharts”