Nadex Strikes Plotting Question

Jtru94

New member
First, I want to say, I don't think I could have gained so much valuable thinkscript experience without the help of this community. I am very grateful for you all!

I have a purely aesthetic question:

context: I like to trade Nadex from time to time and I think I've zeroed in on a very reliable 5 minute binary strategy. I decided to see if I could automatically code how the Nadex platform automatically updates their strike prices. After all, it is one thing to know how to read a chart, but it is another thing to know how that information practically correlates to the mechanics of your intended investment vehicle. I have come up with the below code (using the rounded close of every previous 5 minute bar) and it has proven very helpful. However, it does not always display the correct strikes BECAUSE Nadex updates their subsequent strike prices with 10 seconds remaining on the current binary contract and if there is higher volatility occurring in the final bar of the final minute, then the Nadex strike prices WILL differ from the close of the 5 minute bar. (this does not affect my binary trading that often because, for me, the purpose of plotting those strike prices is for relative use). Also, I am not going to spend an arm and a leg on a Nadex API tied to a ninja trader platform for the same information (won't work with TOS).

Code:
input showlines = yes;

def last5close = close(period = AggregationPeriod.FIVE_MIN)[1];

def placevalueroundup = if GetSymbol() == "AUD/USD" or GetSymbol() == "EUR/USD" or GetSymbol() == "GBP/USD" or GetSymbol() == "USD/CAD" then 4 else 2;
def last5closeRounded = Round(last5close, placevalueroundup);
def isVolt = SecondsTillTime(1205) > 0
    and SecondsFromTime(0810) >= 0;

DEF multiplier =
if GetSymbol() == "AUD/USD" and isVolt then .0004 else
if GetSymbol() == "AUD/USD" and !isVolt then .0002 else
if GetSymbol() == "EUR/USD" and isVolt then .0004 else
if GetSymbol() == "EUR/USD" and !isVolt then .0002 else
if GetSymbol() == "GBP/USD" and isVolt then .0004 else
if GetSymbol() == "GBP/USD" and !isVolt then .0002 else
if GetSymbol() == "USD/JPY" and isVolt then .04 else
if GetSymbol() == "USD/JPY" and !isVolt then .02 else
if GetSymbol() == "EUR/JPY" then .05 else
if GetSymbol() == "GBP/JPY" then .05 else
if GetSymbol() == "USD/CAD" then .0005 else
Double.NaN;

def L0 = last5closeRounded;
def L1 = last5closeRounded + multiplier;
def L2 = last5closeRounded + 2 * multiplier;
def L_1 = last5closeRounded - multiplier;
def L_2 = last5closeRounded - 2 * multiplier;

plot level0 = L0;
level0.SetDefaultColor(Color.MAGENTA);
plot level1 = L1;
level1.SetDefaultColor(Color.RED);
plot level2 = L2;
level2.SetDefaultColor(Color.RED);
plot levelneg1 = L_1;
levelneg1.SetDefaultColor(Color.GREEN);
plot levelneg2 = L_2;
levelneg2.SetDefaultColor(Color.GREEN);

level0.setlineweight(2);
level1.setlineweight(2);
level2.setlineweight(2);
levelneg1.setlineweight(2);
levelneg2.setlineweight(2);

level0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
level1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
level2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
levelneg1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
levelneg2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

level0.sethiding(!showlines);
level1.sethiding(!showlines);
level2.sethiding(!showlines);
levelneg1.sethiding(!showlines);
levelneg2.sethiding(!showlines);

input showSTRIKE_bubbles = yes;
input bubble_mover    = 1; #Moves bubbles left/right then number of bars input here
def   n               = bubble_mover;
def   n1              = n + 1;

AddChartBubble(showSTRIKE_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), level0[n1],  "$" + level0, Color.MAGENTA, yes);
AddChartBubble(showSTRIKE_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), level1[n1],  "$" + level1, Color.RED, yes);
AddChartBubble(showSTRIKE_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), level2[n1],  "$" + level2, Color.RED, no);
AddChartBubble(showSTRIKE_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), levelneg1[n1],  "$" + levelneg1, Color.GREEN, no);
AddChartBubble(showSTRIKE_bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), levelneg2[n1],  "$" + levelneg2, Color.GREEN, no);

For an image (sorry this is my first time): see this link.

If you look at the image, you will notice that it structurally mimics a type of pivots indicator in that because it uses previous ([1]) values, it will project the "current" values ahead of the current price and i colored the lines accordingly as well (though these lines are not actually pivots).

So here is my aesthetic question:

how can I display ONLY the current five minute strike lines? not the past; not the future; just the present. The closest way I could figure out how to do that was via the chart bubbles and hiding the lines. If possible, I also want to add a "displace" function, so that i could plot the current strikes in the future by x number of bars.

Also, I think that the chart bubble code sequence in the above code is an exact repeat of someone else's code on this site. I apologize for not keeping track of that. If you recognize it, and it is yours, PLEASE let me know so I can give you credit.
 

Similar threads

Top