I need to dinamically create an market order and set TakeProfit and StopLoss by ninjascript.
I noted that creating by Strategy Builder StopLoss and TakeProfit are defined in State == State.Configure, but all trades gives the same configuration.
I need to create market orders when some condition happend and set TP and SL dinamically depending on the condition.
Could you give me some code sample?
Thank you so much!
PD: I need market orders, not stop or limit orders.
I have this code:
double tp=a.max
double sl=a.min;
if(condition)
{
SetProfitTarget("PT", CalculationMode.Price,tp);
SetStopLoss("SL", CalculationMode.Price, sl, true);
EnterLong(Size,"Buy");
}
The long is created with the correct size, but TP and SL doesnt get configured.
tp and sl variables are ok (min and max prices of a session), I used Print() to confirm that.
For example> Sell - Price: 1,17776 SL : 1,17984 TP : 1,17574
Comment