marketinfo: what is the code for "sign of last price change" (+/-)

Dannoo007
195
Dannoo007  

Hello all,

Newbie here (bear with me) - I thought there should be some marketinfo constant to return the direction of last price change, I looked into this but could not sort it out: so what would you suggest as code for returning the sign of the last price change (both ask and bid)? I am trying to use it as a condition, but it looks like only MODE_ASK and MODE_BID are available. For example, I would need:

if ... "MODE_ASK (last tick) - MODE_ASK (the previous tick)" > 0 (i.e. if ASK price is increasing..)

then BUYSIGNAL

Many thanks!

Dan

edit

... ie. how to fill in the bit of "marketState" below (copypasted from here)

if(marketState == 1)
  {
    // trading strategy for an uptrend
  }
else 
    if(marketState == 2)
      {
        // strategy for a downtrend
      }
    else 
        if(marketState == 3)
          {
            // strategy for a flat
          }
        else
          {
            // error: this state is not supported!
          }
Simon Gniadkowski
17393
Simon Gniadkowski  
Just use a variable to hold the value of the Bid price at the last tick . . and compare it with the Bid price on the current tick . . .
William Roeder
25064
William Roeder  
Has to be a static or global so it's remembered between start() calls
int start(){
   static double lastBid;
   if (Bid > lastBid){ Print("up tick"); .. }
   else{               Print("dn tick"); .. }
   lastBid = Bid;
}
Dannoo007
195
Dannoo007  

oh. AWESOME!

you guys make it look so easy !! :))

many thanks!
Dan