Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Combinatorial Data-Sets

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

  • bkool
    replied
    The Solution

    The solution came from using the int array as follows:

    // --------------
    // Variables
    int[] w = new int[3]; // array of 3

    protected override void OnBarUpdate()
    {
    if (CurrentBar < BarsRequired) return;

    if (ToTime(Time[0]) >= ToTime(t1, 00, 0) && ToTime(Time[0]) <= ToTime(t2, 00, 0))
    {for (x = 0; ( x < 3); x++)
    {p = x;
    if (p == x) {ds = x;
    {
    // data-sets
    if (ds == 0){x = 6; y = 4; z = 2; a = -2; b = 6; c = -4;}
    if (ds == 1){x = 1; y = 5; z = 9; a = -1; b = 0; c = -12;}
    if (ds == 2){x = 4; y = 0; z = 11; a = 8; b = -2; c = 3;}

    // conditions
    if (Indicator 1 <= x
    && Indicator 2 <= y
    && Indicator 3 <= z
    && Indicator 4 <= a
    && Indicator 5 <= b)
    {w[x] = 1;
    }}}}

    if (w[0] + w[1] + w[2] >= 1)
    {signalBar1 = CurrentBar; cond1 = true;
    w[0] = 0; w[1] = 0; w[2] = 0;
    }

    if (cond1 && CurrentBar == signalBar1 // bool flags
    && Position.MarketPosition == MarketPosition.Flat)

    {EnterLong("Long 1a");
    SetStopLoss("Long 1a", CalculationMode.Ticks, sL1, false);
    if (BarsSinceEntry() == bseL1) cond1 = false;
    }

    etc ....

    // --------------------

    I hope you find it useful...

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    So the method would return the flag value then for pattern found or not? I'm not sure why it wouldn't work, but might need to see / test your snippet for that.

    For timeframes, it can get more involved as you would also have to ensure calling in the correct BarsInProgress context.

    DataSeries would help you if you need to have access to prior values, which can be handy if you plan to add conditions to the patterns, as they would likely not happen all on the exact same bar / timestamp you likely need to weaken the rules a bit (give and take one index / bar) to allow for signals to be seen.

    Leave a comment:


  • bkool
    replied
    Hi Bertrand,
    Not merely simplifying. This is pattern of patterns, and it may get too complicated when I use additional data-sets or time frames. I have tried to call the data-sets as is from a private void, but that didn't work.
    Would it be helpful to have the data-sets as DataSeries, or in a switch/case format?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    What are you trying to simplify bkool? The pattern your 'indicator chain' forms?

    Leave a comment:


  • bkool
    started a topic Combinatorial Data-Sets

    Combinatorial Data-Sets

    Hello,

    I am working on a strategy the combines several different indicators. The values of these indicators had been separately optimized for specific market conditions, generating distinct data-sets.
    I need a combinatorial programming solution in order to call each data-set when triggered.
    Currently, my solution looks as follows:


    // --------------

    protected override void OnBarUpdate()
    {
    if (CurrentBar < BarsRequired) return;

    if (ToTime(Time[0]) >= ToTime(t1, 00, 0) && ToTime(Time[0]) <= ToTime(t2, 00, 0))
    {p1 = true; p2 = true; p3 = true; // bool flags


    if (p1)
    {ds1 = 1; // data-set 1
    if (ds1 == 1)
    {x = 6; y = 4; z = 2; a = -2; b = 6; c = -4;
    {
    if (Indicator 1 <= x
    && Indicator 2 <= y
    && Indicator 3 <= z
    && Indicator 4 <= a
    && Indicator 5 <= b)
    {w1 = 1; // int flag
    }}}}

    if (p2)
    {ds2 = 1; // data-set 2
    if (ds2 == 1)
    {x = 1; y = 5; z = 9; a = -1; b = 0; c = -12;
    {
    if (Indicator 1 <= x
    && Indicator 2 <= y
    && Indicator 3 <= z
    && Indicator 4 <= a
    && Indicator 5 <= b)
    {w2 = 1; // int flag
    }}}}

    if (p3)
    {ds3 = 1; // data-set 3
    if (ds3 == 1)
    {x = 4; y = 0; z = 11; a = 8; b = -2; c = 3;
    {
    if (Indicator 1 <= x
    && Indicator 2 <= y
    && Indicator 3 <= z
    && Indicator 4 <= a
    && Indicator 5 <= b)
    {w3 = 1; // int flag
    }}}}
    }

    if (w1 + w2 + w3 >= 1)
    {signalBar1 = CurrentBar; cond1 = true;
    w1 = 0; w2 = 0; w3 = 0;
    }

    if (cond1 && CurrentBar == signalBar1 // bool flags
    && Position.MarketPosition == MarketPosition.Flat)

    {EnterLong("Long 1a");
    SetStopLoss("Long 1a", CalculationMode.Ticks, sL1, false);
    if (BarsSinceEntry() == bseL1) cond1 = false;
    }

    etc ....

    // --------------------

    As this scheme may be further extended with additional data-sets,
    I am looking for a different solution, where a single list of indicators is able to call many data-sets separately.

    Thanks much,

    bkool

Latest Posts

Collapse

Topics Statistics Last Post
Started by bsbisme, Yesterday, 02:08 PM
1 response
15 views
0 likes
Last Post NinjaTrader_Gaby  
Started by prdecast, Today, 06:07 AM
0 responses
3 views
0 likes
Last Post prdecast  
Started by i019945nj, 12-14-2023, 06:41 AM
3 responses
60 views
0 likes
Last Post i019945nj  
Started by TraderBCL, Today, 04:38 AM
2 responses
18 views
0 likes
Last Post TraderBCL  
Started by martin70, 03-24-2023, 04:58 AM
14 responses
106 views
0 likes
Last Post martin70  
Working...
X