• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Need help with Syntax

Cmeeker778

New member
plot arrow_up = open("period" = AggregationPeriod.FIVE_MIN); RSI crosses above 30 within 1 bar + StochasticFast crosses above 20;

basically I'm trying to plot a boolean up or down arrow at the the open of a 5 min price bar; based on RSI, Momentum and Stochastic fast slope; or cross above the oversold/overbought areas

I've never written an indicator so any help would be much appreciated!
 

Pensar

Well-known member
VIP
@Cmeeker778 - Here's something that can help, not certain how you are trying to do the higher aggregation though. This code will find these conditions on whatever timeframe you are viewing.

Code:
def rsi = RSI() crosses above 30 within 1 bar;
def sto = StochasticFast() crosses above 20;

plot arrow_up = rsi and sto;
     arrow_up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
 

Pensar

Well-known member
VIP
@Cmeeker778 Well, as long as you are on the 5 min timeframe, the arrows will plot based on the 5 min RSI and the 5 min StochasticFast, no aggregation period needed. Now if you decide to go to a 3 or 1 min chart, the arrows will be based on the 3 or 1 min timeframes unless you hard code the referenced indicators to use a 5 min aggregation. Otherwise, no agg period needs to be coded in.

The above code will give you an arrow every time the plot is true, otherwise, no arrow will be seen.
 

Cmeeker778

New member
@Cmeeker778 Probably. How do you define a "change of slope" and what is is the plot that is changing?
I'm working with this. Not quite where or how I want it, but its a start.

def rsi = isascending(open, 30);
def sto = isascending(open, 20); plot arrow_up= (rsi and sto); arrow_up.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
def rsi = isdescending(open, 70);
def sto = isadescending(open, 80); plot arrow_down= (rsi and sto); arrow_down.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN);
 

Pensar

Well-known member
VIP
You may want to rename your second set of variables, the ThinkScript editor wont accept it as currently coded. However, there is no reference to either the RSI or the StochasticFast in that code. When you are using "IsAscending" and "IsDecending", your code seems to be comparing the open price to the (open+close)/2 of the last 30,20,70,or 80 price bars. See https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/IsAscending and https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/IsDescending. If you are simply trying to find if the current RSI value is greater than the previous RSI value, maybe try something like def up = RSI() > RSI()[1];. Unless I'm just not comprehending what you are trying to do. :unsure:
 

Cmeeker778

New member
You may want to rename your second set of variables, the ThinkScript editor wont accept it as currently coded. However, there is no reference to either the RSI or the StochasticFast in that code. When you are using "IsAscending" and "IsDecending", your code seems to be comparing the open price to the (open+close)/2 of the last 30,20,70,or 80 price bars. See https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/IsAscending and https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/IsDescending. If you are simply trying to find if the current RSI value is greater than the previous RSI value, maybe try something like def up = RSI() > RSI()[1];. Unless I'm just not comprehending what you are trying to do. :unsure:
Okay thanks! Ya just want to populate a directional up arrow as the RSI and Stochastic started to accelerate higher; past the overbought/oversold levels.
My intention for "open" was to plot an arrow at the open price when a new five 5 min pops up.

I'm using these for scalp trades in binary options
I'll give your input a shot! thank you.
 
Last edited:

Similar threads

Top