uspilotzzz
New member
Hey all, totally new to TOS here and learning thinkscript. I have been messing around with making studies and then using a study to add a strategy with entry and exit rules. Here is a very basic candlestick set up that I wanted to add an adjustable stop and profit target to.
def entrycandle = Close < open;
def low3and2 = low[3] <= low[2];
def high3and2 = high[3] <= high[2];
def low2and1 = low[2] <= low[1];
def high2and1 = high[2] <= high[1];
def highandhigh1 = high <= high[1];
def greencandle3 = close[3] > open[3];
def greencandle2 = close[2] > open[2];
def greencandle1 = close[1] > open[1];
def engulffing = close < low[1];
input stoploss = 8;
input profittarget = 12;
plot signal = entrycandle and low3and2 and high3and2 and low2and1 and high2and1 and highandhigh1 and greencandle3 and greencandle2 and greencandle1 and engulffing;
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
alert(signal,"TurnDown", alert.Bar,sound.ding);
addOrder(OrderType.sell_TO_OPEN, signal);
addorder (ordertype.buy_to_close, entryprice() +8);
addorder (ordertype.buy_to_close, entryprice() - 12);
I have also been trying to use the script stoplosslx and profittargetlx but I cant find any info on how that should be written
thanks
def entrycandle = Close < open;
def low3and2 = low[3] <= low[2];
def high3and2 = high[3] <= high[2];
def low2and1 = low[2] <= low[1];
def high2and1 = high[2] <= high[1];
def highandhigh1 = high <= high[1];
def greencandle3 = close[3] > open[3];
def greencandle2 = close[2] > open[2];
def greencandle1 = close[1] > open[1];
def engulffing = close < low[1];
input stoploss = 8;
input profittarget = 12;
plot signal = entrycandle and low3and2 and high3and2 and low2and1 and high2and1 and highandhigh1 and greencandle3 and greencandle2 and greencandle1 and engulffing;
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
alert(signal,"TurnDown", alert.Bar,sound.ding);
addOrder(OrderType.sell_TO_OPEN, signal);
addorder (ordertype.buy_to_close, entryprice() +8);
addorder (ordertype.buy_to_close, entryprice() - 12);
I have also been trying to use the script stoplosslx and profittargetlx but I cant find any info on how that should be written
thanks
Last edited by a moderator: