Hi All,
I am trying to backtest on MultiCharts EL a strategy quite simple (as I was believing) but I end up with no way to translate it in MC EasyLanguage.
To simplify the logic at the utmost, let say I want to put 3 sell limit order above current price and 3 buy limit below limit price.
For exemple:
Sell Limit Close+10
Sell Limit Close+5
Sell Limit Close+2
Buy Limit Close -2
Buy Limit Close -5
Buy Limit Close -10
In one bar, we could have several limit orders triggered.
Once all are triggered, I reset everything and start again.
So, is it possible to do something like that in a MC signal? I know I can put one buy limit and one sell limit, but how to handle the others layers in same time?
As a workaround, I thought about using market orders when I detected a cross of my levels but we can have several cross on one tick and we finally get slippages that you will not have with a limit orders.
Would anyone have an idea to achieve that, or at least a workaround?
Great thanks in advance.
Layering Limits strategy
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Layering Limits strategy
Hello nvitale,So, is it possible to do something like that in a MC signal? I know I can put one buy limit and one sell limit, but how to handle the others layers in same time?
The second and third limit orders are handled the same way as the first limit order.
You just need to have a line in the code for each order.
Code: Select all
var:
price(0),
Le1(0),
Le2(0),
Le3(0),
Se1(0),
Se2(0),
Se3(0),
MP(0) ;
MP= Marketposition;
price = last;
Le1 = price- 0.0001 ;
Le2 = price- 0.00015 ;
Le3 = price- 0.0002 ;
Se1 = price+ 0.0001;
Se2 = price+ 0.00015 ;
Se3 = price+ 0.0002 ;
If MP = 0 then begin
Buy ("LE1")next bar 1 contract at Le1 limit;
Buy ("LE2")next bar 1 contract at Le2 limit;
Buy ("LE3")next bar 1 contract at Le3 limit;
SellShort ("SE1")next bar 1 contract at Se1 limit;
SellShort ("SE2")next bar 1 contract at Se2 limit;
SellShort ("SE3")next bar 1 contract at Se3 limit;
end;
- Attachments
-
- levels.png
- (35.19 KiB) Downloaded 440 times
Re: Layering Limits strategy
Thanks a lot for that.
But in this case how do we know that
A - a limit have been taken so we do not reset it
B - all limits have been taken so we restart from beginning and set all limit orders
We might be able to use EntriesName() but can not see a way to answer A and B.
If we have the succession in time:
- BuyLimit1 Fill
- BuyLimit2 Fill
- SellLimit3 Fill
Do we have
EntriesName(0) = SellLimit3
EntriesName(1) = BuyLimit2
EntriesName(2) = BuyLimit1
Thanks again.
But in this case how do we know that
A - a limit have been taken so we do not reset it
B - all limits have been taken so we restart from beginning and set all limit orders
We might be able to use EntriesName() but can not see a way to answer A and B.
If we have the succession in time:
- BuyLimit1 Fill
- BuyLimit2 Fill
- SellLimit3 Fill
Do we have
EntriesName(0) = SellLimit3
EntriesName(1) = BuyLimit2
EntriesName(2) = BuyLimit1
Thanks again.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Layering Limits strategy
That is possible to check the market position and current contracts values, as well as the name of the entry order. Please check the following reserved words categories:Strategy_Position, Strategy_Position_Trades.T
But in this case how do we know that
A - a limit have been taken so we do not reset it
B - all limits have been taken so we restart from beginning and set all limit orders