0
votes

Pullback area

Hi, how do I store and get the value of high and open price of previous closed candle since the value will keep changing on every previous closed candle? The idea is to get the High & open from a certain condition when the condition true store the value of Open and High. Technical term called as a pullback area.

double high=0,open=0,
AskPrice=MarketInfo(OrderSymbol(),MODE_ASK),
BidPrice=MarketInfo(OrderSymbol(),MODE_BID);

bool sellcondition = Open[1] > Close[1] && High[1] > Open[1] && Close[1] > Low[1];

if( sellcondition )
{
  open=Open[1];
  high=High[1];
}

if(Bid > open && Bid < high)
{
  OrderSend(Symbol(),OP_SELL,0.01,BidPrice,3,0, 0,"",0,0,clrRed);
}
1
It isn't entirely clear what your problem is. It looks like your code snippet describes exactly what your question is asking about. - Enivid
how do i store the bar array without counting bar as the condition may appear at random bar? usually i saw example people do it by filter a loop with i=0; i<number of bar; i++; i hope you understand what i lm trying to explain - Roller
Do you mean that you want to ask how to remember OHLC parameters of some bar that fits specific condition and then, later in time, possible N bars later, be able to check that there indeed was such a bar and that it had the remembered OHLC parameters? - Enivid
Yes sir correct, but only current bar[0](current market price bid ask) will execute the trade of remembered OHLC of previous SOME bar with the specific condition.-->(how to remember OHLC parameters of some bar that fits specific condition) - Roller
I recommend you editing the question, so it asks that. Otherwise, it is very confusing. - Enivid

1 Answers

0
votes

If you declare your high and open as global scope or static variables and then will only assign values to them when your condition is met, then at any future bar, they will contain the High and Open values of the last time the condition has been met. For example, your code snippet can be modified as follows:

static double high=0,open=0,
AskPrice=MarketInfo(OrderSymbol(),MODE_ASK),
BidPrice=MarketInfo(OrderSymbol(),MODE_BID);

bool sellcondition = Open[1] > Close[1] && High[1] > Open[1] && Close[1] > Low[1];

if( sellcondition )
{
  open=Open[1];
  high=High[1];
}

if(Bid > open && Bid < high)
{
  OrderSend(Symbol(),OP_SELL,0.01,BidPrice,3,0, 0,"",0,0,clrRed);
}