Money Flow Script

Hi,

I am trying to script an indicator that does the following:

• When the security price closes higher, calculate price * volume and add that to the previous value.
• When the security price closes lower, calculate price * volume and subtract that from the previous value.
Not sure what to do to make this work. Here is my attempt:
```//Define the variables
V1 == 0 ;
V2 = VOLUME() ;
V3 = CLOSE() ;
//Calculate Money Flow
V4 = IF(CLOSE() IsUp, V1 + (V2 * V3)) ;
V5 = IF(CLOSE() IsDown, V1 - (V2 * V3)) ;
ACC(V4 and V5, RANGE=All Time)```
Thank you for helping.

Hi Louis,

We have a tool called Turnover with a function TO() which is basically the daily value of trading (close x volume). We can take the TO() value and multiply it by -1 when the IF() condition is false. This will calculate the all-time money flow:

```//Get Turnover value based on the close position;
V1 = IF(CLOSE() IsUp, TO(),TO()*-1);
//Sum the values;
ACC(V1, RANGE=All Time)```

Thanks Darren. Appreciate your help.