Hello,
help greatly appreciated, thanks in advance.
I am new to AmiBroker and come from TradeStation, WealthLab and Metastock. I am currently trying out AmiBroker since the above three are either getting outdated and unsuported or not available in my region without a brokerage account.
Never have been a programming wizard so would appreciate some help. I have put all my steps in this post so you know what I did and hopefully can point me to the mistakes I made.
I tried to write some basic script that will buy at XX price and will sell at a set profit target.
I started out with the following script:
---------------------------------------------
SetOption("ActivateStopsImmediately", True );
PositionSize =-1;
BuyStop_1 = 14.00;
SellStop_1 = 15.00;
Buy = (BuyStop_1);
Sell = (SellStop_1);
---------------------------------------------
Unfortunatly that did not work. Apperantly AmiBroker is not that simple
After some research I found that the following works a little better...
---------------------------------------------
SetOption("ActivateStopsImmediately", True );
PositionSize =-1;
BuyStop_1 = 14.00;
SellStop_1 = 15.00;
Buy = Cross(BuyPrice, BuyStop_1);
Sell = Cross(SellPrice, SellStop_1);
---------------------------------------------
The problem I am left with with this script is that AmiBroker now does buy, but it buys on the close after the crossing has happened.
I however want the buy's and sells to be limit buys and sells that can be triggered intraday. (ofcourse, if the open is lower than the limit, we buy @ open)
I found part of the solution (entry now works) and ended up with the below script but... for the exit, I am still searching for the solution....
-------------------------------------------
BuySignal = (L>14.01);
// buy on the next bar
Buy = Ref( BuySignal, -1);
BuyLimitPrice = 14.00;
SellLimitPrice = 15.00;
// now we check if limit was hit
Buy = Buy AND L < BuyLimitPrice;
// if Open price is below the limit, then we use Open for entry
BuyPrice = Min( Open, BuyLimitPrice );
Sell = Cross( EMA( Close, 45 ), Close );
------------------------------------------
Buy's now happen on the limit (or better) but I can't find a way to prefent the sells from happening on the close.
If anyone can help, thanks in advance !
help greatly appreciated, thanks in advance.
I am new to AmiBroker and come from TradeStation, WealthLab and Metastock. I am currently trying out AmiBroker since the above three are either getting outdated and unsuported or not available in my region without a brokerage account.
Never have been a programming wizard so would appreciate some help. I have put all my steps in this post so you know what I did and hopefully can point me to the mistakes I made.
I tried to write some basic script that will buy at XX price and will sell at a set profit target.
I started out with the following script:
---------------------------------------------
SetOption("ActivateStopsImmediately", True );
PositionSize =-1;
BuyStop_1 = 14.00;
SellStop_1 = 15.00;
Buy = (BuyStop_1);
Sell = (SellStop_1);
---------------------------------------------
Unfortunatly that did not work. Apperantly AmiBroker is not that simple
After some research I found that the following works a little better...
---------------------------------------------
SetOption("ActivateStopsImmediately", True );
PositionSize =-1;
BuyStop_1 = 14.00;
SellStop_1 = 15.00;
Buy = Cross(BuyPrice, BuyStop_1);
Sell = Cross(SellPrice, SellStop_1);
---------------------------------------------
The problem I am left with with this script is that AmiBroker now does buy, but it buys on the close after the crossing has happened.
I however want the buy's and sells to be limit buys and sells that can be triggered intraday. (ofcourse, if the open is lower than the limit, we buy @ open)
I found part of the solution (entry now works) and ended up with the below script but... for the exit, I am still searching for the solution....
-------------------------------------------
BuySignal = (L>14.01);
// buy on the next bar
Buy = Ref( BuySignal, -1);
BuyLimitPrice = 14.00;
SellLimitPrice = 15.00;
// now we check if limit was hit
Buy = Buy AND L < BuyLimitPrice;
// if Open price is below the limit, then we use Open for entry
BuyPrice = Min( Open, BuyLimitPrice );
Sell = Cross( EMA( Close, 45 ), Close );
------------------------------------------
Buy's now happen on the limit (or better) but I can't find a way to prefent the sells from happening on the close.
If anyone can help, thanks in advance !