I am new to the NT Forum and hope that someone can help me with my problem.
I tried to find a similar Topic, but wasn't successful.
I am currently testing a Long-only-strategy with a paper account in realtime and experience some problems with the position size, which weren't occuring in backtests. As you can see from the attached screenshot, the Long-only-strategy is also opening short positions, which shouldn't be.
I try to check whether I am currently long with "Position.MarketPosition == MarketPosition.Long" before making the exit order. However, it seems that this code and/or "Account Sync = True" is not working properly, otherwise there shouldn't occure Shortpositions in the trading account from my point of view.
I would be very thankful if someone could help me with this issue and tell me where the problem is.
Thank you very much in advance!
Cheers PaBa
protected override void OnBarUpdate() { //Enter Long if (Position.MarketPosition == MarketPosition.Flat && entryOrder == null && CrossAbove(SMA(fast), SMA(slow), 1)) { // calculates the number of shares to buy based on the Account Cashvalue Dquantity = ((AccountSize/30)/Close[0]); OrderQuantity = Convert.ToInt32(Dquantity); entryOrder = EnterLongLimit(0, true, OrderQuantity, Close[0],"Long"); PosiQuantity = OrderQuantity; Print("the Entry-Position is "+PosiQuantity); barNumberOfOrder = CurrentBar; } // Exit Long if (Position.MarketPosition == MarketPosition.Long && CrossBelow(SMA(fast), SMA(slow), 1)) { ExitLong(PosiQuantity,"", "Long"); Print("the Exit-Position is "+PosiQuantity); } }
Comment