# Trying to write Seetu to buy/sell daily based on TIME only

**URL:** <https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311>\
**Category:** Seetu\
**Created:** [November 5, 2015, 2:32am UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311 "2015-11-05T02:32:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DogZebra\_Investing](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/dogzebra_investing/32/5086_2.png) [@DogZebra\_Investing](https://forums.collective2.com/u/DogZebra_Investing)\
**Post date:** [November 5, 2015, 2:32am UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/1 "2015-11-05T02:32:46Z")

</div>

I am trying to write Seetu code to simply buy the S&P 500 e-mini (Dec '15 now) at a certain time of the day (night actually). Of course, the buy and sell lines won’t compile and I haven’t seen many examples of them. None base on time at least.

My code.

_SetOption(“C2TradingSystemId”,\*\*\*\*\*\*\*\*);  
SetOption(“InitialEquity”,100000);  
SetPositionSize(1, spsShares);  
SetOption(“Symbols”,"@ESZ5");  
SetOption(“ApplyFromTime”, “2015-11-04”); // Is this even needed? Plan on running it every day.  
SetOption(“ApplyToTime”, “”);  
Buy = (TimeNum()==233000) //Buy when time is 11:30pm  
Sell = (TimeNum()==013000) //Sell when time is 1:30am_

Obviously not my actual strategy but I’d like to know how to do something basic like this!  
Sadly I was actually a computer science major many years ago. It would be beneficial to see more examples of Seetu, so we can get a better idea of how these functions work.  
Thanks,  
Pete

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [November 5, 2015, 11:07am UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/2 "2015-11-05T11:07:31Z")

</div>

Seetu uses end-of-day data for now.

It means we have just one OHLC bar for each day and the TimeNum() always returns 235959 now.

However, you can send signals at desired times using the “Run it” mechanism.

See [https://collective2.com/seetudoc/id\_runit.html](https://collective2.com/seetudoc/id_runit.html)

---

<div class="post-metadata">

**Author:** ![JamesRose](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/jamesrose/32/1302_2.png) [@JamesRose](https://forums.collective2.com/u/JamesRose)\
**Post date:** [November 5, 2015, 12:51pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/3 "2015-11-05T12:51:22Z")

</div>

Hi PistolCapital,

I’m looking to do the same thing but I don’t have experience of writing code in Seetu. If you can make it work would you be able to contact me on [jamesroze@hotmail.com](mailto:jamesroze@hotmail.com) - I have a great idea I’m happy to share with you 50/50. Thanks, J

---

<div class="post-metadata">

**Author:** ![DogZebra\_Investing](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/dogzebra_investing/32/5086_2.png) [@DogZebra\_Investing](https://forums.collective2.com/u/DogZebra_Investing)\
**Post date:** [November 5, 2015, 1:35pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/4 "2015-11-05T13:35:26Z")

</div>

So basically there is no way to have your system automatically buy at 11:30pm unless you are awake and hitting “run”?

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [November 5, 2015, 2:21pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/5 "2015-11-05T14:21:16Z")

</div>

The procedure is this:

1. Add **C2TradingSignal** command(s) to your strategy.  
**C2TradingSignal** generates actual trading signals and describes their details (for example you want to specify a stop loss price).

2. Run Exploration and check the “ **Signals** ” tab if signals are generated correctly and everything is as it should be.

3. If you are satisfied, go to the “ **Run it** ” tab.

4. Check “ **Turn it on!** ”

5. Specify exact time(s) when your strategy should be fired. (Daily at 23:30 in your case.)

Done!

Strategy is running on Collective2 server and generated signals will be sent to your trading system while you are sleeping.

Sweet Dreams! 🙂

[https://collective2.com/seetudoc/id\_seetu\_code\_example\_05.html](https://collective2.com/seetudoc/id_seetu_code_example_05.html)  
[https://collective2.com/seetudoc/id\_runit.html](https://collective2.com/seetudoc/id_runit.html)  
[https://collective2.com/seetudoc/c2tradingsignal.html](https://collective2.com/seetudoc/c2tradingsignal.html)

---

<div class="post-metadata">

**Author:** ![DogZebra\_Investing](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/dogzebra_investing/32/5086_2.png) [@DogZebra\_Investing](https://forums.collective2.com/u/DogZebra_Investing)\
**Post date:** [November 5, 2015, 2:42pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/6 "2015-11-05T14:42:54Z")

</div>

Thanks Bob! Big help. I’ll let you know how it goes. If it works well I’ll be paying for a new system again.

---

<div class="post-metadata">

**Author:** ![DogZebra\_Investing](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/dogzebra_investing/32/5086_2.png) [@DogZebra\_Investing](https://forums.collective2.com/u/DogZebra_Investing)\
**Post date:** [November 5, 2015, 8:35pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/7 "2015-11-05T20:35:28Z")

</div>

I can’t even get the thing to buy.  
Tried to “run it” three times in the past hour and every time the log just said:  
Strategy started  
Strategy ended

I think more examples on how to actually Buy and Sell things using this language would be beneficial to all.

SetOption(“C2TradingSystemId”,\*\*\*\*\*\*\*\*\*);

SetOption(“InitialEquity”,100000);  
SetOption(“Symbols”,"@ESZ5");  
SetPositionSize(1, spsShares);

BuyPrice = SellPrice = Open;

Buy = 1;

C2TradingSignal(sigBTO, Price=BuyPrice, Amount=1, priceType=priceMarket, TypeOfSymbol=instrmntFuture, Duration=tifDay);

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [November 5, 2015, 9:17pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/8 "2015-11-05T21:17:04Z")

</div>

Please use “@ESZ15” instead of “@ESZ5”.

---

<div class="post-metadata">

**Author:** ![DogZebra\_Investing](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/dogzebra_investing/32/5086_2.png) [@DogZebra\_Investing](https://forums.collective2.com/u/DogZebra_Investing)\
**Post date:** [November 5, 2015, 9:55pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/9 "2015-11-05T21:55:01Z")

</div>

Ah. That’s all it was. Thanks Bob.

---

<div class="post-metadata">

**Author:** ![DogZebra\_Investing](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/dogzebra_investing/32/5086_2.png) [@DogZebra\_Investing](https://forums.collective2.com/u/DogZebra_Investing)\
**Post date:** [November 30, 2015, 4:49pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/10 "2015-11-30T16:49:26Z")

</div>

Tried copying and pasting the same code for use in another system and nothing happens. Won’t buy. Pasted below:  
SetOption(“C2TradingSystemId”,\*\*\*\*\*\*\*\*); //New system ID is in here correctly

SetOption(“InitialEquity”,100000);  
SetPositionSize(1, spsShares);  
SetOption(“Symbols”,"@ESZ15");

BuyPrice = Open;

Buy = 1;

C2TradingSignal(sigBTO, Price=BuyPrice, Amount=1, priceType=priceMarket, TypeOfSymbol=instrmntFuture, Duration=tifDay);

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [December 1, 2015, 12:20pm UTC](https://forums.collective2.com/t/trying-to-write-seetu-to-buy-sell-daily-based-on-time-only/8311/11 "2015-12-01T12:20:06Z")

</div>

I can’t find any problem. Can you try it again?
