Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SMA cross

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

    SMA cross

    hello,
    looking at youtube video I tried to create an indicator which will print arrow when price cross sma. but I am getting an error in that, can someone please help me with the code....
    else if (State == State.Configure)
    {
    SMA1 = SMA(Close, 14);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 70)
    return;

    // Set 1
    if (CrossAbove(Close, SMA1, 1))
    {
    Draw.ArrowUp(this, @"Smacross Arrow up_1", false, 0, (Low[0] + (-4 * TickSize)) , Brushes.Lime);
    //EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if (CrossBelow(Close, SMA1, 1))
    {
    Draw.ArrowDown(this, @"Smacross Arrow down_1", false, 0, (High[0] + (4 * TickSize)) , Brushes.Red);
    //EnterShort(Convert.ToInt32(DefaultQuantity), "");
    Attached Files

    #2
    i am getting this error
    cs0103 The name "SMA1" DOSE NOT EXIST IN THE CURRENT CONTEXT

    Comment


      #3
      Hello hir04068,

      Thank you for your post.

      It looks like you just missed the variable definition for the SMA you have used. If you copied this syntax from another location, you likely just missed the variable at the top:

      Code:
      public class smasa : Indicator
          {
      [B]private SMA SMA1;[/B] 
              protected override void OnStateChange()

      I look forward to being of further assistance.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      591 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      343 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      556 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      553 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X