Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy which does not give orders..

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

    Strategy which does not give orders..

    Hello,

    I am programming a simple strategy which part of it checks if RSI is above 50 (uptrend) and opens a long position.

    So I am doing the following:

    if (State==State.DataLoaded)
    {
    _RSIAvgSeries = new Series<double>(this);
    }

    private void AddIndicators()
    {
    _RSI = RSI(Close,Convert.ToInt32(RSIperiod), RSISmoothPeriod);
    AddChartIndicator(_RSI);
    _RSIAvgSeries = RSI(Close, Convert.ToInt32(RSIperiod), RSISmoothPeriod).Avg;

    }

    private void SetEntrySignalState()
    {
    _enterLong = IsUpTrend();
    _enterShort = IsDownTrend();
    }

    private bool IsUpTrend()
    {
    return _RSIAvgSeries[0]> 50;
    }

    private bool IsDownTrend()
    {
    return _RSIAvgSeries[0] < 50;
    }


    protected override void OnBarUpdate()
    {
    SetEntrySignalState();


    if (_enterLong)
    {
    _longEntry = EnterLong(_posSize, LongEntry);
    }

    else if (_enterShort)
    {
    _shortEntry = EnterShort(_posSize, ShortEntry);
    }
    }

    I ran the strategy and I am not getting any long or short orders when the RSI is above 50. Furthermore I am trying to Print(_RSIAvgSeries[0]) to check the value of the RSI but the strategy does not give any results on the output window.

    Could you please help on this because I think I am confused with the logic.

    Thank you.

    #2
    Hello yannistsoupakis, thanks for writing in.

    Do you see any errors coming from the Log tab of the Control Center? If you don't see any messages from the strategy in the Control Center you will need to add Print methods on each line to see why it's not hitting the condition e.g.

    Code:
    //Add lines like this throughout the strategy and observe the output window.
    private bool IsUpTrend()
    {
    [B]Print(_RSIAvgSeries[0] + " " + Time[0]);[/B]
    [B]Print(_RSIAvgSeries[0] > 50);[/B]
    return _RSIAvgSeries[0]> 50;
    }
    Please let me know if I can assist any further.

    Comment


      #3
      Thanks for your response. Print works now but I get _RsiAvgSeries[0] = 0 in all dates.Obviously it should not do this. Do you have any idea on this error?

      Comment


        #4
        Hello, thanks for your reply.

        There is something wrong with either the initialization of RSI or when you are calling it. My test example is able to produce RSI values:

        Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.


        Please reference this example to fix the issue on your script.

        Please let me know if I can assist any further.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        65 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        139 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