Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy - B/S based off different security

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

    Strategy - B/S based off different security

    Hi,

    Can you lead me to the thread or to the code instructions on how to create a Strategy that develops buy/sell decisions based off the movements of an indicator of a different security.

    For example I am looking to buy/sell Gold based on the movements in AUDUSD, so if the Double Stochastics in AUDUSD crosses above 20 then my Strategy will buy Gold and when the Double Stochastics in AUDUSD crosses below 80 I will want to sell Gold.

    The securities mentioned are just an example but I am looking to base my b/s decisions off an indicator of a different security.

    If this is not possible then please add it to the suggestion box.

    Thank you,

    S

    #2
    Hello,

    Yes, this is possible to add another instrument to your strategy and to take signals from that instruments indicator values and execute on another instrument.

    I'd suggest taking a look at the SampleMultiInstrument Strategy under Tools--> Edit NinjaScript--> Strategy
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi Matthew,

      The SampleMultiInstrument Strategy shows me how to create a manual strategy based on 2 indicators for one security.

      I'm actually looking to use a single indicator on security 1 to determine whether to buy/sell on security 2. In my chart I have 2 Data Series and one indicator.

      In the Help Guide under NinjaScript and "Multi-Time Frame & Instruments" it goes over code on how to do this but when I try to replicate the script in my code I am receiving numerous error messages when I compile.

      Are there any examples of a complete NinjaScript that show how to trade 1 or 2 Data Series based off of one indicator?

      Thank you,

      Comment


        #4
        Hello Scarlett09,
        Unfortunately we do not have a sample code but you can create a strategy as per your requirement using a multi instrument code.

        A sample code will be like:

        Code:
        protected override void Initialize()
        {
        	Add("$AUDUSD", PeriodType.Minute, 5, MarketDataType.Last);
                //rest of the code
        }
        Code:
        protected override void OnBarUpdate()
        {
        	if (BarsInProgress == 1)
        	{
        		if (CrossAbove(this.Stochastics(Closes[1], 7, 14, 3), 20, 1))  //if stochastics as claculated on secondary series cross over 20, buy gold
        		{
        			EnterLong(0, 1, "Buy Gold");
        		}
        	}
        }



        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        1 view
        0 likes
        Last Post gentlebenthebear  
        Started by samish18, Yesterday, 08:31 AM
        2 responses
        8 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        389 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        31 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        29 views
        0 likes
        Last Post yertle
        by yertle
         
        Working...
        X