SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Oct 01, 2020 11:29 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Jan 03, 2013 9:56 am 
Offline

Joined: Fri Sep 28, 2012 8:16 am
Posts: 144
Hi,
i try to close position then open opposite position at once.
the orders of the transactions at the same time should all go backwards

here is test code:
Code:
using System;
using System.Drawing;

using OpenQuant.API;
using OpenQuant.API.Indicators;

public class MyStrategy:Strategy
{
   int fastLength = 5;
   int slowLength = 12;
   double Qty = 1;
   
   SMA fastSMA;
   SMA slowSMA;
   
   public override void OnStrategyStart()
   {
      fastSMA = new SMA(Bars,fastLength,Color.Red);
      slowSMA = new SMA(Bars,slowLength,Color.Green);
       
      Draw(fastSMA,0);
      Draw(slowSMA,0);
   }

   public override void OnBar(Bar bar)
   {
      Cross cross = fastSMA.Crosses(slowSMA, bar);
      if(Cross.Above == cross)
      {
         ClosePosition(GetText());
         Buy(1,GetText());
         Buy(2,GetText());
      }
      else if(Cross.Below == cross)
      {
         ClosePosition(GetText());
         Sell(1,GetText());
         Sell(2,GetText());
      }
   }
   int i = 0;
   string GetText()
   {
      ++i;
      return string.Format("{0}",i);
   }
}


Regards
wukan


Attachments:
5B32DBA9-037D-4179-8D06-96C310CA51FF.jpg
5B32DBA9-037D-4179-8D06-96C310CA51FF.jpg [ 95.84 KiB | Viewed 2484 times ]
Top
 Profile  
 
PostPosted: Thu Jan 03, 2013 12:44 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Hi,

this seems to be a side effect of ListView native sorting for entries with the same DateTime. We will try to fix it.

You can click on DateTime column title and resort ListView. Although last dates come first in this case, the order of transactions should be preserved.

Regards,
Anton


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 2 guests


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