So, I have an indicator I am working on that generates buy/sell signals. I am try to calculate the price change or difference between each buy signal and summing the result. I have been racking my brain trying to get this to work. What would be the thinkscript logic to accomplish this. So far i have this below.
bullishpb is the buysignal for example. My logic is that with fold, it will loop through each bar in the chart and if a bullishpb signal is found, then get the value of that close. When I did this, I get a 0.
def bupchg = fold b = 0 to 252 do if bullishpb is true then GetValue(close,-b) else double.nan;
Asking for help. Thank you.
bullishpb is the buysignal for example. My logic is that with fold, it will loop through each bar in the chart and if a bullishpb signal is found, then get the value of that close. When I did this, I get a 0.
def bupchg = fold b = 0 to 252 do if bullishpb is true then GetValue(close,-b) else double.nan;
Asking for help. Thank you.