Sell if closing pri...

Clear all

# [Solved] Sell if closing price is at least 5% lower from the buying point.

7 Posts
4 Users
5 Likes
612 Views
(@joeffrenz)
Posts: 7
Active Member User
Topic starter

Hi VAI,

I'm having a problem with my sell condition. I want to sell if the closing price is at least 5% lower from my buying point. Here's the scenario.

I bought at the closing price of 1.24 then the next day it closed at 0.97. So that's -21% from my buying point.

Here's my selling condition.

Set SellCondition = 100 - (100*(close/Buy)) > 4

100 - (100*(0.97/1.24)) = 21.7741935484

But it ignores my condition. Any help? See the attached image for your reference.

Posted : 20/04/2021 11:03 am
(@snoperg)
Posts: 15

Use blockref to store the close price when your buy condition hit.

//Store the Buy Amount -> Blockref(value if condition1=True,value if condition2=True, Condition1, Condition2)

set cutloss = buyAmt<>0 And gain < -0.05

Posted : 20/04/2021 12:00 pm
georgejr and joeffrenz reacted
(@joeffrenz)
Posts: 7
Active Member User
Topic starter

@snoperg

Works like magic. Thanks!

Posted : 20/04/2021 2:42 pm
snoperg reacted
(@georgejr)
Posts: 5
Active Member User

Hi VAI Users,

Not sure if my issue is related to this question, I have a different buy and sell condition; when I run it, there are more sell executed than buy.

How do I add the condition where I will only sell if there is currently a buy position and crossover (MA50, EMA20)?

```Set BuyCondition = crossover(EMA20, MA50) AND (MACD_Line > MACD_Signal)
Set SellCondition = crossover(MA50,EMA20)
```
Posted : 28/04/2021 4:16 am
(@joeffrenz)
Posts: 7
Active Member User
Topic starter

For Example:

//Comment
//plot(sell,sell,red,main)

//Use

Posted : 28/04/2021 7:56 am
georgejr reacted
(@vanguardai)
Posts: 70