Bingy
Member
Hey Guys,
I'm new to the forum, but have been a long time lurker. I'm currently working on a ThinkScript Strategy and I'm trying to backtest it using ThinkorSwim's "On-Demand" feature. The strategy seems promising, but like any good strategy, it's partially dependent on the stop loss strategy to get an accurate feel for how well the strategy is working over a given timeframe.
Essentially, what I'm wanting it to do is to check for the lowest low within the previous 4 bars PRIOR to the "BuySignal" and then I want it to trigger the stop loss if the current bar closes below this low.
I've tried so many different ways and have spent hours trying to figure this out to no avail, so I'm hoping someone here can help me after I've tried helping myself. Thanks in advance!!
#CODE
def BuySignal = SemiCondition and (CAM_UP or CAM_PB or CAM_DN) and BearPower < -20 and EOM < 0 and LowerVolatility;
def ExitSignal = PercentBcross_DWN_Exceltrade;
#############################
#############################
#*********STOP LOSS DEF NEEDS TO BE COMPLETED IN THIS REGION
def Stop_loss = ;
############################
############################
# Define order placement
AddOrder(OrderType.BUY_TO_OPEN, BuySignal, open[-1], 4, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "Buy");
#Stop loss
AddOrder(OrderType.SELL_TO_CLOSE, Stop_Loss, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "Stopped Out");
AddOrder(OrderType.SELL_TO_CLOSE, ExitSignal, open[-1], 4, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "Sell");
I'm new to the forum, but have been a long time lurker. I'm currently working on a ThinkScript Strategy and I'm trying to backtest it using ThinkorSwim's "On-Demand" feature. The strategy seems promising, but like any good strategy, it's partially dependent on the stop loss strategy to get an accurate feel for how well the strategy is working over a given timeframe.
Essentially, what I'm wanting it to do is to check for the lowest low within the previous 4 bars PRIOR to the "BuySignal" and then I want it to trigger the stop loss if the current bar closes below this low.
I've tried so many different ways and have spent hours trying to figure this out to no avail, so I'm hoping someone here can help me after I've tried helping myself. Thanks in advance!!
#CODE
def BuySignal = SemiCondition and (CAM_UP or CAM_PB or CAM_DN) and BearPower < -20 and EOM < 0 and LowerVolatility;
def ExitSignal = PercentBcross_DWN_Exceltrade;
#############################
#############################
#*********STOP LOSS DEF NEEDS TO BE COMPLETED IN THIS REGION
def Stop_loss = ;
############################
############################
# Define order placement
AddOrder(OrderType.BUY_TO_OPEN, BuySignal, open[-1], 4, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "Buy");
#Stop loss
AddOrder(OrderType.SELL_TO_CLOSE, Stop_Loss, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "Stopped Out");
AddOrder(OrderType.SELL_TO_CLOSE, ExitSignal, open[-1], 4, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "Sell");
Last edited by a moderator: