How to set custom TP or SL price level
4 replies
jorferbust
7 years ago #115408
Hi there:
I get a problem when I try to set a custom price level for the TP or the SL using this formula:
For Long:
TP= Highest + (Highest-OpeningPrice)
SL= OpeningPrice – (Highest-OpeningPrice)
And is very strange, because when I use this formula as an “IF close condition” ( For example: IF Bid>Highest + (Highest-OpeningPrice) THEN ClosePosition) , instead of placing the TP and SL orders, it works.
Any idea what I´m doing wrong?
Maybe a bug?
Thank for your help!
tomas262
7 years ago #138610
jorferbust
7 years ago #138613
tomas262
7 years ago #138634
I think the problem exists with your long order because you are referencing OpenPrice(1000) which does not exists at time you send your order into the market (you have no position to get the price from yet). Hence the calculation of PT and SL is incorrect so MT closes such trade immediately .
jorferbust
7 years ago #138665
Thanks for your help! I didn´t know I couldn´t refer to OpenPrice(MagicNumber) inside the same Market Order that determines the MagicNumber to calculate TP and SL.
Is good to know! 🙂
Viewing 4 replies - 1 through 4 (of 4 total)