[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Changing the stop loss depending on the stock price?



PureBytes Links

Trading Reference Links

The Help file will explain.

Help > SetOptions
Help > BuyPrice
Help> Applystop

The Help files are full of good examples of code.



Regards

ChrisB






Louis Préfontaine wrote:
>
> Hi Chris,
>
> Thanks a lot for the explanation!  Do you know where I could see some 
> example of this code?  I mean, a complete code with all the ideas that 
> you explained to me below?  I learn a lot by modifying existing code 
> and I am not sure what to do with " setoptions( 1 .........);" as an 
> example  or with " BuyPrice = SellPrice = Open;" or with " 
> Applystop(stoptypeL oss,..... ....);"  What do I put to replace the 
> "......" part?   I am still a beginner and I learn a lot when looking 
> at a real code...  I will try to work on what you showed me, but if 
> you could give me maybe just a complete example, that would help me a lot!
>
> Thanks a lot!
>
> Louis
>
> 2008/2/22, ChrisB <kris45mar@xxxxxx net.au 
> <mailto:kris45mar@xxxxxxxxxxxx>>:
>
>     Louis
>
>     In general if you use AFL to code stuff this overrides the Settings
>     values (not always)
>
>     Using the Settings values for Applystops is a great way to start.
>     If you want to use the above code in your backtester formula just try
>     something like this:
>
>     // Set all options here:
>     setoptions( 1 .........);
>     setoptions(2. ........) ;
>     setoptions(3. ........) ; //etcetera
>     BuyPrice = SellPrice = Open;// or whatever you want
>     SetTradeDelays( 1,1,0,00; // etc.
>
>     // Define Buy and Sell conditions
>
>     Buy1 = myBuyCondition:
>     Sell = 0; // if you have only use Applystops to exit.
>
>     amount = IIF(Close < 10, ... , ... ); // etcetera
>     Applystop(stoptypeL oss,..... ....); // etcetera.
>
>     Equity(); // this helps to plot arrows on the charts so you can
>     confirm
>     if AB is doing what you told it to do.
>     // if not you have goofed up code somewhere and
>
>     //then plot your stuff
>
>     Plot(c,"", 1, 64);
>     Plot(whatever else you want);
>     Plotshapes( ........); // etcetera
>
>     In general if you have got something wrong you will an error message
>     that will tell you how to fix this.
>     e.g, if you have not declared a variable first AB will object and let
>     you know.
>
>     so if you did
>     Applystop(StopTypeL oss, ......., amount,..... ...);
>     amount = IIF( whatever.... ....);
>
>     it will let you know with an appropriate error message.
>
>     Regards
>
>     ChrisB
>
>     Louis Préfontaine wrote:
>     >
>     > Hi,
>     >
>     > Where exactly should I put this code? I am still a beginner and I
>     > feel confident about modifying the code for the charts and
>     building a
>     > system with buy,sell, short and cover, but where should I put the
>     > information about this?
>     >
>     > I already can modify some variables with the "settings" button with
>     > which I can choose to use a 10% stop for every stock, but how to
>     > customize it even more?
>     >
>     > Thanks!
>     >
>     > Louis
>     >
>     > 2008/2/20, ChrisB <kris45mar@xxxxxx net.au
>     > <mailto:kris45mar@xxxxx. net.au <mailto:kris45mar%40iinet.net.au>>>:
>     >
>     > Louis
>     >
>     > from a previous recent post by TJ
>     >
>     > > Hello,
>     > > ApplyStop( StopTypeNBar, stopTypeBars, IIF( Buy, 10, 5 ) );
>     > > Best regards,
>     > > Tomasz Janeczko
>     > > amibroker.com <http://amibroker.com> <http://amibroker. com
>     <http://amibroker.com>>
>     >
>     > and from the help files
>     >
>     > /amount/ =
>     > percent/point loss/profit trigger/risk amount.
>     > This could be a number (static stop level) or an array (dynamic
>     > stop level)
>     >
>     > So you should be OK with
>     >
>     > amount = IIf( Close < 10, 10,
>     > IIf(Close > 50, 2.5, 5));
>     >
>     > ApplyStop(stopTypeL oss,stopModePerc ent,amount) ;
>     >
>     > Have not tested this.
>     >
>     > Regards
>     >
>     > ChrisB
>     >
>     > louisprefontaine wrote:
>     > >
>     > > Ok I got an easier question and I hope I'll be clear at first! ;-)
>     > >
>     > > I already use the stop/loss option at 10% stop. But I'd like to
>     have
>     > > a changing stop:
>     > >
>     > > Example:
>     > >
>     > > Close<10 // I'd like a stop of 10%
>     > > Close>10 AND Close<35 //I'd like a stop of 5%
>     > > Close>50 // I'd like a stop of 2.5%
>     > >
>     > > I think you get the idea.
>     > >
>     > > Is there any way to do this?
>     > >
>     > > Thanks again for reading and helping! I hope I'll be good
>     enough soon
>     > > to help others too! ;-)
>     > >
>     > > Louis
>     > >
>     > >
>     >
>     >
>     >
>
>
>  


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/