Switch Statement - AmiBroker | futures io social day trading
futures io futures trading


Switch Statement
Updated: Views / Replies:2,477 / 7
Created: by DonStar Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Switch Statement

  #1 (permalink)
Elite Member
Dallas, TX
 
Futures Experience: Intermediate
Platform: ToS, TradeGuider, eSignal, AmiBroker
Broker/Data: TD Ameritrade/eSignal
Favorite Futures: Stocks
 
DonStar's Avatar
 
Posts: 68 since Dec 2011
Thanks: 28 given, 41 received

Switch Statement

Hi All and a Happy and Properous 2012 to us all!

I want to enhance the Title section of my charts by inserting the day of the week in front of the date: Friday, 12/30/2011.

The DayOfWeek() returns a number. So I need to convert the number to text that says what day it is.

Here is the code I have so far:

for( n = 0; n < 10; n++ )
{
printf("Current n = %f\n", n );

varDayOfWeek = DayOfWeek();

switch(varDayOfWeek)
{
case 0:
varDayOnChart == "Sunday";
printf("Day of week is ") + varDayOnChart + "\n";
break;
case 1:
varDayOnChart == "Monday";
printf("Day of week is ") + varDayOnChart + "\n";
break;
case 2:
varDayOnChart == "Tuesday";
printf("Day of week is ") + varDayOnChart + "\n";
break;
case 3:
varDayOnChart == "Wednesday";
printf("Day of week is ") + varDayOnChart + "\n";
break;
case 4:
varDayOnChart == "Thursday";
printf("Day of week is ") + varDayOnChart + "\n";
break;
}

The error occurs on the last line. The "}" is highlighted and the error message is : Syntax error, unexpected send. Is there semicolon missing at end of the previous line?"

Anyone who can help shed some light on fixing this?

Reply With Quote
 
  #2 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,354 given, 83,237 received

I typically use with { }

So:

switch (varDayOfWeek)
{

case 0:
{
varDayOnChart == "Sunday";
printf("Day of week is ") + varDayOnChart + "\n";
break;
}

}

But don't have AmiBroker or a C++ compiler, so can't say for sure if that is the syntax problem.

It has been a while since I used C++, but you should check strftime and you can format the time and just use a single deceleration with no switch statement.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #3 (permalink)
Elite Member
las vegas
 
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: Velocity/IB
Favorite Futures: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 836 received


Also, I don't see a close bracket for the open bracket below the for statement, unless you just aren't showing it.

Reply With Quote
 
  #4 (permalink)
Membership Temporarily Revoked
London, UK
 
Futures Experience: Advanced
Platform: Amibroker, Sierra Chart
Favorite Futures: Futures/Forex
 
Posts: 36 since Jul 2012
Thanks: 0 given, 5 received

@OP,

you don't need switch

Instead use this function and put it to the Include folder of Amibroker e.g. as DayOfWeekName.afl or whatever name

 
Code
function DayOfWeekName()
{
	dow = DayOfWeek();
	dayStr = 
		WriteIf(dow == 0, "Sunday", 
		WriteIf(dow == 1, "Monday",
		WriteIf(dow == 2, "Tuesday",
		WriteIf(dow == 3, "Wednesday",
		WriteIf(dow == 4, "Thursday",
		WriteIf(dow == 5, "Friday",
		WriteIf(dow == 6, "Saturday", "Unknown")))))));

	return dayStr;
}


then in your main code call that function
 
Code
#include <DayOfWeekName.afl>;

dow = DayOfWeekName();

.
.
.
.


then the title of that main code could look as follows

 
Code
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} - " + dow + " {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

OR

you could use something completely different (so forget about the above one)

like this

 
Code
DayName = StrExtract("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday", SelectedValue(DayOfWeek()));

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} - " + DayName + " {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

Reply With Quote
The following user says Thank You to Letmein for this post:
 
  #5 (permalink)
Trading Apprentice
Kolkata+India
 
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: index,gold
 
Posts: 27 since Aug 2012
Thanks: 10 given, 1 received

Letmein

Hello, i have a question, can the Step MA v7.2 of Igor can be ported in amibroker from MT4 ?

if yes can u pls do it - its an request

regards
sr114

Reply With Quote
 
  #6 (permalink)
Membership Temporarily Revoked
London, UK
 
Futures Experience: Advanced
Platform: Amibroker, Sierra Chart
Favorite Futures: Futures/Forex
 
Posts: 36 since Jul 2012
Thanks: 0 given, 5 received


sr114 View Post
Letmein

Hello, i have a question, can the Step MA v7.2 of Igor can be ported in amibroker from MT4 ?

Yes, it can.


sr114 View Post
if yes can u pls do it

No. I have no time and no interest currently.

Reply With Quote
The following user says Thank You to Letmein for this post:
 
  #7 (permalink)
Trading Apprentice
Kolkata+India
 
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: index,gold
 
Posts: 27 since Aug 2012
Thanks: 10 given, 1 received


Letmein View Post
Yes, it can.



No. I have no time and no interest currently.

thanx for the reply

sr

Reply With Quote
 
  #8 (permalink)
Trading Apprentice
indore + india
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: oil
 
Posts: 1 since Jun 2012
Thanks: 0 given, 0 received


sr114 View Post
thanx for the reply

sr

Have Any other member converted Stepma v7.2.mt4 to Amibroker Afl ???

plz give a reply..

Reply With Quote

Reply



futures io > > > > Switch Statement

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
RE Easylanguage statement for coding price baz111 EasyLanguage Programming 2 December 26th, 2011 11:07 AM
Boehner Caves On Payroll Tax: Official Statement Quick Summary News and Current Events 0 December 22nd, 2011 06:50 PM
Jefferies Re-Releases Statement Quick Summary News and Current Events 0 November 3rd, 2011 11:30 AM
NT7 audio alert - statement expected? subterfuge NinjaTrader Programming 2 March 17th, 2011 10:55 AM
Fed repurchase statement Snoop Traders Hideout 1 November 4th, 2010 08:11 AM


All times are GMT -4. The time now is 08:02 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-17 in 0.11 seconds with 19 queries on phoenix via your IP 54.145.16.43