_Inputs: _ NumShares(1), _ Day_Profit_Target(_ 550 ),_ // day profit target per contract in dollars_ _ Day_StopLoss_Target( -50 ), _ ExitIntraTrade(true);_ vars:______ __ NP( 0 ),___ __ OPP( 0 ),___ __ PLB4Today( 0 ),___ __ ProfToday( 0 ),___ __ MP(0),__ __ tradeON(false),_________ __ myTradePTgtPts(0),_ __ myTradeSTgtPts(0),_ __ myDayPTarget(0),_ __ myDaySTarget(0), __ PriceLStick (0);_ __ MP = MarketPosition;__ NP = NetProfit ;___ OPP = OpenPositionProfit ;___ _ {**************************************_ Initialize at beginning of strategy_ **************************************}_ once begin_ __ __ {****************************************_ __ Multiply day profit target per contract__ __ by the number of contracts_ __ *****************************************}_ __ myDayPTarget = {NumShares *} Day_Profit_Target;____________ __ myDaySTarget = {NumShares *} Day_StopLoss_Target;_ end;_ _ {******************************************************_ Initialize at beginning of day (for day chart)_ NOTE: for 24 hour_ charts use "if date = Sample_StartTime ..."_ *******************************************************}_ _ _ {********************************************_ At end of every bar calculate today's profit_ *********************************************}_ ProfToday = OPP_ ; // Profit today__ __ {********************************************************__ Turn off entries when a day profit or loss target it hit__ *********************************************************}__ if ExitIntraTrade then begin_ __ {******************************************************_ __ Check profit and loss on every bar and exit intraTrade_ __ *******************************************************}____ __ if ProfToday >= myDayPTarget then begin____ _____ tradeON = false;__ _____ if MP = 1 then begin_ ________ sell ("ProfitHit_LX") next bar at market;_ _____ end_ _____ else if MP = -1 then begin_ ________ buyToCover ("ProfitHit_SX") next bar at market;_ _____ end;_ __ end; __ ___ _____ end_ else begin_ __ {****************************************_ __ Check profit and loss only when flat_ __ *****************************************}_ __ If MP = 0 then begin_ _____ if ProfToday >= myDayPTarget then begin____ ________ tradeON = false;__ _____ end ;___ __ end;_ end;_ _ _ Inputs: Price(close), PriceLS (1400); PriceLStick = PriceLS; If Currentbar > 5 and Price crosses over PriceLStick then _Buy ("PriceLSLong") NumShares shares next bar at market; If Currentbar >5 and Price crosses under PriceLStick then _Sell short ("PriceLSShort") NumShares shares next bar at market;
Above code dashes need to be removed start of each line. Code is primarily used for transactional history support resistance.. You create a optimization report regarding price and put in your longest tick history data that you can. You can step 'pricels' increments to see where price has traveled least.
inputs: EMALength(200), MAPrice(close), RoundPrecision(5 {Decimal Places for Price} ), TicksBeyondEntryBar(6), ProfitTarget(5000); vars: EMA(0), TradeTrigger(0), PriceOfEntry(0); inputs: DailyTradesMax(1); vars: DailyTotalTrades(0), BeginDayTotalTrades(0); if ( date <> date[1] ) then begin BeginDayTotalTrades = NumEvenTrades + NumWinTrades + NumLosTrades; end; DailyTotalTrades = ( NumEvenTrades + NumWinTrades + NumLosTrades ) - BeginDayTotalTrades; EMA = Round(XAverage(MAPrice, EMALength), RoundPrecision); inputs: TradeTimeStart(0820), TradeTimeEnd(1315); vars: TradingHours(0); TradingHours = 0; If ( ( Time > TradeTimeStart ) and ( Time <= TradeTimeEnd ) ) then TradingHours = 1; If ( ( close[1] < EMA[1] ) and ( close > EMA ) and ( TradingHours = 1 ) and ( DailyTotalTrades < DailyTradesMax ) ) then begin TradeTrigger = 1; PriceOfEntry = high + ( TicksBeyondEntryBar * ( minmove / pricescale ) ); end; If ( ( close[1] > EMA[1] ) and ( close < EMA ) and ( TradingHours = 1 ) and ( DailyTotalTrades < DailyTradesMax ) ) then begin TradeTrigger = -1; PriceOfEntry = low - ( TicksBeyondEntryBar * ( minmove / pricescale ) ); end; if ( time >= TradeTimeEnd ) then TradeTrigger = 0; If ( TradeTrigger = 1 ) then sellshort("S_Entry") next bar at PriceOfEntry stop; If ( TradeTrigger = -1 ) then buy("L_Entry") next bar at PriceOfEntry stop; if ( MarketPosition = -1 ) then begin TradeTrigger = 0; buytocover("S_PrftTrgt") next bar at ( EntryPrice - ( ProfitTarget * ( minmove / pricescale ) ) ) limit; end; if ( MarketPosition = 1 ) then begin TradeTrigger = 0; sell("L_PrftTrgt") next bar at ( EntryPrice + ( ProfitTarget * ( minmove / pricescale ) ) ) limit; end; if ( time >= TradeTimeEnd ) then begin sell ("L_EOD") this bar on close; buytocover ("S_EOD") this bar on close; end;
above code results today. (ESZ12 240 TICK CHART) Inputs: 200 xma 5000 profit target TradeTimeStart - 0800 TradeTimeEnd - 1600
Inputs: ____MM_________ ("Money Management"), NumShares(1), Day_Profit_Target( 550 ), // day profit target per contract in dollars Day_StopLoss_Target( -50 ), ExitIntraTrade(true), ___ST___________ ("HH-LL Sample Time"), Sample_StartTime( 1000) , Sample_EndTime( 1001) , EOD_Exit_Time (1600), ___BSR____________ ("Buy-Sell Region"), MyPercentHi(.0001), MyPercentLow(.0001); Input: ____Show______ ("Show Items"), Show_HH_LL_of_SamplingTime (True), Show_EntryHigh_Entry_Low (True); variables: NP( 0 ), OPP( 0 ), PLB4Today( 0 ), ProfToday( 0 ), MP(0), tradeON(false), myTradePTgtPts(0), myTradeSTgtPts(0), myDayPTarget(0), myDaySTarget(0); MP = MarketPosition; NP = NetProfit ; OPP = OpenPositionProfit ; {************************************** Initialize at beginning of strategy **************************************} once begin {**************************************** Multiply day profit target per contract by the number of contracts *****************************************} myDayPTarget = {NumShares *} Day_Profit_Target; myDaySTarget = {NumShares *} Day_StopLoss_Target; end; {****************************************************** Initialize at beginning of day (for day chart) NOTE: for 24 hour charts use "if date = Sample_StartTime ..." *******************************************************} if date <> date[1] then begin PLB4Today = NP[1] + OPP[1] ; // Profit before today tradeON = true; end; {******************************************** At end of every bar calculate today's profit *********************************************} ProfToday = NP + OPP - PLB4Today ; // Profit today {******************************************************** Turn off entries when a day profit or loss target it hit *********************************************************} if ExitIntraTrade then begin {****************************************************** Check profit and loss on every bar and exit intraTrade *******************************************************} if ProfToday >= myDayPTarget then begin tradeON = false; if MP = 1 then begin sell ("ProfitHit_LX") next bar at market; end else if MP = -1 then begin buyToCover ("ProfitHit_SX") next bar at market; end; end; if ProfToday <= myDaySTarget then begin tradeON = false; if MP = 1 then begin sell ("Los****_LX") next bar at market; end else if MP = -1 then begin buyToCover ("Los****_SX") next bar at market; end; end; end else begin {**************************************** Check profit and loss only when flat *****************************************} If MP = 0 then begin if ProfToday >= myDayPTarget then begin tradeON = false; end ; end; end; // stop trading when day profit or loss hit======================================================================= end; Variables: HighVal( 999999 ) , LowVal( 0 ) ; if Date <> Date[1] then begin HighVal = 0 ; LowVal = 999999 ; end ; if Time > Sample_StartTime and Time <= Sample_EndTime then begin // collect HH & LL during Smapling Time HighVal = MaxList( High , HighVal ) ; LowVal = MinList( Low, LowVal ) ; // plots If Show_HH_LL_of_SamplingTime then begin //HH Value1 = TL_new(d[1],t[1],HighVal,d,t,HighVal); TL_Setstyle(value1,5); TL_Setcolor(value1, darkcyan); TL_Setsize(value1,1); //LL Value2 = TL_new(d[1],t[1],LowVal,d,t,LowVal); TL_Setstyle(value2,5); TL_Setcolor(value2, darkmagenta); TL_Setsize(value2,1); end; If Show_EntryHigh_Entry_Low then begin //EH Value3 = TL_new(d[1],t[1],HighVal*(1+MyPercentHi*.01),d,t,HighVal*(1+MyPercentHi*.01)); TL_Setstyle(value3,5); TL_Setcolor(value3, cyan); TL_Setsize(value3,1); //LL Value4 = TL_new(d[1],t[1],LowVal*(1-MyPercentLow*.01),d,t,LowVal*(1-MyPercentLow*.01)); TL_Setstyle(value4,5); TL_Setcolor(value4, magenta); TL_Setsize(value4,1); end; end ; if Time >= Sample_EndTime and Time <> SessionEndTime( 0, 1 )and tradeON = true then begin if Close < HighVal*(1+MyPercentHi*.01) and close >= HighVal then buy("BO-LE")NumShares shares next bar at HighVal*(1+MyPercentHi*.01) stop ; if Close > LowVal*(1-MyPercentLow*.01) and close <= LowVal then sellShort("BO-SE")NumShares shares next bar at LowVal*(1-MyPercentLow*.01) stop ; end ; // Plot BO Regin and time > If Show_HH_LL_of_SamplingTime and time >= Sample_EndTime then begin //HH Value1 = TL_new(d[1],t[1],HighVal,d,t,HighVal); TL_Setstyle(value1,5); TL_Setcolor(value1, darkcyan); TL_Setsize(value1,1); //LL Value2 = TL_new(d[1],t[1],LowVal,d,t,LowVal); TL_Setstyle(value2,5); TL_Setcolor(value2, darkmagenta); TL_Setsize(value2,1); end; If Show_EntryHigh_Entry_Low and time >= Sample_EndTime then begin //EH Value3 = TL_new(d[1],t[1],HighVal*(1+MyPercentHi*.01),d,t,HighVal*(1+MyPercentHi*.01)); TL_Setstyle(value3,5); TL_Setcolor(value3, cyan); TL_Setsize(value3,1); //LL Value4 = TL_new(d[1],t[1],LowVal*(1-MyPercentLow*.01),d,t,LowVal*(1-MyPercentLow*.01)); TL_Setstyle(value4,5); TL_Setcolor(value4, magenta); TL_Setsize(value4,1); end;
Author Tams Volume Bias // Volume Bias // version: beta 0.1 // Author: TAMS // Date: 20090627 // Licence: Public use // // Description: // This indicator prints the volume bias on the chart // // Volume Bias is calculated as Up Volume divided by Total Volume. // i.e. The percetage of total volume that has an upward bias. // when there are more up volume than down volume, // the display will show a larger than 50% bias. // Otherwise the display will show a smaller than 50% bias. // // The background color will turn blue if the bias is over 55% // The background color will turn red if the bias is under 45% // otherwise the background will display a neutral color // // the display is formated as follow: // UpVolumeownVolume:UpBias% // // You may choose the display at position 1 or 2 // Position 1 refers to the top of the chart, 2 is the bottom. // inputs: Position_1or2(1), Upcol(blue), Dncol(red), Text.col(yellow), Neucol(darkgray); variables: id.txt(0), vol.bias(0), color(0); if currentbar = 1 then begin id.txt = text_new(d, time, c[1], ""); text_setattribute(id.txt, 0, true); text_setattribute(id.txt, 1, true); end; if ticks > 0 then vol.bias = upticks / ticks else vol.bias = 0; Text_setstring(id.txt, " " + NumToStr(upticks, 0)+ ":"+ NumToStr(downticks, 0)+"="+ NumToStr(vol.bias *100, 0) + "% "); if Position_1or2 = 1 then begin Text_setlocation(id.txt, date, time, getappinfo(aihighestDispValue)); text_setstyle(id.txt, 1, 0); end else begin Text_setlocation(id.txt, date, time, getappinfo(ailowestDispValue)); text_setstyle(id.txt, 1, 1); end; {======================================} if vol.bias > 0.55 then begin Text_Setcolor (id.txt , Text.col); Text_Setbgcolor (id.txt , upcol); end else if vol.bias < 0.45 then begin Text_Setcolor (id.txt , Text.col); Text_Setbgcolor (id.txt , dncol); end else begin Text_Setcolor (id.txt , white); Text_Setbgcolor (id.txt , neucol); end; {======================================}
// START EasyLanguage Code Inputs: Length(15), ShowAvg(true); Value1 = Highest(C, Length); Value2 = Lowest (C, Length); Value3 = ((Value1 + Value2) / 2); Plot1 (Value1, "DonchianHi"); Plot2 (Value2, "DonchianLo"); If ShowAvg = True then begin Plot3(Value3, "DonchianAvg"); end; // END EasyLanguage Code
Inputs: Sample_StartTime( 1700) , Sample_EndTime (1030), EOD_Exit_Time (1600), NumShares(1), Day_Profit_Target( 550 ), // day profit target per contract in dollars Day_StopLoss_Target( -50 ), ExitIntraTrade(true); Input: ____Show______ ("Show Items"), Show_HH_LL_of_SamplingTime (True), Show_EntryHigh_Entry_Low (True); vars: NP( 0 ), OPP( 0 ), PLB4Today( 0 ), ProfToday( 0 ), MP(0), tradeON(false), myTradePTgtPts(0), myTradeSTgtPts(0), myDayPTarget(0), myDaySTarget(0), PriceLStick (0); MP = MarketPosition; NP = NetProfit ; OPP = OpenPositionProfit ; {************************************** Initialize at beginning of strategy **************************************} once begin {**************************************** Multiply day profit target per contract by the number of contracts *****************************************} myDayPTarget = {NumShares *} Day_Profit_Target; myDaySTarget = {NumShares *} Day_StopLoss_Target; end; {****************************************************** Initialize at beginning of day (for day chart) NOTE: for 24 hour charts use "if date = Sample_StartTime ..." *******************************************************} {******************************************** At end of every bar calculate today's profit *********************************************} ProfToday = OPP ; // Profit today {******************************************************** Turn off entries when a day profit or loss target it hit *********************************************************} if ExitIntraTrade then begin {****************************************************** Check profit and loss on every bar and exit intraTrade *******************************************************} if ProfToday >= myDayPTarget then begin tradeON = false; if MP = 1 then begin sell ("ProfitHit_LX") next bar at market; end else if MP = -1 then begin buyToCover ("ProfitHit_SX") next bar at market; end; end; end else begin {**************************************** Check profit and loss only when flat *****************************************} If MP = 0 then begin if ProfToday >= myDayPTarget then begin tradeON = false; end ; end; end; Variables: HighVal( 999999 ) , LowVal( 0 ) ; if Date <> Date[1] then begin HighVal = 0 ; LowVal = 999999 ; end ; if Time > Sample_StartTime and Time <= Sample_EndTime then begin // collect HH & LL during Smapling Time HighVal = MaxList( High , HighVal ) ; LowVal = MinList( Low, LowVal ) ; // plots If Show_HH_LL_of_SamplingTime then begin //HH Value1 = TL_new(d[1],t[1],HighVal,d,t,HighVal); TL_Setstyle(value1,5); TL_Setcolor(value1, darkcyan); TL_Setsize(value1,1); //LL Value2 = TL_new(d[1],t[1],LowVal,d,t,LowVal); TL_Setstyle(value2,5); TL_Setcolor(value2, darkmagenta); TL_Setsize(value2,1); end; If Show_EntryHigh_Entry_Low then begin //EH Value3 = TL_new(d[1],t[1],HighVal,d,t,HighVal); TL_Setstyle(value3,5); TL_Setcolor(value3, cyan); TL_Setsize(value3,1); //LL Value4 = TL_new(d[1],t[1],LowVal,d,t,LowVal); TL_Setstyle(value4,5); TL_Setcolor(value4, magenta); TL_Setsize(value4,1); end; end ; Inputs: Price(close); if Time > Sample_StartTime then begin PriceLStick = ((HighVal + LowVal)/2); If Currentbar > 2 and Price crosses over PriceLStick then Buy ("PriceLSLong") NumShares shares next bar at market; If Currentbar > 2 and Price crosses under PriceLStick then Sell short ("PriceLSShort") NumShares shares next bar at market; end;