Trading from chart like Interactive broker Buy/Sell option

#1
Hi,

First of all, thank you for such a wonderful community of traders and developers. This is my first post in the forum. I am a developer/aspiring trader and look forward to develop a small feature in Amibroker to check my mock trading skills and experiment.

I need guidance on "How can I code Trading from chart like Interactive broker Buy/Sell option in Amibroker and write trades in log file". As of now, clicking buy/sell and placing trade on chart ask to install the IB plugin. I just want to create a custom feature to write the trades into the log file in case of replay option of amibroker or in live market. I have attached the file to display buttons I am referring to in Amibroker.

I am just looking for hints on how to start on this along with any relevant article/afl to get this done.

Looking for your help and guidance.

Thanks & Regards,
Rajat.
 

Attachments

Last edited:
#2
I am experimenting myself and will keep posting my progress here.

Sometime back, I found the following afl from internet. Thanks to the author. I don't remember where I picked up from hence not able to give URL. It comes close however, there are few important things missing.

First I will mention the questions and then the afl here...

Q1 : First I need to drag it like indicator on chart and then I can start putting buy/sell. Rather can it be simply
a button click (like IB buy/sell buttons) or better just use some intitutive methods -
- like single click put the buy while double click put the sell
Q2 : Option to select and drag/drop of same order? How to achieve this.
Q3 : Requesttimedrefresh(1) keep refreshing a lot and in turn not allowing to display the buy hence I changed it to Requesttimedrefresh(100). Not sure, if it will not trigger the order when price crosses this point. Still reading about this method at my end.

-----------------------------

Chart trading afl

-----------------------------

RequestTimedRefresh( 100 );
SetChartOptions( 2, chartHideQuoteMarker );
LButtonDown = GetCursorMouseButtons() == 9;
RButtonDown = GetCursorMouseButtons() == 10;

MousePrice = GetCursorYPosition();

if ( MousePrice )
{
StaticVarSet( "MousePrice", MousePrice );
if ( LButtonDown OR RButtonDown)
StaticVarSet( "ClickedMousePrice", MousePrice );
}

LB = BarCount - 1;
MousePrice = Nz( StaticVarGet( "Mouseprice" ), Null );
ClickedMousePrice = StaticVarGet( "ClickedMousePrice" );

//Plot( C, "", 1, 128 );

//Plot( MousePrice, "", colorWhite, 1 | styleNoRescale | styleDashed | styleNoLabel, 0, 0, 2 );
//PlotText( "CURSOR " + NumToStr( MousePrice[LB], 1.2 ), LB - 5, MousePrice[LB], colorBlack, colorWhite );

if(LButtonDown)
{
Plot( ClickedMousePrice, "", colorGreen, 1 | styleNoLabel | styleNoRescale, 0, 0, 2 );
//PlotText( "ORDER PLACED " + NumToStr( ClickedMousePrice[LB], 1.2 ), LB - 5, ClickedMousePrice[LB], colorBlack, colorWhite );
PlotText( "Buy@" + NumToStr( ClickedMousePrice[LB], 1.2 ), LB - 5, ClickedMousePrice[LB], colorBlack, colorGreen );
}
else if(RButtonDown)
{
Plot( ClickedMousePrice, "", colorRed, 1 | styleNoLabel | styleNoRescale, 0, 0, 2 );
//PlotText( "ORDER PLACED " + NumToStr( ClickedMousePrice[LB], 1.2 ), LB - 5, ClickedMousePrice[LB], colorBlack, colorWhite );
PlotText( "Sell@" + NumToStr( ClickedMousePrice[LB], 1.2 ), LB - 5, ClickedMousePrice[LB], colorBlack, colorRed );
}
 

manus

New Member
#3
From yahoo finance and google finance how to get live data for nifty futures? it is giving spot nifty prices.

Hi,

First of all, thank you for such a wonderful community of traders and developers. This is my first post in the forum. I am a developer/aspiring trader and look forward to develop a small feature in Amibroker to check my mock trading skills and experiment.

