limit order in express code

Post Reply
Thom
Posts: 5
Joined: 11 Mar 2014 14:43

limit order in express code

Post by Thom »

Hello there,

is there a possibility to open positions as soon as a certain line is crossed or directly place limit orders at a certain price level?

Taking the following situation:

Image

As soon as the blue line is crossed, a long contract should be bought. If I use the built in sentimentor logic it's only calculated at every bar which means in this case it would buy too late.

I know there's an Intraday entry solution whs-futurestation-nano-express-programm ... -t904.html,
But it's not backtestable and therefore doesn't help me.

Is there any solution to trigger/place a buy order directly at the blue line which is backtestable?

Any help is appreciated!

Regards,
Thom
Brian
Posts: 3
Joined: 27 Apr 2014 21:54

Re: limit order in express code

Post by Brian »

I programmed something like with SetLongTrigger() in Express. On each bar set exactly for each next bar (only the NEXT bar) a long trigger (at your blue line). Just quickly read up in the Express documentation on this function.
Thom
Posts: 5
Joined: 11 Mar 2014 14:43

Re: limit order in express code

Post by Thom »

Brian thank you for the input, I read up on the function! But unfortunately there seem to be 2 major problems. Lets take this example:

Image

I want to place 2 orders, one on the top blue line to go long and one on the bottom blue line to go short.
What I did know, I used the SetLongTrigger() method (starting at the white bar indicated by the small green triangle), setting the long trigger on the top blue line.

To make this visible and backtestable, I also had to set the sentiment on 100 to automaticly open positions. Now the 2 problems are:

1) The position is opened to early, because of the "limit price next bar" setting. The position should be opened starting as soon as the big white bar crosses the top blue line.
2) As I had to set the sentiment to a value of 100, the SetShortTrigger() (bottom blue line) is completely ignored. So if the third red bar would fall through the bottom blue line no position is opened.

-> I need a way to place 2 orders at the same time (one long order at the top and one short order at the bottom blue bar).

Is this even possible with the sentimentor logic or is this only possible by completely ignoring backtesting?

Cheers,
Thom
Seuche
Posts: 29
Joined: 06 Apr 2013 16:29

Re: limit order in express code

Post by Seuche »

That's not possible with one Study.

For the longTrigger you have to set the sentiment for each following periode to 100 AND SetLongTrigger(top blueline) AND Confirmation price next bar

I think you could do it with two different Studys.

For your example :
You calculate both blue lines in one Express-Code.
You have Study1 with 'Confirmation price next bar' and Sentiment = 100 and SetLongTriffer(top blueline)
AND
Study2 with 'Confirmation price next bar' AND Sentiment = 0 and SetShortTrigger=(bot blueline)

In both studys you have to calclulate which of the blue lines was touched.

For example Study2 :
IF High>=top blueline then
begin
Sentiment=50 ;
Set ShortTrigger(void);
end
Thom
Posts: 5
Joined: 11 Mar 2014 14:43

Re: limit order in express code

Post by Thom »

Thank you! "Confirmation price next bar" and using two different studies were the missing link.

Nice weekend everyone, cheers
Thom
Post Reply

Return to “WHS NANOTRADER - EXPRESS PROGRAMMING”