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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          20 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          30 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          47 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          38 views
          0 likes
          Last Post CarlTrading  
          Working...
          X