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.
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)
//If BuyCondition is true, buyAmt will keep the close price as buy amount. When SellCondition is True, buyAmt will be 0
set buyAmt= blockref(close,0,BuyCondition ,SellCondition)
set gain=if(buyAmt<>0, (close - buyAmt)/close,0)
set cutloss = buyAmt<>0 And gain < -0.05
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)
Just adding to @joeffrenz
plot(buy,buy,green,main) and plot(sell,sell,red,main) will plot all the buy and sell signals, while plotbuysell(buy,sell,green,red,main) will only plot pairs of buy and sell signals.