Calculations Performed Only at Close of Bar??

K

KarlWolff

Member
I'd like to adjust an indicator to not have intrabar calculations. For example, a buy/sell should only occur when a line is convincingly crossed, meaning the close of the bar. I don't want an indicator bouncing around a decision line; this can be done with a tab selection in TS. Any suggestions for TOS?
 
horserider

horserider

Well-known member
VIP
Might depend on how the study is coded. If it includes a "data" selection input. It allows a selection of variables.
Seems your basic choices are open, high, low, close. Pick " close".

If it is set to something other than close in the code then the code may need to be edited and set to "close"
 
Last edited:
K

KarlWolff

Member
Thanks for your reply! Yup, using "DATA." How would I go about adjusting it? Here's the code:
------------------------------------------------------------------------------------------------------------------------------
declare lower;
def agg = AggregationPeriod.FIVE_MIN;
plot data = close(period = agg);

data.SetDefaultColor(Color.WHITE);
data.SetLineWeight(3);
data.SetPaintingStrategy(PaintingStrategy.LINE);
data.SetStyle(Curve.LONG_DASH);
data.HideBubble();
data.HideTitle();

plot BDfastEMA=ExpAverage(DATA,8);

BDfastEMA.SetDefaultColor(Color.VIOLET);
BDfastEMA.SetLineWeight(5);
BDfastEMA.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
BDfastEMA.SetStyle(Curve.FIRM);
BDfastEMA.HideBubble();
BDfastEMA.HideTitle();

plot BDslowEMA=ExpAverage(DATA,40);

BDslowEMA.SetDefaultColor(Color.YELLOW);
BDslowEMA.SetLineWeight(3);
BDslowEMA.SetPaintingStrategy(PaintingStrategy.LINE);
BDslowEMA.SetStyle(Curve.FIRM);
BDslowEMA.HideBubble();
BDslowEMA.HideTitle();

def UpCross = if BDfastEMA > BDslowEma AND BDfastEMA[1] < BDslowEMA then 1 else 0;
Plot BDup = if UpCross then high else double.nan;

BDup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BDup.SetLineWeight(5);
BDup.SetDefaultColor(color.WHITE);
BDup.HideBubble();
BDup.HideTitle();

def DnCross = if BDfastEMA < BDslowEma AND BDfastEMA[1] > BDslowEMA then 1 else 0;
Plot BDdn = if DnCross then low else double.nan;

BDdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BDdn.SetLineWeight(5);
BDdn.SetDefaultColor(color.WHITE);
BDdn.HideBubble();
BDdn.HideTitle();

# END
 
horserider

horserider

Well-known member
VIP
plot data = close(period = agg); Already specifies close in your code so looks like you have what you want.

If you wish to be able to choose the data type insert the line below into the code.
input data = close;
 
horserider

horserider

Well-known member
VIP
Yep. Just be patient. Jump up and down with the bar while you wait.
 

Similar threads

Top