PureBytes Links
Trading Reference Links
|
Another thing you can do when you get this kind of syntax error --
which is almost always a missing language structure character -- is to
use the Prettify selection over the suspect code. It will indent and
space out the code to make it easier to see the problem.
I don't like the way Prettify aggressively adds white space and extra
returns to my code in general, so I just Undo the operation once I can
see the problem.
Prettify is a powerful debug aid.
Best regards,
Dennis
On Jul 30, 2008, at 1:38 AM, Barry Scarborough wrote:
> Good coding practice is to indent your nested statements and end an
> if, else or for loop with a comment to the ending brace that tells
> you what the brace is ending,
>
> if( a == x)
> {
> ...
> ...
> if(x == y)
> {
> ...
> } // end x == y
> } // end a == x
>
> You may think this is a waste of time but it really isn't. Trying to
> find a missing brace will make up for all the time it took to add the
> indentation and comments. Besides indenting code makes it much easier
> to read and catch mistakes. It will really pay off when you come back
> to your code months later and try to figure out what it is doing.
>
> You pays your money and you takes your choice,
> Barry
>
>
>
>
> ibroker@xxxxxxxxxxxxxxx, "murthysuresh" <money@xxx> wrote:
>>
>> thanks. you have a real eye. i have been staring at that error for
> 3
>> hours before i decided to post it.
>>
>> --- In amibroker@xxxxxxxxxxxxxxx, "tuzo_wilson" <j.tuzo.wilson@>
>> wrote:
>>>
>>> --- In amibroker@xxxxxxxxxxxxxxx, "murthysuresh" <money@> wrote:
>>>>
>>>> i cannot find where the syntax error is. it points to the end
> of
>> the
>>>> code. i cannot find it to fix it. pl help
>>>
>>> It looks like you are missing a closing brace bracket "}". I
> think
>>> you need to match up a bracket with the "if(Name()==STOCKNAME ){"
>>> statement so add a closing bracket to the end of the AFL.
>>>
>>>
>>> Tuzo
>>>
>>>> SetChartOptions(0,chartShowArrows|chartShowDates);
>>>> _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g,
>> Hi %
>>>> g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C,
> SelectedValue
>> (
>>>> ROC( C, 1 ) ) ));
>>>> Plot( C, "Close", ParamColor("Color", colorBlack ),
> styleNoTitle
>> |
>>>> ParamStyle("Style") | GetPriceStyle() );
>>>> //_TRACE("ABTest: test trace1 ");
>>>>
>>>> //#include "C:\Program
>>>> Files\AmiBroker\sharedLibrary\DateTimeToNumber.afl"
>>>>
>>>>
>>>> StaticVarSetText( "TradeType" , "Stocks" ); //Stocks|Forex
>>>> StaticVarSetText( "forexSymbol" , "SBUX" ); //"EUR.USD-IDEALPRO-
>> CASH|
>>>> StaticVarSetText( "StockSymbol", "SBUX" ); // "YHOO"
>>>> StaticVarSetText( "ShortOrLong" , "Long" ); //"Short|Long"
>>>> StaticVarSetText( "EntryPrice" , "14.5,15.5" );
>>>> StaticVarSetText( "ExitPrice" , "14.3" );
>>>> StaticVarSetText( "EntryDate" , "1080715,1080723" );
>>>> StaticVarSetText( "ExitDate", "1080725" );
>>>> StaticVarSetText( "EntryTime", "13:19:45,12:19:12" );
>>>> //StaticVarSet( "ExitTime" ,Time_To_Num("17:52:17"));
>>>>
>>>>
>>>> StaticVarSet( "NoOfEntries" , 2 );
>>>> StaticVarSet( "NoOfExits" , 1 );
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> function returnBarIndex( array )
>>>> {
>>>> indx = -1;
>>>>
>>>> for ( i = 1; i < BarCount;i++ )
>>>> {
>>>>
>>>> if ( array[i] == True )
>>>> {
>>>> indx = i;
>>>> }
>>>> }
>>>>
>>>> return indx;
>>>> }
>>>>
>>>>
>>>>
>>>> function returnShiftedArray( array, shift )
>>>> {
>>>>
>>>>
>>>> newArray = array;
>>>>
>>>> for ( i = 1; i < BarCount;i++ )
>>>> {
>>>>
>>>> if ( ( array[i] == True ) && ( ( shift + i ) >= 0 ) &&
> (
>> (
>>>> shift + i ) < BarCount ) )
>>>> {
>>>>
>>>> newArray[shift+i] = True;
>>>> newArray[i] = False;
>>>>
>>>>
>>>> }
>>>> }
>>>>
>>>>
>>>> return newArray;
>>>> }
>>>>
>>>> // get the static variables
>>>>
>>>> TradeType = StaticVarGetText( "TradeType" );
>>>> forexSymbol = StaticVarGetText( "forexSymbol" );
>>>> StockSymbol = StaticVarGetText( "StockSymbol" );
>>>> ShortOrLong = StaticVarGetText( "ShortOrLong" );
>>>>
>>>> ExitPrice = StaticVarGet( "ExitPrice" );// obsolete
>>>>
>>>>
>>>>
>>>> ExitDate = StaticVarGet( "ExitDate" );// obsolete
>>>>
>>>>
>>>>
>>>> ExitTime = StaticVarGet( "NoOfEntries" );// obsolete
>>>>
>>>> for ( i = 0 ;i <= StaticVarGet( "NoOfEntries" ) ;i++ )
>>>> {
>>>> VarSet( "EntryDate"+(i-1), StrToNum(StrExtract
>>>> (StaticVarGetText("ExitDate"), (i-1) )) );
>>>> }
>>>>
>>>> for ( i = 0 ;i <= StaticVarGet( "NoOfExits" ) ;i++ )
>>>> {
>>>> VarSet( "ExitDate"+(i-1), StrToNum(StrExtract(StaticVarGetText
>>>> ("ExitDate"), (i-1) )) );
>>>> }
>>>>
>>>> Buy = Sell = Short = Cover = entry=entryPrices=exitPrices=False;
>>>>
>>>> if ( TradeType == "Stocks" )
>>>> {
>>>> stockname = stockSymbol;
>>>>
>>>> SetOption( "FuturesMode", False );
>>>> }
>>>> else
>>>> {
>>>> stockname = forexSymbol;
>>>> SetOption( "FuturesMode", True );
>>>>
>>>> }
>>>> if(Name()==STOCKNAME ){
>>>> dn=DateNum();
>>>> switch ( Interval() )
>>>> {
>>>>
>>>>
>>>> case inDaily:
>>>>
>>>> for (b=0;b<BarCount;b++){
>>>>
>>>> for ( i = 0 ;i <= StaticVarGet( "NoOfEntries" )-
>>>> 1 ;i++ )
>>>> {
>>>> if(dn[b]== VarGet( "EntryDate"+i)){
>>>>
>>>> entryPrices[b]=VarGet
>>>> ( "EntryPrice"+i);
>>>>
>>>> PlotText( "entry"
>>>> +VarGet( "EntryPrice"+i) ,b,VarGet( "EntryPrice"+i)
>> +1,colorBlue );
>>>>
>>>> }
>>>>
>>>> for ( j = 0 ;j <= StaticVarGet( "NoOfExits" )-
>>>> 1 ;j++ )
>>>> {
>>>> if(dn[b]== VarGet( "ExitDate"+j)){
>>>>
>>>> entryPrices[b]=VarGet
>>>> ( "ExitPrice"+j);
>>>>
>>>> PlotText( "Closure"
>>>> +VarGet( "ExitPrice"+j) ,b,VarGet( "ExitPrice"+j)+1,colorRed);
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>> }
>>>>
>>>> /*
>>>> if(dn[b]==EntryDate0)
>>>> Buy[b]=True;
>>>> entryPrices[b]=EntryPrice0;
>>>>
>>>> if(dn[b]==EntryDate1){
>>>> Buy[b]=True;
>>>> entryPrices[b]=EntryPrice1;
>>>> PlotText( "entry"
>>>> +EntryPrice1 ,b,EntryPrice1,colorBlue );
>>>>
>>>> }*/
>>>> }
>>>> // entry =Name() == STOCKNAME AND ((BarIndex() = ValueWhen(
>> DateNum
>>>> () == EntryDate0 , BarIndex() );
>>>> //entry=Name()==STOCKNAME AND ((BarIndex()==ValueWhen
>>>> (DateNum()==EntryDate0 , BarIndex()) ) OR (BarIndex()
> ==ValueWhen
>>>> (DateNum()==EntryDate1 , BarIndex())));
>>>>
>>>>
>>>>
>>>> //exit=Name()==STOCKNAME AND BarIndex()==ValueWhen(DateNum()
>>>> ==ExitDate , BarIndex());
>>>>
>>>> break;
>>>>
>>>>
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>> switch ( ShortOrLong )
>>>> {
>>>>
>>>> case "Long":
>>>> Buy = entry;
>>>> Sell = Closure;
>>>> Short = False;
>>>> Cover = False;
>>>>
>>>>
>>>>
>>>> break;
>>>>
>>>>
>>>>
>>>>
>>>> }
>>>>
>>>
>>
>
>
>
> ------------------------------------
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> For other support material please check also:
> http://www.amibroker.com/support.html
> Yahoo! Groups Links
>
>
>
------------------------------------
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|