for easier understanding, let me give you an example.
i have opened a long position at $1219 for 1 contract, and then buy signal comes again.
the strategy add another contract to the long position at $1221, and after that the strategy trigger the add function again, so another contract added at $1223.
so i have three contracts in a long position at the price of 1219, 1221 and 1223.
my question is any keywords can do the job , so that i can know the three contracts entry price, and the profit of each of the three contracts?
i know there are many keywords read the above info, but they read the info between different positions, but not the multiple contracts within the position.
thanks a lot.
know the entry price and profit of a multicontracts position
Re: know the entry price and profit of a multicontracts posi
oh, after i checked the dictionary up, it seems that postradeprofit and postradeentryprice can do the job....
postradeprofit(0,2) for the profit of the first contracts of the position with three contracts in total.
postradeprofit(0,1) for the profit of the second contracts.
postradeprofit(0,0) for the profit of the third contracts.
similar for the postradeentryprice?
correct me if i am wrong, thanks.
postradeprofit(0,2) for the profit of the first contracts of the position with three contracts in total.
postradeprofit(0,1) for the profit of the second contracts.
postradeprofit(0,0) for the profit of the third contracts.
similar for the postradeentryprice?
correct me if i am wrong, thanks.
Re: know the entry price and profit of a multicontracts posi
actually, the reason i raise this question is that, my program seems can't get the profit info of the contract quite well, and keep on buy or sellshort immediately after the stop loss. the stoploss function become useless....
a problem screen shot showed as follows
from the screenshot, you see that there are two problems, the first one is that my third contracts doesn't recorded a loss over my specified target, actually it's a winner trade... but the stoploss happen.
and second problem , after the stoploss, the program immediately sell short again in the next bar(as the K value is still above 80)...
so please help, thanks!
a problem screen shot showed as follows
from the screenshot, you see that there are two problems, the first one is that my third contracts doesn't recorded a loss over my specified target, actually it's a winner trade... but the stoploss happen.
and second problem , after the stoploss, the program immediately sell short again in the next bar(as the K value is still above 80)...
so please help, thanks!
Last edited by johnmok on 28 Oct 2011, edited 1 time in total.
Re: know the entry price and profit of a multicontracts posi
Not related to your code, but you can take a picture by clicking the chart - file - save image as file. I think it is easier and better to watch as using a camera.
Re: know the entry price and profit of a multicontracts posi
actually...i just make a silly mistake....
my strategy is something like the rsi value > 80 and then i sell short , and set stop loss to the strategy
and i set the code as
but the problem is that, for an rsi type strategy, when you have to stop loss the sell short position, the rsi are usually still higher than 80, that means immediately after the stop loss, the condition of rsivalue > 80 will be true, and therefore, sellshort again immediately after stop loss.
the solution is simple, change the code to
then for most case, the system won't enter market again after stop loss, it will wait the rsi value drop below 80, and if the rsi goes up again, the system will then go short.
that solve my problem.
my strategy is something like the rsi value > 80 and then i sell short , and set stop loss to the strategy
and i set the code as
Code: Select all
if myRSIvalue > 80 then sell short next bar market
the solution is simple, change the code to
Code: Select all
if myRSIvalue cross over 80 then sell short next bar market
that solve my problem.