Sono riuscito a costruire finalmente un sistema che effettivamente funziona per testare i pivots. Non ho ancora capito esattamente in che periodi funzionano, ma funzionano.
Tuttavia ancora va perfezionato:
Inputs: ...S_PrTol(0.001), R_PrTol(0.001), Support_Length(24), Resistance_Length(12)...
Variables: ...support(0), resistance(0), RPivotAll(0), SPivotAll(0), R1(0), R2(0), R3(0), S1(0), S2(0), S3(0), PivPnt(0), Resistance1(0), Resistance2(0), Resistance3(0), Support1(0), Support2(0), Support3(0)...
support = Lowest(Low[1], Support_Length);
resistance = Highest(High[1], Resistance_Length);
If Date <> Date[1] then Begin
PivPnt = (HighD(1) + LowD(1) + CloseD(1)) / 3;
Resistance1 = (PivPnt * 2) - LowD(1);
Resistance2 = PivPnt + (HighD(1) - LowD(1));
Resistance3 = Resistance1 + (HighD(1) - LowD(1));
Support1 = (PivPnt * 2) - HighD(1);
Support2 = PivPnt - (HighD(1) - LowD(1));
Support3 = Support1 - (HighD(1) - LowD(1));
end;
S1 = IFF(( support > Support1 * (1 - S_PrTol) and support < Support1 * (1 + S_PrTol) ),1,0);
S2 = IFF(( support > Support2 * (1 - S_PrTol) and support < Support2 * (1 + S_PrTol) ),1,0);
S3 = IFF(( support > Support3 * (1 - S_PrTol) and support < Support3 * (1 + S_PrTol) ),1,0);
R1 = IFF(( resistance > Resistance1 * (1 - R_PrTol) and resistance < Resistance1 * (1 + R_PrTol) ),1,0);
R2 = IFF(( resistance > Resistance2 * (1 - R_PrTol) and resistance < Resistance2 * (1 + R_PrTol) ),1,0);
R3 = IFF(( resistance > Resistance3 * (1 - R_PrTol) and resistance < Resistance3 * (1 + R_PrTol) ),1,0);
SPivotAll = IFF((S1 = 1) or (S2 = 1),1,0);
RPivotAll = IFF((R1 = 1) or (R2 = 1),1,0);
If CurrentBar > 1 and Fast crosses above Slow and SPivotAll = 1
Then
Buy next Bar at Open;
If CurrentBar > 1 and Fast crosses below Slow and RPivotAll = 1
Then
Sell next Bar at Open;
----------
Il problema è in grassetto, perché va bene considerare Highest high e Lowest low, però non so come dirgli di considerare gli Highest High e Lowest Low avvenuti x barre prima, che però siano avvenuti OGGI. E' molto semplice ma non so la risposta.
support = Lowest(Low[1], Support_Length) purché oggi;
resistance = Highest(High[1], Resistance_Length) purché oggi;
Tuttavia ancora va perfezionato:
Inputs: ...S_PrTol(0.001), R_PrTol(0.001), Support_Length(24), Resistance_Length(12)...
Variables: ...support(0), resistance(0), RPivotAll(0), SPivotAll(0), R1(0), R2(0), R3(0), S1(0), S2(0), S3(0), PivPnt(0), Resistance1(0), Resistance2(0), Resistance3(0), Support1(0), Support2(0), Support3(0)...
support = Lowest(Low[1], Support_Length);
resistance = Highest(High[1], Resistance_Length);
If Date <> Date[1] then Begin
PivPnt = (HighD(1) + LowD(1) + CloseD(1)) / 3;
Resistance1 = (PivPnt * 2) - LowD(1);
Resistance2 = PivPnt + (HighD(1) - LowD(1));
Resistance3 = Resistance1 + (HighD(1) - LowD(1));
Support1 = (PivPnt * 2) - HighD(1);
Support2 = PivPnt - (HighD(1) - LowD(1));
Support3 = Support1 - (HighD(1) - LowD(1));
end;
S1 = IFF(( support > Support1 * (1 - S_PrTol) and support < Support1 * (1 + S_PrTol) ),1,0);
S2 = IFF(( support > Support2 * (1 - S_PrTol) and support < Support2 * (1 + S_PrTol) ),1,0);
S3 = IFF(( support > Support3 * (1 - S_PrTol) and support < Support3 * (1 + S_PrTol) ),1,0);
R1 = IFF(( resistance > Resistance1 * (1 - R_PrTol) and resistance < Resistance1 * (1 + R_PrTol) ),1,0);
R2 = IFF(( resistance > Resistance2 * (1 - R_PrTol) and resistance < Resistance2 * (1 + R_PrTol) ),1,0);
R3 = IFF(( resistance > Resistance3 * (1 - R_PrTol) and resistance < Resistance3 * (1 + R_PrTol) ),1,0);
SPivotAll = IFF((S1 = 1) or (S2 = 1),1,0);
RPivotAll = IFF((R1 = 1) or (R2 = 1),1,0);
If CurrentBar > 1 and Fast crosses above Slow and SPivotAll = 1
Then
Buy next Bar at Open;
If CurrentBar > 1 and Fast crosses below Slow and RPivotAll = 1
Then
Sell next Bar at Open;
----------
Il problema è in grassetto, perché va bene considerare Highest high e Lowest low, però non so come dirgli di considerare gli Highest High e Lowest Low avvenuti x barre prima, che però siano avvenuti OGGI. E' molto semplice ma non so la risposta.
support = Lowest(Low[1], Support_Length) purché oggi;
resistance = Highest(High[1], Resistance_Length) purché oggi;