\nSetChartOptions( 0, chartShowArrows | chartShowDates );
\n_N( Title = StrFormat( “{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}”, O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
\nTitle = Title + “\\n” + NumToStr( DateNum() );
\nTitle = Title + “\\n” + NumToStr( TimeNum() );
\nPlot( C, “Close”, ParamColor( “Color”, colorBlack ), styleNoTitle | ParamStyle( “Style” ) | GetPriceStyle() );
\n\/\/_TRACE(“ABTest: test trace1 “);<\/p>\n\/\/#include “C:\\Program Files\\AmiBroker\\sharedLibrary\\DateTimeToNumber.afl”<\/p>\n
\/*
\n#include “C:\\Program Files\\AmiBroker\\sharedLibrary\\DateTimeToNumber.afl”
\n StaticVarSetText( “TradeType” ,”Stocks”); \/\/Stocks|Forex
\n StaticVarSetText( “forexSymbol” ,”AAPL”); \/\/”EUR.USD-IDEALPRO-CASH|
\n StaticVarSetText( “StockSymbol”,”AAPL”); \/\/ “YHOO”
\n StaticVarSetText( “ShortOrLong” ,”Short”); \/\/”Short|Long”
\n StaticVarSet( “EntryPrice” ,163.52000);
\n StaticVarSet( “ExitPrice” ,148.18000);
\n StaticVarSet( “EntryDate” ,Date_To_Num(“20080721”));
\n StaticVarSet( “ExitDate” ,Date_To_Num(“20080721”));
\n StaticVarSet( “EntryTime”,Time_To_Num(“11:01:47”) );
\n StaticVarSet( “ExitTime” ,Time_To_Num(“17:52:17”));<\/p>\n
StaticVarSetText( “TradeType” , “Stocks” ); \/\/Stocks|Forex
\nStaticVarSetText( “forexSymbol” , “SBUX” ); \/\/”EUR.USD-IDEALPRO-CASH|
\nStaticVarSetText( “StockSymbol”, “SBUX” ); \/\/ “YHOO”
\nStaticVarSetText( “ShortOrLong” , “Long” ); \/\/”Short|Long”
\nStaticVarSetText( “EntryPrice” , “14.5,15.5” );
\nStaticVarSetText( “ExitPrice” , “14.3” );
\nStaticVarSetText( “EntryDate” , “1080717,1080723” );
\nStaticVarSetText( “ExitDate”, “1080725” );
\nStaticVarSetText( “EntryTime”, “142500,120000” );
\nStaticVarSetText( “ExitTime” , “110500” );
\nStaticVarSetText( “Tradeid” , “4” );
\nStaticVarSetText( “TradeStrategy” , “fsdfdsfds” );
\nStaticVarSetText( “TradeComments” , “this is the comment” );<\/p>\n
StaticVarSet( “NoOfEntries” , 2 );
\nStaticVarSet( “NoOfExits” , 1 );<\/p>\n
*\/<\/p>\n
function returnBarIndex( array )
\n{
\n indx = -1;<\/p>\n
for ( i = 1; i < BarCount;i++ )
\n {<\/p>\n
if ( array[i] == True )
\n {
\n indx = i;
\n }
\n }<\/p>\n
return indx;
\n}<\/p>\n
function returnShiftedArray( array, shift )
\n{<\/p>\n
newArray = array;<\/p>\n
for ( i = 1; i = 0 ) && ( ( shift + i ) < BarCount ) )
\n {<\/p>\n
newArray[shift+i] = True;
\n newArray[i] = False;<\/p>\n
}
\n }<\/p>\n
return newArray;
\n}<\/p>\n
if ( StrToUpper( Name() ) == StrToUpper( StaticVarGetText( “forexSymbol” ) ) OR ( StrToUpper( Name() ) == StrToUpper( StaticVarGetText( “StockSymbol” ) ) ) )<\/p>\n
{
\n\/\/ get the static variables<\/p>\n
TradeType = StaticVarGetText( “TradeType” );
\n forexSymbol = StaticVarGetText( “forexSymbol” );
\n StockSymbol = StaticVarGetText( “StockSymbol” );
\n ShortOrLong = StaticVarGetText( “ShortOrLong” );<\/p>\n
if ( TradeType == “Stocks” )
\n {
\n stockname = stockSymbol;<\/p>\n
SetOption( “FuturesMode”, False );
\n }
\n else
\n {
\n stockname = forexSymbol;
\n SetOption( “FuturesMode”, True );<\/p>\n
}<\/p>\n
for ( i = 0 ;i < StaticVarGet( “NoOfEntries” ) ;i++ )
\n {
\n VarSet( “EntryDate” + ( i ), StrToNum( StrExtract( StaticVarGetText( “EntryDate” ), ( i ) ) ) );
\n VarSet( “EntryPrice” + ( i ), StrToNum( StrExtract( StaticVarGetText( “EntryPrice” ), ( i ) ) ) );
\n VarSet( “EntryTime” + ( i ), StrToNum( StrExtract( StaticVarGetText( “EntryTime” ), ( i ) ) ) );<\/p>\n
_TRACE( “ABTest: test 182 ” + “EntryDate” + ( i ) + NumToStr( VarGet( “EntryDate” + ( i ) ) ) );
\n _TRACE( “ABTest: test 182 ” + “EntryDate” + ( i ) + “string” + StrExtract( StaticVarGetText( “EntryDate” ), ( i ) ) );
\n }<\/p>\n
\/\/ TESTING IF THE VARIABLES EXIST
\n for ( i = 0 ;i < StaticVarGet( “NoOfEntries” ) ;i++ )
\n {
\n _TRACE( “ABTest: test 182 TESTING” + “EntryDate” + ( i ) + NumToStr( VarGet( “EntryDate” + ( i ) ) ) );
\n _TRACE( “ABTest: test 182 TESTING timeframe” + inWeekly );
\n }<\/p>\n
for ( j = 0 ;j < StaticVarGet( “NoOfExits” ) ;j++ )
\n {
\n VarSet( “ExitDate” + ( j ), StrToNum( StrExtract( StaticVarGetText( “ExitDate” ), ( j ) ) ) );
\n VarSet( “ExitTime” + ( j ), StrToNum( StrExtract( StaticVarGetText( “ExitTime” ), ( j ) ) ) );<\/p>\n
VarSet( “ExitPrice” + ( j ), StrToNum( StrExtract( StaticVarGetText( “ExitPrice” ), ( j ) ) ) );
\n \/\/ _TRACE( “ABTest: test 182 ” + “ExitDate” + ( j ) + “string” + StrExtract( StaticVarGetText( “ExitDate” ), ( j ) ) );<\/p>\n
}<\/p>\n
\/\/Buy = Sell = Short = Cover = entryPrices = exitPrices = False;<\/p>\n
\/\/ if the symbol matches what i am looking for
\n dn = DateNum();<\/p>\n
tn = TimeNum();<\/p>\n
entryPrices = exitPrices = Buy = Sell = Short = Cover = False;<\/p>\n
range = H – L;<\/p>\n
switch ( Interval() )
\n {
\n \/\/ START OF SWITCH.<\/p>\n
case inDaily:<\/p>\n
for ( b = 0;b < BarCount;b++ )
\n {
\n \/\/ START OF DAILY<\/p>\n
for ( i = 0 ;i \tdn[b] – 1 ) AND ( VarGet( “EntryDate” + i ) < dn[b] + 1\t ) )
\n {<\/p>\n
entryPrices[b] = VarGet( “EntryPrice” + i );
\n Buy[b] = Short[b] = True;
\n \/\/_TRACE( “ABTest: test 182 matching price ” + NumToStr( VarGet( “EntryPrice” + i ) ) ) ;<\/p>\n
PlotText( StaticVarGetText( “ShortOrLong” ) + ” entry ” + i + ” ” + “:” + entryPrices[b] , b, High[b] + range[b], colorBlue );
\n \/\/ PlotText( “entry” + VarGet( “EntryPrice” + i ) , b, EntryPrice0, colorBlue );<\/p>\n
\/\/ _TRACE( “ABTest: test 182 MATCHED ” + NumToStr( VarGet( “EntryDate” + i ) ) + NumToStr( dn[b] ) );<\/p>\n
}<\/p>\n
for ( j = 0 ;j \tdn[b] – 1 ) AND ( VarGet( “ExitDate” + j ) < dn[b] + 1\t ) )<\/p>\n
{<\/p>\n
exitPrices[b] = VarGet( “ExitPrice” + j );
\n Sell[b] = Cover[b] = True;<\/p>\n
PlotText( StaticVarGetText( “ShortOrLong” ) + ” Exit ” + j + “:” + VarGet( “ExitPrice” + j ) , b, Low[b] – range[b], colorRed );
\n \/\/ _TRACE( “ABTest: test 182 MATCHED ” + NumToStr( VarGet( “ExitPrice” + j ) ) + NumToStr( dn[b] ) + NumToStr( VarGet( “ExitDate” + j )));<\/p>\n
}<\/p>\n
}<\/p>\n
}<\/p>\n
} \/\/ START OF DAILY<\/p>\n
break;<\/p>\n
case inWeekly:<\/p>\n
for ( b = 1;b < BarCount – 1;b++ )
\n {
\n \/\/ START OF weekly<\/p>\n
for ( i = 0 ;i 0)
\n \tPreviousBar=b-1;
\n \tNextBar=b;
\n \tif(b=\tdn[b] ) AND ( VarGet( “EntryDate” + i ) < dn[b+1]\t) )
\n {<\/p>\n
entryPrices[b] = VarGet( “EntryPrice” + i );
\n Buy[b] = Short[b] = True;
\n _TRACE( “ABTest: test 182 matching price entry ” + NumToStr( VarGet( “EntryPrice” + i ) ) ) ;<\/p>\n
PlotText( StaticVarGetText( “ShortOrLong” ) + ” entry” + i + ” ” + “:” + entryPrices[b] , b, High[b] + range[b], colorBlue );
\n \/\/ PlotText( “entry” + VarGet( “EntryPrice” + i ) , b, EntryPrice0, colorBlue );<\/p>\n
\/\/ \/\/( “ABTest: test 182 MATCHED ” + NumToStr( VarGet( “EntryDate” + i ) ) + NumToStr( dn[b] ) );<\/p>\n
}<\/p>\n
for ( j = 0 ;j =\tdn[b-1] ) AND (VarGet( “EntryDate” + i )= \tdn[b] ) AND ( VarGet( “ExitDate” + j ) < dn[b+1]\t ) )<\/p>\n
{<\/p>\n
exitPrices[b] = VarGet( “ExitPrice” + j );
\n Sell[b] = Cover[b] = True;<\/p>\n
PlotText( StaticVarGetText( “ShortOrLong” ) + ” Exit” + j + “:” + VarGet( “ExitPrice” + j ) , b, Low[b] – range[b], colorRed );
\n \/\/ _TRACE( “ABTest: test 182 MATCHED ” + NumToStr( VarGet( “ExitPrice” + j ) ) + NumToStr( dn[b] ) + NumToStr( VarGet( “ExitDate” + j )));<\/p>\n
}<\/p>\n
}<\/p>\n
}<\/p>\n
} \/\/ START OF weekly<\/p>\n
break;<\/p>\n
\/\/_TRACE(“ABTest: test 182 ” +”getting to break”);<\/p>\n
case in1Minute:<\/p>\n
case in5Minute:<\/p>\n
case in15Minute:<\/p>\n
case inHourly:<\/p>\n
for ( b = 1;b < BarCount – 1;b++ )
\n {
\n \/\/ START OF intraday<\/p>\n
for ( i = 0 ;i =\ttn[b] ) AND ( VarGet( “EntryTime” + i ) < tn[b+1]\t) )
\n {<\/p>\n
entryPrices[b] = VarGet( “EntryPrice” + i );
\n Buy[b] = Short[b] = True;
\n _TRACE( “ABTest: test 182 matching price entry ” + NumToStr( VarGet( “EntryPrice” + i ) ) ) ;<\/p>\n
PlotText( StaticVarGetText( “ShortOrLong” ) + ” entry” + i + ” ” + “:” + entryPrices[b] , b, High[b] + range[b], colorBlue );
\n \/\/ PlotText( “entry” + VarGet( “EntryPrice” + i ) , b, EntryPrice0, colorBlue );<\/p>\n
\/\/ \/\/( “ABTest: test 182 MATCHED ” + NumToStr( VarGet( “EntryDate” + i ) ) + NumToStr( dn[b] ) );<\/p>\n
}<\/p>\n
for ( j = 0 ;j =\tdn[b-1] ) AND (VarGet( “EntryDate” + i )=\ttn[b] ) AND ( VarGet( “ExitTime” + j ) < tn[b+1]\t) )<\/p>\n
{<\/p>\n
exitPrices[b] = VarGet( “ExitPrice” + j );
\n Sell[b] = Cover[b] = True;<\/p>\n
PlotText( StaticVarGetText( “ShortOrLong” ) + ” Exit” + j + “:” + VarGet( “ExitPrice” + j ) , b, Low[b] – range[b], colorRed );
\n \/\/ _TRACE( “ABTest: test 182 MATCHED ” + NumToStr( VarGet( “ExitPrice” + j ) ) + NumToStr( dn[b] ) + NumToStr( VarGet( “ExitDate” + j )));<\/p>\n
}<\/p>\n
}<\/p>\n
}<\/p>\n
} \/\/ end of intraday<\/p>\n
break;<\/p>\n
\/\/_TRACE(“ABTest: test 182 ” +”getting to break”);<\/p>\n
}\/\/ end of switch.<\/p>\n
PlotShapes( IIf( Buy OR Short, shapeSmallCircle, shapeNone ), colorBrightGreen, 0, EntryPrices, 0 );<\/p>\n
PlotShapes( IIf( Sell OR Cover, shapeSmallCircle, shapeNone ), colorRed, 0 , ExitPrices, 0 );<\/p>\n
Miny = Status( “axisminy” );<\/p>\n
Maxy = Status( “axismaxy” );<\/p>\n
pxheight = Status( “pxheight” );<\/p>\n
y = ( GetCursorYPosition() – Miny ) \/ ( Maxy – Miny );<\/p>\n
y = ( 1 – y ) * pxheight;<\/p>\n
y = y – 20;<\/p>\n
x = 10;<\/p>\n
GfxSelectPen( colorRed, 1 );<\/p>\n
GfxSelectSolidBrush( colorCustom1 );<\/p>\n
\/\/GfxRectangle( 2, y-100, 270, y ) ;<\/p>\n
GfxSelectFont( “Tahoma”, 8, 700 );<\/p>\n
GfxSetBkMode( 1 );<\/p>\n
GfxSetTextColor( colorGreen );<\/p>\n
GfxTextOut( Name() + ” Tradeid= ” + StaticVarGetText( “Tradeid” ) , x, y ) ;<\/p>\n
GfxTextOut( ” Strategy= ” + StaticVarGetText( “TradeStrategy” ) , x, y + 10 ) ;<\/p>\n
GfxTextOut( ” Comments= ” + StaticVarGetText( “TradeComments” ) , x, y + 20 ) ;<\/p>\n
} \/\/ \/\/ if the symbol matches what i am looking for<\/p>\n
<\/CODE><\/p>\n","protected":false},"excerpt":{"rendered":"
the objective is to plot trades on chart so that it can be revieweed periodically to learn to trade better. the objective is to produce a generic afl that will take in the symbol, trade dates and prices and plot on a chart. support different timeframes so the plotting is still visible. daily, weekly, intraday, […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,1],"tags":[139],"_links":{"self":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/1844"}],"collection":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/comments?post=1844"}],"version-history":[{"count":0,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/1844\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/media?parent=1844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/categories?post=1844"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/tags?post=1844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}