|
East Ridge, Tennessee, USA
Experience: Master
Platform: TradeStation
Trading: Futures, Stocks, Options, Forex
Posts: 17 since Nov 2022
Thanks Given: 4
Thanks Received: 4
|
QUESTION: Why does the following code used to detect and plot a PaintBar for certain specified Pivots fail in giving the error that it cannot reference historical data into the future?...
Input: MinRatio (3.1415927);
Input: TrigSet(4);
Variables: LowPivotPrice1(0), LowPivotBar1(0), HighPivotPrice1(0), HighPivotBar1(0);
Variables: LowLS1(1), LowRS1(TrigSet), HighLS1(1), HighRS1(1);
Value1 = TrigSet - 1;
Value2 = High[Value1];
Value3 = Low[Value1];
// SHORT trade setup conditions
Condition1 = Low < Lowest(Low, Value1)[1]; { Active or pertinent Low breaks below the Low Pivot to be called the Trigger Point at 1 tick below that Trigger Pivot }
Condition2 = Value2 >= Highest(High, Value1);
{ High for the Trigger Set is the Trigger Set Extreme at its first bar (subsequent ties allowed) }
Condition3 = Pivot(Low, 233, LowLS1, Trigset, 1, -1, LowPivotPrice1, LowPivotBar1) <> -1;
{ Low Pivot with a minimum Right Strength of <Trigger Set> }
Condition4 = Pivot(High, 233, HighLS1, HighRS1, 1, 1, HighPivotPrice1, HighPivotBar1) <> -1;
{ High Pivot behind Low Pivot }
Condition5 = High[Value1] > HighPivotPrice1;
{ High Pivot must be less than the Trigger Set Extreme High }
Condition6 = Open[Value1] >= Low[LowPivotBar1] or High[Value1] >= Low[LowPivotBar1];
{ Prevents gaps from causing unwanted entry points too far from the Trigger Point if not filled on that bar by the eventual High for that bar }
Condition7 = BarNumber[LowPivotBar1] > BarNumber[HighPivotBar1];
{ High Pivot must occur first }
{ Not sure how to disregard any High Pivots occurring within the Trigger Set that would usurp the 1st instance of a High Pivot that must occur behind the Trigger pivot }
Value4 = Value2 - LowPivotPrice1;
{ Distance from the Trigger Set Extreme to the Low Pivot (Trigger Pivot) called the Standard Profit Projection (SPP) to be later used for stop placements }
Value5 = HighPivotPrice1 - LowPivotPrice1;
{ Height of the bars prior to the Trigger Set back to the High Pivot }
Condition8 = Value2 - HighPivotPrice1 <= Value5;
{ Disallows any overly long "tail" in the Trigger Set that would cause a lopsided pattern }
// ***************************************************
Variables: LowPivotPrice2(0), LowPivotBar2(0), HighPivotPrice2(0), HighPivotBar2(0);
Variables: HighLS2(1), HighRS2(TrigSet), LowLS2(1), LowRS2(1);
// LONG trade setup conditions
Condition9 = High > Highest(High, Value1)[1]; { Active or pertinent High breaks above
the High Pivot to be called the Trigger Point at 1 tick above that Trigger Pivot }
Condition10 = Value3 <= Lowest(Low, Value1);
{ Low for the Trigger Set is the Trigger Set Extreme at its first bar
(subsequent ties allowed) }
Condition11 = Pivot(High, 233, HighLS2, HighRS2, 1, 1, HighPivotPrice2, HighPivotBar2) <> -1;
{ High Pivot with a minimum Right Strength of <Trigger Set> }
Condition12 = Pivot(Low, 233, LowLS2, LowRS2, 1, -1, LowPivotPrice2, LowPivotBar2) <> -1;
{ Low Pivot behind High Pivot }
Condition13 = Low[Value1] < LowPivotPrice2;
{ Low Pivot must be greater than the Trigger Set Extreme Low }
Condition14 = Open[Value1] <= High[HighPivotBar2] or Low[Value1] <= High[HighPivotBar2];
{ Prevents gaps from causing unwanted entry points too far from the Trigger Point if
not filled on that bar by the eventual Low for that bar }
Condition15 = BarNumber[HighPivotBar2] > BarNumber[LowPivotBar2];
{ Low Pivot must occur first }
{ Not sure how to disregard any Low Pivots occurring within the Trigger Set that
would usurp the 1st instance of a Low Pivot that must occur behind the Trigger Pivot }
Value6 = HighPivotPrice2 - Value3;
{ Distance from the Trigger Set Extreme to the Low Pivot (Trigger Pivot) called the
Standard Profit Projection (SPP) to be later used for stop placements }
Value7 = HighPivotPrice2 - LowPivotPrice2;
{ Height of the bars prior to the Trigger Set back to the High Pivot }
Condition16 = HighPivotPrice2 - Value3 <= Value7;
{ Disallows any overly long "tail" in the Trigger Set that would cause a lopsided pattern }
Condition17 = (BarNumber[Value1] - BarNumber[HighPivotBar1]) / TrigSet >= MinRatio;
Condition18 = (BarNumber[Value1] - BarNumber[LowPivotBar2]) / TrigSet >= MinRatio;
If Condition17 and LowPivotBar1 = LowRS1 then
begin
PlotPaintBar[TrigSet](High, Low, "Short Trade", Red);
Alert("Short Trade Alert!");
end;
|