I would really need to ask you something, I have one issue with NinjaScript and I am not sure if its caused because of any bug of NT7 or because of any rule of broker. Let me explain...
I have one strategy what I wrote and this strategy is working with two instruments. EURUSD and GBPUSD.
It works like this. I run (backtest) this strategy on 60Min GBPUSD.
The strategy is trading on this GBPUSD instrument.
But the strategy will also load 60Min EURUSD data.
Add("$EURUSD", PeriodType.Minute, 60);
Example:
Initialize() {
Add("$EURUSD", PeriodType.Minute, 60);
}
OnBarUpdate() {
...
some calculations and indicators working with EURUSD and GBPUSD
...
if (Closes[1][0]>myIndicatorValue) { // if current EURUSD close
// is higher than myIndicatorValue
EnterLong(0, 1, ("myId"+(id++))); // buy GBPUSD
SetStopLoss...
SetProfitTarget...
}
}
And both of them has the same period (60Minute).
So when new bar is created on GBPUSD the OnBarUpdate method is called, and after that the OnBarUpdate method is called AGAIN because there is also new bar created on EURUSD in the same moment. (Because they have same timeframe so the bars are created in same time on the instruments).
I was debuging the code (I was watching via Print(...) what is happening inside the code when is executing) and really [bold]EVERYTIME[/bold] is the EnterLong command called [bold]twice[/bold]. And this is I guess correct. This is what I expected.
But when you will take a look at the attachment you will see that sometimes is filled just one Enter command. The secondone is not even appear in the table. WHY?? I dont understand...
I was looking in the code and as I told you the strategy REALLY EVERYTIME call the EnterLong TWICE. But as you can see in attachment - sometimes it has behaviour like the strategy call the EnterLong just one - but WHY? There is profit/loss just for one contract.
BUT EVERYTIME THERE SHOULD BE PROFIT/LOSS FOR TWO CONTRACTS BECAUSE THE STRATEGY CALL THE ENTERLONG TWICE EVERYTIME.
Is this bug of NinjaTrader or is this any special behaviour of broker that sometimes from SOME reason dont accept my one of my two ENterLongs?
Thank you for your response, I really need to know this because I am going to trade this strategy via NinjaTrader as soon as possible but I need to know why is this sometimes happening..?
Why sometimes there is just one trade EVEN my strategy called the EnterLong method twice..?
Thank you again.. if you will need I can provide you whole the source code of strategy and indicators.
But I think it is really weird - my strategy is EVERYTIME call the method EnterLong TWICE! I checked via Print(..any log..) So why is in most of time really trading with twice EnterLongs how it should, and sometimes just with one EnterLong..?-thats incorrect!
I know that I could use
if (BarsInProgress==1){
enterLong conditions
}
I realize that in most of time, when NinjaTrader/or broker is ignoring my EnterLong command it the loosig trade! And thats perfect!
So now I dont know if its bug of NinjaTrader or any rule behaviour of broker. Because everytime the missing trades are still the same. Everytime I backtest the strategy I see still the same missing trades. So I dont know if its just coincidence.? And most of the time the missing trades are the loosing.? coincidence?
Thank you
/// EDIT
Hello I found out new thing..
Attachment log.xls is tab TRADES from strategy analyzer. In second attachment log2-orders is tab orders. I am sending it to you because I found out there is some order (for example 9.april.2007 at 20:00) whichone is trade just one (and should be twice as I explained on the top) but there is any CANCELLED order in tab orders..
But I dont understand why is it cancelled and what it means..?
I think this could be the reason why some of the sent EnterLong commands are ignored .. ?
Thank you very much for your help !!


Comment