Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cannot implicitly convert type 'double' to 'indicator

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

    Cannot implicitly convert type 'double' to 'indicator

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class EMA123 : Strategy
    {
    private MAMA EMA1;
    private MAMA EMA2;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "EMA123";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    LOT = 1;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    EMA1 = MAMA(0.5, 0.005).Default[0];
    EMA2 = MAMA(High, 0.5, 0.005).Fama[0];
    }
    }​

    #2
    Hello siddhugaddi,

    MAMA is an indicator class. Default[0] is the index of a specific bar and is a double.

    EMA1 = MAMA(0.5, 0.005);
    EMA2 = MAMA(High, 0.5, 0.005);

    Print(EMA1.Default[0]);
    Print(EMA2.Fama[0]);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ok sir then this will print the value
      suppose i want to store those value in EMA1 & EMA2 variable then what should i need to do

      Comment


        #4
        Hello siddhugaddi,

        EMA1 and EMA2 are being assigned the indicator instances which you can reference at anytime.

        For example to use this in a condition:

        if (EMA1[0] > EMA2[0])
        {
        Print(Time[0] + " The MAMA using Close is greater than MAMA using High");
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          done sir
          thank you so much for your support

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          50 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          126 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          69 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X