How to do price shifting?

Created at 06 Jan 2014, 06:48
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!
Zjhehe's avatar

Zjhehe

Joined 06.01.2014

How to do price shifting?
06 Jan 2014, 06:48


I'm trying to code an EA that determines entry based on price action. Right now, the logic is to use a for (counter) loop to scan each price period (candlestick) for the open, high, low, and close price. These will be compared to the price a certain 'n' shifts back. Only, I don't quite understand how to do the price shift say 2 bars back then have the for loop add one increment to the period shift back so when it loops again, it will shift three bars back. Then the second part to do this retrieving the price data (OHLC).

 

Ps. I'm pretty sure I'm not using 'MarketDepth'


@Zjhehe
Replies

jeex
06 Jan 2014, 19:19

Looking n periods back
int nBack = ...;

double nClose = MarketSeries.Close.Last(nBack);

.Last is the most convenient way of looking n timeframes back.
 


@jeex