SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Aug 20, 2019 11:59 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu Jun 23, 2011 2:40 pm 
Offline

Joined: Thu Apr 21, 2011 9:58 pm
Posts: 1
Code:
//OnTrade which defines trade Side   
private int positionSide = 0;
private double currentPrice = 0;
public override void OnTrade(Trade trade)
{
   if(currentPrice != 0)
   {
      if(currentPrice == trade.Price)
      {
         if(positionSide == 1)
         {
            //then position side is Buy
   
         }
         else //positionSide == 2
         {
            //then position side is Sell
         }
      }
      else if(trade.Price > currentPrice)
      {
         //then position side is Buy
         positionSide = 1;
         currentPrice = trade.Price;
      }
      else if(trade.Price < currentPrice)
      {
         //then position side is Sell
         positionSide = 2;
         currentPrice = trade.Price;
      }
   }
   else
   {
      currentPrice = trade.Price;
   }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group