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

Re: [amibroker] Re: Help to reset ApplyStop



PureBytes Links

Trading Reference Links

SetOption( "ReverseSignalForcesExit", 0 );

-- 
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com



2008/7/12 ozzyapeman <zoopfree@xxxxxxxxxxx>:
> Graham (or anyone), one more quick question if you don't mind.
>
> What is the easiest way to ensure that when I already have an open
> Long position, that I don't open a Short and vice versa? Should I
> place SetPositionSize inside the loop?
>
> Or is there some other way to specify in the original Buy and Short
> rules not to Buy or Short if it's opposite is already true? I can't
> test the inBuy or inShort variables because those only get defined
> lower down:
>
>
> SetTradeDelays( 1, 1, 1, 1 );
> SetPositionSize(1,spsShares);
>
> Sell = Cover = 0;
> BuyPrice = SellPrice = ShortPrice = CoverPrice = O;
>
> myMA1 = MA(C,4);
> MyMA2 = MA(C,15);
>
> Buy = (myMA1 > MyMA2);
> Short = (myMA1 < MyMA2);
>
> inBuy = inShort = 0;
> ValueAtBuy = ValueAtShort = Null;
>
>
> for( i = 0; i < BarCount; i++ )
> { //various trade rules here
> }
>
>
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxx> wrote:
>>
>> Because AB AFL goes through each line if you define something later
>> then it will override previous results.
>>
>> When you use a loop it interupts this normal flow as well
>>
>> I find that if I am defining or changing trade signals with a loop it
>> is best to incorporate the other exits within the loop. ie define them
>> as conditions. This may be just because I have not found another way
>> to do it.
>> In this case add the actual price conditions to the loop and remove
>> the applystop
>>
>> Sorry I do not think I explained this very well, so hope you get my
> meaning.
>>
>> --
>> Cheers
>> Graham Kav
>> AFL Writing Service
>> http://www.aflwriting.com
>>
>>
>>
>> 2008/7/12 ozzyapeman <zoopfree@xxx>:
>> > Hello, would appreciate if anyone could help me with fixing this stop
>> > problem.
>> >
>> > I want to apply a stop on either a Buy or Short, should the price move
>> > against me by 20 pips on a Forex trade. I am able to code it (see
> below) and
>> > run it in the backtester. The trades correctly get stopped out at
> 20 pips
>> > against.  However, new Buys and Shorts do not happen until the
> original, and
>> > now "phantom", Buy or Short runs it's course. So as far as
> entering new
>> > positions is concerned, it's as if the stop command is not even
> there! I
>> > want to enter a new Buy or Short immediately after a stop, so long
> as the
>> > Buy or Short rules are currently true.
>> >
>> > This quirk leads me to believe that some variable is not being reset
>> > correctly. But whether I place the stop command inside the loop or
> out, I
>> > get the same result in the backtester. How do I reset the variables
>> > correctly so that the program is ready to Buy or Sell again as
> soon as a
>> > stop has occured?
>> >
>> >
>> > Sell = Cover = 0;
>> > BuyPrice = SellPrice = ShortPrice = CoverPrice = O;
>> >
>> > myMA1 = MA(C,4);
>> > MyMA2 = MA(C,15);
>> >
>> > Buy = (myMA1 > MyMA2);
>> > Short = (myMA1 < MyMA2);
>> > ApplyStop(0,2,.0020,1);
>> >
>> >
>> > inBuy = inShort = 0;
>> > ValueAtBuy = ValueAtShort = Null;
>> >
>> > for( i = 0; i < BarCount; i++ )
>> >
>> > { //various sell and cover rules
>> >
>> > }
>> >
>> >   Buy =   ExRem(Buy, Sell);
>> >   Sell =  ExRem(Sell, Buy);
>> >   Short = ExRem(Short, Cover);
>> >   Cover = ExRem(Cover, Short);
>> >   SetPositionSize(2,spsShares);
>> >
>> >

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

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/