Scopiazzando un po' in giro e customizzando ho scritto questo indicatore
che CON I SUOI LIMITI , specie su titoli abbastanza scambiati sulle legs di analisi puo' essere interessante.
Si tratta in pratica di un analizzatore dell' andamento storico di
spread (liberamente componibili sia orizz. che vert.).
La vera GRANDE limitazione è che non rappresenta il prezzo sul
mark, ma sul LAST.
Contattasto il ToS support dicono che sono consci della limitazione, ma purtroppo il problema è dell' "architettura software".
Comunque accontentiamoci, penso che per qualcuno l' indicatore (specie in frame lenti) sarà interessante
Il codice sotto fa una analisi (SUL LAST) di un ICondor su AAPL.
Divertitevi.
#hint symbol1: Enter the option 1 symbol in the standard format . SYMBOL YYMMDD C/P STRIKE
#hint symbol2: Enter the option 2 symbol in the standard format . SYMBOL YYMMDD C/P STRIKE
#hint symbol3: Enter the option 3 symbol in the standard format . SYMBOL YYMMDD C/P STRIKE
#hint symbol4: Enter the option 4 symbol in the standard format . SYMBOL YYMMDD C/P STRIKE
#hint symbol1Multiplier: Enter the quantity of option 1 in the spread (+ numbers long, - numbers short)
#hint symbol2Multiplier: Enter the quantity of option 2 in the spread (+ numbers long, - numbers short)
#hint symbol3Multiplier: Enter the quantity of option 3 in the spread (+ numbers long, - numbers short)
#hint symbol4Multiplier: Enter the quantity of option 4 in the spread (+ numbers long, - numbers short)
#hint spreadMultiplier: Enter an optional multiplier for the number of contracts purchased
#hint display: Total Value shows the dollar value of the spread, Contract Cost shows the price to purchase the spread contracts, Bar Percent Change shows the bar to bar percent change in the spread price
#hint smoothingPeriod: Enter an optional smoothing period on the chart
#hint entryPrice: Enter an optional entry price for the Contract Cost mode only
declare lower;
input symbol1 = ".AAPL110618C340";
input symbol2 = ".AAPL110618C345";
input symbol3 = ".AAPL110618P320";
input symbol4 = ".AAPL110618P315";
input smoothingPeriod = 1;
input symbol1Multiplier = -1;
input symbol2Multiplier = +1;
input symbol3Multiplier = -1;
input symbol4Multiplier = +1;
input spreadMultiplier = 1;
input display = {TotalValue, default ContractCost, BarPercentChange};
input entryPrice = 0.0;
def displayMultiplier = if display == display.TotalValue then 100 else 1;
rec close1 = if !IsNaN(close(symbol1)) then close(symbol1) else close1[1];
rec close2 = if !IsNaN(close(symbol2)) then close(symbol2) else close2[1];
rec close3 = if !IsNaN(close(symbol3)) then close(symbol3) else close3[1];
rec close4 = if !IsNaN(close(symbol4)) then close(symbol4) else close4[1];
def spreadValue = if display == display.BarPercentChange then ((-(close1[1] * symbol1Multiplier + close2[1] * symbol2Multiplier + close3[1] * symbol3Multiplier + close4[1] * symbol4Multiplier) + (close1 * symbol1Multiplier + close2 * symbol2Multiplier + close3 * symbol3Multiplier + close4 * symbol4Multiplier)) * 100) / (close1[1] * symbol1Multiplier + close2[1] * symbol2Multiplier + close3[1] * symbol3Multiplier + close4[1] * symbol4Multiplier) else Average((close1 * symbol1Multiplier + close2 * symbol2Multiplier + close3 * symbol3Multiplier + close4 * symbol4Multiplier) * displayMultiplier, smoothingPeriod) * spreadMultiplier;
plot spread = if close then spreadValue else double.nan;
spread.SetPaintingStrategy(paintingStrategy.LINE_VS_POINTS);
spread.AssignValueColor(if (spread > spread[1] and spread >= 0) then color.green else if spread > 0 then color.dark_green else if spread < spread[1] and spread < 0 then color.red else color.dark_red);
spread.SetLineWeight(1);
plot zero = 0;
zero.SetDefaultColor(color.dark_gray);
plot entry = if display == display.ContractCost then entryPrice else double.nan;
entry.AssignValueColor(if spread > entryPrice then color.green else color.red);
----
Allego immagine