Selling 1/2 Position at and EMA


Category:
0
0

Hi –

 

Is it possible to code up a conditional order to sell 1/2 the position (1/2 of the Buy_To_Open tradeSize) when price crosses above an EMA then then sell the rest of the position when  another condition is true (MACD Cross)?

I’ve watched your helpful videos and have tried to use the tradeSize property but cant get it to work – it currently sells the whole position at the EMA  Code snippet below – whole script attached.

Thanks

AddOrder(OrderType.SELL_TO_CLOSE, condition = exit1, price = open[-1], tradeSize = tradeSize2, tickcolor = GetColor(3), arrowcolor = GetColor(3), name = “EMA Sell”);

AddOrder(OrderType.SELL_TO_CLOSE, condition = exit2, price = open[-1], tradeSize = tradeSize2, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = “MACD Sell”);

AddOrder(OrderType.SELL_TO_CLOSE, low <= stopPrice, tickcolor = GetColor(5), arrowcolor = GetColor(5), name = “S/L”);

 

  • Tradesize1 is a variable that is always 2X TradeSize2
Attachments:
RESOLVED
Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on June 20, 2020 5:40 pm
140 views
0
Private answer

The short answer is no. This is not possible using the Conditional Order nor is it possible using the AddOrder() function in a Chart Strategy.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on June 20, 2020 10:00 pm