people with nt,
in september of 2019 i decided to adapt some strategies of mine to nt. after an unbelievable amount of hard work, i now finally have a number of strategies that i'm ready to trade with real funds on nt and yesterday i created two charts with one strategy each and enabled them.
however, today one strategy reversed from a long to a short position and it ended up with two contracts instead of one. this is an error that i thought i had solved back in october of last year when i was evaluating nt on simulator but it has appeared again. consequently, i have suspended all automated trading until i can solve this definitely.
most of my strategies have one same general structure, i have one condition to enter a short position and its corresponding condition to exit this position. i also have a condition to enter a long position and its corresponding condition to exit this position.
this issue with duplicate positions will happen if and when both the condition to exit a position and to enter a position in the opposite direction become true at the same time at the close of one same bar.
for example (this is not what is happening in my code but should be useful to illustrate this situation), if price is 2% lower than the highest high of the last 50 bars, the strategy should exit all long positions. and if price is 2.3% lower than the highest high of the last 50 bars then the strategy should enter a short position. there will be a lot of cases when at the end of one bar both of these conditions will be true at the same time and nt then ends up with a position of twice the size it should be as it executes both an exit and a reversal order.
in october of 2019 i thought i had solved this problem by adding checks for positions status to my code, and at least on backtests and optimization processes it seemed like this was enough:
// Set 1
if ( conditions for short position
&& (Position.MarketPosition != MarketPosition.Short) )
{
EnterShort(Convert.ToInt32(Posi), entry1 );
}
// Set 2
if ( (Position.MarketPosition == MarketPosition.Short)
&& conditions to exit short positions )
{
ExitShort(Convert.ToInt32(Posi), entry1 );
ExitShort(Convert.ToInt32(Posi), entry2 );
}
// Set 3
if ( conditions for long position
&& (Position.MarketPosition != MarketPosition.Long) )
{
EnterLong(Convert.ToInt32(Posi), entry1 );
}
// Set 4
if ( (Position.MarketPosition == MarketPosition.Long)
&& conditions to exit long positions )
{
ExitLong(Convert.ToInt32(Posi), entry1 );
ExitLong(Convert.ToInt32(Posi), entry2 );
}
i now realize that this is not working as it is intended, so i ask from the people with nt, ¿how could i trade my strategies automated and have nt only enter positions in the appropriate size? ¿are there better checks than those i incorporated? ¿is it possible to delay exit orders by fractions of a second so that entries - reversals could execute first? ¿would nesting these conditions inside of one another solve these problems?
very well, this is a crucial matter for me, if i'm not able to solve these issues i can't trade my strategies automated and would really have no use for nt anymore. thanks, regards.
Comment