How to define BUY / SELL conditions

Created at 20 Jul 2022, 20:21
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
JE

jeremy.ayres

Joined 27.06.2019

How to define BUY / SELL conditions
20 Jul 2022, 20:21


I'm using a MACD as part of a strategy and would like some pointers on the best way to identify if price action is long or short depending on the MACD crossover e.g., crosses UP = Buy and crosses DOWN = Sell. I'mm currently doing this:

{
            var currentLivePrice = livePrice.Result.Last(0); 	
			// Current live price is the live price -0 periods.
            var currentslowMA = slowMA.Result.Last(0); 	
			// Current slow MA is the slow MA -0 periods.
            var previousLivePrice = livePrice.Result.Last(1);	
			// Previous live price is the live price -1 period.
            var previousslowMA = slowMA.Result.Last(1);	
			// Previous slow MA is the slow MA -1 period.
            var longPosition = Positions.Find(label, SymbolName, TradeType.Buy);
			// Needed to define what longPosition is (open long trades).
            var shortPosition = Positions.Find(label, SymbolName, TradeType.Sell);
			// Needed to define what shortPosition is (open short trades).

 


@jeremy.ayres