Skip to content

ESEC Futures

Market Analysis and Trader Eduation

Menu
  • About
  • Order Flow and Price Action Trading
  • Trader Funding
  • Trading Strategies
Menu

Market Delta Code for Trade Station

Posted on December 18, 2021December 18, 2021 by Vlad

This market delta code will only analyze price action data from the data displayed on you screen, so to go further back in time adjust your chart setting accordingly.

inputs:
Threshold1( 150 ),
Threshold2( 300 ),
Threshold3( 600 ),
DisplayDelta( false ),
Type( 1 ), // 1 = Use Upticks/Downticks, 2 = Use Bid/Ask
BidAskArraySz( 1000 );

variables:
TickSize( MinMove / PriceScale ),
PriceAtIndex( Open ),
BaseIndex( BidAskArraySz/2 ),
Red1(RGB(255,185,185)),
Red2(RGB(255,128,128)),
Red3(RGB(255,0,0)),
Red4(RGB(128,0,0)),
Green1(RGB(210,255,210)),
Green2(RGB(125,255,125)),
Green3(RGB(0,255,0)),
Green4(RGB(0,128,0)),
i( 0 );

variables:
intrabarpersist Price( 0 ),
intrabarpersist MyVol( 0 ),
intrabarpersist VolTmp( 0 ),
intrabarpersist LastTick( 0 ),
intrabarpersist MyCurrentBar( 0 ),
intrabarpersist Index( 0 ),
intrabarpersist BidAskDelta( 0 ),
intrabarpersist xDelta( 0 ),
intrabarpersist TextString(””),
intrabarpersist MyUpTicks( 0 ),
intrabarpersist MyDownTicks( 0 );

Arrays:
intrabarpersist Bid[](0),
intrabarpersist Ask[](0);

Array_SetMaxIndex( Bid, BidAskArraySz );
Array_SetMaxIndex( Ask, BidAskArraySz );

if (Type = 1 or Type = 2) and LastBarOnChart and BarType < 2 then
begin
MyVol = Ticks;
PriceAtIndex = Open;

if CurrentBar > MyCurrentBar then
begin
VolTmp = 0;
MyCurrentBar = CurrentBar;
MyUpTicks = 0;
MyDownTicks = 0;

for i = 0 to BidAskArraySz – 1
begin
Bid[i] = 0;
Ask[i] = 0;
end;
end;

Index = BaseIndex + (Close – PriceAtIndex) / TickSize;

if InsideBid < InsideAsk then
begin
if Type = 1 then
begin
// Use Upticks/Downticks
if DownTicks <> MyDownTicks then
Bid[Index] = Bid[Index] + MyVol – VolTmp
else if UpTicks <> MyUpTicks then
Ask[Index] = Ask[Index] + MyVol – VolTmp
else
begin
if Close <= LastTick then
Bid[Index] = Bid[Index] + MyVol – VolTmp
else
Ask[Index] = Ask[Index] + MyVol – VolTmp;
end;
end
else
begin
// Use Bid/Ask
// Warning: TradeStation provides snapshot of bid/ask
if Close <= InsideBid then
Bid[Index] = Bid[Index] + MyVol – VolTmp
else if Close >= InsideAsk then
Ask[Index] = Ask[Index] + MyVol – VolTmp
else
begin
// Last tick was between bid/ask
if Close <= LastTick then
Bid[Index] = Bid[Index] + MyVol – VolTmp
else
Ask[Index] = Ask[Index] + MyVol – VolTmp;
end;
end;
end;

MyUpTicks = UpTicks;
MyDownTicks = DownTicks;
VolTmp = MyVol;
LastTick = Close;

xDelta = 0;
Price = Low;

while Price <= High
begin
Index = BaseIndex + (Price – PriceAtIndex) / TickSize;
TextString = NumToStr(Bid[Index],0) + ” x ” + NumToStr(Ask[Index],0);
Value99 = Text_New(Date, Time, 0, ” “);
Text_SetString(Value99, TextString);
Text_SetLocation(Value99, Date, Time, Price);
Text_SetStyle(Value99, 1, 1);

BidAskDelta = Ask[Index] – Bid[Index];
if BidAskDelta > Threshold3 then
Text_SetColor(Value99, Green4)
else if BidAskDelta > Threshold2 then
Text_SetColor(Value99, Green3)
else if BidAskDelta > Threshold1 then
Text_SetColor(Value99, Green2)
else if BidAskDelta >= 0 then
Text_SetColor(Value99, Green1)
else if BidAskDelta < -Threshold3 then
Text_SetColor(Value99, Red4)
else if BidAskDelta < -Threshold2 then
Text_SetColor(Value99, Red3)
else if BidAskDelta < -Threshold1 then
Text_SetColor(Value99, Red2)
else
Text_SetColor(Value99, Red1);

xDelta = xDelta + BidAskDelta;

Price = Price + TickSize;
end;

if DisplayDelta = true then
begin
Value99 = Text_New(Date, Time, 0, ” “);
Text_SetString(Value99, NumToStr(xDelta, 0 ));
Text_SetLocation(Value99, Date, Time, Low – TickSize);
Text_SetStyle(Value99, 1, 1);

if xDelta >= 0 then
Text_SetColor(Value99, Green)
else
Text_SetColor(Value99, Red);
end;
end;

Enjoy

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Best Deals in Trader Funding for June 2022
  • Pop-n-Crap Set Up
  • June Weekend Crypto Trading Order Flow Concepts
  • 6E Euro Futures and Resting Liquidity via BookMap
  • Best Funded Trader Deals & Sales for May
  • LeeLoo Birthday 83% Off – Code OPT83
  • Perfect Crude 5/19
  • Apex 80% Off Funded Trader Program
  • BTC Trade opportunity – combining a few concepts
  • Funded Trader Deals Feb 2022
  • BTC Liquidity Pull Set Up
  • Leeloo Trading 25,000 Funded Account $23
  • About
  • Order Flow and Price Action Trading
  • Trader Funding
  • Trading Strategies
© 2025 ESEC Futures | Powered by Minimalist Blog WordPress Theme