First ventures into autotrading  [SOLVED]

Questions about MultiCharts and user contributed studies.
bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

First ventures into autotrading

Postby bowlesj3 » 30 Jan 2020

Hi,

After a fair bit of reading of the wiki and the MC64 help I am finally for the first time programming a script which will be using auto-trading commands but in an interactive discretionary trader way. The compiler does not seem to like my buy statement. Below is the code I have (simplified a bit to reduce reading) and a few things I have tried. In my mind based upon what I have been reading about the buy command in the help it should be straight forward but the compiler seems to be fussy. I am wondering if someone can spot the problem. In the mean time I will try more ideas.

Thanks,
John

Code: Select all

[IntrabarOrderGeneration = true] //I want the order to have no end of bar or next bar restrictions Variables: MySide("X"), MySize(0), LinePriceForAsk(0); if LastBarOnChart_s then begin MySide = "L"; MySize = 100; LinePriceForAsk = 24; //These are the things I have tried Buy MySize Shares at LinePriceForAsk limit; //this best represents what I want to do. The cursor stops at MySize. By MySize Shares on close at LinePriceForAsk limit; //Cursor stops at LinePriceForAsk Buy MySize Shares on close at LinePriceForAsk or better; //Cursor stops at LinePriceForAsk\ Buy Mysize Shares next bar at LinePriceForAsk limit; //This works but will it wait for the next bar or execute immediately? //I am using 1 second bars. I guess I could put the code on 30 minute bars and see if it works immediately. //I have to leave the house for a bit. Will be back in 2 hours roughly. end;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: First ventures into autotrading

Postby TJ » 30 Jan 2020

See post #7
7) This Bar on Close
viewtopic.php?t=10811

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: First ventures into autotrading

Postby TJ » 30 Jan 2020

//This works but will it wait for the next bar or execute immediately?
//I am using 1 second bars. I guess I could put the code on 30 minute bars and see if it works immediately.
If you are using a 1-sec chart, you should just use market-order. Because the time flies so quickly, your order will be withdrawn and resubmitted before you can blink your eyes.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: First ventures into autotrading  [SOLVED]

Postby TJ » 30 Jan 2020

Here are the basics of auto-trading:

1. Your trading logics are evaluated at EOB, and the trading decisions are made for the next bar.
1a. except, if IOG is enabled, then the logic will be evaluated every tick, and the trading decision is made for the next tick.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: First ventures into autotrading

Postby bowlesj3 » 30 Jan 2020

Here are the basics of auto-trading:

1. Your trading logics are evaluated at EOB, and the trading decisions are made for the next bar.
1a. except, if IOG is enabled, then the logic will be evaluated every tick, and the trading decision is made for the next tick.
Thanks for the logic TJ, that will be very helpful.


Return to “MultiCharts”