Total number of trades code not totaling


Category:
0
0

Hello Pete,

I have some code for a chart label that isn’t calculating the sum total correctly for the “number of trades on the day” . The code seems to only be counting for the current 1-minute bar.

 

I would like it to take the the sum total of all 1 miunte bars.

 

def Trades = Fundamental(FundamentalType.TICK_COUNT);
def newDay1 = GetDay() <> GetDay()[1];
rec todaystrades = if newDay1 then trades else todaystrades[1] + trades;
AddLabel(yes, Concat(“trades# “, trades), (if trades > 100 then Color.green else Color.BLACK));

Marked as spam
Posted by (Questions: 22, Answers: 63)
Asked on February 3, 2019 9:05 pm
137 views
0
Private answer

The problem is that you are computing the sum total of trades but you are not using that in your label. Your label is set to display trades while it should be set to display todaystrades.

So this is wrong:

AddLabel(yes, Concat(“trades# “, trades), (if trades > 100 then Color.green else Color.BLACK))

And this is correct:

AddLabel(yes, Concat(“trades# “, todaystrades), (if todaystrades > 100 then Color.green else Color.BLACK))

Marked as spam
Posted by (Questions: 37, Answers: 4117)
Answered on February 6, 2019 9:25 am
0
genius !!!
( at February 6, 2019 2:27 pm)