Open vs Close vs Last?


New member

I am new to ThinkScript (and this website). So far I have developed a strategy that creates a buy order after certain conditions are met for RSI and MACD. It includes a stop loss command that seems to work as well as a sell command when the price drops below a moving average. The problem that I am having is that I have not yet found a way to sell when the price breaks through the moving average. the code works based on either the open price or close price of the last bar. Here is the sell order code.

AddOrder(OrderType.SELL_TO_CLOSE, close < SMAPriority, tickColor = GetColor(1), arrowColor = GetColor(1), name = "TMB_Sell");

The problem I am having is that I would like to create the sell order right when the price drops through the moving average, and not 10 ticks or 35 seconds later at the close of the bar. In some cases, the price drops considerably between the cross of the moving average and the close of the bar. I tried many different ways and searched the internet but am not finding what I am looking for. I imagine there is a simple method that I have overlooked.

Any help would be greatly appreciated.


Similar threads