I need guidance on "How can I code Trading from chart like Interactive broker Buy/Sell option in Amibroker and write trades in log file". As of now, clicking buy/sell and placing trade on chart ask to install the IB plugin. I just want to create a custom feature to write the trades into the log file in case of replay option of amibroker or in live market. I have attached the file to display buttons I am referring to in Amibroker.

I am just looking for hints on how to start on this along with any relevant article/afl to get this done.

Looking for your help and guidance.

Thanks & Regards,
Rajat.
 
#4
Hi Manus,

I believe that you have posted your question in the wrong thread. It would be great if you can initiate a new thread so that discussion is focused on the original topic.

Dear senior members,

Looking for guidance. Thanks in advance for your guidance.
 

mastermind007

Well-Known Member
#5
I am experimenting myself and will keep posting my progress here.

Sometime back, I found the following afl from internet. Thanks to the author. I don't remember where I picked up from hence not able to give URL. It comes close however, there are few important things missing.

First I will mention the questions and then the afl here...

Q1 : First I need to drag it like indicator on chart and then I can start putting buy/sell. Rather can it be simply
a button click (like IB buy/sell buttons) or better just use some intitutive methods -
- like single click put the buy while double click put the sell
Q2 : Option to select and drag/drop of same order? How to achieve this.
Q3 : Requesttimedrefresh(1) keep refreshing a lot and in turn not allowing to display the buy hence I changed it to Requesttimedrefresh(100). Not sure, if it will not trigger the order when price crosses this point. Still reading about this method at my end.

-----------------------------

Chart trading afl

-----------------------------

RequestTimedRefresh( 100 );
SetChartOptions( 2, chartHideQuoteMarker );
LButtonDown = GetCursorMouseButtons() == 9;
RButtonDown = GetCursorMouseButtons() == 10;

MousePrice = GetCursorYPosition();

if ( MousePrice )
{
StaticVarSet( "MousePrice", MousePrice );
if ( LButtonDown OR RButtonDown)
StaticVarSet( "ClickedMousePrice", MousePrice );
}

LB = BarCount - 1;
MousePrice = Nz( StaticVarGet( "Mouseprice" ), Null );
ClickedMousePrice = StaticVarGet( "ClickedMousePrice" );

//Plot( C, "", 1, 128 );

//Plot( MousePrice, "", colorWhite, 1 | styleNoRescale | styleDashed | styleNoLabel, 0, 0, 2 );
//PlotText( "CURSOR " + NumToStr( MousePrice[LB], 1.2 ), LB - 5, MousePrice[LB], colorBlack, colorWhite );

if(LButtonDown)
{
Plot( ClickedMousePrice, "", colorGreen, 1 | styleNoLabel | styleNoRescale, 0, 0, 2 );
//PlotText( "ORDER PLACED " + NumToStr( ClickedMousePrice[LB], 1.2 ), LB - 5, ClickedMousePrice[LB], colorBlack, colorWhite );
PlotText( "Buy@" + NumToStr( ClickedMousePrice[LB], 1.2 ), LB - 5, ClickedMousePrice[LB], colorBlack, colorGreen );
}
else if(RButtonDown)
{
Plot( ClickedMousePrice, "", colorRed, 1 | styleNoLabel | styleNoRescale, 0, 0, 2 );
//PlotText( "ORDER PLACED " + NumToStr( ClickedMousePrice[LB], 1.2 ), LB - 5, ClickedMousePrice[LB], colorBlack, colorWhite );
PlotText( "Sell@" + NumToStr( ClickedMousePrice[LB], 1.2 ), LB - 5, ClickedMousePrice[LB], colorBlack, colorRed );
}
Single Click buy and double click sell is not intuitive.
 
#6
Thanks @Mastermind for your suggestion and it make sense. However, I look forward to have some glimpse of code for guidance. We can certainly decide these interaction things in a better manner if we have the base code to start with.

Please members, contribute and guide.