An idea for extreme volatile situations "movile risk level"

Hello there:



 This morning I was watching ticker HILS  (Hillstream Biopharma), and noticed that today (june 13th , 2022 ) it has spiked  really big right after the market opened… going from  near 1,10  to more than 1,90 (more than 70 % ) in a matter of less than half hour,  it was even halted for a few  minutes, so I was wondering…



Maybe we could write a code that actually sends a limit order with a stop loss…, and maybe modify the stop loss to "chase " the trend…



What I mean for that, is for example, let's say that I send an limit order to buy HILS at 1,15 (this was already above the EMA(20)  and SMA(9) of the intraday one minute chart)  with a stop loss at 1,09…



Once the stock is 1,21 (more than 5% above from where I bought it), the code modifies the stop loss so that It is now at 1,18 (so that  2,5 % is profit is locked in)…



Once the  stocks hits for example 1,38 (20 % profit) the stop loss is modified to 1,32 ( 14% profit locked in)… and so on…



I wonder if that is possible to do in python using Ibridgepy…   ??  Has anyone tried using this kind of "movile risk levels"  ??, and if you haven't done so… is this a good idea??  What do you think about it??



And what will happen  if the stock is halted for a few minutes ?  (like this one…)

Hi Ghery,



You can use trailing stop-loss here. Let's understand how you can use trailing stop-loss (TSL) step by step:

 

  1. You can set TSL at some percentage of the close price like this: close_price * (1 - stop_loss_percentage).
  2. You can update the TSL in each iteration of your strategy using the same formula. The idea here is that the TSL should be some percentage, let's say 5% lower than the close price. 
  3. You are updating the value of TSL in each iteration of the strategy this is good until the close price of the current candle is greater than the previous candle. But what if the current candles close price drops? In that case, you will need to keep the previous value of the TSL. In other words, at any time you will have two values of the TSL:
    1. One that you calculated for the previous candle let's call it PTSL
    2. One that you calculate for the current candle we can call this CTSL
    3. You need the max of PTSL and CTSL i.e. TSL = max(PTSL, CTSL)
  4. And finally, if the price ever hits the TSL you exit your position.

Check this article to read more about trailing stop-loss.

I hope this helps!