Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Prints from indicator valid but not from strategy

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

    Prints from indicator valid but not from strategy

    HI i have indicator and use indicator in strategy. Below is a function in indicator where I plot values Values[25][0] = -22; and print and it prints accordingly like -22.
    Filled R (22) In Function Ind:-22

    However in my strategy, when i call this value it prints 0 always .
    Print("values25R:" + fvgIndicator.Values[25][0])

    What am i missing?

    function inside indicator:

    else if (fvg.type == FVGType.S && (FillType == FVGFillType.CLOSE_THROUGH ? (Closes[iDataSeriesIdx][0] <= fvg.lowerPrice) : (Lows[iDataSeriesIdx][0] <= fvg.lowerPrice)))
    {
    if (DrawObjects[fvg.tag] != null)
    {
    fvg.filled = true;
    fvg.fillTime = Times[iDataSeriesIdx][0];
    filled.Add(fvg);
    // Values[25][0] = -2;
    Debug("FILLED SUPPORT" + Time[0]);
    if(lastS == null)
    lastS = fvg;
    else{
    if(fvg.gapStartTime > lastS.gapStartTime)
    lastS = fvg;
    Values[25][0] = -22;
    Print("Filled S (-22) In Function Ind:"+Values[25][0]);​

    #2
    Hello tkaboris,

    It looks like you are trying to use the drawing objects collection which would only work in realtime, are you testing in realtime and allowing at least a few bars to elapse before checking the value? In general it would not be suggested to use drawing objects for the purpose of plotting, you should instead have the indicator store values it needs to series so they can be accessed both historically and in realtime by the strategy.

    Comment


      #3
      ok i added type so now it has
      public Series<FVG> rFilled;

      cs = new Series<FVG>(this);
      cr = new Series<FVG>(this);
      ls = new Series<FVG>(this);
      lr = new Series<FVG>(this);​
      rFilled = new Series<FVG>(this);


      AddPlot(Brushes.Transparent, "Filled R In Function");

      in configure
      rFilled = new Series<FVG>(this);

      Since there are several types of plots, how to i properly set values in function?

      if (fvg.type == FVGType.R && (FillType == FVGFillType.CLOSE_THROUGH ? (Closes[iDataSeriesIdx][0] >= fvg.upperPrice) : (Highs[iDataSeriesIdx][0] >= fvg.upperPrice)))
      {
      if (DrawObjects[fvg.tag] != null)
      {
      fvg.filled = true;
      fvg.fillTime = Times[iDataSeriesIdx][0];
      filled.Add(fvg);
      // Values[24][0] = 2;
      Debug("FILLED RESISTANCE" + Time[0]);
      if(lastR == null)
      lastR = fvg;
      else{
      if(fvg.gapStartTime > lastR.gapStartTime)
      lastR = fvg;
      Values[24][0] = 22;
      Print("Filled R (22) In Function Ind:"+Values[24][0]);​

      Comment


        #4
        Hello tkaboris,

        The series you made needs to be made private, you can see how to make a series here: https://ninjatrader.com/support/help...ightsub=series

        The code you are using is still using DrawObjects[fvg.tag] which is not synchronized with the indicator or strategy, that is the charts drawing object collection. That does not work historically or in other tools like backtesting. You need to replace the use of the drawing object with other logic to store whatever values the drawing object represents and then plot that value. If you want to also draw something on the chart you can but it would not be suggested to use DrawObjects[fvg.tag] for the purpose of plotting because that will be null most of the time.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        53 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X