Hello,
Yes his code works.
In your code, you are doing mistake.
Should be:
Buy = Cross(MA(C,10),MA(C,40));
BuyPrice = Open;
Short = Cross(MA(C,60), MA(C,15));
ShortPrice = Open;
Cover = Buy; // this is necessary for lines below to work
Sell =Short; // this is necessary
Buypos=Flip(Buy,Sell);
Shortpos=Flip(Short,Cover);
Best regards,
Tomasz Janeczko
amibroker.com
On 2010-05-18 02:12, pragaon wrote:
> matthias,
>
> Does your code works? I tried to use it in my code but it is not working. The
> TP/SL percentages stays 3 and 5.
>
> My code is like this:
>
>
> Buy = Cross(MA(C,10),MA(C,40));
> BuyPrice = Open;
> Sell =0;
> Short = Cross(MA(C,60), MA(C,15));
> ShortPrice = Open;
> Cover = 0;
>
> Buypos=Flip(Buy,Sell);
> Shortpos=Flip(Short,Cover);
>
> _TRACE("#" + "Buypos " + Buypos);
> _TRACE("#" + "Shortpos " + Shortpos);
>
> SLpercent=IIf(Buypos,3,IIf(Shortpos,7,0));
> TPpercent=IIf(Buypos,5,IIf(Shortpos,10,0));
>
>
> ApplyStop( 0, 1, SLpercent, 1 );
> ApplyStop( 1, 1, TPpercent, 1);
>
>
> --- In [email protected], "Matthias"<m.kusche...@...> wrote:
>
>>
>> Hi,
>>
>>
>>
>> I use this one:
>>
>> buypos=Flip(Buy,Sell);
>>
>> Shortpos=Flip(Short,Cover);
>>
>> SLbuy=Optimize("SLbuy",0.5,0.3,0.7,0.05); ////If you wanna optimize your
>> stops and profit targets
>>
>> SLshort=Optimize("SLshort",0.5,0.3,0.7,0.05);
>>
>> TPbuy=Optimize("TPbuy",1,0.9,1.2,0.05);
>>
>> TPshort=Optimize("TPshort",1,0.9,1.2,0.05);
>>
>> SL=IIf(Buypos,SLbuy,IIf(Shortpos,slshort,0));
>>
>> TP=IIf(Buypos,TPbuy,IIf(Shortpos,tpshort,0));
>>
>> ApplyStop(stopTypeLoss,stopModePercent,SL);
>>
>> ApplyStop(stopTypeProfit,stopModePercent,TP);
>>
>>
>>
>> Sorry for the strange line breaks...
>>
>> Cheers,
>>
>> Matthias
>>
>>
>>
>>
>>
>>
>>
>>
>> --- In [email protected], "Markus Witzler"<funnybiz@> wrote:
>>
>>> Hello,
>>>
>>> I want to specify different appystop conditions for long and short
>>>
>> posisions.
>>
>>> How does AB recognize which one is for which trade?
>>>
>>> Thanks
>>>
>>> Markus
>>>
>>>
>>>
>>> __________ Information from ESET Smart Security, version of virus
>>>
>> signature database 4668 (20091207) __________
>>
>>> The message was checked by ESET Smart Security.
>>>
>>> http://www.eset.com
>>>
>>>
>>
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>
>
>