Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing SampleMACrossOver Strategy

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

    Changing SampleMACrossOver Strategy

    Hi,

    Someone can help me. I would like to change a little bit the Strategy - SmapleMACrossOver.
    At

    }
    else if (State == State.DataLoaded)
    {
    smaFast = SMA(Fast);
    smaSlow = SMA(Slow);

    smaFast.Plots[0].Brush = Brushes.Goldenrod;


    At SMASlow = SMA(Slow) .......i would like to multiply this SMA(slow) to move the sma to another place( or distance)...like SMA(slow) * 1.125, moving the SMA 25 points above the original point,,,

    SMA(100)...would be SMA(100)*1.125..... so would Plot a line 12,5 points above the SMA(100) .

    Thanks

    Anderson​
    Last edited by andmferreira; 04-08-2024, 04:51 AM.

    #2
    Hello Anderson,

    If you don't need this plotted, you can do this in the strategy.

    Print(smaSlow[0] * 1.125);

    If you want this plotted, create a custom indicator that calls the SMA() and then multiplies the returned value by 1.125 and assign this to the Values[plot index][barsAgo index].

    AddPlot(Brushes.Blue, "MyPlot");

    Values[0][0] = SMA(100)[0] * 1.125
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea B., Thank you for your answer. i tried to change as you mentioned but it is still having a problem. sending you a pic.
      Attached Files

      Comment


        #4
        Hello andmferreira,

        The SMA(200) call needs a barsAgo index to select a value from a specific bar.

        SMA(200)[0] * 1.125
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          hi Chelsea. Thank you again. It helped to compile the strategy code. but when i try to use the strategy analyzer, the code has this error message:

          Strategy 'RoboSMA200b': Error on calling 'OnBarUpdate' method on bar 0: Index was outside the bounds of the array.

          Comment


            #6
            Hello andmferreira,

            Have you called AddPlot() as directed in Post # 2 to add a plot to the indicator?
            (In State.SetDefaults)
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            62 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            134 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            75 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X