Help with "Buy" function

Questions about MultiCharts and user contributed studies.
tk993
Posts: 6
Joined: 13 Aug 2013

Help with "Buy" function

Postby tk993 » 13 Aug 2013

I'm working on writing out one of my strategies so that I might not need to manually trade it in the future.

Basically at the open of each day I want to place buy and sell orders. I've got all of those orders written in based on the current position and market variables. However, it requires either "this bar" or "next bar" to be added to the line.

So this is what one part of the code became:

Code: Select all

if marketposition = 1 then begin

if currentcontracts < 3 then begin
buy ("s2BullBuy < 3") 1 contracts this bar at s2 limit;
buy ("s3BullBuy < 3") 1 contracts this bar at s3 limit;
sell ("r3BullSell < 3") 1 contracts this bar at r3 limit;
end;
I added "this bar", but it says that "this bar" only works with "Close" I can't use the limit. s2, s3, r3 were all defined earlier.

Essentially the strategy is supposed to place between 1 and 4 orders at the start of each day. The next day they are either cancelled or they were filled and the new orders based on current position and market conditions are put in.

Ideally, I'd like one of the open orders to cancel if it isn't filled by the 4:30 close, and the other to last overnight, but I'll wait on that.

Is this possible to do with the EasyLanguage or do I need to do this in .net? I was told it was possible to do it in EasyLanguage and I'm really enjoying how the easy language has been working so far, but I'm probably willing to learn .net if necessary.

Any help is appreciated.

Thanks,
tk

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Help with "Buy" function

Postby TJ » 13 Aug 2013

What is your chart resolution?

tk993
Posts: 6
Joined: 13 Aug 2013

Re: Help with "Buy" function

Postby tk993 » 13 Aug 2013

I assume chart resolution is the same as period. It's a daily chart that I'm working off of.

I was thinking that there might be a code to specify that the orders will remain open until current daily bar closes. That would probably work as a solution. Though then the time change would happen at 5:00pm the day before, and I'd prefer the orders switch over at 9:30 every day.

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Help with "Buy" function

Postby TJ » 13 Aug 2013

::
Is this possible to do with the EasyLanguage or do I need to do this in .net? I was told it was possible to do it in EasyLanguage and I'm really enjoying how the easy language has been working so far, but I'm probably willing to learn .net if necessary.
Any help is appreciated.
Thanks,
tk
EasyLanguage is pretty powerful... especially with the new keywords added by MultiCharts.

I would suggest you to try one task at a time:

get 1 order working first,
then attempt the multi-order strategies.
Scale-in/scale-out is advanced level programming, it will take you some time and effort.


You can start here:
Autotrade / Backtest / Optimization FAQ
viewtopic.php?f=16&t=10811


Return to “MultiCharts”