I'm a user of MultiCharts 8.5, which is the latest version in the area I live in (provided by KWay).
I do day trade. I am seeking a way that I can be sure that my strategy position can always be closed at the end of each session even if the commodity has few ticks.
The base approach is, of course, to close my position during the last signal calculation. But it could fail with no ticks coming in during the last few minutes, leaving no chances for the signal to be calculated. To enhance the base approach, I can use the function "RecalcLastBarAfter()" to bring up the signal calculation where I get a last chance to close my position.
The problem is "is it safe to do so (both the base approach and the RecalcLastBarAfter() approach)." For lack of understanding of the underlying mechanism, I'm wondering if I'm risking the chance of duplicate orders by doing so. If the underlying mechanism deals with the signal calculation "concurrently" rather than "sequentially," it certainly could happen by chance. Could you please tell me that:
1. is it safe to do so (both the combination of the two approaches),
2. what I should be aware of when doing so, and
3. what do you recommend I do to achieve the goal if this is not desirable?
Thanks a lot!
It it safe to close position by means of RecalcLastBarAfter? [SOLVED]
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: It it safe to close position by means of RecalcLastBarAf
Hello scotthkao,
It is safe if you know what you need to achieve, you know how the code works and you have debugged and tested it. Please check the following code that shows how to close the position prior to the session close using RecalcLastBarAfter.
It is safe if you know what you need to achieve, you know how the code works and you have debugged and tested it. Please check the following code that shows how to close the position prior to the session close using RecalcLastBarAfter.
Re: It it safe to close position by means of RecalcLastBarAf
Code: Select all
[intrabarordergeneration = true]
input: TimeClosePosition(0);
if (currenttime_s >= TimeClosePosition) then
Begin
RecalcLastBarAfter(1);
sell ("EOD_LX") next bar market;
buytocover("EOD_SX") next bar market;
End;
Can I have the code above in a signal and have my original signal in another?
If I do so, can the code above close the position of another signal?
Thanks a lot!
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: It it safe to close position by means of RecalcLastBarAf [SOLVED]
You can have two signals applied to your chart - they will form a single strategy. Signals can close positions of one another. You can turn on/off IOG individually for each signal.This code needs IOG. I'm not quite familiar with IOG so could I ask a simple question of you?
Can I have the code above in a signal and have my original signal in another?
If I do so, can the code above close the position of another signal?
Thanks a lot!