Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing from a strategy or from an indicator

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

    Drawing from a strategy or from an indicator

    Could anyone explain to me the reason why, when I put this code in a strategy script, it draws Fibonacci retracements over my chart but when I put it in an indicator it does not.

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (High[0] == MAX(High, 34)[0])
    {
    RemoveDrawObjects();
    DrawFibonacciRetracements("My fibonacci retracements" + CurrentBar, 1, MIN(Low, 34)[0], 0, High[0]);
    PlaySound("DRUM.wav");
    }
    // Condition set 2
    if (Low[0] == MIN(Low, 34)[0])
    {
    RemoveDrawObjects();
    DrawFibonacciRetracements("My fibonacci retracements" + CurrentBar, 1, MAX(High, 34)[0], 0, Low[0]);
    PlaySound("REMD.wav");
    }
    // Condition set 3
    if (CrossAbove(Close, SMA(Close, 100), 1))
    {
    PlaySound("ringout.wav");
    }
    // Condition set 4
    if (CrossBelow(Close, SMA(Close, 100), 1))
    {
    PlaySound("online.wav");
    }
    }

    Gérard

    #2
    Not sure I follow. Are you saying that putting this strategy on chart will draw the fib retracements and as you then add another indicator like e.g. SMA to the the same chart the fib retracements are gone?

    Please clarify. Thanks

    Comment


      #3
      When I use Market Replay for 06/25/07 here is what happens :

      - experiment 1
      . I attach the strategy : fib retracements immediately appear on the chart which happened to be previously displayed on my screen;
      . I start to replay from the very beginning and then :
      - on the 15th candle, a swing low happens : I can hear the sound and the fibs are drawn over the current candle
      - on the 22th candle, a swing high happens : sound again and the fibs are drawn over the current candle

      - experiment 2
      . I get rid of any strategy and attach the same code inside an indicator : no fibs appear
      . I restart the playing and then
      - on the 15th candle, same swing low : no sound, no fibs
      - on the 22th candle, same swing high : no sound, no fibs.

      I wish I could have my fibs automatically drawn from an indicator which I would attach to my default template and which would allow me to use chart trader

      Comment


        #4
        Then likely the conditions in your indicator which trigger the drawing of the fibs never become true. Please verify by placing Print() statements instead of the drawing statements.

        Next steps: Please try to understand why your conditions do not become true by simplifying your indicator until it finally works as expected.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        148 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        5 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        5 views
        0 likes
        Last Post tkaboris  
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,283 views
        0 likes
        Last Post Leafcutter  
        Working...
        X