+1 888 340 6572 GET STARTED
MultiCharts Project Management
previous_open_issue.png
Go to the previous open issue
previous_issue.png
Go to the previous issue (open or closed)
star_faded.png
Please log in to bookmark issues
bug_report_small.png
Open Bug report MC-2737

"Max number of bars" Auto-Detect does not work correctly in some cases (Multicharts .NET)

action_vote_minus_faded.png
1
Votes
action_vote_plus_faded.png
next_issue.png
Go to the next issue (open or closed)
next_open_issue.png
Go to the next open issue
Description

In Multicharts .NET the max number of bars "Auto-Detect" function does not work properly and calls the StartCalc-Method twice if the Indicator logic is within a method and if "Format Study / Properties / Max number of bars study will reference" is set to "Auto-Detect". When changing the setting to "User Specified" it works correctly.
See example code below.

Steps to reproduce this issue

using System;
using System.Drawing;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{

[SameAsSymbol(true)]
public class bugtest : IndicatorObject
{
public bugtest(object _ctx):base(_ctx) {}

private IPlotObject plot1;



public bool myPattern(IInstrument _bars, IOutput _out)
{

    _out.WriteLine("myPattern() at bar: {0} \t CloseValue: {1}" , _bars.FullSymbolData.Current, _bars.CloseValue); 


    if(_bars.Close[0] > _bars.High[1])           // <-------------
    {
        return true;
    }
    else
    {
        return false;   
    }
}   



protected override void Create() 
{
    plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Point, Color.Yellow) );    
}



protected override void StartCalc() 
{
    //Output.Clear();
    Output.WriteLine("Hello from StartCalc-Function");
}



protected override void CalcBar()
{
    if( myPattern(this.Bars, this.Output) == true)
    {
        plot1.Set(Bars.High[0],  Color.Yellow); 
    }
}

}

}

Comments (1)
#1
user-offline.png  MultiCharts Support (MultiCharts)
Sep 17, 2021 - 06:58
That is designed behaviour. MultiCharts doesn’t look inside the code of the strategy and determine the exact number of bars required for calculation. That’s why this value is autodetected (if the corresponding parameter is selected or if the user specified value is incorrect), e.g. the selection starts from 0, then 6, then 12 and so on. If an autodetected value is not enough for a certain study, then the script is recalculated, and selection continues until the suitable value is found.
History
Issue basics
  • Type of issue
    Bug report
  • Category
    Not determined
  • Targeted for
    Not determined
  • Status
    Not a bug
  • Priority
    Not determined
User pain
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
Affected by this issue (0)
There are no items
People involved
Times and dates
  • Posted at
  • Last updated
Issue details
  • Reproducability
    Not determined
Attachments (0)
There is nothing attached to this issue
Commits (0)
There are no code checkins for this issue
Duplicate issues (0)
This issue does not have any duplicates