Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-Instrument Strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_Austin
    replied
    Loukas, please try exiting the position before opening a position in the other direction:
    Code:
    exitshort1
    exitshort2
    exitshort3
    enterlong5
    
    instead of
    
    enterlong5
    exitshort1
    exitshort2
    exitshort3

    Leave a comment:


  • Loukas
    replied
    Thanks Bertrand, it is working good with the enter. However, with the ExitLong() or ExitShort statement are working. Every enter position is closing only with profit target level instead of closing when I am opening a new position in the opposine direction.

    Initialize()
    EntriesPerDirection = 4;
    EntryHandling = EntryHandling.AllEntries;

    OnBarUpdate()
    if .........something
    {
    EnterShort(1,quantityOrder,"short1");
    EnterShort(2,quantityOrder,"short2");
    EnterShort(3,quantityOrder,"short3");
    ExitLong("long");
    }

    else if ....something
    {
    EnterLong(5,quantityOrder,"long");
    ExitShort("short1");
    ExitShort("short2");
    ExitShort("short3");
    }

    It is entering new positions but is not exiting the latest one....it close only when meet the profit target.

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    You likely need to run with a higher EntriesPerDirection here or set EntryHandling to use UniqueEntries:

    Leave a comment:


  • Loukas
    replied
    I have tried the way below to enter a multiple Enter() statment but it send only an order for the first bar object only (USDCAD) . I tried to connect the EnterShort() statments with "&&" but it is not working neither. Do you have any ideas about it?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    Originally posted by Loukas View Post
    Is there a multiple Enter() statment or I have to enter one by one ?

    e.g

    Add("$USDCAD",PeriodType.Day,1);
    Add("$USDJPY",PeriodType.Day,1);

    .....
    .....

    EnterShort(1,1,shortInst);
    EnterShort(2,1,shortInst);
    This would be the way to go here Loukas.

    Leave a comment:


  • Loukas
    replied
    Is there a multiple Enter() statment or I have to enter one by one ?

    e.g

    Add("$USDCAD",PeriodType.Day,1);
    Add("$USDJPY",PeriodType.Day,1);

    .....
    .....

    EnterShort(1,1,shortInst);
    EnterShort(2,1,shortInst);

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    No worries, if you would like to execute in several symbols you could issue multiple Enter() calls to different series.

    Leave a comment:


  • Loukas
    replied
    Sorry it was my mistake. I would like to make the following changes, instead of going long a single currency I want to going Long a basket of cuurencies. Do you have any ideas about it?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    In my testing here on a daily chart I see trades for your added instrument - your conditions run off BIP0, so the primary series and send then trades to index 1 and 2 - what issues are you seeing? The added series are used internally only and are not visualized if your run for example from your primary chart or Strategy Analyzer backtest.

    Leave a comment:


  • Loukas
    replied
    I didnt manage to solve the problem. I have entered the BarInProgress statment but I didnt understand which is the correct way to send an order for other instruments. I have attached an update of the strategy. Thanks
    Attached Files

    Leave a comment:


  • NinjaTrader_Austin
    replied
    Loukas, your entry conditions are too restrictive. I ran your strategy on $EURCHF as the main instrument, $EURUSD as secondary, and $USDCAD as tertiary instrument (because we don't have USDMXN access) over a 2 year backtest and the conditions for entry were not triggered at all.

    I placed some print statements in the code to help you see what is actually going on. Did you look at the SampleMultiInstrument strategy Bertrand referenced? None of your code is in a BarsInProgress, so the main conditions are checked for every series on every bar, which would make debugging extremely difficult.

    Please take a look at the re-attached strategy, especially the comments I've revised.

    Let me know if you have questions.
    Attached Files

    Leave a comment:


  • Loukas
    replied
    Please have a look at the attachement
    Attached Files

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    Did you reload the strategy fresh after making the needed code change to correctly call the added series? Yes, if you can attach the code that would help as I can then give it a run here for testing.

    Thanks,

    Leave a comment:


  • Loukas
    replied
    At the Logs tab the message is that
    "The strategy has called the Add[] method with an invalid instrument. The USDMXN does not exist..."
    I made the adjustment this the symple "$". The is not any compile error but is still not making any trades.

    I am not sure about EnterLong() if has the correct structure

    if (CrossAbove(RSI(14, 0), 30, 1))
    {
    //Enter a long position on a basket of EM currencies. It is applied on Index Value 1
    EnterShort(1,1,shortInst);
    }
    It checks the Cross of RSI on USDGBP( index 0) and enter a Short on USDMXN(index 1). EnterShort( index number, quantity, signal name)

    Shall I send you the strategy to file to have a better view?
    Thanks

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    Any errors in the log tab, this should be the first place to check if you run into any unexpected issues?

    Please try with a $ sign in front of your FX spot symbols, so :

    // Add("$USDGBP",PeriodTypr.Day,1);
    // index value of 1
    Add("$USDMXN",PeriodType.Day,1);
    // index value of 2
    Add("$EURUSD",PeriodType.Day,1);

    Please also use this EnterLong overload for MultiSeries use, so you can specify to which BIP to submit:

    EnterLong(int barsInProgressIndex, int quantity, string signalName)

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by markpk1, Today, 11:54 AM
1 response
6 views
0 likes
Last Post NinjaTrader_Erick  
Started by Marty125, Today, 11:14 AM
4 responses
17 views
0 likes
Last Post Marty125  
Started by Carlos19, Today, 10:15 AM
2 responses
10 views
0 likes
Last Post Carlos19  
Started by markdshark, 04-16-2023, 09:29 AM
6 responses
232 views
0 likes
Last Post NinjaTrader_Jesse  
Started by siddhugaddi, Today, 10:31 AM
2 responses
15 views
0 likes
Last Post NinjaTrader_Jesse  
Working...
X