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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        181 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        334 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        258 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        358 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        187 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X