'Tradingview Pine Script Exit Strategy

Please help me to add the Pine Script code for Tradingview , Please refer the following Codes . I want to close the buy and sell Orders after 1 Dollar profit.Like I want to try it on gold . E.g., If buy enter at 1805 then it should exit from long at 1806 and for sell if enter at 1804 then it should close at 1803.

strategy("Compare Price Momentum Oscillator [CC]", shorttitle = "CPMO", overlay=false)

length1 = input(title="Length1", type=input.integer, defval=20, minval=1)
length2 = input(title="Length2", type=input.integer, defval=35, minval=1)
spSym = input(title="S&P 500 Symbol", type=input.symbol, defval="SPY")
inp = input(title="Source", type=input.source, defval=close)
res = input(title="Resolution", type=input.resolution, defval="")
rep = input(title="Allow Repainting?", type=input.bool, defval=false)
bar = input(title="Allow Bar Color Change?", type=input.bool, defval=true)
src = security(syminfo.tickerid, res, inp[rep ? 0 : barstate.isrealtime ? 1 : 0])[rep ? 0 : barstate.isrealtime ? 0 : 1]
spSrc = security(spSym, res, inp[rep ? 0 : barstate.isrealtime ? 1 : 0])[rep ? 0 : barstate.isrealtime ? 0 : 1]

pmo = ema(10 * ema(nz(roc(src, 1)), length2), length1)
spPmo = ema(10 * ema(nz(roc(spSrc, 1)), length2), length1)
cpmo = pmo - spPmo

sig = cpmo > 0 ? 1 : cpmo < 0 ? -1 : 0
alertcondition(crossover(sig, 0), "Buy Signal", "Bullish Change Detected")
alertcondition(crossunder(sig, 0), "Sell Signal", "Bearish Change Detected")
cpmoColor = sig > 0 ? color.green : sig < 0 ? color.red : color.black
barcolor(bar ? cpmoColor : na)
plot(cpmo, title="CPMO", color=cpmoColor, linewidth=2)
long = crossover(sig,0)
short = crossunder(sig,0)
strategy.entry("long" , true, when = long)
strategy.entry("Short" , false, when = short)

enter image description here



Solution 1:[1]

It is rather straightforward: you simply need to set .gallery to hide overflowing content, and then add a simple CSS transition to the img element.

p/s: You might want to use object-fit to ensure you don't end up skewing the aspect ratio of the image.

:root {
  --wid: 300px;
}

.gallery {
  background: grey;
  width: var(--wid);
  overflow: hidden;
}

img {
  display: block;
  height: 250px;
  width: var(--wid);
  transition: all .25s ease-in-out;
  
  /* Optional: to avoid skewing of aspect ratio */
  object-fit: contain;
}

img:hover {
  transform: scale(1.5);
}
<div class="gallery">
  <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/Wikipedia_logo_%28svg%29.svg/1250px-Wikipedia_logo_%28svg%29.svg.png" />
</div>

Solution 2:[2]

    :root {
      --wid: 300px;
    }

    .gallery {
      background: grey;
      width: var(--wid);
      overflow: hidden;
     
    }

    img {
      display: flex;
      height: 250px;
      width: var(--wid);
      transition: all .50s ease-in-out;
      
      /* Optional: to avoid skewing of aspect ratio */
      object-fit: contain;
    }

    img:hover {
      transform: scale(2);
    }
    <div class="gallery">
      <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/07/Wikipedia_logo_%28svg%29.svg/1250px-Wikipedia_logo_%28svg%29.svg.png" />
    </div>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Terry
Solution 2 Hamada Elbanoby