Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

a code to start with

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

    a code to start with

    Hi, I am new here, if I want to chage the code below to Ninja strategy, what will it be? Thank you very much.

    inputs: MA1(10), MA2(60),MA3(200);
    variables: var1( 0 ), var2( 0 ), var3( 0 );
    var1 = AverageFC( c, MA1 ) ;
    var2 = AverageFC( c, MA2 ) ;
    var3 = AverageFC( c, MA3 ) ;

    condition1 = var1 > var2 ;
    condition2 = var1 < var2 ;
    condition3 = var2 > var3;
    condition4 = var2 < var3;
    if condition1 and condition3 then buy next bar at market ;
    if condition2 and condition4 then sellshort next bar at market ;​

    #2
    Hi, I am new here, if I want to chage the code below to Ninja strategy, what will it be? Thank you very much.

    inputs: MA1(10), MA2(60),MA3(200);
    variables: var1( 0 ), var2( 0 ), var3( 0 );
    var1 = AverageFC( c, MA1 ) ;
    var2 = AverageFC( c, MA2 ) ;
    var3 = AverageFC( c, MA3 ) ;

    condition1 = var1 > var2 ;
    condition2 = var1 < var2 ;
    condition3 = var2 > var3;
    condition4 = var2 < var3;
    if condition1 and condition3 then buy next bar at market ;
    if condition2 and condition4 then sellshort next bar at market ;

    Comment


      #3
      Hello dragonkevin,

      It looks like this is code for a different platform so that would not be something you can just make into a strategy in NinjaTrader, you would have to use NinjaScript (C# language) to remake what that code does in NinjaTrader.

      I would suggest taking a look at some of the existing NinjaScript content like indicators and strategies that come with the platform as a starting point. Once you are comfortable using NinjaScript you could start looking at how to convert that code. You would need to review what each of the items you posted does in the other platform for example what the AverageFC does and then try to match that with a NinjaScript feature or use math/logic to recreate that feature.

      There are some educational references in the following link that can help with learning NinjaScript. https://ninjatrader.com/support/help..._resources.htm

      You can find a video that goes over creating a strategy and running it in the following link. That would also be a good place to learn about using inputs and variables. https://youtu.be/VxU4FR6GWNA

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      47 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      23 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X