I am currently using IB as my broker and have a systems that use MaxPositionProfit for various components of my script (including triggering a trailing stop). The function will sometimes create false values from IB which will cause my trailing stop to trigger prematurely (it will say I had a large unrealize max profit, that really never happened). Whatever this function is referencing seems to be causing an issue. Is there an alternative way to calculate the maxpositionprofit without using this reserve word? Is there a way for MC to calculate this value internally?
The only other reserve word that I found as an alternative is MaxContractProfit. My fear is that this reserve word uses the same calculation methods (with only an additional division of position size).
Is there a difference in the back end calculation of the reserve words MaxPositionProfit vs. MaxContractProfit if you trade only 1 contract? Or am I going to experience the same problems that I do with MaxPositionProfit?
MaxPositionProfit & MaxContractProfit
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
Re: MaxPositionProfit & MaxContractProfit
Hello Guceri,
There will be no difference if you use 1 contract. Few questions:
There will be no difference if you use 1 contract. Few questions:
- Do you auto-trade in SA or in AA mode?
- At the moment when you start auto-trading, do you have an open market position?
Re: MaxPositionProfit & MaxContractProfit
SA Mode
In regards to the position when I turn on SA Mode, it is hard to tell. Sometimes I have to turn off automation for a second to refresh a chart, change a script, or restart my system, etc. There can be times when there is already the designated position on, yes. I have not found this to be a problem.
The trailing stop I scripted and other components (which get triggered based on a maxpositionprofit) do not seem to be affected by restarting SA Mode when there is a position on.
What values is Maxpositionprofit pulling from IB? If it is the "Unrealized PnL" then there could be a problem. This value is faulty during IB's nightly reset.
In regards to the position when I turn on SA Mode, it is hard to tell. Sometimes I have to turn off automation for a second to refresh a chart, change a script, or restart my system, etc. There can be times when there is already the designated position on, yes. I have not found this to be a problem.
The trailing stop I scripted and other components (which get triggered based on a maxpositionprofit) do not seem to be affected by restarting SA Mode when there is a position on.
What values is Maxpositionprofit pulling from IB? If it is the "Unrealized PnL" then there could be a problem. This value is faulty during IB's nightly reset.
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
Re: MaxPositionProfit & MaxContractProfit
That is a good choice, however I recommend you to read about the modes of auto-trading to know how exactly it works in MC.SA Mode
In SA mode, whenever you start auto-trading, the strategy engine thinks there is no open position and no MaxPositionProfit. Please use this feature to tell the engine the correct values in order to avoid mismatch with broker values.In regards to the position when I turn on SA Mode, it is hard to tell. Sometimes I have to turn off automation for a second to refresh a chart, change a script, or restart my system, etc. There can be times when there is already the designated position on, yes. I have not found this to be a problem.
The MaxPositionProfit doesn't get any values from IB. It is maximum profit calculated by the strategy engine since the moment you start auto-trading. That is why it is very important for you to use the "Assign Market Position At Broker" feature and specify the correct MaxPositionProfit.What values is Maxpositionprofit pulling from IB? If it is the "Unrealized PnL" then there could be a problem. This value is faulty during IB's nightly reset.
Re: MaxPositionProfit & MaxContractProfit
I believe what you are referencing is not what the issue is. Even if I put $0 in the maxpositionprofit value upon start up of automation, this value will become accurate if the max position profit is highest AFTER the automation is turned on. I was under the impression that this value is only for PRIOR maxpositionprofit before the automation was turned on. This is not the issue I have.
Here is a more concrete example of the issue.
If have a position on, A trailing stop should be triggered at a MaxPositionProfit of $600. It is 5 PM, and I am long 1 contract. My current MaxPositionProfit is $400. At 1 AM, I have a trailing stop that gets activated. Since 5PM, the position PnL has not been higher. There is no reason for MaxPositionProfit, to show a value higher then $400 at this point. Having a trailing stop triggered would mean that there was a false value calculated.
Here is a more concrete example of the issue.
If have a position on, A trailing stop should be triggered at a MaxPositionProfit of $600. It is 5 PM, and I am long 1 contract. My current MaxPositionProfit is $400. At 1 AM, I have a trailing stop that gets activated. Since 5PM, the position PnL has not been higher. There is no reason for MaxPositionProfit, to show a value higher then $400 at this point. Having a trailing stop triggered would mean that there was a false value calculated.
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
Re: MaxPositionProfit & MaxContractProfit
I double-checked with our developers: the keyword MaxPositionProfit is locally calculated by the strategy engine, it does not get any values from broker end. When you assign market position at broker you should specify the MaxPositionProfit that was reached since the moment the position was opened if you want your trailing to trigger immediately (for example) and work further correctly .I believe what you are referencing is not what the issue is. Even if I put $0 in the maxpositionprofit value upon start up of automation, this value will become accurate if the max position profit is highest AFTER the automation is turned on. I was under the impression that this value is only for PRIOR maxpositionprofit before the automation was turned on. This is not the issue I have.
Please come to our live chat during working hours (6:30 am – 2:45 pm EST) to let our operators connect to your computer remotely in order to study the issue and help you: http://messenger.providesupport.com/mes ... pport.htmlHere is a more concrete example of the issue.
If have a position on, A trailing stop should be triggered at a MaxPositionProfit of $600. It is 5 PM, and I am long 1 contract. My current MaxPositionProfit is $400. At 1 AM, I have a trailing stop that gets activated. Since 5PM, the position PnL has not been higher. There is no reason for MaxPositionProfit, to show a value higher then $400 at this point. Having a trailing stop triggered would mean that there was a false value calculated.